add DHT security mode and event queue overflow policy. bidirectional
node-to-peer ID mapping with Sybil/impersonation checks, configurable event queue overflow strategy (drop_oldest/drop_newest/fail)
This commit is contained in:
@@ -307,8 +307,18 @@ pub fn startImpl(p2p: *P2P) Error!void {
|
||||
};
|
||||
|
||||
if (p2p.dht_coordinator) |dht| {
|
||||
dht.* = network.DhtCoordinator.initInsecureForDevelopment(p2p.allocator, rt, p2p.local_node_id);
|
||||
std.log.info("DHT coordinator initialized with node ID (from identity): ", .{});
|
||||
if (p2p.config.network.dht_secure_mode) {
|
||||
if (p2p.config.network.dht_tofu_callback) |tofu_cb| {
|
||||
dht.* = network.DhtCoordinator.initWithTofu(p2p.allocator, rt, p2p.local_node_id, tofu_cb);
|
||||
std.log.info("DHT coordinator initialized in SECURE mode with TOFU callback", .{});
|
||||
} else {
|
||||
dht.* = network.DhtCoordinator.init(p2p.allocator, rt, p2p.local_node_id);
|
||||
std.log.warn("DHT coordinator initialized in SECURE mode WITHOUT TOFU callback - all unknown peers will be REJECTED. Provide dht_tofu_callback for peer acceptance.", .{});
|
||||
}
|
||||
} else {
|
||||
dht.* = network.DhtCoordinator.initInsecureForDevelopment(p2p.allocator, rt, p2p.local_node_id);
|
||||
std.log.warn("DHT running in INSECURE development mode - set network.dht_secure_mode=true for production", .{});
|
||||
}
|
||||
|
||||
// Wire DHT coordinator to handler context
|
||||
if (p2p.handler_registry) |hr| {
|
||||
|
||||
Reference in New Issue
Block a user