mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-16 21:56:40 -05:00
reverseproxy: Fix parsing of source IP in case it's an ipv6 address (#5569)
This commit is contained in:
parent
56af1ceb32
commit
2ddb717144
1 changed files with 7 additions and 1 deletions
|
@ -637,7 +637,13 @@ func (h Handler) prepareRequest(req *http.Request, repl *caddy.Replacer) (*http.
|
|||
addrPort, err := netip.ParseAddrPort(address)
|
||||
if err != nil {
|
||||
// OK; probably didn't have a port
|
||||
addrPort, _ = netip.ParseAddrPort(address + ":0")
|
||||
addr, err := netip.ParseAddr(address)
|
||||
if err != nil {
|
||||
// Doesn't seem like a valid ip address at all
|
||||
} else {
|
||||
// Ok, only the port was missing
|
||||
addrPort = netip.AddrPortFrom(addr, 0)
|
||||
}
|
||||
}
|
||||
proxyProtocolInfo := ProxyProtocolInfo{AddrPort: addrPort}
|
||||
caddyhttp.SetVar(req.Context(), proxyProtocolInfoVarKey, proxyProtocolInfo)
|
||||
|
|
Loading…
Reference in a new issue