From 1a8bde76f203d856e1b49010c14bf5db0fb105d4 Mon Sep 17 00:00:00 2001 From: Caesar Kabalan Date: Fri, 19 May 2023 01:28:43 -0500 Subject: [PATCH] Limit splitting subnets too small based on NORMAL/AWS mode --- dist/index.html | 2 +- dist/main.js | 27 ++++++++++++++++++++++++--- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/dist/index.html b/dist/index.html index 3a703af..b1d1bb3 100644 --- a/dist/index.html +++ b/dist/index.html @@ -40,7 +40,7 @@
-
+
diff --git a/dist/main.js b/dist/main.js index 1a2dc71..f6597c1 100644 --- a/dist/main.js +++ b/dist/main.js @@ -1,6 +1,20 @@ let subnetMap = {}; let maxNetSize = 0; let infoColumnCount = 5 +// NORMAL mode: +// - Smallest subnet: /30 +// - Two reserved addresses per subnet: +// - Network Address (network + 0) +// - Broadcast Address (last network address) +// AWS mode (future): +// - Smallest subnet: /28 +// - Two reserved addresses per subnet: +// - Network Address (network + 0) +// - AWS Reserved - VPC Router +// - AWS Reserved - VPC DNS +// - AWS Reserved - Future Use +// - Broadcast Address (last network address) +let operatingMode = 'NORMAL' $('input#network,input#netsize').on('input', function() { $('#input_form')[0].classList.add('was-validated'); @@ -221,9 +235,16 @@ function mutate_subnet_map(verb, network, subnetTree) { if (mapKey === network) { if (verb === 'split') { let netSplit = mapKey.split('/') - let new_networks = split_network(netSplit[0], parseInt(netSplit[1])) - subnetTree[mapKey][new_networks[0]] = {} - subnetTree[mapKey][new_networks[1]] = {} + // operatingMode NORMAL + let minSubnetSize = 30 + if (operatingMode === 'AWS') { + minSubnetSize = 28 + } + if (parseInt(netSplit[1]) < minSubnetSize) { + let new_networks = split_network(netSplit[0], parseInt(netSplit[1])) + subnetTree[mapKey][new_networks[0]] = {} + subnetTree[mapKey][new_networks[1]] = {} + } } else if (verb === 'join') { subnetTree[mapKey] = {} } else {