Closed shellus closed 6 years ago
i change code to
if resp != nil &&
(resp.serverAddr.IP() == addr.IP.String() ||
resp.serverAddr.Port() == uint16(addr.Port)) {
return NATError, mappedAddr, errors.New(fmt.Sprintf("Server error: response IP/port resp addr[%s][%d] local addr[%s][%d]", resp.serverAddr.IP(), resp.serverAddr.Port(), addr.IP.String(), uint16(addr.Port)))
}
run go-stun.exe -vvv
echo
$ go-stun.exe -vvv
2017/10/26 11:26:55 Do Test1
2017/10/26 11:26:55 Send To: 217.10.68.152:3478
2017/10/26 11:26:55
00000000 00 01 00 18 21 12 a4 42 ff ae d5 56 fd cd b4 74 |....!..B...V...t|
00000010 59 62 7c ed 80 22 00 0c 53 74 75 6e 43 6c 69 65 |Yb|.."..StunClie|
00000020 6e 74 00 00 80 28 00 04 3b cb 0f aa |nt...(..;...|
2017/10/26 11:26:55
00000000 01 01 00 44 21 12 a4 42 ff ae d5 56 fd cd b4 74 |...D!..B...V...t|
00000010 59 62 7c ed 00 01 00 08 00 01 8d 31 2f 58 e6 ca |Yb|........1/X..|
00000020 00 04 00 08 00 01 0d 96 d9 0a 44 98 00 05 00 08 |..........D.....|
00000030 00 01 0d 97 d9 74 7a 88 80 20 00 08 00 01 ac 23 |.....tz.. .....#|
00000040 0e 4a 42 88 80 22 00 10 56 6f 76 69 64 61 2e 6f |.JB.."..Vovida.o|
00000050 72 67 20 30 2e 39 36 00 |rg 0.96.|
2017/10/26 11:26:55 Received: {packet nil: false, local: 47.88.230.202:36145, remote: 217.10.68.152:3478, changed: 217.116.122.136:3479, other: <nil>, identical: false}
2017/10/26 11:26:55 Do Test2
2017/10/26 11:26:55 Send To: 217.10.68.152:3478
2017/10/26 11:26:55
00000000 00 01 00 20 21 12 a4 42 2b c0 3c 5f d0 96 5c 8c |... !..B+.<_..\.|
00000010 6b 34 b0 9c 80 22 00 0c 53 74 75 6e 43 6c 69 65 |k4..."..StunClie|
00000020 6e 74 00 00 00 03 00 04 00 00 00 06 80 28 00 04 |nt...........(..|
00000030 91 78 5f bf |.x_.|
2017/10/26 11:26:56
00000000 01 01 00 44 21 12 a4 42 2b c0 3c 5f d0 96 5c 8c |...D!..B+.<_..\.|
00000010 6b 34 b0 9c 00 01 00 08 00 01 8d 31 2f 58 e6 ca |k4.........1/X..|
00000020 00 04 00 08 00 01 0d 97 d9 74 7a 88 00 05 00 08 |.........tz.....|
00000030 00 01 0d 97 d9 74 7a 88 80 20 00 08 00 01 ac 23 |.....tz.. .....#|
00000040 0e 4a 42 88 80 22 00 10 56 6f 76 69 64 61 2e 6f |.JB.."..Vovida.o|
00000050 72 67 20 30 2e 39 36 00 |rg 0.96.|
2017/10/26 11:26:56 Received: {packet nil: false, local: 47.88.230.202:36145, remote: 217.10.68.152:3478, changed: 217.116.122.136:3479, other: <nil>, identical: false}
Server error: response IP/port resp addr[217.10.68.152][3478] local addr[217.10.68.152][3478]
i use ss-redir Transparent Proxying and some iptables REDIRECT
#add IP mark, tproxy usage
ip rule add fwmark 0x01/0x01 table 100
ip route add local 0.0.0.0/0 dev lo table 100
#UDP
iptables -t mangle -N SSUDP
iptables -t mangle -A SSUDP -d 47.88.230.202/32 -j RETURN
iptables -t mangle -A SSUDP -d 0.0.0.0/8 -j RETURN
iptables -t mangle -A SSUDP -d 10.0.0.0/8 -j RETURN
iptables -t mangle -A SSUDP -d 127.0.0.0/8 -j RETURN
iptables -t mangle -A SSUDP -d 169.254.0.0/16 -j RETURN
iptables -t mangle -A SSUDP -d 172.16.0.0/12 -j RETURN
iptables -t mangle -A SSUDP -d 192.168.0.0/16 -j RETURN
iptables -t mangle -A SSUDP -d 224.0.0.0/4 -j RETURN
iptables -t mangle -A SSUDP -d 240.0.0.0/4 -j RETURN
iptables -t mangle -A SSUDP -p udp -j TPROXY --on-port 12345 --on-ip 0.0.0.0 --tproxy-mark 0x1/0x1
iptables -t mangle -A PREROUTING -j SSUDP
#TCP
iptables -t nat -N SSTCP
iptables -t nat -A SSTCP -d 47.88.230.202/32 -j RETURN
iptables -t nat -A SSTCP -d 0.0.0.0/8 -j RETURN
iptables -t nat -A SSTCP -d 10.0.0.0/8 -j RETURN
iptables -t nat -A SSTCP -d 127.0.0.0/8 -j RETURN
iptables -t nat -A SSTCP -d 169.254.0.0/16 -j RETURN
iptables -t nat -A SSTCP -d 172.16.0.0/12 -j RETURN
iptables -t nat -A SSTCP -d 192.168.0.0/16 -j RETURN
iptables -t nat -A SSTCP -d 224.0.0.0/4 -j RETURN
iptables -t nat -A SSTCP -d 240.0.0.0/4 -j RETURN
iptables -t nat -A SSTCP -p tcp -j REDIRECT --to-ports 12345
iptables -t nat -A PREROUTING -j SSTCP
My udp and tcp communication can be used normally. And is through the proxy server. Just go-stun.exe will be given
the stun protocol doesn't work when you are using a proxy
What is the reason for it?
what do you want to do with stun with proxy? between client and proxy? or between proxy and server? you should run the protocol separately in each pair of them
I was wondering if I used the proxy mode to run go-stun would have problems, then I did other things that would also have this problem
stun/discover.go
line 111