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

KeyError: '0100' #23

Open ulope opened 7 years ago

ulope commented 7 years ago

Sometimes calling get_nat_type() fails with KeyError: '0100'.

Truncated traceback:

  File "/Users/ulo/Envs/test/lib/python2.7/site-packages/stun/__init__.py", line 219, in get_nat_type
    changeRequest)
  File "/Users/ulo/Envs/test/lib/python2.7/site-packages/stun/__init__.py", line 136, in stun_test
    bind_resp_msg = dictValToMsgType[msgtype] == "BindResponseMsg"
KeyError: '0100'

According to https://tools.ietf.org/html/rfc5389#appendix-A and https://tools.ietf.org/html/rfc5389#section-18.1 0100 seems to be a success message for reserved method id 0x000 (which admittedly doesn't make much sense).

I'm not sure what the correct behaviour would be here, however a KeyError seems to be the wrong one ;)