Limit splitting subnets too small based on NORMAL/AWS mode

This commit is contained in:
Caesar Kabalan 2023-05-19 01:28:43 -05:00
parent 80cae85368
commit 1a8bde76f2
No known key found for this signature in database
GPG key ID: DDFEF5FF6CFAB608
2 changed files with 25 additions and 4 deletions

2
dist/index.html vendored
View file

@ -40,7 +40,7 @@
</div>
<div class="col-lg-2 col-md-3 col-4">
<div><label for="netsize" class="form-label mb-0 ms-1">Network Size</label></div>
<div><input id="netsize" type="text" class="form-control w-10" value="16" aria-label="Network Size" pattern="^(\d|[12]\d|3[0-2])$" required></div>
<div><input id="netsize" type="text" class="form-control w-10" value="16" aria-label="Network Size" pattern="^(\d|[12]\d|30)$" required></div>
</div>
<div class="col-lg-2 col-md-3 col-3">
<div style="height:1.5rem"></div>

21
dist/main.js vendored
View file

@ -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('/')
// 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 {