xjasonlyu / tun2socks

tun2socks - powered by gVisor TCP/IP stack
https://github.com/xjasonlyu/tun2socks/wiki
GNU General Public License v3.0
2.86k stars 407 forks source link

Shadowsocks proxy - tun2socks panics #49

Closed caribpa closed 3 years ago

caribpa commented 3 years ago

Hey there!

I ā¤ļø tun2socks, it is incredibly convenient whenever I need to pass all TCP+UDP traffic through a SOCKS5 server, amazing job šŸ†!

Out of curiosity, today I tried to use a Shadowsocks server as proxy and tun2socks crashed, I'm using the latest git version (also reproducible in the latest non-git release):

$ tun2socks -version
tun2socks-2.1.5
linux/amd64, go1.16.3, 3f7fdc1

This is the command that produces the panic along with the panic dump:

$ sudo tun2socks -device tun://tun0 -proxy ss://127.0.0.1:9090

panic: runtime error: index out of range [1] with length 1

goroutine 1 [running]:
github.com/xjasonlyu/tun2socks/engine.parseShadowsocks(0xc0001b0000, 0x886e7e, 0x2, 0x1, 0x0, 0x2b0d250cf91f9f9f, 0x4a0000c0000a36c0, 0x2b0000000085fd80, 0xc000093ca0, 0x2b0d250cf91f9f9f, ...)
        github.com/xjasonlyu/tun2socks/engine/parse.go:77 +0x3db
github.com/xjasonlyu/tun2socks/engine.parseProxy(0x7ffe123fe717, 0x16, 0x793b5d, 0x8874f6, 0x4, 0x3)
        github.com/xjasonlyu/tun2socks/engine/parse.go:54 +0x1e5
github.com/xjasonlyu/tun2socks/engine.(*engine).setProxy(0xb67600, 0x0, 0x0)
        github.com/xjasonlyu/tun2socks/engine/engine.go:141 +0x4a
github.com/xjasonlyu/tun2socks/engine.(*engine).start(0xb67600, 0x40d32a, 0x1)
        github.com/xjasonlyu/tun2socks/engine/engine.go:74 +0x1c6
github.com/xjasonlyu/tun2socks/engine.Start(0x0, 0x0)
        github.com/xjasonlyu/tun2socks/engine/engine.go:20 +0x2d
main.main.func1(0x88a504, 0xc, 0x8a66b0)
        github.com/xjasonlyu/tun2socks/main.go:33 +0x2e
main.main()
        github.com/xjasonlyu/tun2socks/main.go:38 +0x83

The panic doesn't happen neither in socks5 nor direct proxy mode. Hope you can take a look šŸ”

xjasonlyu commented 3 years ago

It was caused by invalid shadowsocks URL. Thanks for your feedback!

caribpa commented 3 years ago

Can confirm that https://github.com/xjasonlyu/tun2socks/commit/66710aa203d8b5ce83a2774af337db5fbdd40c2f fixes the issue šŸŽŠ

Closing āœ