fix: xtransport: Ensure we strip [] from host/ip before net.ParseIP
This commit is contained in:
parent
ac4843b460
commit
890dcca270
|
@ -68,6 +68,10 @@ func NewXTransport() *XTransport {
|
||||||
return &xTransport
|
return &xTransport
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ParseIP(ipStr string) net.IP {
|
||||||
|
return net.ParseIP(strings.TrimRight(strings.TrimLeft(ipStr, "["), "]"))
|
||||||
|
}
|
||||||
|
|
||||||
func (xTransport *XTransport) clearCache() {
|
func (xTransport *XTransport) clearCache() {
|
||||||
xTransport.cachedIPs.Lock()
|
xTransport.cachedIPs.Lock()
|
||||||
xTransport.cachedIPs.cache = make(map[string]string)
|
xTransport.cachedIPs.cache = make(map[string]string)
|
||||||
|
@ -232,7 +236,7 @@ func (xTransport *XTransport) Fetch(method string, url *url.URL, accept string,
|
||||||
resolveByProxy = true
|
resolveByProxy = true
|
||||||
}
|
}
|
||||||
var foundIP *string
|
var foundIP *string
|
||||||
if !resolveByProxy && net.ParseIP(host) == nil {
|
if !resolveByProxy && ParseIP(host) == nil {
|
||||||
xTransport.cachedIPs.RLock()
|
xTransport.cachedIPs.RLock()
|
||||||
cachedIP := xTransport.cachedIPs.cache[host]
|
cachedIP := xTransport.cachedIPs.cache[host]
|
||||||
xTransport.cachedIPs.RUnlock()
|
xTransport.cachedIPs.RUnlock()
|
||||||
|
|
Loading…
Reference in New Issue