linux-device
Advanced tools
Comparing version 1.0.8 to 1.0.9
10
index.js
"use strict"; | ||
var DeviceHandle = require('bindings')('DeviceHandle'); | ||
exports = module.exports = DeviceHandle.DeviceHandle; | ||
if(process.env.DEVICE_DEBUG_SERVER) { | ||
let DeviceHandle = require('./remote/client')(process.env.DEVICE_DEBUG_SERVER); | ||
exports = module.exports = DeviceHandle; | ||
} else { | ||
let DeviceHandle = require('./lib/DeviceHandle'); | ||
exports = module.exports = DeviceHandle; | ||
} |
{ | ||
"name": "linux-device", | ||
"version": "1.0.8", | ||
"version": "1.0.9", | ||
"description": "Native addon to communicate with linux devices (can also be used for sockets or FIFOs)", | ||
@@ -31,2 +31,3 @@ "main": "index.js", | ||
}, | ||
"bin": "./bin/remote-device-server", | ||
"homepage": "https://github.com/athombv/node-linux-device#readme", | ||
@@ -36,4 +37,6 @@ "dependencies": { | ||
"nan": "^2.1.0", | ||
"node-gyp": "^3.2.1" | ||
"node-gyp": "^3.2.1", | ||
"socket.io": "1.7.2", | ||
"socket.io-client": "1.7.2" | ||
} | ||
} |
@@ -1,27 +0,58 @@ | ||
const net = require('net'); | ||
"use strict"; | ||
const io = require('socket.io-client'); | ||
const metadata = require('./metadata.json'); | ||
const debugData = { | ||
host: 'localhost', | ||
port: 1337, | ||
debug: true | ||
let server; | ||
let handles = {}; | ||
class DeviceHandleProxy { | ||
constructor(path) { | ||
let args = Array.prototype.slice.apply(arguments); | ||
handles[path] = args.pop(); | ||
this._path = path; | ||
args.unshift('create_handle'); | ||
server.then(serv => serv.emit.apply(serv, args)); | ||
} | ||
} | ||
module.exports = function(url) { | ||
server = new Promise((resolve, reject) => { | ||
let serv = io.connect(url); | ||
serv.on('connect', () => resolve(serv)); | ||
serv.on('connect_error', () => reject()); | ||
serv.on('connect_timeout', () => reject()); | ||
class DeviceHandleProxy { | ||
constructor() { | ||
let args = Array.splice(arguments); | ||
this._opts = debugData; | ||
this._cb = args.pop(); | ||
this._client = net.createConnection(debugData.port, debugData.host); | ||
this._client.once('connect', () => { | ||
this._connected = true; | ||
if(this._opts.debug) console.log('connected'); | ||
this._invoke('constructor', args, this._cb); | ||
serv.on('read_error', function(path, err) { | ||
if(handles[path]) handles[path](err); | ||
}); | ||
this._client.once('error', ()) | ||
} | ||
_invoke(func, args, cb) { | ||
serv.on('read_data', (path, data) => { | ||
if(handles[path]) handles[path](null, data); | ||
}); | ||
} | ||
serv.on('server_error', (error) => { | ||
console.error('[linux-device] An remote error occured:', error); | ||
}); | ||
} | ||
serv.on('connect', () => console.log('REMOTE DEVICE SUPPORT ENABLED, CONNECTED TO:', url)); | ||
serv.on('disconnect', () => { | ||
Object.keys(handles).forEach((handle) => { | ||
handles[handle](new Error('Remote Connection unexpectedly closed.')); | ||
}); | ||
}); | ||
}); | ||
metadata.functions.forEach((func) => { | ||
DeviceHandleProxy.prototype[func] = function() { | ||
server.then(serv => serv.emit.bind(serv, func, this._path).apply(null, arguments)); | ||
}; | ||
}); | ||
metadata.constants.forEach((c, index) => { | ||
DeviceHandleProxy[c] = c; | ||
}); | ||
return DeviceHandleProxy; | ||
}; |
Sorry, the diff of this file is not supported yet
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
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
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
22406
13
125
1
5
4
+ Addedsocket.io@1.7.2
+ Addedsocket.io-client@1.7.2
+ Addedaccepts@1.3.3(transitive)
+ Addedafter@0.8.2(transitive)
+ Addedarraybuffer.slice@0.0.6(transitive)
+ Addedbacko2@1.0.2(transitive)
+ Addedbase64-arraybuffer@0.1.5(transitive)
+ Addedbase64id@1.0.0(transitive)
+ Addedbetter-assert@1.0.2(transitive)
+ Addedblob@0.0.4(transitive)
+ Addedcallsite@1.0.0(transitive)
+ Addedcomponent-bind@1.0.0(transitive)
+ Addedcomponent-emitter@1.1.21.2.1(transitive)
+ Addedcomponent-inherit@0.0.3(transitive)
+ Addedcookie@0.3.1(transitive)
+ Addeddebug@2.2.02.3.3(transitive)
+ Addedengine.io@1.8.2(transitive)
+ Addedengine.io-client@1.8.2(transitive)
+ Addedengine.io-parser@1.3.2(transitive)
+ Addedhas-binary@0.1.7(transitive)
+ Addedhas-cors@1.1.0(transitive)
+ Addedindexof@0.0.1(transitive)
+ Addedisarray@0.0.1(transitive)
+ Addedjson3@3.3.2(transitive)
+ Addedms@0.7.10.7.2(transitive)
+ Addednegotiator@0.6.1(transitive)
+ Addedobject-assign@4.1.0(transitive)
+ Addedobject-component@0.0.3(transitive)
+ Addedoptions@0.0.6(transitive)
+ Addedparsejson@0.0.3(transitive)
+ Addedparseqs@0.0.5(transitive)
+ Addedparseuri@0.0.5(transitive)
+ Addedsocket.io@1.7.2(transitive)
+ Addedsocket.io-adapter@0.5.0(transitive)
+ Addedsocket.io-client@1.7.2(transitive)
+ Addedsocket.io-parser@2.3.1(transitive)
+ Addedto-array@0.1.4(transitive)
+ Addedultron@1.0.2(transitive)
+ Addedws@1.1.1(transitive)
+ Addedwtf-8@1.0.0(transitive)
+ Addedxmlhttprequest-ssl@1.5.3(transitive)
+ Addedyeast@0.1.2(transitive)