Comparing version 0.2.16 to 0.2.18
#!/usr/bin/env node | ||
/* | ||
* Example: | ||
* | ||
* $ dhcp hostname dns --bind 192.168.2.2 | ||
*/ | ||
process.title = 'node-dhcp'; | ||
@@ -9,2 +15,3 @@ | ||
var bind = null; | ||
var opts = {}; | ||
@@ -18,2 +25,4 @@ var force = []; // We force all options here, since the user explicitly stated the option | ||
/* void */ | ||
} else if (arg === 'bind') { | ||
bind = argv[arg]; | ||
} else if (arg === 'range') { | ||
@@ -47,2 +56,2 @@ opts.range = argv[arg].split('-'); | ||
server.listen(); | ||
server.listen(null, bind); |
124
lib/dhcp.js
/** | ||
* @license DHCP.js v0.2.16 28/06/2017 | ||
* @license DHCP.js v0.2.18 28/06/2017 | ||
* http://www.xarg.org/2017/06/a-pure-javascript-dhcp-implementation/ | ||
@@ -61,8 +61,8 @@ * | ||
var self = this; | ||
var sock = dgram.createSocket({type: 'udp4', reuseAddr: true}); | ||
const self = this; | ||
const sock = dgram.createSocket({type: 'udp4', reuseAddr: true}); | ||
sock.on('message', function(buf) { | ||
var req; | ||
let req; | ||
@@ -97,2 +97,4 @@ try { | ||
break; | ||
default: | ||
console.error("Not implemented method", req.options[53]); | ||
} | ||
@@ -126,8 +128,6 @@ } | ||
tools: Tools, // Mapping for config callbacks | ||
config: function(key) { | ||
var val; | ||
var optId = Options.conf[key]; | ||
let val; | ||
const optId = Options.conf[key]; | ||
@@ -152,6 +152,6 @@ // If config setting is set by user | ||
if (key !== 'range' && key !== 'static' && key !== 'randomIP' && Options.opts[optId].enum) { | ||
var values = Options.opts[optId].enum; | ||
const values = Options.opts[optId].enum; | ||
// Check if value is an actual enum string | ||
for (var i in values) { | ||
for (let i in values) { | ||
if (values[i] === val) { | ||
@@ -173,3 +173,3 @@ return parseInt(i, 10); | ||
for (var req of required) { | ||
for (let req of required) { | ||
@@ -189,3 +189,3 @@ // Check if option id actually exists | ||
} else { | ||
throw new Error('Unknown option ' + req); | ||
this.emit('error', 'Unknown option ' + req); | ||
} | ||
@@ -197,3 +197,3 @@ } | ||
for (var req of requested) { | ||
for (let req of requested) { | ||
@@ -205,3 +205,3 @@ // Check if option id actually exists | ||
if (pre[req] === undefined) { | ||
var val = this.config(Options.opts[req].config); | ||
const val = this.config(Options.opts[req].config); | ||
// Add value only, if it's meaningful | ||
@@ -272,5 +272,5 @@ if (val) { | ||
// Is there a static binding? | ||
var _static = this.config('static'); | ||
const _static = this.config('static'); | ||
if (typeof _static === "function") { | ||
var staticResult = _static(clientMAC, req); | ||
const staticResult = _static(clientMAC, req); | ||
if (staticResult) | ||
@@ -283,6 +283,6 @@ return staticResult; | ||
var randIP = this.config('randomIP'); | ||
var _tmp = this.config('range'); | ||
var firstIP = Tools.parseIp(_tmp[0]); | ||
var lastIP = Tools.parseIp(_tmp[1]); | ||
const randIP = this.config('randomIP'); | ||
const _tmp = this.config('range'); | ||
const firstIP = Tools.parseIp(_tmp[0]); | ||
const lastIP = Tools.parseIp(_tmp[1]); | ||
@@ -292,7 +292,7 @@ | ||
// Add all known addresses and save the oldest lease | ||
var ips = [this.config('server')]; // Exclude our own server IP from pool | ||
var oldestMac = null; | ||
var oldestTime = Infinity; | ||
var leases = 0; | ||
for (var mac in this._state) { | ||
const ips = [this.config('server')]; // Exclude our own server IP from pool | ||
let oldestMac = null; | ||
let oldestTime = Infinity; | ||
let leases = 0; | ||
for (let mac in this._state) { | ||
if (this._state[mac].address) | ||
@@ -313,3 +313,3 @@ ips.push(this._state[mac].address); | ||
if (lastIP - firstIP === leases) { | ||
var ip = this._state[oldestMac].address; | ||
const ip = this._state[oldestMac].address; | ||
@@ -330,3 +330,3 @@ // TODO: Notify deleted client | ||
var ip = Tools.formatIp(firstIP + Math.random() * (lastIP - firstIP) | 0); | ||
const ip = Tools.formatIp(firstIP + Math.random() * (lastIP - firstIP) | 0); | ||
@@ -342,5 +342,5 @@ if (ips.indexOf(ip) === -1) { | ||
// Choose first free IP in subnet | ||
for (var i = firstIP; i <= lastIP; i++) { | ||
for (let i = firstIP; i <= lastIP; i++) { | ||
var ip = Tools.formatIp(i); | ||
const ip = Tools.formatIp(i); | ||
@@ -356,3 +356,3 @@ if (ips.indexOf(ip) === -1) { | ||
var lease = this._state[req.chaddr] = this._state[req.chaddr] || new Lease; | ||
const lease = this._state[req.chaddr] = this._state[req.chaddr] || new Lease; | ||
lease.address = this._selectAddress(req.chaddr, req); | ||
@@ -370,3 +370,3 @@ lease.leasePeriod = this.config('leaseTime'); | ||
// Formulate the response object | ||
var ans = { | ||
const ans = { | ||
op: BOOTREPLY, | ||
@@ -402,3 +402,3 @@ htype: 1, // RFC1700, hardware types: 1=Ethernet, 2=Experimental, 3=AX25, 4=ProNET Token Ring, 5=Chaos, 6=Tokenring, 7=Arcnet, 8=FDDI, 9=Lanstar (keep it constant) | ||
var lease = this._state[req.chaddr] = this._state[req.chaddr] || new Lease; | ||
const lease = this._state[req.chaddr] = this._state[req.chaddr] || new Lease; | ||
lease.address = this._selectAddress(req.chaddr); | ||
@@ -415,3 +415,3 @@ lease.leasePeriod = this.config('leaseTime'); | ||
// Formulate the response object | ||
var ans = { | ||
const ans = { | ||
op: BOOTREPLY, | ||
@@ -447,3 +447,3 @@ htype: 1, // RFC1700, hardware types: 1=Ethernet, 2=Experimental, 3=AX25, 4=ProNET Token Ring, 5=Chaos, 6=Tokenring, 7=Arcnet, 8=FDDI, 9=Lanstar (keep it constant) | ||
// Formulate the response object | ||
var ans = { | ||
const ans = { | ||
op: BOOTREPLY, | ||
@@ -484,3 +484,3 @@ htype: 1, // RFC1700, hardware types: 1=Ethernet, 2=Experimental, 3=AX25, 4=ProNET Token Ring, 5=Chaos, 6=Tokenring, 7=Arcnet, 8=FDDI, 9=Lanstar (keep it constant) | ||
var sock = this._sock; | ||
const sock = this._sock; | ||
@@ -501,3 +501,3 @@ sock.bind(port || SERVER_PORT, host || INADDR_ANY, function() { | ||
var sb = Protocol.format(data); | ||
const sb = Protocol.format(data); | ||
@@ -526,8 +526,8 @@ this._sock.send(sb._data, 0, sb._w, CLIENT_PORT, host, function(err, bytes) { | ||
var self = this; | ||
var sock = dgram.createSocket({type: 'udp4', reuseAddr: true}); | ||
const self = this; | ||
const sock = dgram.createSocket({type: 'udp4', reuseAddr: true}); | ||
sock.on('message', function(buf) { | ||
var req; | ||
let req; | ||
@@ -595,7 +595,7 @@ try { | ||
var interfaces = os.networkInterfaces(); | ||
const interfaces = os.networkInterfaces(); | ||
for (var interface in interfaces) { | ||
var addresses = interfaces[interface]; | ||
for (var address in addresses) { | ||
for (let interface in interfaces) { | ||
const addresses = interfaces[interface]; | ||
for (let address in addresses) { | ||
if (addresses[address].family === 'IPv4' && !addresses[address].internal) { | ||
@@ -617,3 +617,3 @@ | ||
// Default list we request | ||
var def = [ | ||
const def = [ | ||
1, // netmask | ||
@@ -626,9 +626,9 @@ 3, // routers | ||
var ft = this._conf.features; | ||
const ft = this._conf.features; | ||
if (ft) { | ||
for (var f of ft) { | ||
for (let f of ft) { | ||
var id = Options.conf[f]; | ||
let id = Options.conf[f]; | ||
if (id) { | ||
@@ -659,6 +659,6 @@ | ||
var mac = this.config('mac'); | ||
const mac = this.config('mac'); | ||
// Formulate the response object | ||
var ans = { | ||
const ans = { | ||
op: BOOTREQUEST, | ||
@@ -717,3 +717,3 @@ htype: 1, // RFC1700, hardware types: 1=Ethernet, 2=Experimental, 3=AX25, 4=ProNET Token Ring, 5=Chaos, 6=Tokenring, 7=Arcnet, 8=FDDI, 9=Lanstar (keep it constant) | ||
// Formulate the response object | ||
var ans = { | ||
const ans = { | ||
op: BOOTREQUEST, | ||
@@ -783,7 +783,7 @@ htype: 1, // RFC1700, hardware types: 1=Ethernet, 2=Experimental, 3=AX25, 4=ProNET Token Ring, 5=Chaos, 6=Tokenring, 7=Arcnet, 8=FDDI, 9=Lanstar (keep it constant) | ||
var options = req.options; | ||
const options = req.options; | ||
this._state.options = {}; | ||
// Map all options from request | ||
for (var id in options) { | ||
for (let id in options) { | ||
@@ -793,4 +793,4 @@ if (id === '53' || id === '51' || id === '58' || id === '59') | ||
var conf = Options.opts[id]; | ||
var key = conf.config || conf.attr; | ||
const conf = Options.opts[id]; | ||
const key = conf.config || conf.attr; | ||
@@ -811,3 +811,3 @@ if (conf.enum) { | ||
var CIDR = Tools.CIDRFromNetmask(this._state.options.netmask); | ||
const cidr = Tools.CIDRFromNetmask(this._state.options.netmask); | ||
@@ -817,3 +817,3 @@ // If router is not given, guess one | ||
this._state.options.router = Tools.formatIp( | ||
Tools.gatewayFromIpCIDR(this._state.address, CIDR)); | ||
Tools.gatewayFromIpCIDR(this._state.address, cidr)); | ||
} | ||
@@ -824,3 +824,3 @@ | ||
this._state.options.broadcast = Tools.formatIp( | ||
Tools.broadcastFromIpCIDR(this._state.address, CIDR)); | ||
Tools.broadcastFromIpCIDR(this._state.address, cidr)); | ||
} | ||
@@ -840,3 +840,3 @@ | ||
// Formulate the response object | ||
var ans = { | ||
const ans = { | ||
op: BOOTREQUEST, | ||
@@ -880,3 +880,3 @@ htype: 1, // RFC1700, hardware types: 1=Ethernet, 2=Experimental, 3=AX25, 4=ProNET Token Ring, 5=Chaos, 6=Tokenring, 7=Arcnet, 8=FDDI, 9=Lanstar (keep it constant) | ||
// Formulate the response object | ||
var ans = { | ||
const ans = { | ||
op: BOOTREQUEST, | ||
@@ -918,3 +918,3 @@ htype: 1, // RFC1700, hardware types: 1=Ethernet, 2=Experimental, 3=AX25, 4=ProNET Token Ring, 5=Chaos, 6=Tokenring, 7=Arcnet, 8=FDDI, 9=Lanstar (keep it constant) | ||
// Formulate the response object | ||
var ans = { | ||
const ans = { | ||
op: BOOTREQUEST, | ||
@@ -953,3 +953,3 @@ htype: 1, // RFC1700, hardware types: 1=Ethernet, 2=Experimental, 3=AX25, 4=ProNET Token Ring, 5=Chaos, 6=Tokenring, 7=Arcnet, 8=FDDI, 9=Lanstar (keep it constant) | ||
var sock = this._sock; | ||
const sock = this._sock; | ||
@@ -970,3 +970,3 @@ sock.bind(port || CLIENT_PORT, host || INADDR_ANY, function() { | ||
var sb = Protocol.format(data); | ||
const sb = Protocol.format(data); | ||
@@ -973,0 +973,0 @@ this._sock.send(sb._data, 0, sb._w, SERVER_PORT, host, function(err, bytes) { |
@@ -12,6 +12,8 @@ | ||
const Tools = require('./tools.js'); | ||
// RFC 1533: https://tools.ietf.org/html/rfc1533 | ||
// RFC 2132: https://www.ietf.org/rfc/rfc2132.txt | ||
// RFC 3011: https://tools.ietf.org/html/rfc3011 | ||
var opts = { | ||
const opts = { | ||
1: {// RFC 2132 | ||
@@ -21,11 +23,11 @@ name: 'Subnet Mask', | ||
config: 'netmask', | ||
default: function () { | ||
default: function() { | ||
// Default is the minimal CIDR for the given range | ||
var range = this.config('range'); | ||
const range = this.config('range'); | ||
var net = this.tools.netmaskFromRange(range[0], range[1]); | ||
const net = Tools.netmaskFromRange(range[0], range[1]); | ||
return this.tools.formatIp(net); | ||
return Tools.formatIp(net); | ||
} | ||
@@ -42,3 +44,3 @@ }, | ||
config: 'router', | ||
default: function () { | ||
default: function() { | ||
@@ -48,3 +50,3 @@ // Let's assume the router is the first host of the range if we don't know better | ||
var range = this.config('range'); | ||
const range = this.config('range'); | ||
@@ -187,9 +189,9 @@ return range[0]; | ||
config: 'broadcast', | ||
default: function () { | ||
default: function() { | ||
var range = this.config('range'); | ||
var ip = range[0]; // range begin is obviously a valid ip | ||
var cidr = this.tools.CIDRFromNetmask(this.config('netmask')); | ||
const range = this.config('range'); | ||
const ip = range[0]; // range begin is obviously a valid ip | ||
const cidr = Tools.CIDRFromNetmask(this.config('netmask')); | ||
return this.tools.formatIp(this.tools.broadcastFromIpCIDR(ip, cidr)); | ||
return Tools.formatIp(Tools.broadcastFromIpCIDR(ip, cidr)); | ||
} | ||
@@ -467,3 +469,3 @@ }, | ||
82: { // RFC 3046, relayAgentInformation | ||
},*/ | ||
@@ -479,3 +481,3 @@ 116: {// RFC 2563: https://tools.ietf.org/html/rfc2563 | ||
}, | ||
118: { // RFC 301 | ||
118: {// RFC 301 | ||
name: 'Subnet Selection', | ||
@@ -485,12 +487,12 @@ type: 'IP', | ||
}, | ||
119: { // dns search list | ||
name: 'Domain Search List', | ||
type: 'ASCII', | ||
config: 'domainSearchList' | ||
}, | ||
121: { // rfc 3442 | ||
name: 'Classless Route Option Format', | ||
type: 'IPs', | ||
config: 'classlessRoute' | ||
}, | ||
119: {// dns search list | ||
name: 'Domain Search List', | ||
type: 'ASCII', | ||
config: 'domainSearchList' | ||
}, | ||
121: {// rfc 3442 | ||
name: 'Classless Route Option Format', | ||
type: 'IPs', | ||
config: 'classlessRoute' | ||
}, | ||
145: {// RFC 6704: https://tools.ietf.org/html/rfc6704 | ||
@@ -501,7 +503,12 @@ name: 'Forcerenew Nonce', | ||
}, | ||
1001: { // TODO: Fix my number! | ||
252: { // https://en.wikipedia.org/wiki/Web_Proxy_Auto-Discovery_Protocol | ||
name: 'Web Proxy Auto-Discovery', | ||
type: 'ASCII', | ||
config: 'wpad' | ||
}, | ||
1001: {// TODO: Fix my number! | ||
name: 'Static', | ||
config: 'static' | ||
}, | ||
1002: { // TODO: Fix my number! | ||
1002: {// TODO: Fix my number! | ||
name: 'Random IP', | ||
@@ -515,5 +522,5 @@ type: 'Bool', | ||
// Create inverse config/attr lookup map | ||
var conf = {}; | ||
var attr = {}; | ||
for (var i in opts) { | ||
const conf = {}; | ||
const attr = {}; | ||
for (let i in opts) { | ||
if (opts[i].config) { | ||
@@ -520,0 +527,0 @@ conf[opts[i].config] = parseInt(i, 10); |
/** | ||
* @license DHCP.js v0.2.16 28/06/2017 | ||
* @license DHCP.js v0.2.18 28/06/2017 | ||
* http://www.xarg.org/2017/06/a-pure-javascript-dhcp-implementation/ | ||
@@ -9,3 +9,3 @@ * | ||
var SeqBuffer = require('./seqbuffer.js'); | ||
const SeqBuffer = require('./seqbuffer.js'); | ||
@@ -20,8 +20,8 @@ module.exports = { | ||
var sb = new SeqBuffer(buf); | ||
const sb = new SeqBuffer(buf); | ||
var hlen, htype; | ||
let hlen, htype; | ||
// RFC 2131 | ||
var msg = { | ||
return { | ||
op: sb.getUInt8(), // op code: 1=request, 2=reply | ||
@@ -40,7 +40,6 @@ htype: (htype = sb.getUInt8()), // hardware addr type: 1 for 10mb ethernet | ||
sname: sb.getUTF8(64), // server host name | ||
file: sb.getASCII(128), // boot file name | ||
file: sb.getUTF8(128), // boot file name | ||
magicCookie: sb.getUInt32(), // contains 99, 130, 83, 99 | ||
options: sb.getOptions() | ||
}; | ||
return msg; | ||
}, | ||
@@ -50,3 +49,3 @@ | ||
var sb = new SeqBuffer; | ||
const sb = new SeqBuffer; | ||
@@ -65,4 +64,4 @@ sb.addUInt8(data.op); | ||
sb.addMac(data.chaddr); | ||
sb.addUTF8(data.sname, 64); | ||
sb.addUTF8(data.file, 128); | ||
sb.addUTF8Pad(data.sname, 64); | ||
sb.addUTF8Pad(data.file, 128); | ||
sb.addUInt32(0x63825363); | ||
@@ -69,0 +68,0 @@ sb.addOptions(data.options); |
/** | ||
* @license DHCP.js v0.2.16 28/06/2017 | ||
* @license DHCP.js v0.2.18 28/06/2017 | ||
* http://www.xarg.org/2017/06/a-pure-javascript-dhcp-implementation/ | ||
@@ -9,6 +9,7 @@ * | ||
var Options = require('./options.js').opts; | ||
const Options = require('./options.js').opts; | ||
function trimZero(str) { | ||
var pos = str.indexOf('\x00'); | ||
const pos = str.indexOf('\x00'); | ||
@@ -20,3 +21,3 @@ return pos === -1 ? str : str.substr(0, pos); | ||
this._data = buf || new Buffer.alloc(len || 1500); // alloc() fills the buffer with '0' | ||
this._data = buf || Buffer.alloc(len || 1500); // alloc() fills the buffer with '0' | ||
} | ||
@@ -72,11 +73,16 @@ | ||
// | ||
addUTF8: function(val, fixLen) { | ||
addUTF8: function(val) { | ||
this._w += this._data.write(val, this._w, 'utf8'); | ||
}, | ||
addUTF8Pad: function(val, fixLen) { | ||
if (fixLen) { | ||
this._data.fill(0, this._w, this._w + fixLen); | ||
this._data.write(val.slice(0, fixLen), this._w, 'utf8'); // TODO: not optimal truncation | ||
this._w += fixLen; | ||
} else { | ||
this._w += this._data.write(val, this._w, 'utf8'); | ||
let len = Buffer.from(val, 'utf8').length; | ||
for (let n = 0; len > fixLen; n++) { | ||
val = val.slice(0, fixLen - n); // Truncate as long as character length is > fixLen | ||
len = Buffer.from(val, 'utf8').length; | ||
} | ||
this._data.fill(0, this._w, this._w + fixLen); | ||
this._data.write(val, this._w, 'utf8'); | ||
this._w += fixLen; | ||
}, | ||
@@ -87,12 +93,10 @@ getUTF8: function(len) { | ||
// | ||
addASCII: function(val, fixLen) { | ||
if (fixLen) { | ||
this._data.fill(0, this._w, this._w + fixLen); | ||
this._data.write(val.slice(0, fixLen), this._w, 'ascii'); | ||
this._w += fixLen; | ||
} else { | ||
this._w += this._data.write(val, this._w, 'ascii'); | ||
} | ||
addASCII: function(val) { | ||
this._w += this._data.write(val, this._w, 'ascii'); | ||
}, | ||
addASCIIPad: function(val, fixLen) { | ||
this._data.fill(0, this._w, this._w + fixLen); | ||
this._data.write(val.slice(0, fixLen), this._w, 'ascii'); | ||
this._w += fixLen; | ||
}, | ||
getASCII: function(len) { | ||
@@ -103,4 +107,4 @@ return trimZero(this._data.toString('ascii', this._r, this._r += len)); | ||
addIP: function(ip) { | ||
var self = this; | ||
var octs = ip.split('.'); | ||
const self = this; | ||
const octs = ip.split('.'); | ||
@@ -111,3 +115,3 @@ if (octs.length !== 4) { | ||
for (var val of octs) { | ||
for (let val of octs) { | ||
@@ -133,3 +137,3 @@ val = parseInt(val, 10); | ||
if (ips instanceof Array) { | ||
for (var ip of ips) { | ||
for (let ip of ips) { | ||
this.addIP(ip); | ||
@@ -142,4 +146,4 @@ } | ||
getIPs: function(len) { | ||
var ret = []; | ||
for (var i = 0; i < len; i += 4) { | ||
const ret = []; | ||
for (let i = 0; i < len; i += 4) { | ||
ret.push(this.getIP()); | ||
@@ -152,3 +156,3 @@ } | ||
var octs = mac.split(/[-:]/); | ||
const octs = mac.split(/[-:]/); | ||
@@ -159,3 +163,3 @@ if (octs.length !== 6) { | ||
for (var val of octs) { | ||
for (let val of octs) { | ||
val = parseInt(val, 16); | ||
@@ -176,3 +180,3 @@ if (0 <= val && val < 256) { | ||
var mac = this._data.toString('hex', this._r, this._r += hlen); | ||
const mac = this._data.toString('hex', this._r, this._r += hlen); | ||
@@ -196,9 +200,9 @@ if (htype !== 1 || hlen !== 6) { | ||
for (var i in opts) { | ||
for (let i in opts) { | ||
if (opts.hasOwnProperty(i)) { | ||
var opt = Options[i]; | ||
var len = 0; | ||
var val = opts[i]; | ||
const opt = Options[i]; | ||
let len = 0; | ||
let val = opts[i]; | ||
@@ -240,5 +244,4 @@ if (val === null) { | ||
continue; // Min length has to be 1 | ||
if (len > 255) { | ||
console.error(val + ' too long, truncating...'); | ||
val = val.slice(0, 250); // TODO: needs a better truncation mechanism | ||
for (let n = 0; len > 255; n++) { | ||
val = val.slice(0, 255 - n); // Truncate as long as character length is > 255 | ||
len = Buffer.from(val, 'utf8').length; | ||
@@ -275,8 +278,8 @@ } | ||
var options = {}; | ||
var buf = this._data; | ||
const options = {}; | ||
const buf = this._data; | ||
while (this._r < buf.length) { | ||
var opt = this.getUInt8(); | ||
let opt = this.getUInt8(); | ||
@@ -289,3 +292,3 @@ if (opt === 0xff) { // End type | ||
var len = this.getUInt8(); | ||
let len = this.getUInt8(); | ||
@@ -296,3 +299,3 @@ if (opt in Options) { | ||
this._r += len; | ||
console.error('Type ' + opt + ' not known'); | ||
console.error('Option ' + opt + ' not known'); | ||
} | ||
@@ -307,3 +310,3 @@ } | ||
if (arr instanceof Array) { | ||
for (var i = 0; i < arr.length; i++) { | ||
for (let i = 0; i < arr.length; i++) { | ||
this.addUInt8(arr[i]); | ||
@@ -316,4 +319,4 @@ } | ||
getUInt8s: function(len) { | ||
var ret = []; | ||
for (var i = 0; i < len; i++) { | ||
const ret = []; | ||
for (let i = 0; i < len; i++) { | ||
ret.push(this.getUInt8()); | ||
@@ -326,3 +329,3 @@ } | ||
if (arr instanceof Array) { | ||
for (var i = 0; i < arr.length; i++) { | ||
for (let i = 0; i < arr.length; i++) { | ||
this.addUInt16(arr[i]); | ||
@@ -335,4 +338,4 @@ } | ||
getUInt16s: function(len) { | ||
var ret = []; | ||
for (var i = 0; i < len; i += 2) { | ||
const ret = []; | ||
for (let i = 0; i < len; i += 2) { | ||
ret.push(this.getUInt16()); | ||
@@ -339,0 +342,0 @@ } |
@@ -6,3 +6,3 @@ | ||
parseIp: function (str) { | ||
var octs = str.split("."); | ||
const octs = str.split("."); | ||
@@ -24,5 +24,5 @@ if (octs.length !== 4) { | ||
formatIp: function (num) { | ||
var ip = ""; | ||
let ip = ""; | ||
for (var i = 24; i >= 0; i -= 8) { | ||
for (let i = 24; i >= 0; i -= 8) { | ||
@@ -46,3 +46,3 @@ if (ip) | ||
var first = ip >>> 24; | ||
const first = ip >>> 24; | ||
@@ -83,7 +83,7 @@ if (first <= 127) { | ||
var s = 0; | ||
var d = 0; | ||
var t = net & 1; | ||
var wild = t; | ||
for (var i = 0; i < 32; i++) { | ||
let s = 0; | ||
let d = 0; | ||
let t = net & 1; | ||
let wild = t; | ||
for (let i = 0; i < 32; i++) { | ||
d += t ^ net & 1; | ||
@@ -124,3 +124,3 @@ t = net & 1; | ||
var cidr = 32 - Math.floor(Math.log2((ip1 ^ (ip2 - 1)) + 2)) - 1; | ||
const cidr = 32 - Math.floor(Math.log2((ip1 ^ (ip2 - 1)) + 2)) - 1; | ||
@@ -127,0 +127,0 @@ return this.netmaskFromCIDR(cidr); |
{ | ||
"name": "dhcp", | ||
"title": "dhcp", | ||
"version": "0.2.16", | ||
"version": "0.2.18", | ||
"homepage": "https://github.com/infusion/node-dhcp", | ||
@@ -42,3 +42,3 @@ "bugs": { | ||
"engines": { | ||
"node": "*" | ||
"node": ">=5.10.0" | ||
}, | ||
@@ -45,0 +45,0 @@ "scripts": { |
@@ -213,3 +213,3 @@ var should = require('should'); | ||
sb.addASCII('pqs', 8); | ||
sb.addASCIIPad('pqs', 8); | ||
@@ -225,3 +225,3 @@ sb._r.should.be.equal(0); | ||
// Same with UTF8 | ||
sb.addUTF8('pqs', 8); | ||
sb.addUTF8Pad('pqs', 8); | ||
@@ -228,0 +228,0 @@ sb._r.should.be.equal(0); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
76504
2152