update module path
This commit is contained in:
parent
0fc8789cfa
commit
0dc7a7dffc
|
@ -3,7 +3,7 @@ package main
|
|||
import (
|
||||
"time"
|
||||
|
||||
"github.com/thinkgos/go-socks5/ccsocks5"
|
||||
"git.tcp.direct/kayos/go-socks5/ccsocks5"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/thinkgos/go-socks5"
|
||||
"git.tcp.direct/kayos/go-socks5"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
2
auth.go
2
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
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
6
go.mod
6
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
|
||||
)
|
||||
|
|
16
handle.go
16
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).
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"io"
|
||||
"net"
|
||||
|
||||
"github.com/thinkgos/go-socks5/bufferpool"
|
||||
"git.tcp.direct/kayos/go-socks5/bufferpool"
|
||||
)
|
||||
|
||||
// Option user's option
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue