Skip to content
  • Thomas Bellman's avatar
    ef213a61
    Add flag 'forcemask' for resolve_ipnets() function. · ef213a61
    Thomas Bellman authored
    This new flag to the resolve_ipnets() function causes it to add an
    appropriate explicit host mask (/32 or /128 depending on IP family)
    if the input did not contain a mask.  I.e, if calling:
    
        $hosts = [ "www.example.com", "smurf.example.net/28",
                   "203.0.113.99", "2001:db8:113::99" ]
        $addrs = resolve_ipnets($hosts, "forcemask")
    
    the return value from resolve_ipnets() will be something like:
    
        [ "192.0.2.17/32", "2001:db8:1:2::17/128",
          "198.51.100.23/28", "2001:db8:51:100::23/28",
          "203.0.113.99/32", "2001:db8:113::99/128"
        ]
    
    Since there is no mask specified for www.example.com, an explicit
    /32 will be added to its IPv4 address, and an explicit /128 to its
    IPv6 address.  Likewise for the numeric addresses.  However, as the
    smurf.example.net/28 name contained a netmask, that /28 will be kept
    (although using the same mask for both IPv4 and IPv6 is unlikely to
    be something you want).
    
    This can be useful when the result is to be used in situations where
    plain IP addresses are not allowed, only complete CIDR specifications.
    An example, and the motivation for implementing this, is Munin, where
    "cidr_allow" directives in munin-node configuration files must include
    the prefix length.
    ef213a61
    Add flag 'forcemask' for resolve_ipnets() function.
    Thomas Bellman authored
    This new flag to the resolve_ipnets() function causes it to add an
    appropriate explicit host mask (/32 or /128 depending on IP family)
    if the input did not contain a mask.  I.e, if calling:
    
        $hosts = [ "www.example.com", "smurf.example.net/28",
                   "203.0.113.99", "2001:db8:113::99" ]
        $addrs = resolve_ipnets($hosts, "forcemask")
    
    the return value from resolve_ipnets() will be something like:
    
        [ "192.0.2.17/32", "2001:db8:1:2::17/128",
          "198.51.100.23/28", "2001:db8:51:100::23/28",
          "203.0.113.99/32", "2001:db8:113::99/128"
        ]
    
    Since there is no mask specified for www.example.com, an explicit
    /32 will be added to its IPv4 address, and an explicit /128 to its
    IPv6 address.  Likewise for the numeric addresses.  However, as the
    smurf.example.net/28 name contained a netmask, that /28 will be kept
    (although using the same mask for both IPv4 and IPv6 is unlikely to
    be something you want).
    
    This can be useful when the result is to be used in situations where
    plain IP addresses are not allowed, only complete CIDR specifications.
    An example, and the motivation for implementing this, is Munin, where
    "cidr_allow" directives in munin-node configuration files must include
    the prefix length.
Loading