Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add build tag to skip special iprange handling for tinygo #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions ip_isprivate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//go:build !tinygo

package plugin

import "net"

func IsSpecialIpRangeToBeSkipped(ip net.IP) bool {
return ip.IsPrivate() || ip.IsLoopback() || ip.IsUnspecified()
}
11 changes: 11 additions & 0 deletions ip_isprivate_tinygo.go
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 1 addition & 1 deletion operators_logic.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down