do not edit the generated x_net_proxy.go

This commit is contained in:
Philip Hamer 2021-12-03 15:59:00 -05:00
parent 7f3a5bcae0
commit f724bd6a6c
No known key found for this signature in database
GPG Key ID: 1977721B2884BED3
2 changed files with 9 additions and 16 deletions

View File

@ -15,6 +15,13 @@ import (
"strings" "strings"
) )
// // proxyDialerEx extends the generated proxy_Dialer
type proxyDialerEx interface {
proxy_Dialer
// UsesTLS indicates whether we expect to dial to a TLS proxy
UsesTLS() bool
}
type netDialerFunc struct { type netDialerFunc struct {
fn func(network, addr string) (net.Conn, error) fn func(network, addr string) (net.Conn, error)
usesTLS bool usesTLS bool
@ -30,11 +37,11 @@ func (ndf *netDialerFunc) UsesTLS() bool {
func init() { func init() {
proxy_RegisterDialerType("http", func(proxyURL *url.URL, forwardDialer proxy_Dialer) (proxy_Dialer, error) { proxy_RegisterDialerType("http", func(proxyURL *url.URL, forwardDialer proxy_Dialer) (proxy_Dialer, error) {
return &httpProxyDialer{proxyURL: proxyURL, forwardDial: forwardDialer.Dial, usesTLS: forwardDialer.UsesTLS()}, nil return &httpProxyDialer{proxyURL: proxyURL, forwardDial: forwardDialer.Dial, usesTLS: false}, nil
}) })
proxy_RegisterDialerType("https", func(proxyURL *url.URL, forwardDialer proxy_Dialer) (proxy_Dialer, error) { proxy_RegisterDialerType("https", func(proxyURL *url.URL, forwardDialer proxy_Dialer) (proxy_Dialer, error) {
fwd := forwardDialer.Dial fwd := forwardDialer.Dial
if !forwardDialer.UsesTLS() { if dialerEx, ok := forwardDialer.(proxyDialerEx); !ok || !dialerEx.UsesTLS() {
tlsDialer := &tls.Dialer{ tlsDialer := &tls.Dialer{
Config: &tls.Config{}, Config: &tls.Config{},
NetDialer: &net.Dialer{}, NetDialer: &net.Dialer{},

View File

@ -27,10 +27,6 @@ func (proxy_direct) Dial(network, addr string) (net.Conn, error) {
return net.Dial(network, addr) return net.Dial(network, addr)
} }
func (proxy_direct) UsesTLS() bool {
return false
}
// A PerHost directs connections to a default Dialer unless the host name // A PerHost directs connections to a default Dialer unless the host name
// requested matches one of a number of exceptions. // requested matches one of a number of exceptions.
type proxy_PerHost struct { type proxy_PerHost struct {
@ -63,10 +59,6 @@ func (p *proxy_PerHost) Dial(network, addr string) (c net.Conn, err error) {
return p.dialerForRequest(host).Dial(network, addr) return p.dialerForRequest(host).Dial(network, addr)
} }
func (p *proxy_PerHost) UsesTLS() bool {
return p.def.UsesTLS() || p.bypass.UsesTLS()
}
func (p *proxy_PerHost) dialerForRequest(host string) proxy_Dialer { func (p *proxy_PerHost) dialerForRequest(host string) proxy_Dialer {
if ip := net.ParseIP(host); ip != nil { if ip := net.ParseIP(host); ip != nil {
for _, net := range p.bypassNetworks { for _, net := range p.bypassNetworks {
@ -169,8 +161,6 @@ func (p *proxy_PerHost) AddHost(host string) {
type proxy_Dialer interface { type proxy_Dialer interface {
// Dial connects to the given address via the proxy. // Dial connects to the given address via the proxy.
Dial(network, addr string) (c net.Conn, err error) Dial(network, addr string) (c net.Conn, err error)
// UsesTLS indicates whether we expect to dial to a TLS proxy
UsesTLS() bool
} }
// Auth contains authentication parameters that specific Dialers may require. // Auth contains authentication parameters that specific Dialers may require.
@ -348,10 +338,6 @@ func (s *proxy_socks5) Dial(network, addr string) (net.Conn, error) {
return conn, nil return conn, nil
} }
func (s *proxy_socks5) UsesTLS() bool {
return s.forward.UsesTLS()
}
// connect takes an existing connection to a socks5 proxy server, // connect takes an existing connection to a socks5 proxy server,
// and commands the server to extend that connection to target, // and commands the server to extend that connection to target,
// which must be a canonical address with a host and port. // which must be a canonical address with a host and port.