fix(gateway): fix error wrapping and scope in channel-only host resolution
This commit is contained in:
parent
db9e335d60
commit
b80a7b6a82
1 changed files with 18 additions and 6 deletions
|
|
@ -192,14 +192,26 @@ func resolveChannelOnlyListenHost(host string, port int) (string, error) {
|
||||||
if err := probeTCPBind(host, port); err == nil {
|
if err := probeTCPBind(host, port); err == nil {
|
||||||
return host, nil
|
return host, nil
|
||||||
} else if isLoopbackHost(host) {
|
} else if isLoopbackHost(host) {
|
||||||
if fallbackErr := probeTCPBind("0.0.0.0", port); fallbackErr == nil {
|
fallbackErr := probeTCPBind("0.0.0.0", port)
|
||||||
logger.WarnCF("channels", "Loopback host unavailable in channel-only mode, fallback to wildcard", map[string]any{
|
if fallbackErr == nil {
|
||||||
"host": host,
|
logger.WarnCF(
|
||||||
"port": port,
|
"channels",
|
||||||
})
|
"Loopback host unavailable in channel-only mode, fallback to wildcard",
|
||||||
|
map[string]any{
|
||||||
|
"host": host,
|
||||||
|
"port": port,
|
||||||
|
},
|
||||||
|
)
|
||||||
return "0.0.0.0", nil
|
return "0.0.0.0", nil
|
||||||
}
|
}
|
||||||
return "", fmt.Errorf("bind %s:%d failed: %w", host, port, err)
|
return "", fmt.Errorf(
|
||||||
|
"bind fallback 0.0.0.0:%d failed after %s:%d failed: %w (original error: %v)",
|
||||||
|
port,
|
||||||
|
host,
|
||||||
|
port,
|
||||||
|
fallbackErr,
|
||||||
|
err,
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
return "", fmt.Errorf("bind %s:%d failed: %w", host, port, err)
|
return "", fmt.Errorf("bind %s:%d failed: %w", host, port, err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue