From 41f397add77739331ed1a5bc5708ecd805daa406 Mon Sep 17 00:00:00 2001 From: Darrell Taylor Date: Fri, 30 Oct 2015 18:34:35 +0000 Subject: [PATCH] =?UTF-8?q?moved=20username=20and=20password=20into=20cred?= =?UTF-8?q?entials,=20and=20upped=20the=20version=20of=20irc=20as=20ssl=20?= =?UTF-8?q?didn=E2=80=99t=20work=20with=20the=20older=20version.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- social/irc/91-irc.html | 8 +++++--- social/irc/91-irc.js | 24 +++++++++++++++++++----- social/irc/locales/en-US/91-irc.json | 6 ++++-- social/irc/package.json | 2 +- 4 files changed, 29 insertions(+), 11 deletions(-) diff --git a/social/irc/91-irc.html b/social/irc/91-irc.html index 6260a0f7..9dc209d3 100644 --- a/social/irc/91-irc.html +++ b/social/irc/91-irc.html @@ -92,6 +92,10 @@ ircserver: {type:"irc-server", required:true}, channel: {value:"",required:true,validate:RED.validators.regex(/^#/)} }, + credentials: { + username: {type:"text"}, + password: {type:"password"} + }, color:"Silver", inputs:0, outputs:2, @@ -218,9 +222,7 @@ port: {value:"6667"}, ssl: {value:false}, cert: {value:false}, - nickname: {value:"",required:true}, - username: {value:""}, - password: {value:""} + nickname: {value:"",required:true} }, credentials: { username: {type:"text"}, diff --git a/social/irc/91-irc.js b/social/irc/91-irc.js index 1993aece..2fb6f617 100644 --- a/social/irc/91-irc.js +++ b/social/irc/91-irc.js @@ -18,6 +18,7 @@ module.exports = function(RED) { "use strict"; var irc = require("irc"); + // The Server Definition - this opens (and closes) the connection function IRCServerNode(n) { RED.nodes.createNode(this,n); @@ -27,8 +28,6 @@ module.exports = function(RED) { this.cert = n.cert || false; this.channel = n.channel; this.nickname = n.nickname; - this.username = n.username; - this.password = n.password; this.lastseen = 0; this.ircclient = null; this.on("close", function() { @@ -37,8 +36,23 @@ module.exports = function(RED) { this.ircclient.disconnect(); } }); + + this.username = null; + this.password = null; + if (this.credentials && this.credentials.hasOwnProperty("username")) { + this.username = this.credentials.username; + } + if (this.credentials && this.credentials.hasOwnProperty("password")) { + this.password = this.credentials.password; + } + } - RED.nodes.registerType("irc-server",IRCServerNode); + RED.nodes.registerType("irc-server",IRCServerNode, { + credentials: { + username: {type:"text"}, + password: {type:"password"} + } + }); // The Input Node @@ -49,7 +63,7 @@ module.exports = function(RED) { this.channel = n.channel || this.serverConfig.channel; var node = this; 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"}); var options = {autoConnect:true,autoRejoin:false,floodProtection:true,secure:node.serverConfig.ssl,selfSigned:node.serverConfig.cert,port:node.serverConfig.port,retryDelay:20000,userName:node.serverConfig.username,password:node.serverConfig.password}; node.serverConfig.ircclient = new irc.Client(node.serverConfig.server, node.serverConfig.nickname, options); @@ -186,7 +200,7 @@ module.exports = function(RED) { if (node.serverConfig.ircclient === null) { node.log(RED._("irc.errors.connect")+": "+node.serverConfig.server); 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,userName:node.serverConfig.username,password:node.serverConfig.password}; + var options = {autoConnect:true,autoRejoin:false,floodProtection:true,secure:node.serverConfig.ssl,selfSigned:node.serverConfig.cert,port:node.serverConfig.port,retryDelay:20000,userName:node.username,password:node.password}; node.serverConfig.ircclient = new irc.Client(node.serverConfig.server, node.serverConfig.nickname, options); node.serverConfig.ircclient.setMaxListeners(0); node.serverConfig.ircclient.addListener('error', function(message) { diff --git a/social/irc/locales/en-US/91-irc.json b/social/irc/locales/en-US/91-irc.json index 233df59f..c935f2e2 100644 --- a/social/irc/locales/en-US/91-irc.json +++ b/social/irc/locales/en-US/91-irc.json @@ -7,7 +7,9 @@ "port": "Port", "ssl": "Use Secure SSL connection?", "self": "Allow self-signed certificates?", - "nickname": "Nickname" + "nickname": "Nickname", + "username": "Server username", + "password": "Server password" }, "payload": "Send payload to channel(s)", "topic": "Use msg.topic to set nickname or channel(s)", @@ -36,4 +38,4 @@ "topicnotset": "msg.topic not set" } } -} \ No newline at end of file +} diff --git a/social/irc/package.json b/social/irc/package.json index 7b82763d..fc1d6f41 100644 --- a/social/irc/package.json +++ b/social/irc/package.json @@ -3,7 +3,7 @@ "version" : "0.0.3", "description" : "A Node-RED node to talk to an IRC server", "dependencies" : { - "irc" : "0.3.11" + "irc" : "~0.4.0" }, "repository" : { "type":"git",