Skip to content

Commit 35889ad

Browse files
Winter-Sorenseetadevacul71
authored
eg/870-add-circuit-relay-dcutr-autonat-demonstration (libp2p#975)
* added layout of full nat traversal example * refactored circuit relay module to accept reservation * fixed DCUtRs false positive connection * Fix linting, type checking, test failures, and documentation issues - Fix AutoNATService type mismatch by casting IHost to BasicHost - Add type: ignore comments for raw_conn attribute access (implementation-specific) - Fix stream handler type mismatch in listener.py with proper casting - Fix all line length violations (E501) by breaking long lines - Remove unused variable listener_peer_info - Fix docstring format (D301) by using raw string for backslashes - Fix DCUtR test failures by restoring cache trust in _have_direct_connection - Add examples.nat to documentation toctree to fix build warning All linting, type checking, tests, and documentation builds now pass. * added newsfragement --------- Co-authored-by: Manu Sheel Gupta <[email protected]> Co-authored-by: acul71 <[email protected]>
1 parent cec7750 commit 35889ad

File tree

8 files changed

+1297
-20
lines changed

8 files changed

+1297
-20
lines changed

docs/examples.nat.rst

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
examples.nat package
2+
====================
3+
4+
Submodules
5+
----------
6+
7+
examples.nat.dialer module
8+
--------------------------
9+
10+
.. automodule:: examples.nat.dialer
11+
:members:
12+
:show-inheritance:
13+
:undoc-members:
14+
15+
examples.nat.listener module
16+
----------------------------
17+
18+
.. automodule:: examples.nat.listener
19+
:members:
20+
:show-inheritance:
21+
:undoc-members:
22+
23+
examples.nat.relay module
24+
-------------------------
25+
26+
.. automodule:: examples.nat.relay
27+
:members:
28+
:show-inheritance:
29+
:undoc-members:
30+
31+
Module contents
32+
---------------
33+
34+
.. automodule:: examples.nat
35+
:members:
36+
:show-inheritance:
37+
:undoc-members:

docs/examples.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Examples
1717
examples.circuit_relay
1818
examples.kademlia
1919
examples.mDNS
20+
examples.nat
2021
examples.rendezvous
2122
examples.random_walk
2223
examples.multiple_connections

examples/nat/__init__.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
"""
2+
NAT Traversal Examples for py-libp2p
3+
4+
This package contains examples demonstrating NAT traversal using:
5+
- Circuit Relay v2: Relay connections through publicly reachable nodes
6+
- DCUtR: Direct Connection Upgrade through Relay (hole punching)
7+
- AutoNAT: Automatic NAT detection and reachability assessment
8+
9+
Examples:
10+
- relay.py: Publicly reachable relay node
11+
- listener.py: NAT'd node that advertises via relay
12+
- dialer.py: NAT'd node that connects via relay and attempts hole punching
13+
"""

0 commit comments

Comments
 (0)