diff --git a/ip_isprivate.go b/ip_isprivate.go new file mode 100644 index 0000000..1805156 --- /dev/null +++ b/ip_isprivate.go @@ -0,0 +1,9 @@ +//go:build !tinygo + +package plugin + +import "net" + +func IsSpecialIpRangeToBeSkipped(ip net.IP) bool { + return ip.IsPrivate() || ip.IsLoopback() || ip.IsUnspecified() +} diff --git a/ip_isprivate_tinygo.go b/ip_isprivate_tinygo.go new file mode 100644 index 0000000..dacd7d1 --- /dev/null +++ b/ip_isprivate_tinygo.go @@ -0,0 +1,11 @@ +//go:build tinygo + +package plugin + +import "net" + +func IsSpecialIpRangeToBeSkipped(ip net.IP) bool { + //"IsPrivate" is not defined for tinygo, see: tinygo.org/docs/reference/lang-support/stdlib/#netnetip + // therfore we return false here + return false +} diff --git a/operators_logic.go b/operators_logic.go index 323592f..6f2bba8 100644 --- a/operators_logic.go +++ b/operators_logic.go @@ -71,7 +71,7 @@ func (o *geo) executeEvaluationInternal(tx transaction, value string) (bool, err return false, fmt.Errorf("invalid ip %q", value) } - if ip.IsPrivate() || ip.IsLoopback() || ip.IsUnspecified() { + if IsSpecialIpRangeToBeSkipped(ip) { return false, nil }