node-red-contrib-mikrotik
Advanced tools
Comparing version 0.2.2 to 0.3.1
/** | ||
* Created by Bladerunner on 11/03/16. | ||
*/ | ||
var mikrotik = require('mikronode-ng'); | ||
var mikrotik = require('mikronode-ng2'); | ||
@@ -11,8 +11,18 @@ module.exports = function(RED) { | ||
this.port = n.port; | ||
this.username = n.username; | ||
this.password = n.password; | ||
if ((!this.credentials) || (!this.credentials.secusername)) { | ||
// take care the even non "converted" credentials that | ||
// are still unsafe stored, can be used. | ||
this.credentials = { | ||
secusername: n.username, | ||
secpassword: n.password | ||
} | ||
} | ||
} | ||
RED.nodes.registerType("mikrotik-device", NodeMikrotikDevice); | ||
RED.nodes.registerType("mikrotik-device", NodeMikrotikDevice,{ | ||
credentials: { | ||
secusername: { type: "text" }, | ||
secpassword: { type: "password" } | ||
} | ||
}); | ||
function NodeMikrotik(config) { | ||
@@ -29,3 +39,7 @@ RED.nodes.createNode(this,config); | ||
var password = this.device.password; | ||
if (!!this.device.credentials) { | ||
username= this.device.credentials.secusername; | ||
password = this.device.credentials.secpassword; | ||
} | ||
var command; | ||
@@ -54,14 +68,10 @@ | ||
this.on('input', function(msg) { | ||
var cmd = command; | ||
if (command == '') cmd = msg.payload; | ||
if (cmd == '') return false; | ||
if (cmd.command) cmd = cmd.command; | ||
if (command == '') command = msg.payload; | ||
if(command == '') return false; | ||
connection = mikrotik.getConnection(host, username, password, {closeOnDone : true, port: port}); | ||
connection.getConnectPromise().then(function(conn) { | ||
conn.getCommandPromise(cmd).then(function resolved(values) { | ||
conn.getCommandPromise(command).then(function resolved(values) { | ||
var parsed = mikrotik.parseItems(values); | ||
@@ -74,7 +84,8 @@ var pl = []; | ||
msg.command = cmd; | ||
msg.command = command; | ||
msg.success = true; | ||
node.send(msg); | ||
}, function rejected(reason) { | ||
node.error('Error executing cmd['+cmd+']: ' + JSON.stringify(reason)); | ||
node.error('Error executing cmd['+command+']: ' + JSON.stringify(reason)); | ||
}); | ||
@@ -81,0 +92,0 @@ }, |
{ | ||
"name": "node-red-contrib-mikrotik", | ||
"version": "0.2.2", | ||
"version": "0.3.1", | ||
"description": "Node based on node-red-contrib-mikrotik to work with Mikrotik devices which fixes device configuration problem", | ||
@@ -14,2 +14,11 @@ "scripts": { | ||
"url": "https://www.freevision.sk" | ||
}, | ||
{ | ||
"name": "Nikola 0nikola1", | ||
"email": "n@bobetic.com", | ||
"url": "https://github.com/0nikola1" | ||
}, | ||
{ | ||
"name": "Konrad Mattheis", | ||
"url": "https://github.com/konne" | ||
} | ||
@@ -23,7 +32,8 @@ ], | ||
"keywords": [ | ||
"node-red" | ||
"node-red", | ||
"mikrotik" | ||
], | ||
"license": "ISC", | ||
"dependencies": { | ||
"mikronode-ng": "^1.0.5" | ||
"mikronode-ng2": "^1.0.12" | ||
}, | ||
@@ -34,8 +44,8 @@ "main": "mikrotik.js", | ||
"type": "git", | ||
"url": "git+https://github.com/alhafoudh/node-red-contrib-mikrotik.git" | ||
"url": "git+https://github.com/node-red-contrib/node-red-contrib-mikrotik.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/alhafoudh/node-red-contrib-mikrotik/issues" | ||
"url": "https://github.com/node-red-contrib/node-red-contrib-mikrotik/issues" | ||
}, | ||
"homepage": "https://github.com/alhafoudh/node-red-contrib-mikrotik#readme" | ||
"homepage": "https://github.com/node-red-contrib/node-red-contrib-mikrotik#readme" | ||
} |
@@ -1,18 +0,42 @@ | ||
node-red-contrib-mikrotik | ||
========================== | ||
Node based on node-red-contrib-mikrotik to work with Mikrotik devices which fixes device configuration problem. | ||
[](https://cla-assistant.io/node-red-contrib/node-red-contrib-mikrotik) | ||
 | ||
[](https://www.codefactor.io/repository/github/node-red-contrib/node-red-contrib-mikrotik) | ||
[](https://badge.fury.io/js/node-red-contrib-mikrotik) | ||
# node-red-contrib-mikrotik a mikrotik node for Node-RED | ||
Install | ||
------- | ||
Run command on Node-RED installation directory | ||
## Install | ||
[](https://nodei.co/npm/node-red-contrib-mikrotik/) | ||
npm install node-red-contrib-mikrotik | ||
Config | ||
------- | ||
Install via the palette manage in the Node-RED admin ui (no restart needed). | ||
<p>A <a href="http://nodered.org" target="_new">Node-RED</a> node that provides API for Mikrotik WiFi routers.</p> | ||
This is an alfa verion. Available actions: log, resources, wifi, connections, reboot, raw. | ||
Alternatively run the following command in your Node-RED user directory (typically `~/.node-red`): | ||
```sh | ||
npm install node-red-contrib-mikrotik | ||
``` | ||
then restart Node-RED and add an instance of the mikrotik node. | ||
# Config | ||
Available actions: | ||
- ***log*** | ||
- ***resources*** | ||
- ***wifi*** | ||
- ***connections*** | ||
- ***reboot*** | ||
- ***raw*** | ||
## Usage | ||
### Basic | ||
TBD | ||
----- | ||
### RAW | ||
For the usage of the RAW mode there are [here](docs/example-flows.md) some examples. |
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
43
11315
5
86
1
+ Addedmikronode-ng2@^1.0.12
+ Addedmikronode-ng2@1.0.12(transitive)
- Removedmikronode-ng@^1.0.5
- Removedmikronode-ng@1.0.11(transitive)