Skip to content

Loading…

Ensure port is an integer, away message code moved into IRC class, flood protection #139

Merged
merged 2 commits into from

2 participants

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 24 additions and 17 deletions.
  1. +17 −2 lib/irclink.js
  2. +1 −1 lib/restore.js
  3. +0 −8 lib/socket.js
  4. +6 −6 views/templates.jade
View
19 lib/irclink.js
@@ -17,13 +17,17 @@ var IRCLink = function(hostname, port, ssl, selfSigned, nick, realName, password
else
this.away = away;
+ var pPort = parseInt(port);
+ if (!pPort)
+ pPort = (ssl ? 6697 : 6667);
+
if (channels === undefined || !rejoin)
var channels = new Array();
this.client = new irc.Client(hostname, nick, {
userName: nick,
realName: realName,
- port: port || (ssl ? 6697 : 6667),
+ port: pPort,
debug: false,
showErrors: false,
autoRejoin: true,
@@ -33,7 +37,7 @@ var IRCLink = function(hostname, port, ssl, selfSigned, nick, realName, password
secure: ssl,
selfSigned: selfSigned,
certExpired: false,
- floodProtection: false,
+ floodProtection: true,
floodProtectionDelay: 1000,
stripColors: true
});
@@ -135,12 +139,23 @@ IRCLink.prototype = {
disconnect: function() {
this.client.disconnect();
},
+ setAway: function() {
+ this.client.send('AWAY', this.away);
+ },
addSocket: function(socket) {
+ // set ourselves as not being away
+ if (this.sockets.length == 0)
+ this.client.send('AWAY', '');
+
this.sockets.push(socket);
},
removeSocket: function(socket) {
var index = this.sockets.indexOf(socket);
if (index != -1) this.sockets.splice(index, 1);
+
+ // set ourselves as away
+ if (this.sockets.length == 0)
+ this.client.send('AWAY', this.away);
},
logMessage: function(target, msg) {
if (this.username) {
View
2 lib/restore.js
@@ -15,7 +15,7 @@ module.exports = function (connections) {
connection.associateUser(doc.user);
connections[doc.user] = connection;
// set ourselves as away
- connection.client.send('AWAY', doc.away);
+ connection.setAway();
});
});
}
View
8 lib/socket.js
@@ -83,10 +83,6 @@ module.exports = function(socket, connections) {
socket.emit('restore_connection', {nick: connection.client.nick,
server: connection.client.opt.server, channels: connection.client.chans});
connection.clearUnreads();
-
- // set ourselves as not being away
- if (connection.sockets.length == 0)
- connection.client.send('AWAY', '');
}
// register this socket with our user's IRC connection
@@ -156,10 +152,6 @@ module.exports = function(socket, connections) {
// keep the session alive, remove this socket, and clear unreads
connection.removeSocket(socket);
connection.clearUnreads();
-
- // set ourselves as away
- if (connection.sockets.length == 0)
- connection.client.send('AWAY', connection.away);
}
});
View
12 views/templates.jade
@@ -46,10 +46,6 @@ script(id="overview_connection", type="text/html")
label(for="connect-secure") SSL
.controls
input#connect-secure(type="checkbox")
- .control-group
- label(for="connect-rejoin") Bouncer Mode
- .controls
- input#connect-rejoin(type="checkbox")
.control-group#ssl-self-signed
label(for="connect-selfSigned") Self-signed SSL Cert
.controls
@@ -59,6 +55,10 @@ script(id="overview_connection", type="text/html")
.controls
input#connect-nick(type="text")
.control-group
+ label(for="connect-password") Password (optional)
+ .controls
+ input#connect-password(type="password")
+ .control-group
label(for="connect-realName") Real Name
.controls
input#connect-realName(type="text")
@@ -67,9 +67,9 @@ script(id="overview_connection", type="text/html")
.controls
input#connect-away(type="text", placeholder="AFK")
.control-group
- label(for="connect-password") Password
+ label(for="connect-rejoin") Bouncer Mode
.controls
- input#connect-password(type="password")
+ input#connect-rejoin(type="checkbox")
a(id="connect-button", class="btn btn-primary", type="button") Connect
script(id="overview_settings", type="text/html")
Something went wrong with that request. Please try again.