Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions ifconfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var child_process = require('child_process');
*
*/
var ifconfig = module.exports = {
exec: child_process.exec,
exec: child_process.execFile,
status: status,
down: down,
up: up
Expand Down Expand Up @@ -188,11 +188,16 @@ function parse_status_interface(callback) {
*
*/
function status(interface, callback) {
var cmd = "";
if (callback) {
this.exec('ifconfig ' + interface, parse_status_interface(callback));
cmd = 'ifconfig ' + interface;
cmd = cmd.split(' ');
this.exec(cmd[0], cmd.slice(1), parse_status_interface(callback));
}
else {
this.exec('ifconfig -a', parse_status(interface));
cmd = 'ifconfig -a';
cmd = cmd.split(' ');
this.exec(cmd[0], cmd.slice(1), parse_status(interface));
}
}

Expand All @@ -214,7 +219,9 @@ function status(interface, callback) {
*
*/
function down(interface, callback) {
return this.exec('ifconfig ' + interface + ' down', callback);
var cmd = 'ifconfig ' + interface + ' down';
cmd = cmd.split(' ');
return this.exec(cmd[0], cmd.slice(1), callback);
}

/**
Expand All @@ -241,9 +248,11 @@ function down(interface, callback) {
*
*/
function up(options, callback) {
return this.exec('ifconfig ' + options.interface +
' ' + options.ipv4_address +
' netmask ' + options.ipv4_subnet_mask +
' broadcast ' + options.ipv4_broadcast +
' up', callback);
var cmd = 'ifconfig ' + options.interface +
' ' + options.ipv4_address +
' netmask ' + options.ipv4_subnet_mask +
' broadcast ' + options.ipv4_broadcast +
' up', callback;
cmd = cmd.split(' ');
return this.exec(cmd[0], cmd.slice(1));
}