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

Logic error in handling error response #6

Open Feng-Zihao opened 10 years ago

Feng-Zihao commented 10 years ago

in the logic of stun_test, there's code as below around line

    # around line 113:
    recvCorr = False
    while not recvCorr:
        # around line 136,
        bind_resp_msg = dictValToMsgType[msgtype] == "BindResponseMsg"
        tranid_match = tranid.upper() == binascii.b2a_hex(buf[4:20]).upper()
        if bind_resp_msg and tranid_match:

It does not handle the logic which the stun server return BindErrorResponseMsg, which lead to infinite loop.

This can be reproduce with a self setup stun server, and run the function with source ip = '0.0.0.0'.

But it's not a very big problem, I suggest to throw an error in this situation. Because the server did response, but just it's an error response.

Thanks.

jtriley commented 9 years ago

@Feng-Zihao Thanks for reporting. Which stun server are you using to test locally - stuntman?

Feng-Zihao commented 9 years ago

Oh... First reply from github issues !! I'm using this one, on linux. http://www.stunprotocol.org/