From 9389979d7cf98b7950f0032b67330647fceba77b Mon Sep 17 00:00:00 2001 From: Alexander Kaschta <alexander.kaschta9@kit.edu> Date: Mon, 11 Nov 2024 18:26:24 +0100 Subject: [PATCH] FIX: ipaddress function imports --- src/components/BCDList.vue | 2 +- src/components/IPAddressTypeBadge.vue | 3 +-- src/components/SubnetInfo.vue | 4 ++-- src/util/ipaddress.js | 5 ++++- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/components/BCDList.vue b/src/components/BCDList.vue index 53ee9517c..dc7ed0215 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 700bb2948..5a3fb0654 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 65e1fa4f3..f6047a4db 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 1c0c8c781..79fdbb921 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])) -- GitLab