server: Use addrmgr.NetAddress for ban/whitelist.#3638
Open
davecgh wants to merge 2 commits intodecred:masterfrom
Open
server: Use addrmgr.NetAddress for ban/whitelist.#3638davecgh wants to merge 2 commits intodecred:masterfrom
davecgh wants to merge 2 commits intodecred:masterfrom
Conversation
44e1740 to
e7ef66b
Compare
e7ef66b to
5d31339
Compare
5d31339 to
465e79e
Compare
This modifies the lifecycle of peers to use the more modern Run pattern that based on contexts. In particular, this replaces the Start and WaitForDisconnect methods with a single method named Run and arranges for it to block until the provided context is cancelled or the peer is disconnected. This is more flexible for the caller since it can easily turn blocking code into async code while the reverse is not true. The new Run method waits for all goroutines that it starts to shutdown before returning to help ensure an orderly shutdown. Since all exported methods that send messages to the various groroutines via channels already select across the quit channel which is closed when the peer disconnects, the peer is now forcibly disconnected when the context is cancelled. This approach allows the flexibility for callers to use any combination of manually disconnecting peers via the Disconnect method and allowing them to automatically be disconnected when the context is cancelled. It also updates the server code accordingly.
Currently, the whitelist and banning detection splits the host and port multiple times since the address previously hadn't been parsed yet. However, it is no longer necessary since the parsed address is now available as soon as the peer first connects. This updates the detection funcs to take the parsed address directly.
465e79e to
cec584e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This requires #3633.
Currently, the whitelist and banning detection splits the host and port multiple times since the address previously hadn't been parsed yet.
However, it is no longer necessary since the parsed address is now available as soon as the peer first connects.
This updates the detection funcs to take the parsed address directly.