Skip to content
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

Bind Discovery Using Neutral Network Version #8359

Merged
merged 4 commits into from Jan 29, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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