move netchecks to subfolder of wgchecks

This commit is contained in:
2023-03-30 14:28:19 +02:00
parent 0c85d8ae1a
commit 8488a9e4cd
2 changed files with 1 additions and 1 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")
}

View File

@@ -4,7 +4,7 @@ import (
"fmt"
"net"
"git.ruekov.eu/ruakij/routingtabletowg/lib/netchecks"
"git.ruekov.eu/ruakij/routingtabletowg/lib/wgchecks/netchecks"
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
)