From 2afaef24b3d440581df1bd742921287884370ec7 Mon Sep 17 00:00:00 2001 From: Brian Dwyer Date: Sun, 7 Mar 2021 12:50:44 -0500 Subject: [PATCH] Adjust override logic --- pkg/gontlm-proxy.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/pkg/gontlm-proxy.go b/pkg/gontlm-proxy.go index fdf1507..e4c1cc8 100644 --- a/pkg/gontlm-proxy.go +++ b/pkg/gontlm-proxy.go @@ -83,17 +83,20 @@ func Run() { proxyDialer := func(addr string, pxyUrl *url.URL) proxyplease.DialContext { cacheKey := addr - if pxyUrl != nil && pxyUrl.Host != "" { - cacheKey = strings.Split(pxyUrl.Host, ":")[0] + if pxyUrl != nil && pxyUrl.Host != "" && ProxyOverrides == nil { + cacheKey = pxyUrl.Host } + s, _, _ := dialerCache.Memoize(cacheKey, func() (pxyCtx interface{}, err error) { if ProxyOverrides != nil { - if pxy, ok := (*ProxyOverrides)[addr]; ok { - if pxy == nil { - d := net.Dialer{} - return d.DialContext, nil + for _, s := range []string{addr, strings.Split(addr, ":")[0]} { + if pxy, ok := (*ProxyOverrides)[strings.ToLower(s)]; ok { + if pxy == nil { + d := net.Dialer{} + return d.DialContext, nil + } + pxyUrl = pxy } - pxyUrl = pxy } }