mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-12 04:30:04 +00:00
Bind Discovery Using Neutral Network Version (#8359)
* fix it * terence's review
This commit is contained in:
parent
d254f24a23
commit
b74dd967af
@ -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":
|
||||
@ -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")
|
||||
|
Loading…
Reference in New Issue
Block a user