mirror of https://github.com/status-im/go-waku.git
fix: port number verification
This commit is contained in:
parent
e8c08ac18b
commit
79bb101787
|
@ -5,6 +5,7 @@ import (
|
||||||
"crypto/ecdsa"
|
"crypto/ecdsa"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"math"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net"
|
"net"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
@ -161,7 +162,13 @@ func GetENRandIP(addr ma.Multiaddr, privK *ecdsa.PrivateKey) (*enode.Node, *net.
|
||||||
}
|
}
|
||||||
|
|
||||||
r := &enr.Record{}
|
r := &enr.Record{}
|
||||||
r.Set(enr.TCP(port))
|
|
||||||
|
if port > 0 && port <= math.MaxUint16 {
|
||||||
|
r.Set(enr.TCP(uint16(port))) // lgtm [go/incorrect-integer-conversion]
|
||||||
|
} else {
|
||||||
|
return nil, nil, fmt.Errorf("could not set port %d", port)
|
||||||
|
}
|
||||||
|
|
||||||
r.Set(enr.IP(net.ParseIP(ip)))
|
r.Set(enr.IP(net.ParseIP(ip)))
|
||||||
|
|
||||||
err = enode.SignV4(r, privK)
|
err = enode.SignV4(r, privK)
|
||||||
|
|
Loading…
Reference in New Issue