milestone 19: hygiene sweep - dead ecs surface, single-source constants, tls classification, frontend state hazards, docker smoke network fix
This commit is contained in:
+10
-16
@@ -62,24 +62,19 @@ pub const udp_limit_max: u16 = 4096;
|
||||
pub const max_cname_depth = 8;
|
||||
|
||||
/// `"cname:"` plus the longest `matcher.Reason` tag, which the comptime block
|
||||
/// below proves fits the 32 bytes `logger.Entry` stores.
|
||||
/// below proves fits what `logger.Entry` stores.
|
||||
const cname_reason_prefix = "cname:";
|
||||
const max_reason_len = 32;
|
||||
|
||||
comptime {
|
||||
for (std.enums.values(matcher.Reason)) |reason| {
|
||||
if (cname_reason_prefix.len + @tagName(reason).len > max_reason_len) {
|
||||
if (cname_reason_prefix.len + @tagName(reason).len > logger_mod.max_reason_len) {
|
||||
@compileError("a matcher.Reason tag no longer fits the query log's reason field");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// RFC 5952 text of any IPv6 address. `logger.Entry` truncates at the same
|
||||
/// width, so nothing an address formats to is ever cut.
|
||||
const max_ip_text = 45;
|
||||
|
||||
/// `udp://` or `tcp://`, an IPv6 literal in brackets, and a port.
|
||||
const max_resolver_text = "tcp://[".len + max_ip_text + "]:65535".len;
|
||||
const max_resolver_text = "tcp://[".len + logger_mod.max_client_len + "]:65535".len;
|
||||
|
||||
/// Ruling 20 leaves the pool's answering endpoint out of reach: the pool tracks
|
||||
/// it, but reading it back would mean new plumbing through `transport.Client`
|
||||
@@ -157,9 +152,9 @@ pub const Handler = struct {
|
||||
unfiltered_queries: std.atomic.Value(u64) = .init(0),
|
||||
safesearch_rewrites: std.atomic.Value(u64) = .init(0),
|
||||
ecs_strip_failed: std.atomic.Value(u64) = .init(0),
|
||||
/// Mirrors the tracker's own `dropped_full`, refreshed on every query:
|
||||
/// `Tracker.track` reports nothing back, and a counter that only the
|
||||
/// tracker holds would not appear beside the rest of these.
|
||||
/// Mirrors the tracker's own `dropped_full`, refreshed on every query
|
||||
/// from what `Tracker.track` returns: a counter that only the tracker
|
||||
/// holds would not appear beside the rest of these.
|
||||
tracker_full: std.atomic.Value(u64) = .init(0),
|
||||
};
|
||||
|
||||
@@ -276,8 +271,7 @@ pub const Handler = struct {
|
||||
const started = std.Io.Clock.real.now(io);
|
||||
|
||||
if (self.tracker) |tracker| {
|
||||
tracker.track(io, from);
|
||||
self.stats.tracker_full.store(tracker.snapshotStats(io).dropped_full, .monotonic);
|
||||
self.stats.tracker_full.store(tracker.track(io, from), .monotonic);
|
||||
}
|
||||
|
||||
// Ruling 4: no snapshot means no group and no filtering, and the query
|
||||
@@ -501,7 +495,7 @@ const Context = struct {
|
||||
|
||||
bump(if (uncloaked) &ctx.handler.stats.uncloak_blocked else &ctx.handler.stats.blocked);
|
||||
|
||||
var reason_buf: [max_reason_len]u8 = undefined;
|
||||
var reason_buf: [logger_mod.max_reason_len]u8 = undefined;
|
||||
return ctx.reply(bytes, .{
|
||||
.blocked = true,
|
||||
.block_reason = blockReason(&reason_buf, reason, uncloaked),
|
||||
@@ -541,7 +535,7 @@ const Context = struct {
|
||||
fn log(ctx: *Context, fields: LogFields) void {
|
||||
const sink = ctx.handler.sink orelse return;
|
||||
|
||||
var ip_buf: [max_ip_text]u8 = undefined;
|
||||
var ip_buf: [logger_mod.max_client_len]u8 = undefined;
|
||||
var w: std.Io.Writer = .fixed(&ip_buf);
|
||||
ctx.from.format(&w) catch unreachable;
|
||||
|
||||
@@ -819,7 +813,7 @@ fn cnameTarget(p: packet.Packet, owner: name.Name) ?name.Name {
|
||||
/// The `block_reason` column. An uncloaked block names the level that matched
|
||||
/// the CNAME target, prefixed so that it is not mistaken for a decision about
|
||||
/// the name the client asked for.
|
||||
fn blockReason(buf: *[max_reason_len]u8, reason: matcher.Reason, uncloaked: bool) []const u8 {
|
||||
fn blockReason(buf: *[logger_mod.max_reason_len]u8, reason: matcher.Reason, uncloaked: bool) []const u8 {
|
||||
const tag = @tagName(reason);
|
||||
if (!uncloaked) return tag;
|
||||
@memcpy(buf[0..cname_reason_prefix.len], cname_reason_prefix);
|
||||
|
||||
Reference in New Issue
Block a user