566c6b246a
This diff addresses another point of https://github.com/ooni/probe/issues/1956: > - [ ] observe that we're still using a bunch of private interfaces for common interfaces such as the `Dialer`, so we can get rid of these private interfaces and always use the ones in `model`, which allows us to remove a bunch of legacy wrappers Additional cleanups may still be possible. The more I cleanup, the more I see there's extra legacy code we can dispose of (which seems good?).
33 lines
830 B
Go
33 lines
830 B
Go
package resolver
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/ooni/probe-cli/v3/internal/model"
|
|
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
|
)
|
|
|
|
// BogonResolver is a bogon aware resolver. When a bogon is encountered in
|
|
// a reply, this resolver will return an error.
|
|
//
|
|
// Deprecation warning
|
|
//
|
|
// This resolver is deprecated. The right thing to do would be to check
|
|
// for bogons right after a domain name resolution in the nettest.
|
|
type BogonResolver struct {
|
|
model.Resolver
|
|
}
|
|
|
|
// LookupHost implements Resolver.LookupHost
|
|
func (r BogonResolver) LookupHost(ctx context.Context, hostname string) ([]string, error) {
|
|
addrs, err := r.Resolver.LookupHost(ctx, hostname)
|
|
for _, addr := range addrs {
|
|
if netxlite.IsBogon(addr) {
|
|
return nil, netxlite.ErrDNSBogon
|
|
}
|
|
}
|
|
return addrs, err
|
|
}
|
|
|
|
var _ model.Resolver = BogonResolver{}
|