How many echoes may one ping ask for? (#1379) #1380
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
jaylouisw/packetforge!1380
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/ping-count"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
How many echoes may one ping ask for? Fixes #1379.
A count is a loop bound, and three surfaces took it from whoever asked:
engine/simulator.jsping()—opts.count || 4, then a loop. Measured: 5000 echoes in 23 ms, so1e9echoes is roughly 4,600 seconds of engine time and a response nobody can hold.
count: -5produced zeroreplies and
count: 'abc'produced an empty answer that reads like a dead network — neither is a count, andneither was questioned.
POST /ping— passed the number straight through, so all of the above was one unauthenticated request away.web/app.js—parseInt(...) || 4. The field carriesmin=1 max=50, but a browser does not clamp a typedvalue, so
9999was sent and 9999 replies drawn.Same shape as the port-count ceiling (#1319): a number that bounds work, guarded at one door and not the others.
One rule, applied at each door
Simulator.ping()clamps to 50 (default 4), floors a fraction, falls back to 4 for anything that is not acount, and reports both
count(what was sent) andrequestedCount(what was asked for,nullwhen nothing wasasked) — so a clamp is visible instead of silent.
POST /pinganswers400 E_BAD_COUNTnaming the range for anything that is not a whole number 1..50; anexplicit
nullis treated as no count at all; the 200 body now carriescount.ping <addr> 51with the range, andping <addr> 0no longer silently sends four.Two parser defects fell out of writing that
ping 10.0.0.1 abcsent four echoes as if the word were not there. Now refused,with the usage line.
attook whatever followed it:ping 10.0.0.1 5 at laterevaluated toNaNand silently pinged at the wronginstant, and a bare
atwas dropped. Both are refused, naming the value.Evidence
test/ping-count.test.js— 39 checks: the engine sends 50 for a billion and reports both numbers, falls backto four for
0/-5/'abc'/null/'', floors1.9to 1, and the reply list is exactly as long as the count itreports; the console refuses
51,0,999999, a stray word and a bad instant, whileat <ms>still works; thedialog and the console refuse and accept the same table of values; and over HTTP
51/0/-1/1.5/'abc'are400s naming the range,
nullis absent,50returns 50 replies withcount: 50, and no count returns four.engine/simulator.js→ 2 of 39engine/cli.js→ 9 of 39server/index.js→ 7 of 39web/app.js→ 3 of 39docs/CLI.mdgains the ping syntax with the three refusals;docs/ARCHITECTURE.mdgains the count contract.Suite: 193 suites, 7,444 assertions, 0 failed. Syntax: 261 files, OK.
A count is a loop bound, and three surfaces took it from whoever asked: engine/simulator.js ping() `opts.count || 4`, then a loop. Measured: 5000 echoes in 23 ms, so 1e9 echoes is roughly 4,600 seconds of engine time and a response nobody can hold. `-5` produced ZERO replies and `'abc'` produced an empty answer that reads like a dead network, because neither is a count and neither was questioned. POST /ping passed the number straight through, so all of the above was one unauthenticated request away. web/app.js dialog `parseInt(...) || 4`. The field carries min=1 max=50, but a browser does not clamp a typed value, so 9999 was sent and 9999 replies were drawn. One rule - a whole number from 1 to 50 - applied at each door, and the engine no longer trusts its callers: - simulator.ping() clamps to 50 (default 4), floors a fraction, falls back to 4 for anything that is not a count, and reports both `count` (what was sent) and `requestedCount` (what was asked for, null when nothing was asked), so a clamp is visible instead of silent. - POST /ping answers 400 E_BAD_COUNT naming the range for anything that is not a whole number 1..50; an explicit null is treated as no count at all; the 200 body now carries `count`. - the console refuses `ping <addr> 51` with the range, and `ping <addr> 0` no longer silently sends four. - the dialog checks the field before sending and says the same thing. Two parser defects fell out of writing that: - a stray word was ignored, so `ping 10.0.0.1 abc` sent four echoes as if the word were not there. It is now refused with the usage line. - `at` took whatever followed it: `ping 10.0.0.1 5 at later` evaluated to NaN and silently pinged at the wrong instant, and a bare `at` was dropped. Both are refused now, naming the value. Evidence: test/ping-count.test.js, 39 checks - the engine sends 50 for a billion and reports both numbers, falls back to four for 0/-5/'abc'/null/'', floors 1.9 to 1, and the reply list is exactly as long as the count it reports; the console refuses 51, 0, 999999, a stray word and a bad instant, and `at <ms>` still works; the dialog and the console refuse and accept the same table of values; and over HTTP, 51/0/-1/1.5/'abc' are 400s naming the range, null is treated as absent, 50 returns 50 replies and reports count 50, and no count returns four. Reverting engine/simulator.js fails 2 of 39, engine/cli.js 9, server/index.js 7, web/app.js 3. docs/CLI.md gains the ping syntax with the three refusals; docs/ARCHITECTURE.md gains the count contract. Suite: 193 suites, 7,444 assertions, 0 failed. Syntax: 261 files, OK.