fix(netxlite): clearly document quirk and make code robust (#468)

This quirk really saddens me. It's a piece of tech debt we're
carrying over from the original netx implementation.

We cannot remove it _until_ we have legacy netx code around.

The second best thing we can do is to clearly move this code in
a place where it's clear it's a quirk and write and use some extra
code that makes sure the quirk's assumptions are always met.

Sigh.

See https://github.com/ooni/probe/issues/1591
This commit is contained in:
Simone Basso 2021-09-06 20:17:45 +02:00 committed by GitHub
commit aa77867145
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 153 additions and 77 deletions

View file

@ -84,6 +84,9 @@ func (d *dialerResolver) DialContext(ctx context.Context, network, address strin
// than just calling ReduceErrors. We are not ready to do that
// yet, though. To do that, we need first to modify nettests so
// that we actually avoid dialing when measuring.
//
// See also the quirks.go file. This is clearly a QUIRK.
addrs = quirkSortIPAddrs(addrs)
var errorslist []error
for _, addr := range addrs {
target := net.JoinHostPort(addr, onlyport)
@ -93,7 +96,7 @@ func (d *dialerResolver) DialContext(ctx context.Context, network, address strin
}
errorslist = append(errorslist, err)
}
return nil, reduceErrors(errorslist)
return nil, quirkReduceErrors(errorslist)
}
// lookupHost performs a domain name resolution.