UNPKG

opennms

Version:

Client API for the OpenNMS network monitoring platform

1 lines 18.4 kB
{"remainingRequest":"/data/node_modules/babel-loader/lib/index.js!/data/node_modules/ip-address/lib/ipv4.js","dependencies":[{"path":"/data/node_modules/ip-address/lib/ipv4.js","mtime":1553611387160},{"path":"/data/.babelrc","mtime":1553611371556},{"path":"/data/node_modules/cache-loader/dist/cjs.js","mtime":1553611387012},{"path":"/data/node_modules/babel-loader/lib/index.js","mtime":1553611386992}],"contextDependencies":[],"result":["'use strict';\n\nvar BigInteger = require('jsbn').BigInteger;\nvar common = require('./common.js');\nvar padStart = require('lodash.padstart');\nvar repeat = require('lodash.repeat');\nvar sprintf = require('sprintf-js').sprintf;\n\nvar constants = require('./v4/constants.js');\n\n/**\n * Represents an IPv4 address\n * @class Address4\n * @param {string} address - An IPv4 address string\n */\nfunction Address4(address) {\n this.valid = false;\n this.address = address;\n this.groups = constants.GROUPS;\n\n this.v4 = true;\n\n this.subnet = '/32';\n this.subnetMask = 32;\n\n var subnet = constants.RE_SUBNET_STRING.exec(address);\n\n if (subnet) {\n this.parsedSubnet = subnet[0].replace('/', '');\n this.subnetMask = parseInt(this.parsedSubnet, 10);\n this.subnet = '/' + this.subnetMask;\n\n if (this.subnetMask < 0 || this.subnetMask > constants.BITS) {\n this.valid = false;\n this.error = 'Invalid subnet mask.';\n\n return;\n }\n\n address = address.replace(constants.RE_SUBNET_STRING, '');\n }\n\n this.addressMinusSuffix = address;\n\n this.parsedAddress = this.parse(address);\n}\n\n/*\n * Parses a v4 address\n */\nAddress4.prototype.parse = function (address) {\n var groups = address.split('.');\n\n if (address.match(constants.RE_ADDRESS)) {\n this.valid = true;\n } else {\n this.error = 'Invalid IPv4 address.';\n }\n\n return groups;\n};\n\n/**\n * Return true if the address is valid\n * @memberof Address4\n * @instance\n * @returns {Boolean}\n */\nAddress4.prototype.isValid = function () {\n return this.valid;\n};\n\n/**\n * Returns the correct form of an address\n * @memberof Address4\n * @instance\n * @returns {String}\n */\nAddress4.prototype.correctForm = function () {\n return this.parsedAddress.map(function (part) {\n return parseInt(part, 10);\n }).join('.');\n};\n\n/**\n * Returns true if the address is correct, false otherwise\n * @memberof Address4\n * @instance\n * @returns {Boolean}\n */\nAddress4.prototype.isCorrect = common.isCorrect(constants.BITS);\n\n/**\n * Converts a hex string to an IPv4 address object\n * @memberof Address4\n * @static\n * @param {string} hex - a hex string to convert\n * @returns {Address4}\n */\nAddress4.fromHex = function (hex) {\n var padded = padStart(hex.replace(/:/g, ''), 8, '0');\n var groups = [];\n var i;\n\n for (i = 0; i < 8; i += 2) {\n var h = padded.slice(i, i + 2);\n\n groups.push(parseInt(h, 16));\n }\n\n return new Address4(groups.join('.'));\n};\n\n/**\n * Converts an integer into a IPv4 address object\n * @memberof Address4\n * @static\n * @param {integer} integer - a number to convert\n * @returns {Address4}\n */\nAddress4.fromInteger = function (integer) {\n return Address4.fromHex(integer.toString(16));\n};\n\n/**\n * Converts an IPv4 address object to a hex string\n * @memberof Address4\n * @instance\n * @returns {String}\n */\nAddress4.prototype.toHex = function () {\n return this.parsedAddress.map(function (part) {\n return sprintf('%02x', parseInt(part, 10));\n }).join(':');\n};\n\n/**\n * Converts an IPv4 address object to an array of bytes\n * @memberof Address4\n * @instance\n * @returns {Array}\n */\nAddress4.prototype.toArray = function () {\n return this.parsedAddress.map(function (part) {\n return parseInt(part, 10);\n });\n};\n\n/**\n * Converts an IPv4 address object to an IPv6 address group\n * @memberof Address4\n * @instance\n * @returns {String}\n */\nAddress4.prototype.toGroup6 = function () {\n var output = [];\n var i;\n\n for (i = 0; i < constants.GROUPS; i += 2) {\n var hex = sprintf('%02x%02x', parseInt(this.parsedAddress[i], 10), parseInt(this.parsedAddress[i + 1], 10));\n\n output.push(sprintf('%x', parseInt(hex, 16)));\n }\n\n return output.join(':');\n};\n\n/**\n * Returns the address as a BigInteger\n * @memberof Address4\n * @instance\n * @returns {BigInteger}\n */\nAddress4.prototype.bigInteger = function () {\n if (!this.valid) {\n return null;\n }\n\n return new BigInteger(this.parsedAddress.map(function (n) {\n return sprintf('%02x', parseInt(n, 10));\n }).join(''), 16);\n};\n\n/**\n * The first address in the range given by this address' subnet.\n * Often referred to as the Network Address.\n * @memberof Address4\n * @instance\n * @returns {Address4}\n */\nAddress4.prototype.startAddress = function () {\n var startAddress = new BigInteger(this.mask() + repeat(0, constants.BITS - this.subnetMask), 2);\n\n return Address4.fromBigInteger(startAddress);\n};\n\n/**\n * The last address in the range given by this address' subnet\n * Often referred to as the Broadcast\n * @memberof Address4\n * @instance\n * @returns {Address4}\n */\nAddress4.prototype.endAddress = function () {\n var endAddress = new BigInteger(this.mask() + repeat(1, constants.BITS - this.subnetMask), 2);\n\n return Address4.fromBigInteger(endAddress);\n};\n\n/**\n * Converts a BigInteger to a v4 address object\n * @memberof Address4\n * @static\n * @param {BigInteger} bigInteger - a BigInteger to convert\n * @returns {Address4}\n */\nAddress4.fromBigInteger = function (bigInteger) {\n return Address4.fromInteger(parseInt(bigInteger.toString(), 10));\n};\n\n/**\n * Returns the first n bits of the address, defaulting to the\n * subnet mask\n * @memberof Address4\n * @instance\n * @returns {String}\n */\nAddress4.prototype.mask = function (optionalMask) {\n if (optionalMask === undefined) {\n optionalMask = this.subnetMask;\n }\n\n return this.getBitsBase2(0, optionalMask);\n};\n\n/**\n * Returns the bits in the given range as a base-2 string\n * @memberof Address4\n * @instance\n * @returns {string}\n */\nAddress4.prototype.getBitsBase2 = function (start, end) {\n return this.binaryZeroPad().slice(start, end);\n};\n\n/**\n * Returns true if the given address is in the subnet of the current address\n * @memberof Address4\n * @instance\n * @returns {boolean}\n */\nAddress4.prototype.isInSubnet = common.isInSubnet;\n\n/**\n * Returns a zero-padded base-2 string representation of the address\n * @memberof Address4\n * @instance\n * @returns {string}\n */\nAddress4.prototype.binaryZeroPad = function () {\n return padStart(this.bigInteger().toString(2), constants.BITS, '0');\n};\n\nmodule.exports = Address4;",{"version":3,"sources":["node_modules/ip-address/lib/ipv4.js"],"names":["BigInteger","require","common","padStart","repeat","sprintf","constants","Address4","address","valid","groups","GROUPS","v4","subnet","subnetMask","RE_SUBNET_STRING","exec","parsedSubnet","replace","parseInt","BITS","error","addressMinusSuffix","parsedAddress","parse","prototype","split","match","RE_ADDRESS","isValid","correctForm","map","part","join","isCorrect","fromHex","hex","padded","i","h","slice","push","fromInteger","integer","toString","toHex","toArray","toGroup6","output","bigInteger","n","startAddress","mask","fromBigInteger","endAddress","optionalMask","undefined","getBitsBase2","start","end","binaryZeroPad","isInSubnet","module","exports"],"mappings":"AAAA;;AAEA,IAAIA,aAAaC,QAAQ,MAAR,EAAgBD,UAAjC;AACA,IAAIE,SAASD,QAAQ,aAAR,CAAb;AACA,IAAIE,WAAWF,QAAQ,iBAAR,CAAf;AACA,IAAIG,SAASH,QAAQ,eAAR,CAAb;AACA,IAAII,UAAUJ,QAAQ,YAAR,EAAsBI,OAApC;;AAEA,IAAIC,YAAYL,QAAQ,mBAAR,CAAhB;;AAEA;;;;;AAKA,SAASM,QAAT,CAAkBC,OAAlB,EAA2B;AACzB,OAAKC,KAAL,GAAa,KAAb;AACA,OAAKD,OAAL,GAAeA,OAAf;AACA,OAAKE,MAAL,GAAcJ,UAAUK,MAAxB;;AAEA,OAAKC,EAAL,GAAU,IAAV;;AAEA,OAAKC,MAAL,GAAc,KAAd;AACA,OAAKC,UAAL,GAAkB,EAAlB;;AAEA,MAAID,SAASP,UAAUS,gBAAV,CAA2BC,IAA3B,CAAgCR,OAAhC,CAAb;;AAEA,MAAIK,MAAJ,EAAY;AACV,SAAKI,YAAL,GAAoBJ,OAAO,CAAP,EAAUK,OAAV,CAAkB,GAAlB,EAAuB,EAAvB,CAApB;AACA,SAAKJ,UAAL,GAAkBK,SAAS,KAAKF,YAAd,EAA4B,EAA5B,CAAlB;AACA,SAAKJ,MAAL,GAAc,MAAM,KAAKC,UAAzB;;AAEA,QAAI,KAAKA,UAAL,GAAkB,CAAlB,IAAuB,KAAKA,UAAL,GAAkBR,UAAUc,IAAvD,EAA6D;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T,CAAqBvB,SAAS8B,WAAWL,QAAX,EAAT,EAAgC,EAAhC,CAArB,CAAP;AACD,CAFD;;AAIA;;;;;;;AAOArC,SAASkB,SAAT,CAAmB2B,IAAnB,GAA0B,UAAUG,YAAV,EAAwB;AAChD,MAAIA,iBAAiBC,SAArB,EAAgC;AAC9BD,mBAAe,KAAKzC,UAApB;AACD;;AAED,SAAO,KAAK2C,YAAL,CAAkB,CAAlB,EAAqBF,YAArB,CAAP;AACD,CAND;;AAQA;;;;;;AAMAhD,SAASkB,SAAT,CAAmBgC,YAAnB,GAAkC,UAAUC,KAAV,EAAiBC,GAAjB,EAAsB;AACtD,SAAO,KAAKC,aAAL,GAAqBpB,KAArB,CAA2BkB,KAA3B,EAAkCC,GAAlC,CAAP;AACD,CAFD;;AAIA;;;;;;AAMApD,SAASkB,SAAT,CAAmBoC,UAAnB,GAAgC3D,OAAO2D,UAAvC;;AAEA;;;;;;AAMAtD,SAASkB,SAAT,CAAmBmC,aAAnB,GAAmC,YAAY;AAC7C,SAAOzD,SAAS,KAAK8C,UAAL,GAAkBL,QAAlB,CAA2B,CAA3B,CAAT,EAAwCtC,UAAUc,IAAlD,EAAwD,GAAxD,CAAP;AACD,CAFD;;AAIA0C,OAAOC,OAAP,GAAiBxD,QAAjB","file":"ipv4.js","sourceRoot":"/data","sourcesContent":["'use strict';\n\nvar BigInteger = require('jsbn').BigInteger;\nvar common = require('./common.js');\nvar padStart = require('lodash.padstart');\nvar repeat = require('lodash.repeat');\nvar sprintf = require('sprintf-js').sprintf;\n\nvar constants = require('./v4/constants.js');\n\n/**\n * Represents an IPv4 address\n * @class Address4\n * @param {string} address - An IPv4 address string\n */\nfunction Address4(address) {\n this.valid = false;\n this.address = address;\n this.groups = constants.GROUPS;\n\n this.v4 = true;\n\n this.subnet = '/32';\n this.subnetMask = 32;\n\n var subnet = constants.RE_SUBNET_STRING.exec(address);\n\n if (subnet) {\n this.parsedSubnet = subnet[0].replace('/', '');\n this.subnetMask = parseInt(this.parsedSubnet, 10);\n this.subnet = '/' + this.subnetMask;\n\n if (this.subnetMask < 0 || this.subnetMask > constants.BITS) {\n this.valid = false;\n this.error = 'Invalid subnet mask.';\n\n return;\n }\n\n address = address.replace(constants.RE_SUBNET_STRING, '');\n }\n\n this.addressMinusSuffix = address;\n\n this.parsedAddress = this.parse(address);\n}\n\n/*\n * Parses a v4 address\n */\nAddress4.prototype.parse = function (address) {\n var groups = address.split('.');\n\n if (address.match(constants.RE_ADDRESS)) {\n this.valid = true;\n } else {\n this.error = 'Invalid IPv4 address.';\n }\n\n return groups;\n};\n\n/**\n * Return true if the address is valid\n * @memberof Address4\n * @instance\n * @returns {Boolean}\n */\nAddress4.prototype.isValid = function () {\n return this.valid;\n};\n\n/**\n * Returns the correct form of an address\n * @memberof Address4\n * @instance\n * @returns {String}\n */\nAddress4.prototype.correctForm = function () {\n return this.parsedAddress.map(function (part) {\n return parseInt(part, 10);\n }).join('.');\n};\n\n/**\n * Returns true if the address is correct, false otherwise\n * @memberof Address4\n * @instance\n * @returns {Boolean}\n */\nAddress4.prototype.isCorrect = common.isCorrect(constants.BITS);\n\n/**\n * Converts a hex string to an IPv4 address object\n * @memberof Address4\n * @static\n * @param {string} hex - a hex string to convert\n * @returns {Address4}\n */\nAddress4.fromHex = function (hex) {\n var padded = padStart(hex.replace(/:/g, ''), 8, '0');\n var groups = [];\n var i;\n\n for (i = 0; i < 8; i += 2) {\n var h = padded.slice(i, i + 2);\n\n groups.push(parseInt(h, 16));\n }\n\n return new Address4(groups.join('.'));\n};\n\n/**\n * Converts an integer into a IPv4 address object\n * @memberof Address4\n * @static\n * @param {integer} integer - a number to convert\n * @returns {Address4}\n */\nAddress4.fromInteger = function (integer) {\n return Address4.fromHex(integer.toString(16));\n};\n\n/**\n * Converts an IPv4 address object to a hex string\n * @memberof Address4\n * @instance\n * @returns {String}\n */\nAddress4.prototype.toHex = function () {\n return this.parsedAddress.map(function (part) {\n return sprintf('%02x', parseInt(part, 10));\n }).join(':');\n};\n\n/**\n * Converts an IPv4 address object to an array of bytes\n * @memberof Address4\n * @instance\n * @returns {Array}\n */\nAddress4.prototype.toArray = function () {\n return this.parsedAddress.map(function (part) {\n return parseInt(part, 10);\n });\n};\n\n/**\n * Converts an IPv4 address object to an IPv6 address group\n * @memberof Address4\n * @instance\n * @returns {String}\n */\nAddress4.prototype.toGroup6 = function () {\n var output = [];\n var i;\n\n for (i = 0; i < constants.GROUPS; i += 2) {\n var hex = sprintf('%02x%02x',\n parseInt(this.parsedAddress[i], 10),\n parseInt(this.parsedAddress[i + 1], 10));\n\n output.push(sprintf('%x', parseInt(hex, 16)));\n }\n\n return output.join(':');\n};\n\n/**\n * Returns the address as a BigInteger\n * @memberof Address4\n * @instance\n * @returns {BigInteger}\n */\nAddress4.prototype.bigInteger = function () {\n if (!this.valid) {\n return null;\n }\n\n return new BigInteger(this.parsedAddress.map(function (n) {\n return sprintf('%02x', parseInt(n, 10));\n }).join(''), 16);\n};\n\n/**\n * The first address in the range given by this address' subnet.\n * Often referred to as the Network Address.\n * @memberof Address4\n * @instance\n * @returns {Address4}\n */\nAddress4.prototype.startAddress = function () {\n var startAddress = new BigInteger(this.mask() +\n repeat(0, constants.BITS - this.subnetMask), 2);\n\n return Address4.fromBigInteger(startAddress);\n};\n\n/**\n * The last address in the range given by this address' subnet\n * Often referred to as the Broadcast\n * @memberof Address4\n * @instance\n * @returns {Address4}\n */\nAddress4.prototype.endAddress = function () {\n var endAddress = new BigInteger(this.mask() +\n repeat(1, constants.BITS - this.subnetMask), 2);\n\n return Address4.fromBigInteger(endAddress);\n};\n\n/**\n * Converts a BigInteger to a v4 address object\n * @memberof Address4\n * @static\n * @param {BigInteger} bigInteger - a BigInteger to convert\n * @returns {Address4}\n */\nAddress4.fromBigInteger = function (bigInteger) {\n return Address4.fromInteger(parseInt(bigInteger.toString(), 10));\n};\n\n/**\n * Returns the first n bits of the address, defaulting to the\n * subnet mask\n * @memberof Address4\n * @instance\n * @returns {String}\n */\nAddress4.prototype.mask = function (optionalMask) {\n if (optionalMask === undefined) {\n optionalMask = this.subnetMask;\n }\n\n return this.getBitsBase2(0, optionalMask);\n};\n\n/**\n * Returns the bits in the given range as a base-2 string\n * @memberof Address4\n * @instance\n * @returns {string}\n */\nAddress4.prototype.getBitsBase2 = function (start, end) {\n return this.binaryZeroPad().slice(start, end);\n};\n\n/**\n * Returns true if the given address is in the subnet of the current address\n * @memberof Address4\n * @instance\n * @returns {boolean}\n */\nAddress4.prototype.isInSubnet = common.isInSubnet;\n\n/**\n * Returns a zero-padded base-2 string representation of the address\n * @memberof Address4\n * @instance\n * @returns {string}\n */\nAddress4.prototype.binaryZeroPad = function () {\n return padStart(this.bigInteger().toString(2), constants.BITS, '0');\n};\n\nmodule.exports = Address4;\n"]}]}