2021-08-17 10:29:06 +02:00
|
|
|
package websteps
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"github.com/apex/log"
|
|
|
|
"github.com/ooni/probe-cli/v3/internal/engine/netx"
|
2022-01-07 18:33:37 +01:00
|
|
|
"github.com/ooni/probe-cli/v3/internal/model"
|
2021-08-17 10:29:06 +02:00
|
|
|
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
|
|
|
"github.com/ooni/probe-cli/v3/internal/runtimex"
|
|
|
|
)
|
|
|
|
|
|
|
|
type DNSConfig struct {
|
|
|
|
Domain string
|
2022-01-07 18:33:37 +01:00
|
|
|
Resolver model.Resolver
|
2021-08-17 10:29:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// DNSDo performs the DNS check.
|
|
|
|
func DNSDo(ctx context.Context, config DNSConfig) ([]string, error) {
|
|
|
|
resolver := config.Resolver
|
|
|
|
if resolver == nil {
|
|
|
|
childResolver, err := netx.NewDNSClient(netx.Config{Logger: log.Log}, "doh://google")
|
|
|
|
runtimex.PanicOnError(err, "NewDNSClient failed")
|
2021-08-20 16:09:21 +02:00
|
|
|
resolver = childResolver
|
2021-09-05 18:03:50 +02:00
|
|
|
resolver = &netxlite.ResolverIDNA{
|
2022-01-07 18:33:37 +01:00
|
|
|
Resolver: resolver,
|
2021-09-05 18:03:50 +02:00
|
|
|
}
|
2021-08-17 10:29:06 +02:00
|
|
|
}
|
2021-08-20 16:09:21 +02:00
|
|
|
return resolver.LookupHost(ctx, config.Domain)
|
2021-08-17 10:29:06 +02:00
|
|
|
}
|