同时设置Websocket允许来源域和防盗链时,以Websocket设置为优先

This commit is contained in:
刘祥超
2023-06-16 09:56:37 +08:00
parent 83ac62cda3
commit ac2d57d2f1
5 changed files with 54 additions and 7 deletions

View File

@@ -9,11 +9,8 @@ import (
"github.com/iwind/TeaGo/logs"
"net/http"
"os"
"regexp"
)
var urlPrefixRegexp = regexp.MustCompile("^(?i)(http|https|ftp)://")
// 请求特殊页面
func (this *HTTPRequest) doPage(status int) (shouldStop bool) {
if len(this.web.Pages) == 0 {
@@ -49,7 +46,7 @@ func (this *HTTPRequest) doPageLookup(pages []*serverconfigs.HTTPPageConfig, sta
for _, page := range pages {
if page.Match(status) {
if len(page.BodyType) == 0 || page.BodyType == shared.BodyTypeURL {
if urlPrefixRegexp.MatchString(page.URL) {
if urlSchemeRegexp.MatchString(page.URL) {
var newStatus = page.NewStatus
if newStatus <= 0 {
newStatus = status