Skip to content

Commit

Permalink
Merge pull request #88 from appcelerator/timob-16747_3_2_X
Browse files Browse the repository at this point in the history
[TIMOB-16747] Fixed bug where 'ipconfig /all' output was incorrectly bei...
  • Loading branch information
ayeung committed Mar 27, 2014
2 parents 1d5ddaf + 092856e commit bff7075
Showing 1 changed file with 4 additions and 32 deletions.
36 changes: 4 additions & 32 deletions lib/net.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ exports.interfaces = function (callback) {
.replace(/\n\n/g, '\n') // remove double lines
.replace(/[\n][\t ]/g, ' ') // if the next line indents, bring it up a line
.replace(/ /g, '~') // if indented with spaces, mark with ~ so we can match
.replace(/ethernet adapter ([^:]*:)\n/ig, '$1') // on Windows, remove Ethernet adapter
.replace(/ethernet adapter ([^:]*:)/ig, '$1') // on Windows, remove "Ethernet adapter"
.split('\n').forEach(function (line) {
if (line = line.trim()) {
var m = line.match(/([^:~]*).*?((?:[0-9A-F][0-9A-F][:-]){5}[0-9A-F][0-9A-F])/i);
m && m.length > 1 && m[2] && (macs[m[1]] = m[2])
m && m.length > 1 && m[2] && (macs[m[1]] = m[2]);
}
});

Expand All @@ -120,36 +120,8 @@ exports.interfaces = function (callback) {
* @param {Function} callback - The function to call with the result
*/
exports.online = function online(callback) {
exports.interfaces(function (interfaces) {
var done = false,
isOnline = false,
ifaces = Object.keys(interfaces);

async.whilst(
function () {
return !done;
},
function (next) {
var iface = ifaces.shift();
if (!iface) {
done = true;
return next();
}

if (!interfaces[iface].macAddress) {
return next();
}

dns.resolve('api.appcelerator.net', function (err) {
isOnline = !err;
done = true;
next();
});
},
function () {
return callback(null, isOnline);
}
);
dns.resolve('api.appcelerator.net', function (err) {
callback(null, !err);
});
};

Expand Down

0 comments on commit bff7075

Please sign in to comment.