summaryrefslogtreecommitdiff
path: root/plugins/http/config/ip.go
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/http/config/ip.go')
-rw-r--r--plugins/http/config/ip.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/plugins/http/config/ip.go b/plugins/http/config/ip.go
new file mode 100644
index 00000000..c4981f74
--- /dev/null
+++ b/plugins/http/config/ip.go
@@ -0,0 +1,26 @@
+package config
+
+import "net"
+
+// Cidrs is a slice of IPNet addresses
+type Cidrs []*net.IPNet
+
+// IsTrusted checks if the ip address exists in the provided in the config addresses
+func (c *Cidrs) IsTrusted(ip string) bool {
+ if len(*c) == 0 {
+ return false
+ }
+
+ i := net.ParseIP(ip)
+ if i == nil {
+ return false
+ }
+
+ for _, cird := range *c {
+ if cird.Contains(i) {
+ return true
+ }
+ }
+
+ return false
+}