mirror of
https://codeberg.org/cunicu/cunicu.git
synced 2025-09-26 21:01:14 +08:00
fix: Fix linter warnings
Signed-off-by: Steffen Vogel <post@steffenvogel.de>
This commit is contained in:
@@ -134,7 +134,7 @@ func (k Key) IPAddress(p net.IPNet) net.IPNet {
|
||||
m := new(big.Int).SetBytes(n)
|
||||
i := new(big.Int).SetBytes(b)
|
||||
|
||||
d.Rsh(d, uint(ones))
|
||||
d.Rsh(d, uint(ones)) //nolint:gosec
|
||||
i.And(i, m)
|
||||
d.Or(d, i)
|
||||
|
||||
|
@@ -17,8 +17,8 @@ var (
|
||||
errNoPortFound = errors.New("failed to find port")
|
||||
)
|
||||
|
||||
func FindRandomPortToListen(network string, min, max int) (int, error) {
|
||||
if max < min {
|
||||
func FindRandomPortToListen(network string, mini, maxi int) (int, error) {
|
||||
if maxi < mini {
|
||||
return -1, errInvalidPortRange
|
||||
}
|
||||
if !strings.HasPrefix(network, "udp") {
|
||||
@@ -26,7 +26,7 @@ func FindRandomPortToListen(network string, min, max int) (int, error) {
|
||||
}
|
||||
|
||||
for attempts := 100; attempts > 0; attempts-- {
|
||||
port := min + rand.Intn(max-min+1) //nolint:gosec
|
||||
port := mini + rand.Intn(maxi-mini+1) //nolint:gosec
|
||||
if canListenOnPort(network, port) {
|
||||
return port, nil
|
||||
}
|
||||
|
@@ -43,7 +43,7 @@ func OffsetIP(ip net.IP, off int) net.IP {
|
||||
|
||||
if isV6 := ip.To4() == nil; isV6 {
|
||||
num := binary.BigEndian.Uint64(ip[8:])
|
||||
binary.BigEndian.PutUint64(oip[8:], num+uint64(off))
|
||||
binary.BigEndian.PutUint64(oip[8:], num+uint64(off)) //nolint:gosec
|
||||
} else {
|
||||
num := binary.BigEndian.Uint32(ip[12:])
|
||||
binary.BigEndian.PutUint32(oip[12:], num+uint32(off)) //nolint:gosec
|
||||
|
Reference in New Issue
Block a user