deduplicate common logic across proxy, visitor, and metrics modules (#5213)

- Replace duplicate parseBasicAuth with existing httppkg.ParseBasicAuth
- Extract buildDomains helper in BaseProxy for HTTP/HTTPS/TCPMux proxies
- Extract toProxyStats helper to deduplicate ProxyStats construction
- Extract startVisitorListener helper in BaseProxy for STCP/SUDP proxies
- Extract acceptLoop helper in BaseVisitor for STCP/XTCP visitors
This commit is contained in:
fatedier
2026-03-07 12:00:27 +08:00
committed by GitHub
parent cf396563f8
commit bb3d0e7140
11 changed files with 74 additions and 177 deletions

View File

@@ -53,15 +53,7 @@ func (pxy *HTTPSProxy) Run() (remoteAddr string, err error) {
pxy.Close()
}
}()
domains := make([]string, 0, len(pxy.cfg.CustomDomains)+1)
for _, d := range pxy.cfg.CustomDomains {
if d != "" {
domains = append(domains, d)
}
}
if pxy.cfg.SubDomain != "" {
domains = append(domains, pxy.cfg.SubDomain+"."+pxy.serverCfg.SubDomainHost)
}
domains := pxy.buildDomains(pxy.cfg.CustomDomains, pxy.cfg.SubDomain)
addrs := make([]string, 0)
for _, domain := range domains {