bidirectional ip reflection for listener address discovery

This commit is contained in:
2026-02-09 16:02:23 -03:00
parent 59e9e420be
commit 7b47ef155c
31 changed files with 3192 additions and 269 deletions

View File

@@ -45,6 +45,7 @@ const P2P = p2p_module.P2P;
const handleDataResponseCallback = p2p_module.handleDataResponseCallback;
const registerNodeIdCallback = p2p_module.registerNodeIdCallback;
const sendDhtMessageCallback = p2p_module.sendDhtMessageCallback;
const addObservedAddressCallback = p2p_module.addObservedAddressCallback;
const P2PEvent = @import("events.zig").P2PEvent;
const P2PConfig = @import("config.zig").P2PConfig;
@@ -227,6 +228,11 @@ pub fn startImpl(p2p: *P2P) Error!void {
.send_fn = sendDhtMessageCallback,
.context = p2p,
});
// Wire the observed address callback for IP Reflection / Bundled STUN
ctx.setObservedAddressCallback(.{
.add_fn = addObservedAddressCallback,
.context = p2p,
});
}
}
@@ -234,6 +240,11 @@ pub fn startImpl(p2p: *P2P) Error!void {
p2p.peer_manager = p2p.allocator.create(network.peer.PeerManager) catch return Error.SystemError;
p2p.peer_manager.?.* = network.peer.PeerManager.init(p2p.allocator);
// Wire peer_manager to handler context for IP Reflection
if (p2p.handler_registry) |registry| {
registry.context.setP2PComponents(p2p.peer_manager, null, null, null);
}
// Initialize connection pool
const connection_config = core.connection.ConnectionConfig{
.connection_type = .tcp,