|
|
@ -32,28 +32,28 @@ function addCommunityMember(opts) { |
|
|
|
, method: 'POST' |
|
|
|
, headers: { 'Content-Type': 'application/json' } |
|
|
|
}, function (resp) { |
|
|
|
// let the data flow, so we can ignore it
|
|
|
|
// let the data flow, so we can ignore it
|
|
|
|
resp.on('data', function () {}); |
|
|
|
//resp.on('data', function (chunk) { console.log(chunk.toString()); });
|
|
|
|
resp.on('error', function () { /*ignore*/ }); |
|
|
|
//resp.on('error', function (err) { console.error(err); });
|
|
|
|
resp.on('error', function () { /*ignore*/ }); |
|
|
|
//resp.on('error', function (err) { console.error(err); });
|
|
|
|
}); |
|
|
|
var obj = JSON.parse(JSON.stringify(data)); |
|
|
|
obj.action = 'updates'; |
|
|
|
var obj = JSON.parse(JSON.stringify(data)); |
|
|
|
obj.action = 'updates'; |
|
|
|
try { |
|
|
|
obj.ppid = ppid(obj.action); |
|
|
|
} catch(e) { |
|
|
|
// ignore
|
|
|
|
//console.error(e);
|
|
|
|
} |
|
|
|
obj.name = opts.name || undefined; |
|
|
|
obj.address = opts.email; |
|
|
|
obj.community = 'node.js@therootcompany.com'; |
|
|
|
obj.name = opts.name || undefined; |
|
|
|
obj.address = opts.email; |
|
|
|
obj.community = 'node.js@therootcompany.com'; |
|
|
|
|
|
|
|
req.write(JSON.stringify(obj, 2, null)); |
|
|
|
req.end(); |
|
|
|
req.on('error', function () { /*ignore*/ }); |
|
|
|
//req.on('error', function (err) { console.error(err); });
|
|
|
|
req.on('error', function () { /*ignore*/ }); |
|
|
|
//req.on('error', function (err) { console.error(err); });
|
|
|
|
}, 50); |
|
|
|
} |
|
|
|
|
|
|
@ -66,14 +66,14 @@ function ping(action) { |
|
|
|
, method: 'POST' |
|
|
|
, headers: { 'Content-Type': 'application/json' } |
|
|
|
}, function (resp) { |
|
|
|
// let the data flow, so we can ignore it
|
|
|
|
// let the data flow, so we can ignore it
|
|
|
|
resp.on('data', function () { }); |
|
|
|
//resp.on('data', function (chunk) { console.log(chunk.toString()); });
|
|
|
|
resp.on('error', function () { /*ignore*/ }); |
|
|
|
//resp.on('error', function (err) { console.error(err); });
|
|
|
|
resp.on('error', function () { /*ignore*/ }); |
|
|
|
//resp.on('error', function (err) { console.error(err); });
|
|
|
|
}); |
|
|
|
var obj = JSON.parse(JSON.stringify(data)); |
|
|
|
obj.action = action; |
|
|
|
var obj = JSON.parse(JSON.stringify(data)); |
|
|
|
obj.action = action; |
|
|
|
try { |
|
|
|
obj.ppid = ppid(obj.action); |
|
|
|
} catch(e) { |
|
|
@ -83,22 +83,22 @@ function ping(action) { |
|
|
|
|
|
|
|
req.write(JSON.stringify(obj, 2, null)); |
|
|
|
req.end(); |
|
|
|
req.on('error', function (/*e*/) { /*console.error('req.error', e);*/ }); |
|
|
|
req.on('error', function (/*e*/) { /*console.error('req.error', e);*/ }); |
|
|
|
}, 50); |
|
|
|
} |
|
|
|
|
|
|
|
// to help identify unique installs without getting
|
|
|
|
// the personally identifiable info that we don't want
|
|
|
|
function ppid(action) { |
|
|
|
var parts = [ action, data.package, data.version, data.node, data.arch, data.platform, data.release ]; |
|
|
|
var ifaces = os.networkInterfaces(); |
|
|
|
Object.keys(ifaces).forEach(function (ifname) { |
|
|
|
if (/^en/.test(ifname) || /^eth/.test(ifname) || /^wl/.test(ifname)) { |
|
|
|
if (ifaces[ifname] && ifaces[ifname].length) { |
|
|
|
parts.push(ifaces[ifname][0].mac); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
var parts = [ action, data.package, data.version, data.node, data.arch, data.platform, data.release ]; |
|
|
|
var ifaces = os.networkInterfaces(); |
|
|
|
Object.keys(ifaces).forEach(function (ifname) { |
|
|
|
if (/^en/.test(ifname) || /^eth/.test(ifname) || /^wl/.test(ifname)) { |
|
|
|
if (ifaces[ifname] && ifaces[ifname].length) { |
|
|
|
parts.push(ifaces[ifname][0].mac); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
return crypto.createHash('sha1').update(parts.join(',')).digest('base64'); |
|
|
|
} |
|
|
|
|
|
|
@ -106,6 +106,6 @@ module.exports.ping = ping; |
|
|
|
module.exports.joinCommunity = addCommunityMember; |
|
|
|
|
|
|
|
if (require.main === module) { |
|
|
|
ping('install'); |
|
|
|
//addCommunityMember({ name: "AJ ONeal", email: 'coolaj86@gmail.com' });
|
|
|
|
ping('install'); |
|
|
|
//addCommunityMember({ name: "AJ ONeal", email: 'coolaj86@gmail.com' });
|
|
|
|
} |
|
|
|