use the network and address from the dialInfo if there is no proxy or the upstream network is unix

This commit is contained in:
WeidiDeng 2025-10-11 09:01:11 +08:00
parent ed4281ff57
commit 740ff2cef8
No known key found for this signature in database
GPG key ID: 25F87CE1741EC7CD

View file

@ -276,7 +276,7 @@ func (h *HTTPTransport) NewTransport(caddyCtx caddy.Context) (*http.Transport, e
// This means we can safely use the address in dialInfo if proxy is not used (the address and network will be same any way) // This means we can safely use the address in dialInfo if proxy is not used (the address and network will be same any way)
// or if the upstream is unix (because there is no way socks or http proxy can be used for unix address). // or if the upstream is unix (because there is no way socks or http proxy can be used for unix address).
if dialInfo, ok := GetDialInfo(ctx); ok { if dialInfo, ok := GetDialInfo(ctx); ok {
if strings.HasPrefix(dialInfo.Network, "unix") { if caddyhttp.GetVar(ctx, proxyVarKey) == nil || strings.HasPrefix(dialInfo.Network, "unix") {
network = dialInfo.Network network = dialInfo.Network
address = dialInfo.Address address = dialInfo.Address
} }