chore(lint): fix golines formatting in gateway files
This commit is contained in:
parent
8c1b1feaad
commit
be39b34b7b
3 changed files with 30 additions and 13 deletions
|
|
@ -10,10 +10,10 @@ import (
|
||||||
const DefaultGatewayLogLevel = "warn"
|
const DefaultGatewayLogLevel = "warn"
|
||||||
|
|
||||||
type GatewayConfig struct {
|
type GatewayConfig struct {
|
||||||
Host string `json:"host" env:"PICOCLAW_GATEWAY_HOST"`
|
Host string `json:"host" env:"PICOCLAW_GATEWAY_HOST"`
|
||||||
Port int `json:"port" env:"PICOCLAW_GATEWAY_PORT"`
|
Port int `json:"port" env:"PICOCLAW_GATEWAY_PORT"`
|
||||||
HotReload bool `json:"hot_reload" env:"PICOCLAW_GATEWAY_HOT_RELOAD"`
|
HotReload bool `json:"hot_reload" env:"PICOCLAW_GATEWAY_HOT_RELOAD"`
|
||||||
LogLevel string `json:"log_level,omitempty" env:"PICOCLAW_LOG_LEVEL"`
|
LogLevel string `json:"log_level,omitempty" env:"PICOCLAW_LOG_LEVEL"`
|
||||||
AllowedCIDRs []string `json:"allowed_cidrs,omitempty"`
|
AllowedCIDRs []string `json:"allowed_cidrs,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -438,9 +438,15 @@ func setupAndStartServices(
|
||||||
}
|
}
|
||||||
|
|
||||||
if runningServices.ListenHost == gatewayFallbackBindHost {
|
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 {
|
} 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 {
|
if len(runningServices.EffectiveCIDRs) > 0 {
|
||||||
fmt.Printf("✓ Gateway CIDR allowlist enabled: %s\n", strings.Join(runningServices.EffectiveCIDRs, ", "))
|
fmt.Printf("✓ Gateway CIDR allowlist enabled: %s\n", strings.Join(runningServices.EffectiveCIDRs, ", "))
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,11 @@ var (
|
||||||
discoverGatewayCIDRs = discoverLocalInterfaceCIDRs
|
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)
|
host := strings.TrimSpace(configuredHost)
|
||||||
if host == "" {
|
if host == "" {
|
||||||
host = gatewayDefaultLoopbackHost
|
host = gatewayDefaultLoopbackHost
|
||||||
|
|
@ -94,11 +98,17 @@ func resolveGatewayListenDecision(configuredHost string, port int, configuredCID
|
||||||
}
|
}
|
||||||
|
|
||||||
return &gatewayListenDecision{
|
return &gatewayListenDecision{
|
||||||
BindHost: gatewayFallbackBindHost,
|
BindHost: gatewayFallbackBindHost,
|
||||||
Port: port,
|
Port: port,
|
||||||
AllowedCIDRs: fallbackCIDRs,
|
AllowedCIDRs: fallbackCIDRs,
|
||||||
AutoFallback: true,
|
AutoFallback: true,
|
||||||
FallbackReason: fmt.Sprintf("loopback bind %s:%d failed, fallback to %s:%d with CIDR allowlist", host, port, gatewayFallbackBindHost, port),
|
FallbackReason: fmt.Sprintf(
|
||||||
|
"loopback bind %s:%d failed, fallback to %s:%d with CIDR allowlist",
|
||||||
|
host,
|
||||||
|
port,
|
||||||
|
gatewayFallbackBindHost,
|
||||||
|
port,
|
||||||
|
),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -159,7 +169,8 @@ func discoverLocalInterfaceCIDRs() ([]string, error) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
ip := ipNet.IP
|
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
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue