Skip to content
Snippets Groups Projects
Commit 9389979d authored by Alexander Kaschta's avatar Alexander Kaschta :owl:
Browse files

FIX: ipaddress function imports

parent 9a647190
No related branches found
No related tags found
No related merge requests found
...@@ -248,7 +248,7 @@ export default { ...@@ -248,7 +248,7 @@ export default {
methods: { methods: {
format_vni: VNIUtil.format_vni, format_vni: VNIUtil.format_vni,
isIPv4: ipaddress.is_ip_v4, isIPv4: ipaddress.is_ip_v4,
IPAddressCount: ipaddress.ip_num_addr, IPAddressCount: (net) => ipaddress.ip_num_addr(net),
usagePercentage(subnet) { usagePercentage(subnet) {
return (subnet.dns_addr_rr_count / this.IPAddressCount(subnet.cidr) * 100).toFixed(0) return (subnet.dns_addr_rr_count / this.IPAddressCount(subnet.cidr) * 100).toFixed(0)
}, },
......
...@@ -23,10 +23,9 @@ export default { ...@@ -23,10 +23,9 @@ export default {
}, },
methods: { methods: {
ip_net_get_first: ipaddress.ip_net_get_first, 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, ip_to_int: ipaddress.ip_to_int,
int_to_ip: ipaddress.int_to_ip, int_to_ip: ipaddress.int_to_ip,
ip_num_addr: ipaddress.ip_num_addr,
is_ip_v4: ipaddress.is_ip_v4 is_ip_v4: ipaddress.is_ip_v4
} }
} }
......
...@@ -78,9 +78,9 @@ export default { ...@@ -78,9 +78,9 @@ export default {
methods: { methods: {
ipv6, ipv6,
ip_net_get_first: ipaddress.ip_net_get_first, 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_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, ip_to_int: ipaddress.ip_to_int,
int_to_ip: ipaddress.int_to_ip, int_to_ip: ipaddress.int_to_ip,
ipv6_net_get_info(subnet) { ipv6_net_get_info(subnet) {
......
...@@ -22,8 +22,11 @@ export default { ...@@ -22,8 +22,11 @@ export default {
is_ip_v4(ip) { 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) 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) { 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) { ipv6_num_addr(net6) {
return Math.pow(2, 128 - Number(net6.split('/')[1])) return Math.pow(2, 128 - Number(net6.split('/')[1]))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment