summaryrefslogtreecommitdiff
path: root/dialer.go
diff options
context:
space:
mode:
authoratanarjuat <atanarjuat@example.com>2022-05-29 18:11:46 +0200
committeratanarjuat <atanarjuat@example.com>2022-05-29 18:25:26 +0200
commite5067a84ee12230dbfa02778df7d49c74dc39dea (patch)
treec6bea2b9489eadff06b0f985ec4c7960b2cb85eb /dialer.go
parentce4b0fb6fb69ffc61bc4fb21b508a6a23b811d55 (diff)
pass kcp dialer to socks5 proxy
Diffstat (limited to 'dialer.go')
-rw-r--r--dialer.go15
1 files changed, 10 insertions, 5 deletions
diff --git a/dialer.go b/dialer.go
index db4c6ba..f38586d 100644
--- a/dialer.go
+++ b/dialer.go
@@ -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)
}