From 5c560ee32d356eebf44b976e876081b161b86ecb Mon Sep 17 00:00:00 2001 From: Jannik Schönartz Date: Mon, 18 Mar 2019 21:34:42 +0000 Subject: [server/registration] Add client with json instead of parameters (ipxe) --- server/lib/iphelper.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'server/lib/iphelper.js') 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 -- cgit v1.2.3-55-g7522