mirror of
https://github.com/status-im/go-waku.git
synced 2025-01-27 05:56:07 +00:00
chore: allow custom resolver for dns discovery (#930)
This commit is contained in:
parent
e1266b836b
commit
28107bd307
@ -15,6 +15,7 @@ import (
|
||||
|
||||
type dnsDiscoveryParameters struct {
|
||||
nameserver string
|
||||
resolver dnsdisc.Resolver
|
||||
}
|
||||
|
||||
type DNSDiscoveryOption func(*dnsDiscoveryParameters)
|
||||
@ -26,6 +27,12 @@ func WithNameserver(nameserver string) DNSDiscoveryOption {
|
||||
}
|
||||
}
|
||||
|
||||
func WithResolver(resolver dnsdisc.Resolver) DNSDiscoveryOption {
|
||||
return func(params *dnsDiscoveryParameters) {
|
||||
params.resolver = resolver
|
||||
}
|
||||
}
|
||||
|
||||
type DiscoveredNode struct {
|
||||
PeerID peer.ID
|
||||
PeerInfo peer.AddrInfo
|
||||
@ -52,8 +59,12 @@ func RetrieveNodes(ctx context.Context, url string, opts ...DNSDiscoveryOption)
|
||||
opt(params)
|
||||
}
|
||||
|
||||
if params.resolver == nil {
|
||||
params.resolver = GetResolver(ctx, params.nameserver)
|
||||
}
|
||||
|
||||
client := dnsdisc.NewClient(dnsdisc.Config{
|
||||
Resolver: GetResolver(ctx, params.nameserver),
|
||||
Resolver: params.resolver,
|
||||
})
|
||||
|
||||
tree, err := client.SyncTree(url)
|
||||
|
Loading…
x
Reference in New Issue
Block a user