package main import ( "math/big" "net" "sort" "github.com/pyke369/golang-support/uconfig" ) // check if there is a member of "search" in "list". sort list to be more // efficiant. adapt with sorting "search" too func inArray(search, list []string) bool { sort.Strings(list) for _, g := range search { i := sort.Search(len(list), func(i int) bool { return list[i] >= g }) if i < len(list) && list[i] == g { return true } } return false } // parse a uconf array func parseConfigArray(config *uconfig.UConfig, configpath string) []string { result := []string{} for _, i := range config.GetPaths(configpath) { if s := config.GetString(i, ""); s == "" { continue } else { result = append(result, s) } } 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) }