pool, agent: StrictPeers checking for remote host matching#80
Merged
Conversation
shazow
commented
Oct 3, 2019
| // of IPs, so we avoid stripping out hosts. | ||
| if hostname := (*url.URL)(u).Hostname(); hostname == "localhost" { | ||
| return "" | ||
| } else if ip := net.ParseIP(hostname); ip.IsUnspecified() || ip.IsLoopback() { |
Member
Author
There was a problem hiding this comment.
This check helps normalize things like "[::]", "0.0.0.0", "127.0.0.1", etc into an empty host for more effective comparison.
I think this is a Good Idea, but I could also see an argument for having a more explicit CompareRemote(string) bool function.
shazow
commented
Oct 3, 2019
| // StaticPool is a dummy implementation of a pool service that always returns | ||
| // from the same set of host nodes. It does not do any signature checking. | ||
| type StaticPool struct { | ||
| Nodes []store.Node |
Member
Author
There was a problem hiding this comment.
This was another example where it was too tempting/easy to accidentally have side effects/mutations on the internal slice, messing up some test scenarios.
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.
ethnode.ParseNodeURI(...), similar tourl.Parse(...). Closes ethnode: Add NewEnodeURI(uri string) (*EnodeURI, error) #76.UpdateResponse.ActivePeersare nowenode://strings instead of just NodeIDs. This should be safe for previous versions because they only looked atlen(ActivePeers)rather than actual values.UpdateResponse.InvalidPeersmight also be changed toenode://strings for consistency, though thinking about it more it might not make sense since invalid peers are "disconnected" so the pool doesn't necessarily know about their prior host/port etc. Maybe just change them to anenode://string with an empty host? (Updated code to parse defensively so this is a less-breaking change in the future.)StrictModeafter being normalized withParseNodeURI. Closes agent: Add host/port checking to StrictPeer mode #79