Skip to content
Browse files

Hack in SSL support. Like a boss.

  • Loading branch information...
1 parent b344c97 commit 50837880474722ba806974c3d446200372314e99 @dsamarin dsamarin committed
Showing with 19 additions and 3 deletions.
  1. +19 −3 lib/irc/client.js
View
22 lib/irc/client.js
@@ -1,5 +1,6 @@
var util = require("util");
var net = require("net");
+var tls = require("tls");
var events = require("events");
@@ -35,10 +36,17 @@ util.inherits(Client, process.EventEmitter);
Client.prototype.connect = function() {
- var connection = net.createConnection(this.port, this.host);
+ var connection;
+
+ if (this.profile.ssl) {
+ connection = tls.connect (this.port, this.host, {});
+ } else {
+ connection = net.createConnection(this.port, this.host);
+ connection.setTimeout(this.timeout);
+ connection.setKeepAlive(true);
+ }
+
connection.setEncoding(this.encoding);
- connection.setTimeout(this.timeout);
- connection.setKeepAlive(true);
for (var i in this.events) {
if (this.events.hasOwnProperty(i)) {
@@ -163,6 +171,14 @@ Client.prototype.ping_server = function() {
Client.prototype.events = {
+ secureConnect: function() {
+ if (this.connection.authorized) {
+ this.events.connect.call (this);
+ } else {
+ console.log ("%s: Peer certificate was not signed by specified CA: %s", this.name, this.connection.authorizationError);
+ this.connection.end ();
+ }
+ },
connect: function() {
this.raw("NICK "+this.nick);
if (typeof this.password === "string") {

0 comments on commit 5083788

Please sign in to comment.
Something went wrong with that request. Please try again.