diff options
author | atanarjuat <atanarjuat@example.com> | 2022-05-29 18:11:46 +0200 |
---|---|---|
committer | atanarjuat <atanarjuat@example.com> | 2022-05-29 18:25:26 +0200 |
commit | e5067a84ee12230dbfa02778df7d49c74dc39dea (patch) | |
tree | c6bea2b9489eadff06b0f985ec4c7960b2cb85eb /dialer.go | |
parent | ce4b0fb6fb69ffc61bc4fb21b508a6a23b811d55 (diff) |
pass kcp dialer to socks5 proxy
Diffstat (limited to 'dialer.go')
-rw-r--r-- | dialer.go | 15 |
1 files changed, 10 insertions, 5 deletions
@@ -4,7 +4,6 @@ import ( "context" "encoding/base64" "fmt" - "log" "net" "strconv" @@ -134,7 +133,16 @@ func (d *Dialer) Wrap(ctx context.Context, conn net.Conn) (net.Conn, error) { */ // Dial creates an outbound net.Conn and performs the ntor handshake. -func (d *Dialer) Dial(ctx context.Context, network, address string) (net.Conn, error) { +func (d *Dialer) Dial(network, address string) (net.Conn, error) { + ctx := context.Background() + return d.dial(ctx, network, address, func(network, address string) (net.Conn, error) { + conn, err := d.Dialer.DialContext(ctx, network, address) + return conn.(*net.TCPConn), err + }) +} + +// DialContext creates an outbound net.Conn and performs the ntor handshake. +func (d *Dialer) DialContext(ctx context.Context, network, address string) (net.Conn, error) { return d.dial(ctx, network, address, func(network, address string) (net.Conn, error) { return d.Dialer.DialContext(ctx, network, address) }) @@ -153,12 +161,9 @@ func (d *Dialer) dial(ctx context.Context, network, address string, f func(netwo if err != nil { return nil, err } - if d.DialFunc != nil { - log.Println("REPLACING DIALFUNC") f = d.DialFunc } - return d.clientFactory.Dial(network, address, f, args) } |