Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if ('IPv4' !== iface.family || iface.internal !== false) {
// skip over internal (i.e. 127.0.0.1) and non-ipv4 addresses
return;
}
if (alias >= 1) {
// this single interface has multiple ipv4 addresses
console.log(ifname + ':' + alias, iface.address);
} else {
// this interface has only one ipv4 adress
console.log(ifname, iface.address);
}
++alias;
});
});
require('getmac').getMac(function(err,macAddress){
if (err) throw err
mac = macAddress;
});
fs.stat('./device_info.json', function(err, stat) {
if(err == null) {
console.log('found device_info.json');
var device_info = require("./device_info.json");
device_info = JSON.parse(device_info);
for(var i = 0; i < device_info.length; i++) {
mac = device_info[i].mac;
token = device_info[i].token;
//io_relay.emit('token',{token:token});
console.log(mac + " | " + token);
}
} else if(err.code == 'ENOENT') {
});
conn.on('close',function(){
me.emit('socketclose');
});
});
}
return this._socket;
}
}
});
var me = this;
// Get the computer's MAC address
require('getmac').getMac(function(err,addr){
if (err) throw err;
me.MAC = addr;
me.computer = addr;
});
// Boot up the socket server
this.socket.listen(336490,function(){
me.emit('socketready');
});
},
var EventEmitter = require("events").EventEmitter;
var body = new EventEmitter();
var d = new Date();
var light_delay = 0; //command delay in ms
var previous_data = 0;
var username = "init";
var device_name = "init";
var mac = "init";
var ip = "init";
var device_port = "init";
// Fetch the computer's mac address
require('getmac').getMac(function(err,macAddress){
if (err) throw err
mac = macAddress;
})
/////////////////////////////////////////
body.on('update', function () {
var token = body.data;
console.log('user '+username+' | token '+token+' | mac '+mac+' | ip '+ip+' | port '+device_port+' | device_name '+ device_name);
/*query = "insert";
connection.query(query, function(err, rows, fields) {
if (err) {
//console.log('table already exist');
} else {
console.log('created gateway_table');
* Indicates whether the bin is shared publicly or not.
* @private
*/
shared: {
enumerable: false,
writable: true,
configurable: false,
value: false
}
});
var me = this;
// Get the computer's MAC address
require('getmac').getMac(function(err,addr){
if (err) throw err;
me.MAC = addr;
me.computer = addr;
// Handle all requests
me.app.head('/ping_fenix',function(req,res){
res.send(200);
return;
});
me.app.all('/*',function(req,res){
if(req.url !== '/fenix_ping'){
me.addRequest({
method: req.method,
headers: req.headers,
body: req.body.replace(/\/gi,'>'),
query: req.query,
function get_mac () {
require('getmac').getMac(function(err,macAddress){
if (err) throw err
mac = macAddress.replace(/:/g,'').replace(/-/g,'').toLowerCase();
var token = crypto.createHash('sha512').update(mac).digest('hex');
console.log("Device ID: " + mac);
module.exports.mac = mac;
});
}
function get_mac () {
require('getmac').getMac(function(err,macAddress){
if (err) throw err
mac = macAddress.replace(/:/g,'').replace(/-/g,'').toLowerCase();
store_settings({mac:mac});
console.log("Enter device ID (" + mac + ") at http://pyfi.org");
var hostapd_file = "interface=wlan0\n"
+ "driver=nl80211\n"
+ "ssid=Gateway " + mac + "\n"
+ "hw_mode=g\n"
+ "channel=6\n"
+ "ieee80211n=1\n"
+ "wmm_enabled=1\n"
+ "ht_capab=[HT40][SHORT-GI-20][DSSS_CCK-40]\n"
+ "macaddr_acl=0\n"
+ "auth_algs=1\n"
+ "ignore_broadcast_ssid=0\n"
+ "wpa=2\n"
wifiManager.status(function(currentStatus) {
var details = device;
var pathToPhoto = routes.currentPhotosFolder;
var imagePath = pathToPhoto + '/lastPhoto.jpg';
details.network = currentStatus;
delete details.deviceToken;
require('getmac').getMac(function(err, macAddress) {
details.deviceId = macAddress;
fileManager.exists(path.root + "public/files/orientation", function(exists) {
if (exists === false) {
fileManager.createParamValueFile({
orientation: 0
}, "orientation");
}
fileManager.readParamValueFile("orientation", function(orientationJson) {
var orientation;
if (!orientationJson || typeof orientationJson.orientation == 'undefined') {
orientation = 0;
} else {
orientation = orientationJson.orientation;
}
registerAnonymousDevice: function(device, client, callback) {
var url = config.url.device.registerAnonymous;
require('getmac').getMac(function(err, macAddress) {
if (err) throw err;
Matrix.activeDevice.deviceId = macAddress;
params = {
device_id: device.getDeviceId(),
client_token: client.getAccessToken(),
name: device.getName(),
description: device.getDescription()
};
request.post({
url: url,
form: params
}, function(error, response, body) {
function encryptAndStore(key,toEncrypt) {
require('getmac').getMac(function (err, macAddress) {
if (err) throw err
secretKey = macAddress;
var CryptoJS = require("crypto-js");
var ciphertext = CryptoJS.AES.encrypt(toEncrypt, secretKey);
settings.set(key, ciphertext.toString());
});
}