One question, three answers: what is a ping destination? (#1377) #1378
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!1378
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/ping-surface"
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?
One question — what is a ping destination? — asked in three places, answered three ways. Fixes #1377.
#1376 taught the console to resolve a hostname. The other two surfaces that ask the same question did not agree
with it, or with themselves:
engine/cli.jsping10.0.0.999, becausenet.isIp()only checks the shapePOST /ping10.0.0.999threw and came back as a 500web/app.jsdialog/^(\d{1,3}\.){3}\d{1,3}$/— accepted10.0.0.999, refused every hostnameAnd
POST /pingnever returned what the resolver said: a name that does not resolve sends no packet, yet theanswer was only
replies: [{ success: false }]— indistinguishable from four lost echoes, so the UI drew a 0%success rate for something that was never sent.
Fixed at each surface, with one rule
POST /pingvalidates the destination:400withcode: "E_BAD_DESTINATION"and a message naming theproblem (four octets, each 0-255; no whitespace; not empty).
{src:"nobody"}is still a404about the device it named ratherthan a
400about a destination — the order is part of the contract andapi-errorspins it.POST /pingreturns the resolver verdict:dns: { ok, status, address, serverIp }, ornullfor anaddress. The reply already carried
reason: "dns-nxdomain"and sends nothing.resolution — or says the name did not resolve and that nothing was sent, instead of drawing a 0% success rate.
The browser cannot
requirethe engine, so the rule is written twice; the test compares the two across a table ofstrings (addresses, near-addresses, names, an empty target, a target with a space).
Evidence
test/ping-surface.test.js— 21 checks: the dialog and the console accept and refuse the same strings; amistyped octet is a
400with a code and a message; an empty or spaced destination is a400; a missing source is a400; a hostname is accepted and its resolution reported; a name with no zone comes back as a resolver verdictwith one failed reply whose reason says
dns-*, not as a crash; an address still works and reports no resolution.server/index.js→ 9 of 21 failweb/app.js→ 3 of 21 (the dialog rule and the two checks that name it)docs/ARCHITECTURE.mdgains "Ping, and what a destination is" with the request/response shapes and the400.Suite: 192 suites, 7,405 assertions, 0 failed. Syntax: 260 files, OK.