mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-24 01:08:31 +02:00
fix(route): correct URL construction for IPv6 host
This commit is contained in:
@@ -277,11 +277,11 @@ func (r *Route) validate() gperr.Error {
|
|||||||
if r.Port.Listening != 0 {
|
if r.Port.Listening != 0 {
|
||||||
errs.Addf("unexpected listening port for %s scheme", r.Scheme)
|
errs.Addf("unexpected listening port for %s scheme", r.Scheme)
|
||||||
}
|
}
|
||||||
r.ProxyURL = gperr.Collect(&errs, nettypes.ParseURL, fmt.Sprintf("%s://%s:%d", r.Scheme, r.Host, r.Port.Proxy))
|
r.ProxyURL = gperr.Collect(&errs, nettypes.ParseURL, fmt.Sprintf("%s://%s", r.Scheme, net.JoinHostPort(r.Host, strconv.Itoa(r.Port.Proxy))))
|
||||||
case route.SchemeTCP, route.SchemeUDP:
|
case route.SchemeTCP, route.SchemeUDP:
|
||||||
if r.ShouldExclude() {
|
if r.ShouldExclude() {
|
||||||
// should exclude, we don't care the scheme here.
|
// should exclude, we don't care the scheme here.
|
||||||
r.ProxyURL = gperr.Collect(&errs, nettypes.ParseURL, fmt.Sprintf("%s://%s:%d", r.Scheme, r.Host, r.Port.Proxy))
|
r.ProxyURL = gperr.Collect(&errs, nettypes.ParseURL, fmt.Sprintf("%s://%s", r.Scheme, net.JoinHostPort(r.Host, strconv.Itoa(r.Port.Proxy))))
|
||||||
} else {
|
} else {
|
||||||
if r.Bind == "" {
|
if r.Bind == "" {
|
||||||
r.Bind = "0.0.0.0"
|
r.Bind = "0.0.0.0"
|
||||||
@@ -306,8 +306,8 @@ func (r *Route) validate() gperr.Error {
|
|||||||
lScheme := toNetwork(bindIP, r.Scheme)
|
lScheme := toNetwork(bindIP, r.Scheme)
|
||||||
rScheme := toNetwork(remoteIP, r.Scheme)
|
rScheme := toNetwork(remoteIP, r.Scheme)
|
||||||
|
|
||||||
r.LisURL = gperr.Collect(&errs, nettypes.ParseURL, fmt.Sprintf("%s://%s:%d", lScheme, r.Bind, r.Port.Listening))
|
r.LisURL = gperr.Collect(&errs, nettypes.ParseURL, fmt.Sprintf("%s://%s", lScheme, net.JoinHostPort(r.Bind, strconv.Itoa(r.Port.Listening))))
|
||||||
r.ProxyURL = gperr.Collect(&errs, nettypes.ParseURL, fmt.Sprintf("%s://%s:%d", rScheme, r.Host, r.Port.Proxy))
|
r.ProxyURL = gperr.Collect(&errs, nettypes.ParseURL, fmt.Sprintf("%s://%s", rScheme, net.JoinHostPort(r.Host, strconv.Itoa(r.Port.Proxy))))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user