This reworks the HTTPS seeding in the connmgr package and server to make
it easier to use properly and to make use of a couple of the new
capabilities it offers.
The current implementation of the SeedAddrs function is basically a
carbon copy of the older DNS seeding function with some slight
modifications and, as a result, its API is geared more towards the older
functionality which is not the most ideal for the new functionality.
First, since the SeedAddrs function is synchronous, as opposed
to the older async DNS seeder version, an OnSeed callback adds
unnecessary complexity since the addresses can simply be returned from
the function instead.
Next, this existing function does not make it very clear how to use the
additional filtering parameters and it also always sets them in the
query string which unnecessarily imposes a specific implementation on
the seeding server. More desirable behavior is to only set the specific
query parameters when the caller wishes to apply specific filters.
Finally, the code in the server that consumes the returned seeds
currently still contains a quirk that was required by the old DNS
seeding semantics which no longer apply where it attributes the source
of the addresses to the first returned address.
This addresses all of those issues and a couple of other minor nits.
The following is an overview of the changes:
- Modify the SeedAddrs func signature to return the addresses directly
instead of using an OnSeed callback
- Introduce a new HttpsSeederFilters struct along with exported
functions that allow the caller to selectively specify seed filters
- Modify the SeedAddrs func signature to accept a variable number of
filters specified via the aforementioned functions
- This allows only the specific filters the caller desires to be
specified and is easily extensible to support more filters with no
breaking API changes in the future should it be necessary
- Modify the implementation of the SeedAddrs func to only set the query
params for the various filter options if the caller provided them
- Improve the logging to properly handle any invalid addresses returned
from the seeder
- Improve the readability of the random time offset code in SeedAddrs
- Update the server code in accordance with the API changes
- Modify the server code that adds the discovered addresses to the
address manager to look up the IP address of the HTTPS seeder and use
that as the source address
- Fall back to the first returned address in the extremely rare event
the HTTPS seeder IP lookup fails
9 lines
130 B
Modula-2
9 lines
130 B
Modula-2
module github.com/decred/dcrd/connmgr/v3
|
|
|
|
go 1.13
|
|
|
|
require (
|
|
github.com/decred/dcrd/wire v1.3.0
|
|
github.com/decred/slog v1.0.0
|
|
)
|