fix: route autoconfiguration

This commit is contained in:
yusing 2025-05-11 21:38:43 +08:00
parent 1382137f20
commit e300170c51

View file

@ -2,6 +2,7 @@ package docker
import ( import (
"context" "context"
"net"
"net/url" "net/url"
"strconv" "strconv"
"strings" "strings"
@ -164,12 +165,12 @@ func (c *Container) isLocal() bool {
if err != nil { if err != nil {
return false return false
} }
switch url.Hostname() { hostname := url.Hostname()
case "localhost", "127.0.0.1", "::1": ip := net.ParseIP(hostname)
return true if ip != nil {
default: return ip.IsLoopback() || ip.IsUnspecified()
return false
} }
return hostname == "localhost"
} }
func (c *Container) setPublicHostname() { func (c *Container) setPublicHostname() {