add IP Reflection to DHT for zero-infrastructure NAT traversal
bundled STUN. every DHT response now includes observed_addr field so nodes discover their public IP without external STUN servers
This commit is contained in:
@@ -131,6 +131,19 @@ pub fn registerNodeIdCallback(node_id: [32]u8, peer_id: [32]u8, context: ?*anyop
|
||||
std.log.info("Registered DHT node ID mapping: {x} -> connection peer {x}", .{ node_id[0..8].*, peer_id[0..8].* });
|
||||
}
|
||||
|
||||
/// Callback to send DHT messages using simple binary format.
|
||||
/// Called by DHT handlers to send responses in the same format as requests.
|
||||
pub fn sendDhtMessageCallback(peer_id: [32]u8, msg: protocol.message.Message, context: ?*anyopaque) bool {
|
||||
const p2p: *P2P = @ptrCast(@alignCast(context orelse {
|
||||
std.log.err("sendDhtMessageCallback: null context", .{});
|
||||
return false;
|
||||
}));
|
||||
|
||||
// Use the dht module's sendDhtMessageImpl which uses simple binary format
|
||||
const dht_module = @import("dht.zig");
|
||||
return dht_module.sendDhtMessageImpl(p2p, peer_id, msg);
|
||||
}
|
||||
|
||||
/// Callback to handle data responses during file downloads.
|
||||
///
|
||||
/// This function processes incoming DataResponse messages and writes
|
||||
|
||||
Reference in New Issue
Block a user