milestone 18: collapse duplicated infrastructure into shared listener core, crud list helper, resource shells, transport race, name and line helpers, ui modules
CI / test (push) Successful in 1m22s
CI / test-aarch64 (push) Successful in 5m6s
CI / frontend (push) Successful in 45s
CI / cross (push) Successful in 7m53s
CI / docker (push) Failing after 1h10m57s

This commit is contained in:
2026-08-07 18:20:30 +02:00
parent c50c6d285a
commit 6f67940995
82 changed files with 3167 additions and 3114 deletions
+10 -15
View File
@@ -14,6 +14,9 @@
const std = @import("std");
const dns = @import("dns");
const smith_encode = @import("smith_encode.zig");
const sliceInput = smith_encode.sliceInput;
/// A query for example.com A with an EDNS(0) OPT record advertising 4096
/// bytes: id 0x1234, RD set, one question, one additional.
@@ -119,18 +122,6 @@ const max_jumps = dns.types.max_compression_jumps;
pub const chain_at_cap = pointerChain(max_jumps);
pub const chain_past_cap = pointerChain(max_jumps + 1);
/// Encodes `bytes` as a single `Smith.slice` value.
fn sliceInput(comptime bytes: []const u8) *const [4 + bytes.len]u8 {
return &struct {
const value: [4 + bytes.len]u8 = blk: {
var buf: [4 + bytes.len]u8 = undefined;
std.mem.writeInt(u32, buf[0..4], @intCast(bytes.len), .little);
buf[4..].* = bytes[0..bytes.len].*;
break :blk buf;
};
}.value;
}
/// Encodes `bytes` as a `Smith.slice` value followed by one integer, which the
/// name target reads as an offset and the TTL target as an elapsed time.
fn sliceIntInput(comptime bytes: []const u8, comptime int: u64) *const [12 + bytes.len]u8 {
@@ -181,8 +172,12 @@ test "the pointer chain has the documented shape" {
try std.testing.expectEqual(@as(u16, 0xc000), std.mem.readInt(u16, chain_at_cap[3..5], .big));
}
test "a slice input carries its own length" {
const encoded = sliceInput(query);
test "a slice-plus-integer input carries the length, the bytes and the integer" {
const encoded = sliceIntInput(query, 29);
try std.testing.expectEqual(@as(u32, query.len), std.mem.readInt(u32, encoded[0..4], .little));
try std.testing.expectEqualSlices(u8, query, encoded[4..]);
try std.testing.expectEqualSlices(u8, query, encoded[4 .. 4 + query.len]);
try std.testing.expectEqual(
@as(u64, 29),
std.mem.readInt(u64, encoded[4 + query.len ..][0..8], .little),
);
}