mirror of https://github.com/sipwise/ngcpcfg.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
1.0 KiB
31 lines
1.0 KiB
[%
|
|
# Return an array of shared IPs for a given host
|
|
#
|
|
# @param argv.host The host to get all shared IPs for.
|
|
# @param argv.type The interface type or empty string for all types.
|
|
# @param argv.format Optional reformatting of IPv6 addresses
|
|
# @return out The array of shared ips
|
|
-%]
|
|
[% IF !hosts.${argv.host}.defined -%][% argv.host = 'self' -%][% END -%]
|
|
[% out = [] -%]
|
|
[% IF !argv.type.length -%][% argv.type = '.*' -%][% END -%]
|
|
[% FOREACH iface IN hosts.${argv.host}.interfaces -%]
|
|
[% FOREACH realiface IN hosts.${argv.host}.keys -%]
|
|
[% IF realiface == iface -%]
|
|
[% IF hosts.${argv.host}.$realiface.type.grep('^' _ argv.type _ '$').size() -%]
|
|
[% FOREACH ip IN hosts.${argv.host}.$realiface.shared_v6ip -%]
|
|
[% IF argv.format == 'expand' -%]
|
|
[% WHILE ip.match('::') && ip.match(':', 1).size < 8 -%]
|
|
[% ip = ip.replace('::', '::0:') -%]
|
|
[% END -%]
|
|
[% ip = ip.replace('::', ':') -%]
|
|
[% ip = ip.replace('^:', '0:') -%]
|
|
[% ip = ip.replace(':$', ':0') -%]
|
|
[% END -%]
|
|
[% out.push(ip) -%]
|
|
[% END -%]
|
|
[% END -%]
|
|
[% END -%]
|
|
[% END -%]
|
|
[% END -%]
|