diff --git a/src/components/BCDList.vue b/src/components/BCDList.vue index 53ee9517c3f116bc083878ef48cc354d6c720057..dc7ed0215e3630a303770cb8524ff5c88629a072 100644 --- a/src/components/BCDList.vue +++ b/src/components/BCDList.vue @@ -248,7 +248,7 @@ export default { methods: { format_vni: VNIUtil.format_vni, isIPv4: ipaddress.is_ip_v4, - IPAddressCount: ipaddress.ip_num_addr, + IPAddressCount: (net) => ipaddress.ip_num_addr(net), usagePercentage(subnet) { return (subnet.dns_addr_rr_count / this.IPAddressCount(subnet.cidr) * 100).toFixed(0) }, diff --git a/src/components/IPAddressTypeBadge.vue b/src/components/IPAddressTypeBadge.vue index 700bb2948a070ce201bd50386362ddcf03137925..5a3fb0654235711c960389e5c15eb5f72a93013c 100644 --- a/src/components/IPAddressTypeBadge.vue +++ b/src/components/IPAddressTypeBadge.vue @@ -23,10 +23,9 @@ export default { }, methods: { ip_net_get_first: ipaddress.ip_net_get_first, - ip_net_get_last: ipaddress.ip_net_get_last, + ip_net_get_last: (net) => ipaddress.ip_net_get_last(net), ip_to_int: ipaddress.ip_to_int, int_to_ip: ipaddress.int_to_ip, - ip_num_addr: ipaddress.ip_num_addr, is_ip_v4: ipaddress.is_ip_v4 } } diff --git a/src/components/SubnetInfo.vue b/src/components/SubnetInfo.vue index 65e1fa4f3e0456a0eaa0c949c29efcf1fcf0ed2f..f6047a4dbbdab0fd68b72371ed5174581dedd4b5 100644 --- a/src/components/SubnetInfo.vue +++ b/src/components/SubnetInfo.vue @@ -78,9 +78,9 @@ export default { methods: { ipv6, ip_net_get_first: ipaddress.ip_net_get_first, - ip_net_get_last: ipaddress.ip_net_get_last, + ip_net_get_last: (net) => ipaddress.ip_net_get_last(net), ip_net_get_mask: ipaddress.ip_net_get_mask, - ip_num_addr: ipaddress.ip_num_addr, + ip_num_addr: (subnet) => ipaddress.ip_num_addr(subnet), ip_to_int: ipaddress.ip_to_int, int_to_ip: ipaddress.int_to_ip, ipv6_net_get_info(subnet) { diff --git a/src/util/ipaddress.js b/src/util/ipaddress.js index 1c0c8c7813def6c55e833ba303afd7f8e595dc37..79fdbb92124391e06602f303f59494e34483712d 100644 --- a/src/util/ipaddress.js +++ b/src/util/ipaddress.js @@ -22,8 +22,11 @@ export default { is_ip_v4(ip) { return /^(\d|.)+$/.test(ip) && ip.split('.').length === 4 && ip.split('.').map((x) => parseInt(x, 10)).every((x) => x >= 0 && x <= 255) }, + ipv4_subnet_size(n) { + return Math.pow(2, 32 - Number(n)) + }, ip_num_addr(net) { - return Math.pow(2, 32 - Number(net.split('/')[1])) + return this.ipv4_subnet_size(Number(net.split('/')[1])) }, ipv6_num_addr(net6) { return Math.pow(2, 128 - Number(net6.split('/')[1]))