mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Add port, ssl and allow self signed certs to IRC node
This commit is contained in:
parent
be1620dd07
commit
698b2688f6
@ -184,7 +184,19 @@
|
|||||||
<script type="text/x-red" data-template-name="irc-server">
|
<script type="text/x-red" data-template-name="irc-server">
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-config-input-server"><i class="fa fa-globe"></i> IRC Server</label>
|
<label for="node-config-input-server"><i class="fa fa-globe"></i> IRC Server</label>
|
||||||
<input type="text" id="node-config-input-server" placeholder="irc.freenode.net">
|
<input type="text" id="node-config-input-server" placeholder="irc.freenode.net" style="width: 45%;" >
|
||||||
|
<label for="node-config-input-port" style="margin-left: 10px; width: 35px; "> Port</label>
|
||||||
|
<input type="text" id="node-config-input-port" placeholder="Port" style="width:45px">
|
||||||
|
</div>
|
||||||
|
<div class="form-row">
|
||||||
|
<label> </label>
|
||||||
|
<input type="checkbox" id="node-config-input-ssl" style="display: inline-block; width: auto; vertical-align: top;">
|
||||||
|
<label for="node-config-input-ssl" style="width: 70%;">Use Secure SSL connection ?</label>
|
||||||
|
</div>
|
||||||
|
<div class="form-row" id="certrow">
|
||||||
|
<label> </label>
|
||||||
|
<input type="checkbox" id="node-config-input-cert" style="display: inline-block; width: auto; vertical-align: top;">
|
||||||
|
<label for="node-config-input-cert" style="width: 70%;">Allow self-signed certificates ?</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-config-input-nickname"><i class="fa fa-user"></i> Nickname</label>
|
<label for="node-config-input-nickname"><i class="fa fa-user"></i> Nickname</label>
|
||||||
@ -197,10 +209,27 @@
|
|||||||
category: 'config',
|
category: 'config',
|
||||||
defaults: {
|
defaults: {
|
||||||
server: {value:"",required:true},
|
server: {value:"",required:true},
|
||||||
|
port: {value:"6667"},
|
||||||
|
ssl: {value:false},
|
||||||
|
cert: {value:false},
|
||||||
nickname: {value:"",required:true}
|
nickname: {value:"",required:true}
|
||||||
},
|
},
|
||||||
label: function() {
|
label: function() {
|
||||||
return this.server;
|
return this.server;
|
||||||
|
},
|
||||||
|
oneditprepare: function() {
|
||||||
|
$("#node-config-input-ssl").change(function() {
|
||||||
|
if ($("#node-config-input-ssl").is(":checked")) {
|
||||||
|
$("#certrow").show();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$("#certrow").hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
oneditsave: function() {
|
||||||
|
this.ssl = $("#node-config-input-ssl").is(":checked");
|
||||||
|
this.cert = $("#node-config-input-cert").is(":checked");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@ -22,6 +22,9 @@ module.exports = function(RED) {
|
|||||||
function IRCServerNode(n) {
|
function IRCServerNode(n) {
|
||||||
RED.nodes.createNode(this,n);
|
RED.nodes.createNode(this,n);
|
||||||
this.server = n.server;
|
this.server = n.server;
|
||||||
|
this.port = n.port || 6667;
|
||||||
|
this.ssl = n.ssl || false;
|
||||||
|
this.cert = n.cert || false;
|
||||||
this.channel = n.channel;
|
this.channel = n.channel;
|
||||||
this.nickname = n.nickname;
|
this.nickname = n.nickname;
|
||||||
this.lastseen = 0;
|
this.lastseen = 0;
|
||||||
@ -46,7 +49,8 @@ module.exports = function(RED) {
|
|||||||
if (node.serverConfig.ircclient === null) {
|
if (node.serverConfig.ircclient === null) {
|
||||||
node.log("CONNECT: "+node.serverConfig.server);
|
node.log("CONNECT: "+node.serverConfig.server);
|
||||||
node.status({fill:"grey",shape:"dot",text:"connecting"});
|
node.status({fill:"grey",shape:"dot",text:"connecting"});
|
||||||
node.serverConfig.ircclient = new irc.Client(node.serverConfig.server, node.serverConfig.nickname,{autoConnect:true,autoRejoin:false,floodProtection:true,retryDelay:20000});
|
var options = {autoConnect:true,autoRejoin:false,floodProtection:true,secure:node.serverConfig.ssl,selfSigned:node.serverConfig.cert,port:node.serverConfig.port,retryDelay:20000};
|
||||||
|
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) {
|
||||||
if (RED.settings.verbose) { node.log("ERR: "+JSON.stringify(message)); }
|
if (RED.settings.verbose) { node.log("ERR: "+JSON.stringify(message)); }
|
||||||
@ -180,7 +184,8 @@ module.exports = function(RED) {
|
|||||||
if (node.serverConfig.ircclient === null) {
|
if (node.serverConfig.ircclient === null) {
|
||||||
node.log("CONNECT: "+node.serverConfig.server);
|
node.log("CONNECT: "+node.serverConfig.server);
|
||||||
node.status({fill:"grey",shape:"dot",text:"connecting"});
|
node.status({fill:"grey",shape:"dot",text:"connecting"});
|
||||||
node.serverConfig.ircclient = new irc.Client(node.serverConfig.server, node.serverConfig.nickname,{autoConnect:true,autoRejoin:false,floodProtection:true,retryDelay:20000});
|
var options = {autoConnect:true,autoRejoin:false,floodProtection:true,secure:node.serverConfig.ssl,selfSigned:node.serverConfig.cert,port:node.serverConfig.port,retryDelay:20000};
|
||||||
|
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) {
|
||||||
if (RED.settings.verbose) { node.log("ERR: "+JSON.stringify(message)); }
|
if (RED.settings.verbose) { node.log("ERR: "+JSON.stringify(message)); }
|
||||||
|
Loading…
Reference in New Issue
Block a user