Reject IPv6 networks with subnet
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Simon Marsh 2021-05-23 14:03:51 +01:00
parent a88cf6d47a
commit 60922b120e
Signed by: burble
GPG Key ID: 0FCCD13AE1CF7ED8

View File

@ -491,19 +491,32 @@ Vue.component('app-free6', {
// check if a network is already allocated // check if a network is already allocated
check6(n) { check6(n) {
// fixed /48 mask
var mask = BigInt(0xFFFFFFFFFFFF0000n)
var match = null var match = null
this.p6.forEach(obj => { this.p6.forEach(obj => {
// only check longer prefixes than current match // only check longer prefixes than current match
if ((match == null) || (obj.plen >= match.plen)) { if ((match == null) || (obj.plen >= match.plen)) {
var masked = n & obj.mask var masked
// is the new network a subnet of the test obj ?
masked = n & obj.mask
if (obj.subnet == masked) { if (obj.subnet == masked) {
// new, more precise prefix found // new, more precise prefix found
match = obj match = obj
} }
// is the test obj a subnet of this network ?
masked = obj.subnet & mask
if (n == masked) {
// immediate fail, existing subnets not allowed
return false
}
} }
}) })
if ((match != null) && (match.policy != 'open')) { if (match.policy != 'open') {
return false return false
} }