update module path
This commit is contained in:
parent
0fc8789cfa
commit
0dc7a7dffc
@ -3,7 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/thinkgos/go-socks5/ccsocks5"
|
"git.tcp.direct/kayos/go-socks5/ccsocks5"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/thinkgos/go-socks5"
|
"git.tcp.direct/kayos/go-socks5"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
@ -7,8 +7,8 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/thinkgos/go-socks5"
|
"git.tcp.direct/kayos/go-socks5"
|
||||||
"github.com/thinkgos/go-socks5/ccsocks5"
|
"git.tcp.direct/kayos/go-socks5/ccsocks5"
|
||||||
)
|
)
|
||||||
|
|
||||||
func handleErr(err error) {
|
func handleErr(err error) {
|
||||||
|
@ -7,8 +7,8 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/thinkgos/go-socks5"
|
"git.tcp.direct/kayos/go-socks5"
|
||||||
"github.com/thinkgos/go-socks5/ccsocks5"
|
"git.tcp.direct/kayos/go-socks5/ccsocks5"
|
||||||
)
|
)
|
||||||
|
|
||||||
func handleErr(err error) {
|
func handleErr(err error) {
|
||||||
|
2
auth.go
2
auth.go
@ -3,7 +3,7 @@ package socks5
|
|||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
"github.com/thinkgos/go-socks5/statute"
|
"git.tcp.direct/kayos/go-socks5/statute"
|
||||||
)
|
)
|
||||||
|
|
||||||
// AuthContext A Request encapsulates authentication state provided
|
// AuthContext A Request encapsulates authentication state provided
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/thinkgos/go-socks5/statute"
|
"git.tcp.direct/kayos/go-socks5/statute"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestNoAuth(t *testing.T) {
|
func TestNoAuth(t *testing.T) {
|
||||||
|
@ -7,8 +7,8 @@ import (
|
|||||||
|
|
||||||
"golang.org/x/net/proxy"
|
"golang.org/x/net/proxy"
|
||||||
|
|
||||||
"github.com/thinkgos/go-socks5/bufferpool"
|
"git.tcp.direct/kayos/go-socks5/bufferpool"
|
||||||
"github.com/thinkgos/go-socks5/statute"
|
"git.tcp.direct/kayos/go-socks5/statute"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Client is socks5 client.
|
// Client is socks5 client.
|
||||||
|
@ -3,7 +3,7 @@ package ccsocks5
|
|||||||
import (
|
import (
|
||||||
"golang.org/x/net/proxy"
|
"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
|
// Option user's option of the client
|
||||||
|
@ -3,8 +3,8 @@ package ccsocks5
|
|||||||
import (
|
import (
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
"github.com/thinkgos/go-socks5/bufferpool"
|
"git.tcp.direct/kayos/go-socks5/bufferpool"
|
||||||
"github.com/thinkgos/go-socks5/statute"
|
"git.tcp.direct/kayos/go-socks5/statute"
|
||||||
)
|
)
|
||||||
|
|
||||||
// underConnect under connect
|
// 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 (
|
require (
|
||||||
github.com/stretchr/testify v1.6.1
|
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"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/thinkgos/go-socks5/statute"
|
"git.tcp.direct/kayos/go-socks5/statute"
|
||||||
)
|
)
|
||||||
|
|
||||||
// AddressRewriter is used to rewrite a destination transparently
|
// 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 {
|
func (sf *Server) handleConnect(ctx context.Context, writer io.Writer, request *Request) error {
|
||||||
// Attempt to connect
|
// Attempt to connect
|
||||||
dial := sf.dial
|
dial := sf.dial
|
||||||
|
select {
|
||||||
|
case <-ctx.Done():
|
||||||
|
return ctx.Err()
|
||||||
|
default:
|
||||||
|
}
|
||||||
if dial == nil {
|
if dial == nil {
|
||||||
dial = func(ctx context.Context, net_, addr string) (net.Conn, error) {
|
dial = func(ctx context.Context, net_, addr string) (net.Conn, error) { return net.Dial(net_, addr) }
|
||||||
return net.Dial(net_, addr)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
target, err := dial(ctx, "tcp", request.DestAddr.String())
|
target, err := dial(ctx, "tcp", request.DestAddr.String())
|
||||||
if err != nil {
|
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) })
|
sf.goFunc(func() { errCh <- sf.Proxy(writer, target) })
|
||||||
// Wait
|
// Wait
|
||||||
for i := 0; i < 2; i++ {
|
for i := 0; i < 2; i++ {
|
||||||
|
select {
|
||||||
|
case <-ctx.Done():
|
||||||
|
return ctx.Err()
|
||||||
|
default:
|
||||||
|
}
|
||||||
e := <-errCh
|
e := <-errCh
|
||||||
if e != nil {
|
if e != nil {
|
||||||
// return from this function closes target (and conn).
|
// return from this function closes target (and conn).
|
||||||
|
@ -10,8 +10,8 @@ import (
|
|||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/thinkgos/go-socks5/bufferpool"
|
"git.tcp.direct/kayos/go-socks5/bufferpool"
|
||||||
"github.com/thinkgos/go-socks5/statute"
|
"git.tcp.direct/kayos/go-socks5/statute"
|
||||||
)
|
)
|
||||||
|
|
||||||
type MockConn struct {
|
type MockConn struct {
|
||||||
|
@ -5,7 +5,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
"github.com/thinkgos/go-socks5/bufferpool"
|
"git.tcp.direct/kayos/go-socks5/bufferpool"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Option user's option
|
// Option user's option
|
||||||
|
@ -3,7 +3,7 @@ package socks5
|
|||||||
import (
|
import (
|
||||||
"context"
|
"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
|
// RuleSet is used to provide custom rules to allow or prohibit actions
|
||||||
|
@ -6,7 +6,7 @@ import (
|
|||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/thinkgos/go-socks5/statute"
|
"git.tcp.direct/kayos/go-socks5/statute"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestPermitCommand(t *testing.T) {
|
func TestPermitCommand(t *testing.T) {
|
||||||
|
@ -10,8 +10,8 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
"github.com/thinkgos/go-socks5/bufferpool"
|
"git.tcp.direct/kayos/go-socks5/bufferpool"
|
||||||
"github.com/thinkgos/go-socks5/statute"
|
"git.tcp.direct/kayos/go-socks5/statute"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GPool is used to implement custom goroutine pool default use goroutine
|
// GPool is used to implement custom goroutine pool default use goroutine
|
||||||
|
@ -14,7 +14,7 @@ import (
|
|||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"golang.org/x/net/proxy"
|
"golang.org/x/net/proxy"
|
||||||
|
|
||||||
"github.com/thinkgos/go-socks5/statute"
|
"git.tcp.direct/kayos/go-socks5/statute"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestSOCKS5_Connect(t *testing.T) {
|
func TestSOCKS5_Connect(t *testing.T) {
|
||||||
|
@ -12,9 +12,9 @@ import (
|
|||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"golang.org/x/net/proxy"
|
"golang.org/x/net/proxy"
|
||||||
|
|
||||||
"github.com/thinkgos/go-socks5"
|
"git.tcp.direct/kayos/go-socks5"
|
||||||
"github.com/thinkgos/go-socks5/bufferpool"
|
"git.tcp.direct/kayos/go-socks5/bufferpool"
|
||||||
"github.com/thinkgos/go-socks5/ccsocks5"
|
"git.tcp.direct/kayos/go-socks5/ccsocks5"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_Socks5_Connect(t *testing.T) {
|
func Test_Socks5_Connect(t *testing.T) {
|
||||||
|
Loading…
Reference in New Issue
Block a user