-
Notifications
You must be signed in to change notification settings - Fork 130
Handle case where peers advertise a listening port of 0 #1391
Handle case where peers advertise a listening port of 0 #1391
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
int port = peerInfo.getPort(); | ||
if (port == 0) { | ||
// Most peers advertise a port of "0", just set a default best guess in this case | ||
port = EnodeURL.DEFAULT_LISTENING_PORT; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of the default port perhaps we could use the remote port of the current communication? We are already doing this with the remoteAddress.
Also, can these two values ever differ? Such as if we have an eth loadbalancer or proxy in front of us (in case those ever exist for devp2p).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I experimented with trying to use the remote port, but it doesn't match the listening port. When the other nodes are initiating outbound connections, they're free to use whatever port they want for their side of the connection.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Un-resolving this comment because I think its a good question and will be helpful to have it visible here as a kind of documentation. Actually, I think I might add a comment in the codebase as well :D
As a side note, my Geth reports its own
|
Thanks for reporting @xavierlepretre ! I've added a ticket and we will address this soon: https://pegasys1.atlassian.net/browse/PAN-2618 |
PR description
It is common for peers to advertise a listening port of 0. Handle this case by using a default listening port of 30303.