diff options
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) } |