All checks were successful
check / check (push) Successful in 3m20s
The 64-hop cap bounded the walk but not the allocation: the chain was split before it was capped, so a padded header cost a []string proportional to its whole length on every request to the unauthenticated receiver. Cut hops off the right end of each header value in place with strings.LastIndexByte instead, and walk multiple header values in reverse rather than joining them. Bucket assignment is unchanged: the walk still counts every comma-separated entry against the cap, skips empty ones, stops at the first hop that is not a trusted proxy, and falls back to the peer on an unreadable hop or an exhausted cap. Measured over a 1 MB chain: 1,606,043 bytes allocated per call before, 16 bytes after.
8.5 KiB
8.5 KiB