mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
Merge pull request #138 from d4rr3ll/master
Username and password server credentials. Thanks @d4rr3ll
This commit is contained in:
commit
a0ff123673
@ -92,6 +92,10 @@
|
|||||||
ircserver: {type:"irc-server", required:true},
|
ircserver: {type:"irc-server", required:true},
|
||||||
channel: {value:"",required:true,validate:RED.validators.regex(/^#/)}
|
channel: {value:"",required:true,validate:RED.validators.regex(/^#/)}
|
||||||
},
|
},
|
||||||
|
credentials: {
|
||||||
|
username: {type:"text"},
|
||||||
|
password: {type:"password"}
|
||||||
|
},
|
||||||
color:"Silver",
|
color:"Silver",
|
||||||
inputs:0,
|
inputs:0,
|
||||||
outputs:2,
|
outputs:2,
|
||||||
@ -200,6 +204,14 @@
|
|||||||
<label for="node-config-input-nickname"><i class="fa fa-user"></i> <span data-i18n="irc.label.nickname"></span></label>
|
<label for="node-config-input-nickname"><i class="fa fa-user"></i> <span data-i18n="irc.label.nickname"></span></label>
|
||||||
<input type="text" id="node-config-input-nickname">
|
<input type="text" id="node-config-input-nickname">
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-row">
|
||||||
|
<label for="node-config-input-username"><i class="fa fa-user"></i> <span data-i18n="irc.label.username"></span></label>
|
||||||
|
<input type="text" id="node-config-input-username">
|
||||||
|
</div>
|
||||||
|
<div class="form-row">
|
||||||
|
<label for="node-config-input-password"><i class="fa fa-lock"></i> <span data-i18n="irc.label.password"></span></label>
|
||||||
|
<input type="text" id="node-config-input-password">
|
||||||
|
</div>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
@ -212,6 +224,10 @@
|
|||||||
cert: {value:false},
|
cert: {value:false},
|
||||||
nickname: {value:"",required:true}
|
nickname: {value:"",required:true}
|
||||||
},
|
},
|
||||||
|
credentials: {
|
||||||
|
username: {type:"text"},
|
||||||
|
password: {type:"password"}
|
||||||
|
},
|
||||||
label: function() {
|
label: function() {
|
||||||
return this.server;
|
return this.server;
|
||||||
},
|
},
|
||||||
|
@ -18,6 +18,7 @@ module.exports = function(RED) {
|
|||||||
"use strict";
|
"use strict";
|
||||||
var irc = require("irc");
|
var irc = require("irc");
|
||||||
|
|
||||||
|
|
||||||
// The Server Definition - this opens (and closes) the connection
|
// The Server Definition - this opens (and closes) the connection
|
||||||
function IRCServerNode(n) {
|
function IRCServerNode(n) {
|
||||||
RED.nodes.createNode(this,n);
|
RED.nodes.createNode(this,n);
|
||||||
@ -35,8 +36,23 @@ module.exports = function(RED) {
|
|||||||
this.ircclient.disconnect();
|
this.ircclient.disconnect();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.username = null;
|
||||||
|
this.password = null;
|
||||||
|
if (this.credentials && this.credentials.hasOwnProperty("username")) {
|
||||||
|
this.username = this.credentials.username;
|
||||||
}
|
}
|
||||||
RED.nodes.registerType("irc-server",IRCServerNode);
|
if (this.credentials && this.credentials.hasOwnProperty("password")) {
|
||||||
|
this.password = this.credentials.password;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
RED.nodes.registerType("irc-server",IRCServerNode, {
|
||||||
|
credentials: {
|
||||||
|
username: {type:"text"},
|
||||||
|
password: {type:"password"}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
// The Input Node
|
// The Input Node
|
||||||
@ -47,9 +63,11 @@ module.exports = function(RED) {
|
|||||||
this.channel = n.channel || this.serverConfig.channel;
|
this.channel = n.channel || this.serverConfig.channel;
|
||||||
var node = this;
|
var node = this;
|
||||||
if (node.serverConfig.ircclient === null) {
|
if (node.serverConfig.ircclient === null) {
|
||||||
node.log(RED._("irc.errors.connect")+": "+node.serverConfig.server);
|
node.log(RED._("irc.errors.connect")+": "+node.serverConfig.server+" "+node.serverConfig.username+" "+node.serverConfig.ssl);
|
||||||
node.status({fill:"grey",shape:"dot",text:"node-red:common.status.connecting"});
|
node.status({fill:"grey",shape:"dot",text:"node-red:common.status.connecting"});
|
||||||
var options = {autoConnect:true,autoRejoin:false,floodProtection:true,secure:node.serverConfig.ssl,selfSigned:node.serverConfig.cert,port:node.serverConfig.port,retryDelay:20000};
|
var options = {autoConnect:true,autoRejoin:false,floodProtection:true,secure:node.serverConfig.ssl,selfSigned:node.serverConfig.cert,port:node.serverConfig.port,retryDelay:20000};
|
||||||
|
if (node.serverConfig.username !== null) { options["userName"] = node.serverConfig.username }
|
||||||
|
if (node.serverConfig.password !== null) { options["password"] = node.serverConfig.password }
|
||||||
node.serverConfig.ircclient = new irc.Client(node.serverConfig.server, node.serverConfig.nickname, options);
|
node.serverConfig.ircclient = new irc.Client(node.serverConfig.server, node.serverConfig.nickname, options);
|
||||||
node.serverConfig.ircclient.setMaxListeners(0);
|
node.serverConfig.ircclient.setMaxListeners(0);
|
||||||
node.serverConfig.ircclient.addListener('error', function(message) {
|
node.serverConfig.ircclient.addListener('error', function(message) {
|
||||||
@ -185,6 +203,8 @@ module.exports = function(RED) {
|
|||||||
node.log(RED._("irc.errors.connect")+": "+node.serverConfig.server);
|
node.log(RED._("irc.errors.connect")+": "+node.serverConfig.server);
|
||||||
node.status({fill:"grey",shape:"dot",text:"node-red:common.status.connecting"});
|
node.status({fill:"grey",shape:"dot",text:"node-red:common.status.connecting"});
|
||||||
var options = {autoConnect:true,autoRejoin:false,floodProtection:true,secure:node.serverConfig.ssl,selfSigned:node.serverConfig.cert,port:node.serverConfig.port,retryDelay:20000};
|
var options = {autoConnect:true,autoRejoin:false,floodProtection:true,secure:node.serverConfig.ssl,selfSigned:node.serverConfig.cert,port:node.serverConfig.port,retryDelay:20000};
|
||||||
|
if (node.serverConfig.username !== null) { options['userName'] = node.serverConfig.username }
|
||||||
|
if (node.serverConfig.password !== null) { options['password'] = node.serverConfig.password }
|
||||||
node.serverConfig.ircclient = new irc.Client(node.serverConfig.server, node.serverConfig.nickname, options);
|
node.serverConfig.ircclient = new irc.Client(node.serverConfig.server, node.serverConfig.nickname, options);
|
||||||
node.serverConfig.ircclient.setMaxListeners(0);
|
node.serverConfig.ircclient.setMaxListeners(0);
|
||||||
node.serverConfig.ircclient.addListener('error', function(message) {
|
node.serverConfig.ircclient.addListener('error', function(message) {
|
||||||
|
@ -7,7 +7,9 @@
|
|||||||
"port": "Port",
|
"port": "Port",
|
||||||
"ssl": "Use Secure SSL connection?",
|
"ssl": "Use Secure SSL connection?",
|
||||||
"self": "Allow self-signed certificates?",
|
"self": "Allow self-signed certificates?",
|
||||||
"nickname": "Nickname"
|
"nickname": "Nickname",
|
||||||
|
"username": "Server username",
|
||||||
|
"password": "Server password"
|
||||||
},
|
},
|
||||||
"payload": "Send payload to channel(s)",
|
"payload": "Send payload to channel(s)",
|
||||||
"topic": "Use msg.topic to set nickname or channel(s)",
|
"topic": "Use msg.topic to set nickname or channel(s)",
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"name" : "node-red-node-irc",
|
"name" : "node-red-node-irc",
|
||||||
"version" : "0.0.3",
|
"version" : "0.0.4",
|
||||||
"description" : "A Node-RED node to talk to an IRC server",
|
"description" : "A Node-RED node to talk to an IRC server",
|
||||||
"dependencies" : {
|
"dependencies" : {
|
||||||
"irc" : "0.3.11"
|
"irc" : "~0.4.0"
|
||||||
},
|
},
|
||||||
"repository" : {
|
"repository" : {
|
||||||
"type":"git",
|
"type":"git",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user