Comparing version 0.2.5 to 0.2.6
@@ -5,69 +5,30 @@ #!/usr/bin/env node | ||
var path = require('path'); | ||
var dhcp = require('../lib/dhcp.js'); | ||
var Options = require('../lib/options.js'); | ||
var argv = require('minimist')(process.argv.slice(2)); | ||
var opts = {}; | ||
var force = []; // We force all options here, since the user explicitly stated the option | ||
// Create a client | ||
if (path.basename(process.argv[1]).slice(-1) === 'd') { | ||
// minimist pushes all features, without "--" to the "_" key. | ||
// We need the list of features on "features" and all other options passed as is. | ||
// Easist way to do this is this: | ||
argv.features = argv._; | ||
// Create a server | ||
var client = dhcp.createClient(argv); | ||
for (var arg in argv) { | ||
client.on('bound', function() { | ||
if (arg === '_') { | ||
/* void */ | ||
} else if (arg === 'range') { | ||
opts.range = argv[arg].split('-'); | ||
} else if (Options.conf[arg] !== undefined) { | ||
var opt = this._state.options; | ||
// If value is missing, minimist simply makes it true/false | ||
if (typeof argv[arg] !== 'boolean') { | ||
opts[arg] = argv[arg]; | ||
force.push(argv[arg]); | ||
} else { | ||
console.error('Argument ' + arg + ' needs a value.'); | ||
process.exit(); | ||
} | ||
} else if (arg === 'help') { | ||
console.log('Usage:\n\tdhcpd --range 192.168.0.1-192.168.0.99 --option1 value1 --option2 value2 ...'); | ||
process.exit(); | ||
} else { | ||
console.error('Invalid argument ' + arg); | ||
process.exit(); | ||
} | ||
// Print all requested options | ||
for (var i in opt) { | ||
console.log(i, ": ", opt[i] instanceof Array ? opt[i].join(", ") : opt[i]); | ||
} | ||
var server = dhcp.createServer(opts); | ||
// Exit when finished | ||
process.exit(); | ||
}); | ||
server.listen(); | ||
client.listen(); | ||
} else { | ||
// Create a client | ||
var client = dhcp.createClient({ | ||
features: argv._ | ||
}); | ||
client.on('bound', function () { | ||
var opt = this._state.options; | ||
// Print all requested options | ||
for (var i in opt) { | ||
console.log(i, ": ", opt[i] instanceof Array ? opt[i].join(", ") : opt[i]); | ||
} | ||
// Exit when finished | ||
process.exit(); | ||
}); | ||
client.listen(); | ||
// Send first handshake | ||
client.sendDiscover(); | ||
} | ||
// Send first handshake | ||
client.sendDiscover(); |
@@ -462,3 +462,3 @@ | ||
82: { // RFC 3046, relayAgentInformation | ||
},*/ | ||
@@ -480,3 +480,3 @@ 116: {// RFC 2563: https://tools.ietf.org/html/rfc2563 | ||
119: { // dns search list | ||
}, */ | ||
@@ -487,2 +487,12 @@ 145: {// RFC 6704: https://tools.ietf.org/html/rfc6704 | ||
attr: 'renewNonce' | ||
}, | ||
1001: { // TODO: Fix my number! | ||
name: 'Static', | ||
config: 'static' | ||
}, | ||
1002: { // TODO: Fix my number! | ||
name: 'Random IP', | ||
type: 'Bool', | ||
config: 'randomIP', | ||
default: true | ||
} | ||
@@ -489,0 +499,0 @@ }; |
{ | ||
"name": "dhcp", | ||
"title": "dhcp", | ||
"version": "0.2.5", | ||
"version": "0.2.6", | ||
"homepage": "https://github.com/infusion/node-dhcp", | ||
@@ -39,3 +39,3 @@ "bugs": { | ||
"dhcp": "./bin/dhcp-cli.js", | ||
"dhcpd": "./bin/dhcp-cli.js" | ||
"dhcpd": "./bin/dhcpd-cli.js" | ||
}, | ||
@@ -42,0 +42,0 @@ "engines": { |
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
72774
17
2080