Skip to content

Commit 40c6a6b

Browse files
committed
More NAT/Relay options
1 parent 9f4ebd6 commit 40c6a6b

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

client.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,11 @@ func NewClient(config Config) (P2PClient, error) {
163163
fmt.Sprintf("/ip4/0.0.0.0/tcp/%d", config.Port), // Listen on all interfaces
164164
fmt.Sprintf("/ip6/::/tcp/%d", config.Port),
165165
),
166-
libp2p.EnableNATService(),
167-
libp2p.EnableHolePunching(),
168-
libp2p.EnableRelay(),
169-
libp2p.EnableAutoRelayWithStaticRelays([]peer.AddrInfo{}), // Enable auto relay discovery via DHT
166+
libp2p.NATPortMap(), // Try UPnP/NAT-PMP for automatic port forwarding
167+
libp2p.EnableNATService(), // AutoNAT to detect if we're reachable
168+
libp2p.EnableHolePunching(), // DCUtR protocol for NAT hole punching
169+
libp2p.EnableRelay(), // Act as relay for others
170+
libp2p.EnableAutoRelayWithStaticRelays([]peer.AddrInfo{}), // Use relays if we're unreachable
170171
libp2p.AddrsFactory(addressFactory),
171172
libp2p.ConnectionGater(ipFilter),
172173
)

0 commit comments

Comments
 (0)