Add project

This commit is contained in:
2022-11-15 18:12:16 +01:00
parent b250277bab
commit 5d40cde0c8
11 changed files with 538 additions and 10 deletions

View File

@@ -0,0 +1,25 @@
package netchecks
import (
"fmt"
"net"
"reflect"
)
func IPNetIndexByIP(list []net.IPNet, ip net.IP) (int, error) {
for index, ipNetEntry := range list {
if ipNetEntry.Contains(ip) {
return index, nil
}
}
return -1, fmt.Errorf("ip not in ipNet-list")
}
func IPNetIndexByIPNet(list []net.IPNet, ipNet net.IPNet) (int, error) {
for index, ipNetEntry := range list {
if reflect.DeepEqual(ipNetEntry, ipNet) {
return index, nil
}
}
return -1, fmt.Errorf("ipNet not in ipNet-list")
}