mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-25 19:15:34 +00:00
wgengine/netstack: start SOCKS5 server in netstack mode
Updates #707 Updates #504 Signed-off-by: Naman Sood <mail@nsood.in>
This commit is contained in:
parent
fe16ef6812
commit
fec9dcbda1
@ -96,6 +96,7 @@ tailscale.com/cmd/tailscaled dependencies: (generated by github.com/tailscale/de
|
||||
💣 tailscale.com/net/netstat from tailscale.com/ipn/ipnserver
|
||||
tailscale.com/net/packet from tailscale.com/wgengine+
|
||||
tailscale.com/net/portmapper from tailscale.com/net/netcheck+
|
||||
tailscale.com/net/socks5 from tailscale.com/wgengine/netstack
|
||||
tailscale.com/net/stun from tailscale.com/net/netcheck+
|
||||
tailscale.com/net/tlsdial from tailscale.com/control/controlclient+
|
||||
tailscale.com/net/tsaddr from tailscale.com/ipn/ipnlocal+
|
||||
|
@ -14,6 +14,7 @@
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"net"
|
||||
"strings"
|
||||
|
||||
"gvisor.dev/gvisor/pkg/tcpip"
|
||||
@ -30,6 +31,7 @@
|
||||
"gvisor.dev/gvisor/pkg/waiter"
|
||||
"inet.af/netaddr"
|
||||
"tailscale.com/net/packet"
|
||||
"tailscale.com/net/socks5"
|
||||
"tailscale.com/types/logger"
|
||||
"tailscale.com/types/netmap"
|
||||
"tailscale.com/wgengine"
|
||||
@ -113,6 +115,7 @@ func (ns *Impl) Start() error {
|
||||
ns.ipstack.SetTransportProtocolHandler(udp.ProtocolNumber, udpFwd.HandlePacket)
|
||||
go ns.injectOutbound()
|
||||
ns.tundev.PostFilterIn = ns.injectInbound
|
||||
go ns.socks5Server()
|
||||
|
||||
return nil
|
||||
}
|
||||
@ -282,6 +285,21 @@ func (ns *Impl) forwardTCP(client *gonet.TCPConn, wq *waiter.Queue, address stri
|
||||
ns.logf("[v2] netstack: forwarder connection to %s closed", address)
|
||||
}
|
||||
|
||||
func (ns *Impl) socks5Server() {
|
||||
ln, err := net.Listen("tcp", "localhost:1080")
|
||||
if err != nil {
|
||||
ns.logf("could not start SOCKS5 listener: %v", err)
|
||||
return
|
||||
}
|
||||
srv := &socks5.Server{
|
||||
Logf: ns.logf,
|
||||
Dialer: func(ctx context.Context, network, addr string) (net.Conn, error) {
|
||||
return ns.dialContextTCP(ctx, addr)
|
||||
},
|
||||
}
|
||||
ns.logf("SOCKS5 server exited: %v", srv.Serve(ln))
|
||||
}
|
||||
|
||||
func (ns *Impl) acceptUDP(r *udp.ForwarderRequest) {
|
||||
ns.logf("[v2] UDP ForwarderRequest: %v", r)
|
||||
var wq waiter.Queue
|
||||
|
Loading…
Reference in New Issue
Block a user