Repository navigation
fix: ping over the address family -4 or -6 asks for - #159
Conversation
The ICMP pinger resolved its target before the family was set, so with --ipv6 a dual-stack server was pinged over IPv4 while the transfers ran over IPv6.
eb922dc to
cf2bdc1
Compare
maddie
left a comment
There was a problem hiding this comment.
Reviewed at cf2bdc1. The fix is correct: probing.NewPinger resolves during construction with the default "ip" network, so setting the network afterwards could never change the family of the resolved address. newPinger sets it before Resolve(), and pro-bing v0.9.1 honours p.network there (ping.go:418, mapped at ping.go:459-467). I reproduced the old and the new behaviour: ::1 with ip4 and 127.0.0.1 with ip6 returned the wrong-family literal before and now return no suitable address found; a dual-stack name such as dns.google with ip6 resolves to an IPv6 address now and to IPv4 before. The empty network still behaves exactly as before, and defs/server.go:163-168 falls back to TCP when the pinger cannot be created, so no caller regresses.
Build, vet, the full test suite and -race pass. The new test fails on master with the old helper, so it does guard the fix.
Two optional nits, neither blocking:
- 💡
defs/pinger_test.go:50-51— on a host without an AAAA record forlocalhosttheip6subtest skips, so the dual-stack case that actually triggered the report is not asserted in CI. Since the old code returned127.0.0.1with a nil error for this input, the skip branch could assertnewPinger("localhost", "ip6")returns an error instead. - 💡
defs/server.go:230-239— the doc comment promisesip/ip4/ip6, butSetNetworksilently maps anything else, including"", toip. All current callers are correct, so this is only a note that the helper cannot flag a bad network string.
Approved – ready for merge.
The ICMP pinger resolved its target before the address family was set, so
-4and-6did not apply to the ICMP ping. With-6, a dual-stack server was pinged over IPv4 while the HTTP requests went over IPv6.Local server on 127.0.0.1 and ::1, a
localhostserver URL,-6 --debug: