fix(route): allow hostname for stream routes; introduced in 3643add8a3

This commit is contained in:
yusing
2026-01-09 10:09:59 +08:00
parent 7687dca456
commit d4b7ae808f

View File

@@ -286,14 +286,11 @@ func (r *Route) validate() gperr.Error {
r.Bind = "0.0.0.0" r.Bind = "0.0.0.0"
} }
bindIP := net.ParseIP(r.Bind) bindIP := net.ParseIP(r.Bind)
if bindIP == nil {
return gperr.Errorf("invalid bind address %s", r.Bind)
}
remoteIP := net.ParseIP(r.Host) remoteIP := net.ParseIP(r.Host)
if remoteIP == nil {
return gperr.Errorf("invalid remote address %s", r.Host)
}
toNetwork := func(ip net.IP, scheme route.Scheme) string { toNetwork := func(ip net.IP, scheme route.Scheme) string {
if ip == nil { // hostname, indeterminate
return scheme.String()
}
if ip.To4() == nil { if ip.To4() == nil {
if scheme == route.SchemeTCP { if scheme == route.SchemeTCP {
return "tcp6" return "tcp6"