blob: c4981f740bed47b7c86a78ce78c04d08958b75b0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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
}
|