Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed multiple bugs with pystun and added async support #36

Open
robertsdotpm opened this issue Jan 15, 2023 · 0 comments
Open

Fixed multiple bugs with pystun and added async support #36

robertsdotpm opened this issue Jan 15, 2023 · 0 comments

Comments

@robertsdotpm
Copy link

robertsdotpm commented Jan 15, 2023

Hello everyone,

Over the past year I've been working on a new p2p networking library in Python. The software makes heavy use of STUN and uses this library as the basis for NAT enumeration, address lookups, and mapping queries. The software is great. But presently there are a few bugs in the NAT test logic and validation code. The socket code is also 'blocking' so if it's used in a Python program it will prevent anything else from running.

I've fixed these issues and added support for a large number of fallback STUN servers.
My code fully supports IPv6 and TCP, too.

Here's a usage example:

Start the REPR with await support
python3 -m asyncio

from p2pd import *

netifaces = await init_p2pd()

# Load default interface.
i = await Interface() 

# Do STUN calls.
s = STUNClient(interface=i)
wan_ip = await s.get_wan_ip()
mapping = await s.get_mapping(TCP, do_close=1)
nat_info = await s.get_nat_info()

If you print nat_info you'll notice it also includes information on the NATs port allocation behaviour and any observed patterns. The other functions work similarly to pystun. You can also call await i.load_nat() to have the interface load it's associated NAT information.

More information on async network programming can be found at p2pd.net.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant