diff --git a/pkg/config/gateway.go b/pkg/config/gateway.go index 7dc620fc8..3d22568c8 100644 --- a/pkg/config/gateway.go +++ b/pkg/config/gateway.go @@ -10,10 +10,10 @@ import ( const DefaultGatewayLogLevel = "warn" type GatewayConfig struct { - Host string `json:"host" env:"PICOCLAW_GATEWAY_HOST"` - Port int `json:"port" env:"PICOCLAW_GATEWAY_PORT"` - HotReload bool `json:"hot_reload" env:"PICOCLAW_GATEWAY_HOT_RELOAD"` - LogLevel string `json:"log_level,omitempty" env:"PICOCLAW_LOG_LEVEL"` + Host string `json:"host" env:"PICOCLAW_GATEWAY_HOST"` + Port int `json:"port" env:"PICOCLAW_GATEWAY_PORT"` + HotReload bool `json:"hot_reload" env:"PICOCLAW_GATEWAY_HOT_RELOAD"` + LogLevel string `json:"log_level,omitempty" env:"PICOCLAW_LOG_LEVEL"` AllowedCIDRs []string `json:"allowed_cidrs,omitempty"` } diff --git a/pkg/gateway/gateway.go b/pkg/gateway/gateway.go index 9e27f8dec..7e9e66cbc 100644 --- a/pkg/gateway/gateway.go +++ b/pkg/gateway/gateway.go @@ -438,9 +438,15 @@ func setupAndStartServices( } if runningServices.ListenHost == gatewayFallbackBindHost { - fmt.Printf("✓ Health endpoints available on all interfaces at port %d (/health, /ready and /reload POST)\n", cfg.Gateway.Port) + fmt.Printf( + "✓ Health endpoints available on all interfaces at port %d (/health, /ready and /reload POST)\n", + cfg.Gateway.Port, + ) } else { - fmt.Printf("✓ Health endpoints available at http://%s/health, /ready and /reload (POST)\n", runningServices.ListenAddr) + fmt.Printf( + "✓ Health endpoints available at http://%s/health, /ready and /reload (POST)\n", + runningServices.ListenAddr, + ) } if len(runningServices.EffectiveCIDRs) > 0 { fmt.Printf("✓ Gateway CIDR allowlist enabled: %s\n", strings.Join(runningServices.EffectiveCIDRs, ", ")) diff --git a/pkg/gateway/network_policy.go b/pkg/gateway/network_policy.go index 7827dd8b4..4adf0580d 100644 --- a/pkg/gateway/network_policy.go +++ b/pkg/gateway/network_policy.go @@ -30,7 +30,11 @@ var ( discoverGatewayCIDRs = discoverLocalInterfaceCIDRs ) -func resolveGatewayListenDecision(configuredHost string, port int, configuredCIDRs []string) (*gatewayListenDecision, error) { +func resolveGatewayListenDecision( + configuredHost string, + port int, + configuredCIDRs []string, +) (*gatewayListenDecision, error) { host := strings.TrimSpace(configuredHost) if host == "" { host = gatewayDefaultLoopbackHost @@ -94,11 +98,17 @@ func resolveGatewayListenDecision(configuredHost string, port int, configuredCID } return &gatewayListenDecision{ - BindHost: gatewayFallbackBindHost, - Port: port, - AllowedCIDRs: fallbackCIDRs, - AutoFallback: true, - FallbackReason: fmt.Sprintf("loopback bind %s:%d failed, fallback to %s:%d with CIDR allowlist", host, port, gatewayFallbackBindHost, port), + BindHost: gatewayFallbackBindHost, + Port: port, + AllowedCIDRs: fallbackCIDRs, + AutoFallback: true, + FallbackReason: fmt.Sprintf( + "loopback bind %s:%d failed, fallback to %s:%d with CIDR allowlist", + host, + port, + gatewayFallbackBindHost, + port, + ), }, nil } @@ -159,7 +169,8 @@ func discoverLocalInterfaceCIDRs() ([]string, error) { continue } ip := ipNet.IP - if ip.IsLoopback() || ip.IsUnspecified() || ip.IsMulticast() || ip.IsInterfaceLocalMulticast() || ip.IsLinkLocalMulticast() || ip.IsLinkLocalUnicast() { + if ip.IsLoopback() || ip.IsUnspecified() || ip.IsMulticast() || + ip.IsInterfaceLocalMulticast() || ip.IsLinkLocalMulticast() || ip.IsLinkLocalUnicast() { continue }