Repository navigation
fix: small follow-ups to the option handling fixes - #163
Conversation
The largest upload size, the short forms of contradicting options, the source address and mark of a bound connection, and a family localhost has no address in were not asserted. The comment on newPinger now says what an unknown network does.
The size was checked before the servers were listed, so --list with --upload-size out of range ended in a usage error although nothing is uploaded.
Such a file ended the run through a fatal log line, without the prefix the other errors get. The message for a file without a certificate now says that PEM is expected.
With --no-pre-allocate the size is not checked and not used, and scaling it to bytes could overflow on a 32-bit system.
maddie
left a comment
There was a problem hiding this comment.
Reviewed a4c6890 against master (7a9af2a). The four commits are scoped to the follow-ups from the previous review, and the two CI checks are green.
Validation on this head: go build ./..., go vet ./..., gofmt -l ., go test -count=1 ./..., go test -count=1 -race ./... and GOARCH=386 go build ./... all pass. The changed tests also pass five times in a row. No security or apparent-bug finding.
The behavior changes match the commit messages:
--listno longer rejects an out-of-range--upload-sizebecause no payload is allocated (speedtest/speedtest.go:190-202).- An unreadable
--ca-certnow returns the read error instead of callingoutput.Fatal, and the empty-PEM message is accurate (speedtest/speedtest.go:228-238). - The upload payload size is set only in the pre-allocating branch, before
GenerateBlob(defs/server.go:511-520).
💡 nit — defs/pinger_test.go:50-53
When localhost has no address in the requested family, the test only requires newPinger to return some error. It would also pass if the constructor failed for an unrelated reason. Asserting that the error is about the requested family (or at least asserting it is non-nil with a clear message) would make the regression test sharper.
💡 nit — speedtest/dialer_linux_test.go:135
socketMark does an unchecked conn.(*net.TCPConn) assertion. The current callers pass a TCP connection, so this is test-only, but an explicit ok check with t.Fatalf would fail with a useful message instead of a panic if a future caller passes another net.Conn.
Approved. No ❌ errors found.
Follow-ups from the reviews of #159, #161 and #162, one per commit:
-4 -6, the source address and the mark of a bound connection, and a familylocalhosthas no address in. The mark is checked only as root.--listno longer fails over an--upload-sizeout of range, which it does not use.--ca-certfile that cannot be read is reported like other errors, and a file without a certificate getsno usable PEM certificate found.Not changed: the ping collection test still depends on scheduling. The old loop passes it with
GOMAXPROCS=1, and I found no way to make that certain without a hook in the code.