-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontrol-vpn.js
More file actions
34 lines (29 loc) · 1.06 KB
/
control-vpn.js
File metadata and controls
34 lines (29 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
module.exports = function(RED) {
function controlVPNNode(config) {
RED.nodes.createNode(this,config);
var node = this;
this.router = RED.nodes.getNode(config.router).router;
if (this.router){
this.on('input', function(msg, send, done) {
node.router.controlVPN(msg.payload.type,msg.payload.index,msg.payload.state).then((res)=>{
node.status({fill:"green",shape:"dot"});
msg.payload = res;
send(msg);
if (done) {
done();
}
})
.catch((err)=>{
node.status({fill:"red",shape:"ring",text:err.message});
node.error(err);
if (done){
done();
}
})
});
}else{
this.error('No router configuration provided');
}
}
RED.nodes.registerType("control-vpn",controlVPNNode);
}