database64128/shadowsocks-go

Crash when browsing Netflix

Closed this issue · 5 comments

Running server on Asus router using shadowrocket with config:

{
        "servers": [{
                "name": "main",
                "listen": ":5419",
                "protocol": "2022-blake3-aes-128-gcm",
                "enableTCP": true,
                "listenerTFO": true,
                "enableUDP": true,
                "mtu": 1500,
                "psk": "xxxx="
        }],
        "clients": [{
                "name": "direct",
                "protocol": "direct",
                "enableTCP": true,
                "dialerTFO": false,
                "enableUDP": true,
                "mtu": 1500
        }]
}

Crash Log:

2022-11-29T18:41:19.621+0800 WARN service/tcp.go:262 Two-way relay failed {"server": "main", "client": "direct", "listenAddress": ":5419", "clientAddress": "[::ffff:180.160.218.138]:63766", "targetAddress": "ipv4-c054-hkg001-ix.1.oca.nflxvideo.net:443", "nl2r": 1370, "nr2l": 21323, "error": "write tcp x.x.x.x:5419->180.160.218.138:63766: write: broken pipe"}
2022-11-29T18:41:19.623+0800 WARN service/tcp.go:262 Two-way relay failed {"server": "main", "client": "direct", "listenAddress": ":5419", "clientAddress": "[::ffff:180.160.218.138]:63784", "targetAddress": "ipv4-c054-hkg001-ix.1.oca.nflxvideo.net:443", "nl2r": 1370, "nr2l": 21321, "error": "write tcp x.x.x.x:5419->180.160.218.138:63784: write: broken pipe"}
2022-11-29T18:41:19.795+0800 INFO service/tcp.go:249 Two-way relay started {"server": "main", "client": "direct", "listenAddress": ":5419", "clientAddress": "[::ffff:180.160.218.138]:63799", "targetAddress": "ipv4-c003-hkg003-pccw-isp.1.oca.nflxvideo.net:443", "initialPayloadLength": 0}
2022-11-29T18:41:20.230+0800 INFO service/tcp.go:249 Two-way relay started {"server": "main", "client": "direct", "listenAddress": ":5419", "clientAddress": "[::ffff:180.160.218.138]:63800", "targetAddress": "ipv4-c001-hkg003-pccw-isp.1.oca.nflxvideo.net:443", "initialPayloadLength": 0}
2022-11-29T18:41:20.420+0800 INFO service/udp_session_linux.go:342 UDP session relay started {"server": "main", "client": "direct", "listenAddress": ":5419", "clientAddress": "[::ffff:180.160.218.138]:60657", "targetAddress": "", "clientSessionID": 17338808841813140563}
panic: Domain() called on non-domain address

goroutine 374 [running]:
github.com/database64128/shadowsocks-go/conn.Addr.Domain(...)
        github.com/database64128/shadowsocks-go/conn/addr.go:107
github.com/database64128/shadowsocks-go/direct.(*DirectPacketClientPackUnpacker).updateDomainIPCache(0xc019e0, {{}, {0x0, 0xffff08080808, 0xc0c130}, 0x35, 0x0})
        github.com/database64128/shadowsocks-go/direct/packet.go:36 +0x1c0
github.com/database64128/shadowsocks-go/direct.(*DirectPacketClientPackUnpacker).PackInPlace(0xc019e0, {0xcf8000, 0x5c0, 0x5c0}, {{}, {0x0, 0xffff08080808, 0xc0c130}, 0x35, 0x0}, ...)
        github.com/database64128/shadowsocks-go/direct/packet.go:52 +0x8c
github.com/database64128/shadowsocks-go/service.(*UDPSessionRelay).relayServerConnToNatConnSendmmsg(0xc64ab0, 0xf09fd2c6d4aca453, 0xc692c0)
        github.com/database64128/shadowsocks-go/service/udp_session_linux.go:443 +0xff8
github.com/database64128/shadowsocks-go/service.(*UDPSessionRelay).recvFromServerConnRecvmmsg.func1.2()
        github.com/database64128/shadowsocks-go/service/udp_session_linux.go:354 +0x3c
created by github.com/database64128/shadowsocks-go/service.(*UDPSessionRelay).recvFromServerConnRecvmmsg.func1
        github.com/database64128/shadowsocks-go/service/udp_session_linux.go:353 +0x1a9c

Can you compile a test binary for the conn package and see if the tests pass on your router? You should be able to do so with go test -c ./conn.

@database64128 The test also crashes.

--- FAIL: TestAddrIs (0.00s)
    addr_test.go:74: addrIP.IsValid() returned false.
    addr_test.go:77: addrIP.IsIP() returned false.
--- FAIL: TestAddrIP (0.00s)
panic: IP() called on non-IP address [recovered]
	panic: IP() called on non-IP address

goroutine 8 [running]:
testing.tRunner.func1.2({0x15fe90, 0x1b1088})
	/usr/local/Cellar/go/1.19.3/libexec/src/testing/testing.go:1396 +0x27c
testing.tRunner.func1()
	/usr/local/Cellar/go/1.19.3/libexec/src/testing/testing.go:1399 +0x3f4
panic({0x15fe90, 0x1b1088})
	/usr/local/Cellar/go/1.19.3/libexec/src/runtime/panic.go:884 +0x23c
github.com/database64128/shadowsocks-go/conn.Addr.IP(...)
	/Users/william/Downloads/shadowsocks-go/conn/addr.go:97
github.com/database64128/shadowsocks-go/conn.TestAddrIP(0x802f00)
	/Users/william/Downloads/shadowsocks-go/conn/addr_test.go:105 +0x1a8
testing.tRunner(0x802f00, 0x188b6c)
	/usr/local/Cellar/go/1.19.3/libexec/src/testing/testing.go:1446 +0x118
created by testing.(*T).Run
	/usr/local/Cellar/go/1.19.3/libexec/src/testing/testing.go:1493 +0x3a0

Okay, that's weird. If I compile for arm64 target the server and test works fine. But not for arm target.

Can you check if ea642fe resolves the issue?

Thanks, the commit fixes the test and the server.