mirror of https://github.com/status-im/go-waku.git
feat: support multiple DNS discovery URLs (#309)
This commit is contained in:
parent
8d42febe18
commit
c39c4d535c
4
waku.go
4
waku.go
|
@ -354,10 +354,10 @@ func main() {
|
|||
Usage: "Enable DNS discovery",
|
||||
Destination: &options.DNSDiscovery.Enable,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
&cli.StringSliceFlag{
|
||||
Name: "dns-discovery-url",
|
||||
Usage: "URL for DNS node list in format 'enrtree://<key>@<fqdn>'",
|
||||
Destination: &options.DNSDiscovery.URL,
|
||||
Destination: &options.DNSDiscovery.URLs,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "dns-discovery-name-server",
|
||||
|
|
24
waku/node.go
24
waku/node.go
|
@ -226,18 +226,20 @@ func Execute(options Options) {
|
|||
|
||||
var discoveredNodes []dnsdisc.DiscoveredNode
|
||||
if options.DNSDiscovery.Enable {
|
||||
if options.DNSDiscovery.URL != "" {
|
||||
logger.Info("attempting DNS discovery with ", zap.String("URL", options.DNSDiscovery.URL))
|
||||
nodes, err := dnsdisc.RetrieveNodes(ctx, options.DNSDiscovery.URL, dnsdisc.WithNameserver(options.DNSDiscovery.Nameserver))
|
||||
if err != nil {
|
||||
logger.Warn("dns discovery error ", zap.Error(err))
|
||||
} else {
|
||||
var discAddresses []multiaddr.Multiaddr
|
||||
for _, n := range nodes {
|
||||
discAddresses = append(discAddresses, n.Addresses...)
|
||||
if len(options.DNSDiscovery.URLs.Value()) != 0 {
|
||||
for _, url := range options.DNSDiscovery.URLs.Value() {
|
||||
logger.Info("attempting DNS discovery with ", zap.String("URL", url))
|
||||
nodes, err := dnsdisc.RetrieveNodes(ctx, url, dnsdisc.WithNameserver(options.DNSDiscovery.Nameserver))
|
||||
if err != nil {
|
||||
logger.Warn("dns discovery error ", zap.Error(err))
|
||||
} else {
|
||||
var discAddresses []multiaddr.Multiaddr
|
||||
for _, n := range nodes {
|
||||
discAddresses = append(discAddresses, n.Addresses...)
|
||||
}
|
||||
logger.Info("found dns entries ", logging.MultiAddrs("nodes", discAddresses...))
|
||||
discoveredNodes = nodes
|
||||
}
|
||||
logger.Info("found dns entries ", logging.MultiAddrs("nodes", discAddresses...))
|
||||
discoveredNodes = nodes
|
||||
}
|
||||
} else {
|
||||
logger.Fatal("DNS discovery URL is required")
|
||||
|
|
|
@ -103,7 +103,7 @@ type SwapOptions struct {
|
|||
// information for nodes. It's very useful for bootstrapping a p2p network.
|
||||
type DNSDiscoveryOptions struct {
|
||||
Enable bool
|
||||
URL string
|
||||
URLs cli.StringSlice
|
||||
Nameserver string
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue