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

Initial Python>=3 support. #32

Closed jfsanchez91 closed 1 year ago

jfsanchez91 commented 4 years ago

Tested and working on Python2.7 and Python3 (3.5, 3.6, 3.7, 3.8).

rgarrigue commented 4 years ago

Hi @jfsanchez-gh

Gave a shot at your fork, it went :boom: . Tried with 3.6, 3.7, 3.8

~ ᐅ pyenv install 3.6.10
Downloading Python-3.6.10.tar.xz...
-> https://www.python.org/ftp/python/3.6.10/Python-3.6.10.tar.xz
Installing Python-3.6.10...
Installed Python-3.6.10 to /home/remy/.pyenv/versions/3.6.10

~ ᐅ pyenv shell 3.6.10      
~ ᐅ python -mpip install pystun
Collecting pystun
  Using cached https://files.pythonhosted.org/packages/a9/72/0b6a4f8ad71f72ed3b3946a21084a8b3c17de10ddc5fc0dfec43c48fc768/pystun-0.1.0.tar.gz
Installing collected packages: pystun
  Running setup.py install for pystun ... done
Successfully installed pystun-0.1.0
You are using pip version 18.1, however version 20.2b1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
~ ᐅ python                     
Python 3.6.10 (default, Jun  2 2020, 17:16:42) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import stun
>>> nat_type, external_ip, external_port = stun.get_ip_info()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/remy/.pyenv/versions/3.6.10/lib/python3.6/site-packages/stun/__init__.py", line 253, in get_ip_info
    stun_host=stun_host, stun_port=stun_port)
  File "/home/remy/.pyenv/versions/3.6.10/lib/python3.6/site-packages/stun/__init__.py", line 186, in get_nat_type
    _initialize()
  File "/home/remy/.pyenv/versions/3.6.10/lib/python3.6/site-packages/stun/__init__.py", line 93, in _initialize
    dictValToAttr.update({items[i][1]: items[i][0]})
TypeError: 'dict_items' object does not support indexing

Any advice ?