Skip to content

Commit

Permalink
fix: handle discv5 udp port 0
Browse files Browse the repository at this point in the history
This will update the UDP port used in the params with whatever value is obtained from ListenUDP
  • Loading branch information
richard-ramos committed Mar 22, 2024
1 parent 826c7fb commit 219b248
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions waku/v2/discv5/discover.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ func (d *DiscoveryV5) listen(ctx context.Context) error {

}

d.params.udpPort = uint(d.udpAddr.Port)
d.localnode.SetFallbackUDP(d.udpAddr.Port)

listener, err := discover.ListenV5(conn, d.localnode, d.config)
Expand Down
4 changes: 4 additions & 0 deletions waku/v2/protocol/enr/localnode.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ func WithIP(ipAddr *net.TCPAddr) ENROption {

func WithUDPPort(udpPort uint) ENROption {
return func(localnode *enode.LocalNode) (err error) {
if udpPort == 0 {
return nil
}

if udpPort > math.MaxUint16 {
return errors.New("invalid udp port number")
}
Expand Down

0 comments on commit 219b248

Please sign in to comment.