This commit is contained in:
Jeff Becker 2018-08-29 08:12:07 -04:00
parent 1d24781c86
commit 7c6dca6e40
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05
3 changed files with 9 additions and 5 deletions

View File

@ -24,15 +24,15 @@ func main() {
return
}
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)
if err != nil {
return nil, err
}
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)
},
})

View File

@ -71,10 +71,14 @@ type Request struct {
// AddrSpec of the the network that sent the request
RemoteAddr *AddrSpec
// AddrSpec of the desired destination
DestAddr *AddrSpec
DestAddr AddrSpec
bufConn io.Reader
}
func (req *Request) ConnectAddress() string {
return req.DestAddr.Address()
}
type conn interface {
io.WriteCloser
RemoteAddr() net.Addr

View File

@ -38,7 +38,7 @@ type Config struct {
Logger *log.Logger
// 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