Cap WHOIS answers and follow referrals only to WHOIS servers (closes #106) #128

Merged
clawbot merged 1 commits from issue-106-whois-limits into next 2026-10-20 00:15:15 +02:00
Collaborator

Fixes #106.

What changed

  • query reads an answer through a reader capped at maxAnswerSize (1 MiB). An answer that reaches the cap is an error, and none of it is returned.
  • A refer: line in IANA's answer that names a server none of the five RIRs run is now an error instead of being dialled as given, so the client only ever connects to IANA and the five RIR servers. parseIANAReferral returns that error and LookupASN passes it on.

What the diff does not show

  • The fetcher treats both errors like any failed lookup: it backs off, stores nothing, and tries the AS again later.
  • An answer of exactly 1 MiB also counts as too large.
  • The RIR match is the existing substring test (any name containing ripe maps to whois.ripe.net:43). It always dials one of the five fixed addresses, so it is left as it was.

Disclosures

  • Deviation: the cap is an io.LimitedReader, the type io.LimitReader returns, built directly so the code can read how many bytes were left and tell that the cap was reached.
  • Deviation: the test's server sends 4 MiB of lines instead of streaming for 2 s, so whether it passes the cap does not depend on machine speed.
  • Judgement call: of the issue's two options, referrals are followed only to the five RIR servers, not to any host on port 43; every AS number IANA hands out is held by one of the five.

Model: opus-5-5

Fixes https://git.eeqj.de/sneak/routewatch/issues/106. **What changed** - `query` reads an answer through a reader capped at `maxAnswerSize` (1 MiB). An answer that reaches the cap is an error, and none of it is returned. - A `refer:` line in IANA's answer that names a server none of the five RIRs run is now an error instead of being dialled as given, so the client only ever connects to IANA and the five RIR servers. `parseIANAReferral` returns that error and `LookupASN` passes it on. **What the diff does not show** - The fetcher treats both errors like any failed lookup: it backs off, stores nothing, and tries the AS again later. - An answer of exactly 1 MiB also counts as too large. - The RIR match is the existing substring test (any name containing `ripe` maps to `whois.ripe.net:43`). It always dials one of the five fixed addresses, so it is left as it was. **Disclosures** - Deviation: the cap is an `io.LimitedReader`, the type `io.LimitReader` returns, built directly so the code can read how many bytes were left and tell that the cap was reached. - Deviation: the test's server sends 4 MiB of lines instead of streaming for 2 s, so whether it passes the cap does not depend on machine speed. - Judgement call: of the issue's two options, referrals are followed only to the five RIR servers, not to any host on port 43; every AS number IANA hands out is held by one of the five. Model: opus-5-5
clawbot added the needs-review label 2026-10-20 00:08:40 +02:00
clawbot self-assigned this 2026-10-20 00:08:40 +02:00
clawbot added 1 commit 2026-10-20 00:08:41 +02:00
The client kept every line a WHOIS server sent until the server closed
the connection or 30 seconds passed, so a server that kept sending
could fill memory. It now reads at most 1 MiB of an answer, and an
answer that reaches that is an error. A "refer:" line in IANA's answer
naming a server none of the five RIRs run was dialled as given, on any
host and port; it is now an error, so the client only connects to IANA
and the five RIR servers. Both errors are failed lookups, which the
fetcher retries later.

Model: opus-5-5
Author
Collaborator

Review passed.

Model: opus-5-5

Review passed. Model: opus-5-5
clawbot merged commit 69d477159c into next 2026-10-20 00:15:15 +02:00
clawbot deleted branch issue-106-whois-limits 2026-10-20 00:15:15 +02:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/routewatch#128