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",
|
Usage: "Enable DNS discovery",
|
||||||
Destination: &options.DNSDiscovery.Enable,
|
Destination: &options.DNSDiscovery.Enable,
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringSliceFlag{
|
||||||
Name: "dns-discovery-url",
|
Name: "dns-discovery-url",
|
||||||
Usage: "URL for DNS node list in format 'enrtree://<key>@<fqdn>'",
|
Usage: "URL for DNS node list in format 'enrtree://<key>@<fqdn>'",
|
||||||
Destination: &options.DNSDiscovery.URL,
|
Destination: &options.DNSDiscovery.URLs,
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "dns-discovery-name-server",
|
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
|
var discoveredNodes []dnsdisc.DiscoveredNode
|
||||||
if options.DNSDiscovery.Enable {
|
if options.DNSDiscovery.Enable {
|
||||||
if options.DNSDiscovery.URL != "" {
|
if len(options.DNSDiscovery.URLs.Value()) != 0 {
|
||||||
logger.Info("attempting DNS discovery with ", zap.String("URL", options.DNSDiscovery.URL))
|
for _, url := range options.DNSDiscovery.URLs.Value() {
|
||||||
nodes, err := dnsdisc.RetrieveNodes(ctx, options.DNSDiscovery.URL, dnsdisc.WithNameserver(options.DNSDiscovery.Nameserver))
|
logger.Info("attempting DNS discovery with ", zap.String("URL", url))
|
||||||
if err != nil {
|
nodes, err := dnsdisc.RetrieveNodes(ctx, url, dnsdisc.WithNameserver(options.DNSDiscovery.Nameserver))
|
||||||
logger.Warn("dns discovery error ", zap.Error(err))
|
if err != nil {
|
||||||
} else {
|
logger.Warn("dns discovery error ", zap.Error(err))
|
||||||
var discAddresses []multiaddr.Multiaddr
|
} else {
|
||||||
for _, n := range nodes {
|
var discAddresses []multiaddr.Multiaddr
|
||||||
discAddresses = append(discAddresses, n.Addresses...)
|
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 {
|
} else {
|
||||||
logger.Fatal("DNS discovery URL is required")
|
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.
|
// information for nodes. It's very useful for bootstrapping a p2p network.
|
||||||
type DNSDiscoveryOptions struct {
|
type DNSDiscoveryOptions struct {
|
||||||
Enable bool
|
Enable bool
|
||||||
URL string
|
URLs cli.StringSlice
|
||||||
Nameserver string
|
Nameserver string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue