add UPnP IGD for automatic port mapping and external address discovery
This commit is contained in:
@@ -303,7 +303,16 @@ pub fn main() !void {
|
||||
}
|
||||
}
|
||||
|
||||
// Third priority: consensus address from IP Reflection (multi-source)
|
||||
// Third priority: UPnP IGD (automatic port mapping for most consumer routers)
|
||||
if (!found_addr) {
|
||||
if (p2p_node.tryUpnpDiscovery(@intCast(port + 1), 3600)) |external_ip| {
|
||||
mwp_addrs[0] = mwp.Address.initV4(external_ip, port + 1);
|
||||
std.debug.print(" Using UPnP IGD: {d}.{d}.{d}.{d}:{d}\n", .{ external_ip[0], external_ip[1], external_ip[2], external_ip[3], port + 1 });
|
||||
found_addr = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Fourth 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