more
This commit is contained in:
parent
1d24781c86
commit
7c6dca6e40
6
main.go
6
main.go
|
@ -24,15 +24,15 @@ func main() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
serv, err := socks5.New(&socks5.Config{
|
serv, err := socks5.New(&socks5.Config{
|
||||||
Dial: func(_ context.Context, network, addr string) (net.Conn, error) {
|
Dial: func(addr string) (net.Conn, error) {
|
||||||
host, _, err := net.SplitHostPort(addr)
|
host, _, err := net.SplitHostPort(addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if strings.HasSuffix(host, ".onion") {
|
if strings.HasSuffix(host, ".onion") {
|
||||||
return upstream.Dial(network, addr)
|
return upstream.Dial("tcp", addr)
|
||||||
}
|
}
|
||||||
return net.Dial(network, addr)
|
return net.Dial("tcp", addr)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -71,10 +71,14 @@ type Request struct {
|
||||||
// AddrSpec of the the network that sent the request
|
// AddrSpec of the the network that sent the request
|
||||||
RemoteAddr *AddrSpec
|
RemoteAddr *AddrSpec
|
||||||
// AddrSpec of the desired destination
|
// AddrSpec of the desired destination
|
||||||
DestAddr *AddrSpec
|
DestAddr AddrSpec
|
||||||
bufConn io.Reader
|
bufConn io.Reader
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (req *Request) ConnectAddress() string {
|
||||||
|
return req.DestAddr.Address()
|
||||||
|
}
|
||||||
|
|
||||||
type conn interface {
|
type conn interface {
|
||||||
io.WriteCloser
|
io.WriteCloser
|
||||||
RemoteAddr() net.Addr
|
RemoteAddr() net.Addr
|
||||||
|
|
|
@ -38,7 +38,7 @@ type Config struct {
|
||||||
Logger *log.Logger
|
Logger *log.Logger
|
||||||
|
|
||||||
// Optional function for dialing out
|
// Optional function for dialing out
|
||||||
Dial func(ctx context.Context, network, addr string) (net.Conn, error)
|
Dial func(addr string) (net.Conn, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Server is reponsible for accepting connections and handling
|
// Server is reponsible for accepting connections and handling
|
||||||
|
|
Loading…
Reference in New Issue