Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from Jul 8, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 17 additions & 2 deletions lib/irclink.js
Expand Up @@ -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,
Expand All @@ -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
});
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion lib/restore.js
Expand Up @@ -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();
});
});
}
8 changes: 0 additions & 8 deletions lib/socket.js
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
});

Expand Down
12 changes: 6 additions & 6 deletions views/templates.jade
Expand Up @@ -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
Expand All @@ -58,6 +54,10 @@ script(id="overview_connection", type="text/html")
label(for="connect-nick") Nick
.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
Expand All @@ -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")
Expand Down