mirror of
https://github.com/Monibuca/plugin-jessica.git
synced 2025-10-19 22:34:40 +08:00
增加可共用网关端口
This commit is contained in:
@@ -3,7 +3,7 @@ package jessica
|
||||
import (
|
||||
"encoding/binary"
|
||||
"net/http"
|
||||
"strings"
|
||||
"regexp"
|
||||
|
||||
. "github.com/Monibuca/engine/v2"
|
||||
"github.com/Monibuca/engine/v2/avformat"
|
||||
@@ -11,6 +11,8 @@ import (
|
||||
"github.com/gobwas/ws"
|
||||
)
|
||||
|
||||
var streamPathReg = regexp.MustCompile("/(jessica/)?((.+)(\\.flv)|(.+))")
|
||||
|
||||
func WsHandler(w http.ResponseWriter, r *http.Request) {
|
||||
sign := r.URL.Query().Get("sign")
|
||||
isFlv := false
|
||||
@@ -18,9 +20,11 @@ func WsHandler(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(403)
|
||||
return
|
||||
}
|
||||
streamPath := strings.TrimLeft(r.RequestURI, "/")
|
||||
if strings.HasSuffix(streamPath, ".flv") {
|
||||
streamPath = strings.TrimRight(streamPath, ".flv")
|
||||
parts := streamPathReg.FindStringSubmatch(r.RequestURI)
|
||||
stringPath := parts[3]
|
||||
if stringPath == "" {
|
||||
stringPath = parts[5]
|
||||
} else {
|
||||
isFlv = true
|
||||
}
|
||||
conn, _, _, err := ws.UpgradeHTTP(r, w)
|
||||
|
Reference in New Issue
Block a user