UDPServer / ip address resolution #24
No reviewers
Labels
No labels
consider soon
documentation
good first issue
hacktoberfest
help wanted
priority: blocker
priority: high
priority: low
priority: medium
type: bug
type: discussion
type: improvement
type: new feature
type: refactor
type: task
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: LBRYCommunity/herald.go#24
Loading…
Reference in a new issue
No description provided.
Delete branch "feature/18/jeffreypicard/udp-endpoint"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
UDP Ping/Pong protocol implemented, unit tests against itself and prod server.
Also switched to serving udp on the same port as grpc, and taking that
into account when pinging other hubs with udp.
@ -38,3 +38,3 @@
PeerServers map[string]*FederatedServer
PeerServers map[string]*Peer
PeerServersMut sync.RWMutex
NumPeerServers *int64
there's a
net.IP
type that you should use for IPsThis is good. We regret having separate ports for tcp and udp in the client.
@ -22,2 +22,4 @@
Port string
LastSeen time.Time
}
weird. how does that happen?
weird that you're passing this function a pb.ServerMessage. seems like it should take an address and port instead so it can be used elsewhere
@ -222,8 +265,11 @@ func (s *Server) writePeers() {
}
in general, comments should describe the interface and not the implementation. say what it means to notify a peer, not what functions are called inside this one. thats more informative and you can change the implementation without changing the comment.
if you haven't read Philosophy of Software Design, i strongly recommend it (esp the chapters on comments). i can buy you a copy if you'd like
@ -286,3 +328,1 @@
if s.Args.Port == msg.Port &&
(localHosts[msg.Address] || msg.Address == s.Args.Host) {
log.Printf("%s:%s addPeer: Self peer, skipping...\n", s.Args.Host, s.Args.Port)
// addPeer takes a new peer, optionally checks to see if they're online, and
this is a good comment, though i'd delete "takes a new peer as a pb.ServerMessage" since you can tell that from the signature (though maybe rename
msg
tonewPeer
since that's what it is). and in fact, maybe you need a Peer type so pb.ServerMessage is not doing double dutyshould this be a const?
@ -22,2 +22,4 @@
Port string
LastSeen time.Time
}
This happens when the net.IP type is empty and gets turned into a string.
You're right, I thought I had some reason to make it a var originally, but I can't remember now, I'll change that.
Agreed.
@ -286,3 +328,1 @@
if s.Args.Port == msg.Port &&
(localHosts[msg.Address] || msg.Address == s.Args.Host) {
log.Printf("%s:%s addPeer: Self peer, skipping...\n", s.Args.Host, s.Args.Port)
// addPeer takes a new peer, optionally checks to see if they're online, and
I agree. I actually do have a type exactly for this, but it's still called FederatedServer because that's what I called it months ago when I started this. I think I'll actually do a little refactor and rename that to Peer throughout the code base. It definitely makes more sense.
@ -222,8 +265,11 @@ func (s *Server) writePeers() {
}
Makes sense! I'll take a look at that book.
what is
Ts
? preferably make the name more descriptive or add a commenti know Go loves short names, but i'm not a fan. here's a heuristic: the less distance (lines of code) between var declaration and var use, the shorter the name can be. so
i
is perfectly fine as the index of a loop, but its bad as a property of a structvery minor, but i brought this up in the last review so i wanted to point out another example: this comment reveals implementation details. id instead say something like "getAndSetExternalIp detects the server's external IP and stores it"
@ -45,3 +44,4 @@
ExternalIP net.IP
pb.UnimplementedHubServer
}
nice
@ -17,1 +20,4 @@
const magic = 1446058291
const protocolVersion = 1
const defaultFlags = 0b00000000
const availableFlag = 0b00000001
can you add a comment describing what this is for? why is the (wrong) genesis blocktime stored in a var called
magic
?Makes sense.
@ -17,1 +20,4 @@
const magic = 1446058291
const protocolVersion = 1
const defaultFlags = 0b00000000
const availableFlag = 0b00000001
Sure, so the comment is just stolen from the Python implementation and it's an arbitrary number needed for the UDPPing protocol, but I'll add a comment saying that.
Agreed, this is really a last seen timestamp, that I decided to call Ts for "timestamp" I'll rename it to LastSeen, I think that's more correct and descriptive.
Jeff has permission to merge