Skip to content

Commit

Permalink
lookup peers from seeders when starting (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
conradoplg authored Jun 25, 2024
1 parent adaedce commit f4daa78
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
19 changes: 14 additions & 5 deletions dnsseed/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,22 @@ func setup(c *caddy.Controller) error {
return plugin.Error(pluginName, c.Errf("config error: expected 'host:port', got %s", s))
}

// Connect to the bootstrap peer
_, err = seeder.Connect(address, port)
addresses, err := net.LookupHost(address)
if err != nil {
log.Errorf("error connecting to %s:%s: %v", address, port, err)
continue
return plugin.Error(pluginName, c.Errf("error looking up host %s: %v", address, err))
}
log.Infof("Got %d addresses from peer %v: %v", len(addresses), s, addresses)

for _, address := range addresses {
// Connect to the bootstrap peer
_, err = seeder.Connect(address, port)
if err != nil {
log.Errorf("error connecting to %s:%s (will keep trying other peers): %v", address, port, err)
} else {
log.Infof("success connecting to %s:%s (will keep trying other peers)", address, port)
connectedToBootstrap = true
}
}
connectedToBootstrap = true
}

if !connectedToBootstrap {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/zcashfoundation/dnsseeder

go 1.21.0
go 1.21

require (
github.com/btcsuite/btcd v0.22.0-beta
Expand Down

0 comments on commit f4daa78

Please sign in to comment.