-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set external IP and mapping port to es-node ENR when it behind a NAT and the advertise IP is not set #132
Conversation
ethstorage/p2p/discovery.go
Outdated
@@ -149,6 +166,30 @@ func (v *Secp256k1) DecodeRLP(s *rlp.Stream) error { | |||
return nil | |||
} | |||
|
|||
func addNATMappings(tcpPort, udpPort int) (net.IP, int, int, error) { |
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.
We may want to investigate whether libp2p can do this work if we enable NAT option in the libp2p constructor
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.
NAT manager is not public, we cannot directly use it.
Issue: #131
If the es-node is running behind a NAT and without the advertiseIP being set. we can discover the NAT service and add port mappings to the NAT service, then add the external IP and mapping ports to ENR.
How to test:
Run the es-node behind NAT service without advertiseIP being set. Then copy the ENR the es-node output and check it in the https://enr-viewer.com/.
enr:-Li4QCVR_onX8sRp5LVSxHTMbxIkvJVcS3VXu9c3DcFBhnrjK4YmZHc55Mhktqi9Qj-ypbbUms_u56PyrXbBT2po7CCGAYwvPP-9imV0aHN0b3JhZ2XbAYDY15Sfn1_YmtZI8sAAyVTY2ch3QyQ-xcGAgmlkgnY0gmlwhEmqKEKJc2VjcDI1NmsxoQP9Mik329t5ntsy0m8DWu-JRgT6T1TNOCx_M62HV9GPCIN0Y3CCggGDdWRwgnZc
we can see its multiaddr like
run the second es-node with the first es-node ENR and see the log like the following