diff --git a/internal/nodes/http_request.go b/internal/nodes/http_request.go index 4a52952..2da70a1 100644 --- a/internal/nodes/http_request.go +++ b/internal/nodes/http_request.go @@ -469,11 +469,17 @@ func (this *HTTPRequest) configureWeb(web *serverconfigs.HTTPWebConfig, isTop bo if this.web.RequestScripts == nil { this.web.RequestScripts = web.RequestScripts } else { - if web.RequestScripts.OnInitScript != nil && (web.RequestScripts.OnInitScript.IsPrior || isTop) { - this.web.RequestScripts.OnInitScript = web.RequestScripts.OnInitScript + if web.RequestScripts.InitGroup != nil && (web.RequestScripts.InitGroup.IsPrior || isTop) { + if this.web.RequestScripts == nil { + this.web.RequestScripts = &serverconfigs.HTTPRequestScriptsConfig{} + } + this.web.RequestScripts.InitGroup = web.RequestScripts.InitGroup } - if web.RequestScripts.OnRequestScript != nil && (web.RequestScripts.OnRequestScript.IsPrior || isTop) { - this.web.RequestScripts.OnRequestScript = web.RequestScripts.OnRequestScript + if web.RequestScripts.RequestGroup != nil && (web.RequestScripts.RequestGroup.IsPrior || isTop) { + if this.web.RequestScripts == nil { + this.web.RequestScripts = &serverconfigs.HTTPRequestScriptsConfig{} + } + this.web.RequestScripts.RequestGroup = web.RequestScripts.RequestGroup } } } diff --git a/internal/nodes/listener_manager.go b/internal/nodes/listener_manager.go index 7abb785..845e74f 100644 --- a/internal/nodes/listener_manager.go +++ b/internal/nodes/listener_manager.go @@ -14,6 +14,7 @@ import ( "os/exec" "regexp" "runtime" + "sort" "strings" "sync" "time" @@ -29,6 +30,8 @@ type ListenerManager struct { retryListenerMap map[string]*Listener // 需要重试的监听器 addr => Listener ticker *time.Ticker + + lastPortStrings string } // NewListenerManager 获取新对象 @@ -223,8 +226,7 @@ func (this *ListenerManager) addToFirewalld(groupAddrs []string) { return } - remotelogs.Println("FIREWALLD", "open ports automatically") - + // 组合端口号 var ports = []string{} for _, addr := range groupAddrs { var protocol = "tcp" @@ -242,11 +244,20 @@ func (this *ListenerManager) addToFirewalld(groupAddrs []string) { return } + // 检查是否有变化 + sort.Strings(ports) + var newPortStrings = strings.Join(ports, ",") + if newPortStrings == this.lastPortStrings { + return + } + this.lastPortStrings = newPortStrings + firewallCmd, err := exec.LookPath("firewall-cmd") if err != nil || len(firewallCmd) == 0 { return } + remotelogs.Println("FIREWALLD", "open ports automatically") for _, port := range ports { { // TODO 需要支持sudo