Skip to content

Commit

Permalink
aucgbot: SSL/TLS
Browse files Browse the repository at this point in the history
Fixes #4.
  • Loading branch information
auscompgeek committed Dec 12, 2015
1 parent aa359d0 commit fa7cb5b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions aucgbot.js
Expand Up @@ -8,6 +8,7 @@
"use strict";

var net = require("net"),
tls = require("tls"),
url = require("url"),
util = require("util"),
fs = require("fs"),
Expand Down Expand Up @@ -73,17 +74,20 @@ aucgbot.start = function startBot() {
this.started = Date.now();
};

aucgbot.connect = function connectBot(host, port, nick, ident, pass, chans, sasluser, saslpass) {
aucgbot.connect = function connectBot(host, port, nick, ident, pass, chans, sasluser, saslpass, ssl) {
host = host || "127.0.0.1";
port = parseInt(port) || 6667;
var channels = ["#bots"], addr = host + ":" + port, conn, ln;

if (typeof port === "string" && port[0] === "+")
ssl = true;
port = parseInt(port) || (ssl ? 6697 : 6667);
var channels = ["#bots"], addr = host + (ssl ? ":+" : ":") + port, conn, ln;

if (this.conns.hasOwnProperty(addr)) {
console.log("Stubbornly refusing to connect again to", addr);
return;
}

conn = net.connect(port, host, function() {
conn = (ssl ? tls : net).connect(port, host, function() {
console.log("Connected to " + addr);
});
conn.nick = nick;
Expand Down

0 comments on commit fa7cb5b

Please sign in to comment.