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

@@ -795,13 +795,19 @@ test "getPayloadSize DHT messages" {
// Just verify it returns a reasonable value (> 0)
try testing.expect(ser.getPayloadSizePublic(fnr_msg) > 0);
// DHT store_response: 8 + 1 = 9
// DHT store_response with variable-length encoding:
// With observed_addr_len=0: 8 + 1 + 1 = 10 (request_id + success + len byte only)
const store_resp = message.DhtStoreResponse{
.request_id = 1,
.success = true,
};
const sr_msg = message.Message{ .dht_store_response = store_resp };
try testing.expectEqual(@as(usize, 9), ser.getPayloadSizePublic(sr_msg));
try testing.expectEqual(@as(usize, 10), ser.getPayloadSizePublic(sr_msg));
// DHT store_response with IPv4 address (6 bytes): 8 + 1 + 1 + 6 = 16
const store_resp_ipv4 = message.DhtStoreResponse.initWithObserved(1, true, [_]u8{ 192, 168, 1, 1, 0x1F, 0x90 } ++ [_]u8{0} ** 12, 6);
const sr_msg_ipv4 = message.Message{ .dht_store_response = store_resp_ipv4 };
try testing.expectEqual(@as(usize, 16), ser.getPayloadSizePublic(sr_msg_ipv4));
// DHT find_value: 8 + 32 + 32 = 72
const find_value = message.DhtFindValue{