From 0dc7a7dffce83e56f5739196420efa0db79087a6 Mon Sep 17 00:00:00 2001 From: "kayos@tcp.direct" Date: Sun, 16 Oct 2022 18:36:23 -0700 Subject: [PATCH] update module path --- _example/client/main.go | 2 +- _example/server/main.go | 2 +- _example/testassociate/main.go | 4 ++-- _example/testconnect/main.go | 4 ++-- auth.go | 2 +- auth_test.go | 2 +- ccsocks5/client.go | 4 ++-- ccsocks5/option.go | 2 +- ccsocks5/underconn.go | 4 ++-- go.mod | 6 +++--- handle.go | 16 ++++++++++++---- handle_test.go | 4 ++-- option.go | 2 +- ruleset.go | 2 +- ruleset_test.go | 2 +- server.go | 4 ++-- server_test.go | 2 +- testing/socks5_test.go | 6 +++--- 18 files changed, 39 insertions(+), 31 deletions(-) diff --git a/_example/client/main.go b/_example/client/main.go index c8f83ac..15c2354 100644 --- a/_example/client/main.go +++ b/_example/client/main.go @@ -3,7 +3,7 @@ package main import ( "time" - "github.com/thinkgos/go-socks5/ccsocks5" + "git.tcp.direct/kayos/go-socks5/ccsocks5" ) func main() { diff --git a/_example/server/main.go b/_example/server/main.go index d1ad7f8..1716538 100644 --- a/_example/server/main.go +++ b/_example/server/main.go @@ -4,7 +4,7 @@ import ( "log" "os" - "github.com/thinkgos/go-socks5" + "git.tcp.direct/kayos/go-socks5" ) func main() { diff --git a/_example/testassociate/main.go b/_example/testassociate/main.go index ba09bfd..07d8fd9 100644 --- a/_example/testassociate/main.go +++ b/_example/testassociate/main.go @@ -7,8 +7,8 @@ import ( "os" "time" - "github.com/thinkgos/go-socks5" - "github.com/thinkgos/go-socks5/ccsocks5" + "git.tcp.direct/kayos/go-socks5" + "git.tcp.direct/kayos/go-socks5/ccsocks5" ) func handleErr(err error) { diff --git a/_example/testconnect/main.go b/_example/testconnect/main.go index 15dc8f3..af2c588 100644 --- a/_example/testconnect/main.go +++ b/_example/testconnect/main.go @@ -7,8 +7,8 @@ import ( "os" "time" - "github.com/thinkgos/go-socks5" - "github.com/thinkgos/go-socks5/ccsocks5" + "git.tcp.direct/kayos/go-socks5" + "git.tcp.direct/kayos/go-socks5/ccsocks5" ) func handleErr(err error) { diff --git a/auth.go b/auth.go index 1a58df0..2f00b79 100644 --- a/auth.go +++ b/auth.go @@ -3,7 +3,7 @@ package socks5 import ( "io" - "github.com/thinkgos/go-socks5/statute" + "git.tcp.direct/kayos/go-socks5/statute" ) // AuthContext A Request encapsulates authentication state provided diff --git a/auth_test.go b/auth_test.go index 2fe9deb..f3bd261 100644 --- a/auth_test.go +++ b/auth_test.go @@ -8,7 +8,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/thinkgos/go-socks5/statute" + "git.tcp.direct/kayos/go-socks5/statute" ) func TestNoAuth(t *testing.T) { diff --git a/ccsocks5/client.go b/ccsocks5/client.go index 2cc4f40..5a93402 100644 --- a/ccsocks5/client.go +++ b/ccsocks5/client.go @@ -7,8 +7,8 @@ import ( "golang.org/x/net/proxy" - "github.com/thinkgos/go-socks5/bufferpool" - "github.com/thinkgos/go-socks5/statute" + "git.tcp.direct/kayos/go-socks5/bufferpool" + "git.tcp.direct/kayos/go-socks5/statute" ) // Client is socks5 client. diff --git a/ccsocks5/option.go b/ccsocks5/option.go index ce27e0a..94d10b4 100644 --- a/ccsocks5/option.go +++ b/ccsocks5/option.go @@ -3,7 +3,7 @@ package ccsocks5 import ( "golang.org/x/net/proxy" - "github.com/thinkgos/go-socks5/bufferpool" + "git.tcp.direct/kayos/go-socks5/bufferpool" ) // Option user's option of the client diff --git a/ccsocks5/underconn.go b/ccsocks5/underconn.go index 4b9f043..0f4007f 100644 --- a/ccsocks5/underconn.go +++ b/ccsocks5/underconn.go @@ -3,8 +3,8 @@ package ccsocks5 import ( "net" - "github.com/thinkgos/go-socks5/bufferpool" - "github.com/thinkgos/go-socks5/statute" + "git.tcp.direct/kayos/go-socks5/bufferpool" + "git.tcp.direct/kayos/go-socks5/statute" ) // underConnect under connect diff --git a/go.mod b/go.mod index 0cf6508..90f4839 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,8 @@ -module github.com/thinkgos/go-socks5 +module git.tcp.direct/kayos/go-socks5 -go 1.14 +go 1.19 require ( github.com/stretchr/testify v1.6.1 - golang.org/x/net v0.0.0-20210614182718-04defd469f4e + golang.org/x/net latest ) diff --git a/handle.go b/handle.go index e466fbc..261010d 100644 --- a/handle.go +++ b/handle.go @@ -8,7 +8,7 @@ import ( "strings" "sync" - "github.com/thinkgos/go-socks5/statute" + "git.tcp.direct/kayos/go-socks5/statute" ) // AddressRewriter is used to rewrite a destination transparently @@ -108,10 +108,13 @@ func (sf *Server) handleRequest(write io.Writer, req *Request) error { func (sf *Server) handleConnect(ctx context.Context, writer io.Writer, request *Request) error { // Attempt to connect dial := sf.dial + select { + case <-ctx.Done(): + return ctx.Err() + default: + } if dial == nil { - dial = func(ctx context.Context, net_, addr string) (net.Conn, error) { - return net.Dial(net_, addr) - } + dial = func(ctx context.Context, net_, addr string) (net.Conn, error) { return net.Dial(net_, addr) } } target, err := dial(ctx, "tcp", request.DestAddr.String()) if err != nil { @@ -140,6 +143,11 @@ func (sf *Server) handleConnect(ctx context.Context, writer io.Writer, request * sf.goFunc(func() { errCh <- sf.Proxy(writer, target) }) // Wait for i := 0; i < 2; i++ { + select { + case <-ctx.Done(): + return ctx.Err() + default: + } e := <-errCh if e != nil { // return from this function closes target (and conn). diff --git a/handle_test.go b/handle_test.go index 76edfcf..b51180a 100644 --- a/handle_test.go +++ b/handle_test.go @@ -10,8 +10,8 @@ import ( "github.com/stretchr/testify/require" - "github.com/thinkgos/go-socks5/bufferpool" - "github.com/thinkgos/go-socks5/statute" + "git.tcp.direct/kayos/go-socks5/bufferpool" + "git.tcp.direct/kayos/go-socks5/statute" ) type MockConn struct { diff --git a/option.go b/option.go index 56c231c..0bfa9fb 100644 --- a/option.go +++ b/option.go @@ -5,7 +5,7 @@ import ( "io" "net" - "github.com/thinkgos/go-socks5/bufferpool" + "git.tcp.direct/kayos/go-socks5/bufferpool" ) // Option user's option diff --git a/ruleset.go b/ruleset.go index 2e00832..98ad808 100644 --- a/ruleset.go +++ b/ruleset.go @@ -3,7 +3,7 @@ package socks5 import ( "context" - "github.com/thinkgos/go-socks5/statute" + "git.tcp.direct/kayos/go-socks5/statute" ) // RuleSet is used to provide custom rules to allow or prohibit actions diff --git a/ruleset_test.go b/ruleset_test.go index 412b3b0..241f2d5 100644 --- a/ruleset_test.go +++ b/ruleset_test.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/require" - "github.com/thinkgos/go-socks5/statute" + "git.tcp.direct/kayos/go-socks5/statute" ) func TestPermitCommand(t *testing.T) { diff --git a/server.go b/server.go index e66e29c..debf0cf 100644 --- a/server.go +++ b/server.go @@ -10,8 +10,8 @@ import ( "log" "net" - "github.com/thinkgos/go-socks5/bufferpool" - "github.com/thinkgos/go-socks5/statute" + "git.tcp.direct/kayos/go-socks5/bufferpool" + "git.tcp.direct/kayos/go-socks5/statute" ) // GPool is used to implement custom goroutine pool default use goroutine diff --git a/server_test.go b/server_test.go index a645b58..a818128 100644 --- a/server_test.go +++ b/server_test.go @@ -14,7 +14,7 @@ import ( "github.com/stretchr/testify/require" "golang.org/x/net/proxy" - "github.com/thinkgos/go-socks5/statute" + "git.tcp.direct/kayos/go-socks5/statute" ) func TestSOCKS5_Connect(t *testing.T) { diff --git a/testing/socks5_test.go b/testing/socks5_test.go index 9f4cb0a..98547b3 100644 --- a/testing/socks5_test.go +++ b/testing/socks5_test.go @@ -12,9 +12,9 @@ import ( "github.com/stretchr/testify/require" "golang.org/x/net/proxy" - "github.com/thinkgos/go-socks5" - "github.com/thinkgos/go-socks5/bufferpool" - "github.com/thinkgos/go-socks5/ccsocks5" + "git.tcp.direct/kayos/go-socks5" + "git.tcp.direct/kayos/go-socks5/bufferpool" + "git.tcp.direct/kayos/go-socks5/ccsocks5" ) func Test_Socks5_Connect(t *testing.T) {