jtriley / pystun

A Python STUN client for getting NAT type and external IP
https://github.com/jtriley/pystun
MIT License
435 stars 154 forks source link

[Bug] The wrong way to determine the port restricted NAT or restricted NAT #14

Open hmgle opened 9 years ago

hmgle commented 9 years ago

When we do Test3 to determine the client is behind a restricted or port restricted NAT, this line:

ret = stun_test(s, changedIP, port, source_ip, source_port, changePortRequest)

will request stun server sends a response from addr(changedIP:changedPort). As we have just send a request:

ret = stun_test(s, changedIP, changedPort, source_ip, source_port)

both RestricNAT and RestricPortNAT will receive the response. So we alway get typ = RestricNAT even if behind a port restricted NAT.

YF-Tung commented 7 years ago

@hmgle is right. @jtriley please fix this issue, please. Out team was misled by this result for several days.