forked from cerc-io/plugeth
cmd/geth, p2p: add support for custom discovery UDP port (#24979)
This adds a new flag to set the discovery port to be different from the TCP listener port. Co-authored-by: Felix Lange <fjl@twurst.com>
This commit is contained in:
+13
-1
@@ -136,6 +136,10 @@ type Config struct {
|
||||
// the server is started.
|
||||
ListenAddr string
|
||||
|
||||
// If DiscAddr is set to a non-nil value, the server will use ListenAddr
|
||||
// for TCP and DiscAddr for the UDP discovery protocol.
|
||||
DiscAddr string
|
||||
|
||||
// If set to a non-nil value, the given NAT port mapper
|
||||
// is used to make the listening port available to the
|
||||
// Internet.
|
||||
@@ -549,7 +553,15 @@ func (srv *Server) setupDiscovery() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
addr, err := net.ResolveUDPAddr("udp", srv.ListenAddr)
|
||||
listenAddr := srv.ListenAddr
|
||||
|
||||
// Use an alternate listening address for UDP if
|
||||
// a custom discovery address is configured.
|
||||
if srv.DiscAddr != "" {
|
||||
listenAddr = srv.DiscAddr
|
||||
}
|
||||
|
||||
addr, err := net.ResolveUDPAddr("udp", listenAddr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user