HTTP防火墙在启动时检测是否可用

This commit is contained in:
GoEdgeLab
2024-03-08 10:21:59 +08:00
parent 216b5c8674
commit 302c753184

View File

@@ -9,6 +9,7 @@ import (
"os"
"runtime"
"sync"
"time"
)
var currentFirewall FirewallInterface
@@ -41,7 +42,14 @@ func Firewall() FirewallInterface {
endpoint, _ := os.LookupEnv("EDGE_HTTP_FIREWALL_ENDPOINT")
if len(endpoint) > 0 {
var httpFirewall = NewHTTPFirewall(endpoint)
currentFirewall = httpFirewall
for i := 0; i < 10; i++ {
if httpFirewall.IsReady() {
currentFirewall = httpFirewall
remotelogs.Println("FIREWALL", "using http firewall '"+endpoint+"'")
break
}
time.Sleep(1 * time.Second)
}
return httpFirewall
}
}