Skip to main content
Version: v1.6.0

IP helpers

IP Helpers

IpInRange(IPStr, RangeStr) bool

Returns true if the IP IPStr is contained in the IP range RangeStr (uses net.ParseCIDR)

IpInRange("", "")

IpToRange(IPStr, MaskStr) IpStr

Returns the subnet of the IP with the request cidr size. It is intended for scenarios taking actions against the range of an IP, not the IP itself :

type: leaky
type: Range
expression: IpToRange(evt.Meta.source_ip, "/16")

IpToRange("", "24") returns

IpToRange("", "16") returns

IsIPV6(ip string) bool

Returns true if it's a valid IPv6.



LookupHost(host string) []string

  • Only use this function within postoverflows as it is can be very slow
  • Note if you whitelist a domain behind a CDN provider, all domains using the same CDN provider will also be whitelisted
  • Do not use variables within the function as this can be untrusted user input

Returns []string ip addresses that resolvable to the hostname EG: LookupHost('mydomain.tld') => ['', '']

name: me/my_cool_whitelist
description: lets whitelist our own IP
reason: dont ban my IP
- evt.Overflow.Alert.Source.IP in LookupHost('mydomain.tld')
# This can be useful when you have a dynamic ip and use dynamic DNS providers