mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-09 20:10:27 +08:00
网站设置增加HLS加密功能(商业版本)
This commit is contained in:
@@ -282,6 +282,16 @@ func (this *HTTPRequest) Do() {
|
|||||||
if this.web.Compression != nil && this.web.Compression.IsOn && this.web.Compression.Level > 0 {
|
if this.web.Compression != nil && this.web.Compression.IsOn && this.web.Compression.Level > 0 {
|
||||||
this.writer.SetCompression(this.web.Compression)
|
this.writer.SetCompression(this.web.Compression)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HLS
|
||||||
|
if this.web.HLS != nil &&
|
||||||
|
this.web.HLS.Encrypting != nil &&
|
||||||
|
this.web.HLS.Encrypting.IsOn {
|
||||||
|
if this.processHLSBefore() {
|
||||||
|
this.doEnd()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 开始调用
|
// 开始调用
|
||||||
@@ -633,6 +643,11 @@ func (this *HTTPRequest) configureWeb(web *serverconfigs.HTTPWebConfig, isTop bo
|
|||||||
this.web.CC = web.CC
|
this.web.CC = web.CC
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HLS
|
||||||
|
if web.HLS != nil && (web.HLS.IsPrior || isTop) {
|
||||||
|
this.web.HLS = web.HLS
|
||||||
|
}
|
||||||
|
|
||||||
// 重写规则
|
// 重写规则
|
||||||
if len(web.RewriteRefs) > 0 {
|
if len(web.RewriteRefs) > 0 {
|
||||||
for index, ref := range web.RewriteRefs {
|
for index, ref := range web.RewriteRefs {
|
||||||
|
|||||||
16
internal/nodes/http_request_hls.go
Normal file
16
internal/nodes/http_request_hls.go
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||||
|
//go:build !plus
|
||||||
|
|
||||||
|
package nodes
|
||||||
|
|
||||||
|
import "net/http"
|
||||||
|
|
||||||
|
func (this *HTTPRequest) processHLSBefore() (blocked bool) {
|
||||||
|
// stub
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *HTTPRequest) processM3u8Response(resp *http.Response) error {
|
||||||
|
// stub
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -436,7 +436,19 @@ func (this *HTTPRequest) doOriginRequest(failedOriginIds []int64, failedLnNodeId
|
|||||||
if this.web.Optimization != nil && resp.Body != nil && this.cacheRef != nil /** must under cache **/ {
|
if this.web.Optimization != nil && resp.Body != nil && this.cacheRef != nil /** must under cache **/ {
|
||||||
err := this.web.Optimization.FilterResponse(this.URL(), resp)
|
err := this.web.Optimization.FilterResponse(this.URL(), resp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.write50x(err, http.StatusBadGateway, "Page Optimization: Fail to read content from origin", "内容优化:从源站读取内容失败", false)
|
this.write50x(err, http.StatusBadGateway, "Page Optimization: fail to read content from origin", "内容优化:从源站读取内容失败", false)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// HLS
|
||||||
|
if this.web.HLS != nil &&
|
||||||
|
this.web.HLS.Encrypting != nil &&
|
||||||
|
this.web.HLS.Encrypting.IsOn &&
|
||||||
|
resp.StatusCode == http.StatusOK {
|
||||||
|
m3u8Err := this.processM3u8Response(resp)
|
||||||
|
if m3u8Err != nil {
|
||||||
|
this.write50x(m3u8Err, http.StatusBadGateway, "m3u8 encrypt: fail to read content from origin", "m3u8加密:从源站读取内容失败", false)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user