Skip to content

Commit

Permalink
Bind Discovery Using Neutral Network Version (#8359)
Browse files Browse the repository at this point in the history
* fix it

* terence's review
  • Loading branch information
nisdas committed Jan 29, 2021
1 parent d254f24 commit b74dd96
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions beacon-chain/p2p/discovery.go
Expand Up @@ -97,15 +97,11 @@ func (s *Service) createListener(
ipAddr net.IP,
privKey *ecdsa.PrivateKey,
) (*discover.UDPv5, error) {
// Listen to all network interfaces
// for both ip protocols.
var networkVersion string
// BindIP is used to specify the ip
// on which we will bind our listener on
// by default we will listen to all interfaces.
var bindIP net.IP
networkVersion = udpVersionFromIP(ipAddr)
switch networkVersion {
switch udpVersionFromIP(ipAddr) {
case "udp4":
bindIP = net.IPv4zero
case "udp6":
Expand All @@ -121,12 +117,14 @@ func (s *Service) createListener(
return nil, errors.New("invalid local ip provided")
}
bindIP = ipAddr
networkVersion = udpVersionFromIP(ipAddr)
}
udpAddr := &net.UDPAddr{
IP: bindIP,
Port: int(s.cfg.UDPPort),
}
// Listen to all network interfaces
// for both ip protocols.
networkVersion := "udp"
conn, err := net.ListenUDP(networkVersion, udpAddr)
if err != nil {
return nil, errors.Wrap(err, "could not listen to UDP")
Expand Down

0 comments on commit b74dd96

Please sign in to comment.