mirror of
https://github.com/status-im/status-go.git
synced 2025-02-17 17:28:38 +00:00
fix: set nameserver via config
This commit is contained in:
parent
dc87d6bb0f
commit
09723e3b9a
@ -294,6 +294,7 @@ func (b *StatusNode) wakuV2Service(nodeConfig *params.NodeConfig) (*wakuv2.Waku,
|
|||||||
StoreSeconds: nodeConfig.WakuV2Config.StoreSeconds,
|
StoreSeconds: nodeConfig.WakuV2Config.StoreSeconds,
|
||||||
DiscoveryLimit: nodeConfig.WakuV2Config.DiscoveryLimit,
|
DiscoveryLimit: nodeConfig.WakuV2Config.DiscoveryLimit,
|
||||||
DiscV5BootstrapNodes: nodeConfig.ClusterConfig.DiscV5BootstrapNodes,
|
DiscV5BootstrapNodes: nodeConfig.ClusterConfig.DiscV5BootstrapNodes,
|
||||||
|
Nameserver: nodeConfig.WakuV2Config.Nameserver,
|
||||||
EnableDiscV5: nodeConfig.WakuV2Config.EnableDiscV5,
|
EnableDiscV5: nodeConfig.WakuV2Config.EnableDiscV5,
|
||||||
UDPPort: nodeConfig.WakuV2Config.UDPPort,
|
UDPPort: nodeConfig.WakuV2Config.UDPPort,
|
||||||
AutoUpdate: nodeConfig.WakuV2Config.AutoUpdate,
|
AutoUpdate: nodeConfig.WakuV2Config.AutoUpdate,
|
||||||
|
@ -192,6 +192,9 @@ type WakuV2Config struct {
|
|||||||
// PeerExchange determines whether WakuV2 Peer Exchange is enabled or not
|
// PeerExchange determines whether WakuV2 Peer Exchange is enabled or not
|
||||||
PeerExchange bool
|
PeerExchange bool
|
||||||
|
|
||||||
|
// Nameserver determines which nameserver will be used for dns discovery
|
||||||
|
Nameserver string
|
||||||
|
|
||||||
// EnableDiscV5 indicates if DiscoveryV5 is enabled or not
|
// EnableDiscV5 indicates if DiscoveryV5 is enabled or not
|
||||||
EnableDiscV5 bool
|
EnableDiscV5 bool
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ type Config struct {
|
|||||||
WakuNodes []string `toml:",omitempty"`
|
WakuNodes []string `toml:",omitempty"`
|
||||||
Rendezvous bool `toml:",omitempty"`
|
Rendezvous bool `toml:",omitempty"`
|
||||||
DiscV5BootstrapNodes []string `toml:",omitempty"`
|
DiscV5BootstrapNodes []string `toml:",omitempty"`
|
||||||
|
Nameserver string `toml:",omitempty"`
|
||||||
EnableDiscV5 bool `toml:",omitempty"`
|
EnableDiscV5 bool `toml:",omitempty"`
|
||||||
DiscoveryLimit int `toml:",omitempty"`
|
DiscoveryLimit int `toml:",omitempty"`
|
||||||
AutoUpdate bool `toml:",omitempty"`
|
AutoUpdate bool `toml:",omitempty"`
|
||||||
|
@ -89,6 +89,7 @@ type settings struct {
|
|||||||
EnableConfirmations bool // Enable sending message confirmations
|
EnableConfirmations bool // Enable sending message confirmations
|
||||||
PeerExchange bool // Enable peer exchange
|
PeerExchange bool // Enable peer exchange
|
||||||
DiscoveryLimit int // Indicates the number of nodes to discover
|
DiscoveryLimit int // Indicates the number of nodes to discover
|
||||||
|
Nameserver string // Optional nameserver to use for dns discovery
|
||||||
}
|
}
|
||||||
|
|
||||||
// Waku represents a dark communication interface through the Ethereum
|
// Waku represents a dark communication interface through the Ethereum
|
||||||
@ -197,6 +198,7 @@ func New(nodeKey string, fleet string, cfg *Config, logger *zap.Logger, appDB *s
|
|||||||
MinPeersForRelay: cfg.MinPeersForRelay,
|
MinPeersForRelay: cfg.MinPeersForRelay,
|
||||||
PeerExchange: cfg.PeerExchange,
|
PeerExchange: cfg.PeerExchange,
|
||||||
DiscoveryLimit: cfg.DiscoveryLimit,
|
DiscoveryLimit: cfg.DiscoveryLimit,
|
||||||
|
Nameserver: cfg.Nameserver,
|
||||||
}
|
}
|
||||||
|
|
||||||
waku.filters = common.NewFilters()
|
waku.filters = common.NewFilters()
|
||||||
@ -400,8 +402,16 @@ func (w *Waku) dnsDiscover(ctx context.Context, enrtreeAddress string, apply fnA
|
|||||||
|
|
||||||
discNodes, ok := w.dnsAddressCache[enrtreeAddress]
|
discNodes, ok := w.dnsAddressCache[enrtreeAddress]
|
||||||
if !ok {
|
if !ok {
|
||||||
// NOTE: Temporary fix for DNS resolution on android/ios, as gomobile does not support it
|
w.settingsMu.RLock()
|
||||||
discoveredNodes, err := dnsdisc.RetrieveNodes(ctx, enrtreeAddress, dnsdisc.WithNameserver("1.1.1.1"))
|
nameserver := w.settings.Nameserver
|
||||||
|
w.settingsMu.RUnlock()
|
||||||
|
|
||||||
|
var opts []dnsdisc.DnsDiscoveryOption
|
||||||
|
if nameserver != "" {
|
||||||
|
opts = append(opts, dnsdisc.WithNameserver(nameserver))
|
||||||
|
}
|
||||||
|
|
||||||
|
discoveredNodes, err := dnsdisc.RetrieveNodes(ctx, enrtreeAddress, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.logger.Warn("dns discovery error ", zap.Error(err))
|
w.logger.Warn("dns discovery error ", zap.Error(err))
|
||||||
return
|
return
|
||||||
@ -434,6 +444,7 @@ func (w *Waku) addWakuV2Peers(ctx context.Context, cfg *Config) error {
|
|||||||
identifyWg := &sync.WaitGroup{}
|
identifyWg := &sync.WaitGroup{}
|
||||||
identifyWg.Add(len(cfg.WakuNodes))
|
identifyWg.Add(len(cfg.WakuNodes))
|
||||||
for _, addrString := range cfg.WakuNodes {
|
for _, addrString := range cfg.WakuNodes {
|
||||||
|
addrString := addrString
|
||||||
if strings.HasPrefix(addrString, "enrtree://") {
|
if strings.HasPrefix(addrString, "enrtree://") {
|
||||||
// Use DNS Discovery
|
// Use DNS Discovery
|
||||||
go func() {
|
go func() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user