feat(launcher): add host overrides for launcher and gateway

This commit is contained in:
lc6464
2026-04-13 17:29:22 +08:00
parent df9124b824
commit 4e977367c2
8 changed files with 323 additions and 13 deletions
+32
View File
@@ -11,6 +11,11 @@ import (
)
func (h *Handler) effectiveLauncherPublic() bool {
if h.serverHostExplicit {
// -host takes precedence over -public and launcher-config public setting.
return false
}
if h.serverPublicExplicit {
return h.serverPublic
}
@@ -23,7 +28,34 @@ func (h *Handler) effectiveLauncherPublic() bool {
return h.serverPublic
}
func canonicalLauncherBindHost(host string) string {
host = strings.TrimSpace(host)
if host == "" || strings.EqualFold(host, "localhost") {
return "127.0.0.1"
}
return host
}
func (h *Handler) launcherAndGatewayBindHostsAligned() bool {
cfg, err := config.LoadConfig(h.configPath)
if err != nil || cfg == nil {
return false
}
// With -host specified, -public is ignored, so launcher's legacy bind host is loopback.
launcherHost := canonicalLauncherBindHost("127.0.0.1")
gatewayHost := canonicalLauncherBindHost(cfg.Gateway.Host)
return launcherHost == gatewayHost
}
func (h *Handler) gatewayHostOverride() string {
if h.serverHostExplicit {
if h.launcherAndGatewayBindHostsAligned() {
return strings.TrimSpace(h.serverHost)
}
return ""
}
if h.effectiveLauncherPublic() {
return "0.0.0.0"
}