summaryrefslogtreecommitdiffstats
path: root/server/lib/iphelper.js
diff options
context:
space:
mode:
authorJannik Schönartz2019-03-18 22:34:42 +0100
committerJannik Schönartz2019-03-18 22:34:42 +0100
commit5c560ee32d356eebf44b976e876081b161b86ecb (patch)
tree17b842c52b6c04145b2f0f54a6385a18cbb7ee4a /server/lib/iphelper.js
parent[server/registration] Add server registration (diff)
downloadbas-5c560ee32d356eebf44b976e876081b161b86ecb.tar.gz
bas-5c560ee32d356eebf44b976e876081b161b86ecb.tar.xz
bas-5c560ee32d356eebf44b976e876081b161b86ecb.zip
[server/registration] Add client with json instead of parameters (ipxe)
Diffstat (limited to 'server/lib/iphelper.js')
-rw-r--r--server/lib/iphelper.js6
1 files changed, 3 insertions, 3 deletions
diff --git a/server/lib/iphelper.js b/server/lib/iphelper.js
index 5c40313..769dcc3 100644
--- a/server/lib/iphelper.js
+++ b/server/lib/iphelper.js
@@ -1,11 +1,11 @@
/* global __appdir */
var path = require('path')
var db = require(path.join(__appdir, 'lib', 'sequelize'))
-module.exports = { toDecimal, toString, toIPv4, getGroups }
+module.exports = { toDecimal, toIPv4, getGroups, isIPv4 }
// Finds the groups where the ip fits best in the subnets.
async function getGroups (ipString) {
- const ipInt = toDecimal(ipString)
+ const ipInt = toDecimal(ipString)
let fittingIpRanges = await db.iprange.findAll({ where: { startIp: { [db.Op.lte]: ipInt }, endIp: { [db.Op.gte]: ipInt } } })
fittingIpRanges = fittingIpRanges.map(x => x.groupId)
@@ -42,7 +42,7 @@ function eliminateParents (groupId, groupMap, eliminateArray, alreadyChecked = [
// Takes an ip address and converts it to an integer.
function toDecimal (ipString) {
- if (isIPv4(ipString)) return false
+ if (!isIPv4(ipString)) return false
const ipArray = ipString.split('.')
if (ipArray.length !== 4) return false