add dynamic IP attributions
This commit is contained in:
13
utils.go
13
utils.go
@@ -1,6 +1,8 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"math/big"
|
||||
"net"
|
||||
"sort"
|
||||
|
||||
"github.com/pyke369/golang-support/uconfig"
|
||||
@@ -32,3 +34,14 @@ func parseConfigArray(config *uconfig.UConfig, configpath string) []string {
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func nextIP(ip net.IP) net.IP {
|
||||
// Convert to big.Int and increment
|
||||
ipb := big.NewInt(0).SetBytes([]byte(ip))
|
||||
ipb.Add(ipb, big.NewInt(1))
|
||||
|
||||
// Add leading zeros
|
||||
b := ipb.Bytes()
|
||||
b = append(make([]byte, len(ip)-len(b)), b...)
|
||||
return net.IP(b)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user