add NAT-PMP for automatic port mapping and external address discovery
This commit is contained in:
@@ -294,7 +294,16 @@ pub fn main() !void {
|
||||
found_addr = true;
|
||||
}
|
||||
|
||||
// Second priority: consensus address from IP Reflection (multi-source)
|
||||
// Second priority: NAT-PMP (automatic port mapping)
|
||||
if (!found_addr) {
|
||||
if (p2p_node.tryNatPmpDiscovery(@intCast(port + 1), 3600)) |external_ip| {
|
||||
mwp_addrs[0] = mwp.Address.initV4(external_ip, port + 1);
|
||||
std.debug.print(" Using NAT-PMP: {d}.{d}.{d}.{d}:{d}\n", .{ external_ip[0], external_ip[1], external_ip[2], external_ip[3], port + 1 });
|
||||
found_addr = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Third priority: consensus address from IP Reflection (multi-source)
|
||||
if (!found_addr) {
|
||||
const consensus = p2p_node.getConsensusAddress();
|
||||
if (consensus.address) |observed| {
|
||||
|
||||
Reference in New Issue
Block a user