Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,20 @@ bot.on('message', function(event) {
bot.matchMessage(/^hi/, function(event) {
event.reply('hello there!');
});

// Connect via Unix socket
var bot = new IRC.Client();
bot.connect({
path: '/tmp/irc.sock',
nick: 'prawnsbot'
});

// ... optionally with TLS
bot.connect({
path: '/tmp/irc.sock',
tls: true,
nick: 'prawnsbot'
});
~~~

#### Channel/buffer objects. Great for building clients
Expand Down
4 changes: 3 additions & 1 deletion docs/clientapi.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ Add middleware to handle the events for the client instance

##### `.connect([connect_options])`
Start connecting to the IRC network. If `connect_options` is provided it will
override any options given to the constructor.
override any options given to the constructor. Accepts a `path` option to connect
via a Unix domain socket instead of `host`/`port`. Can be combined with `tls`/`ssl`
for TLS over Unix socket.

##### `.raw(raw_data_line)`
Send a raw line to the IRC server
Expand Down
16 changes: 15 additions & 1 deletion src/transports/net.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,15 @@ module.exports = class Connection extends EventEmitter {
}).catch(this.onSocketError.bind(this));
} else {
let socket = null;
if (options.tls || options.ssl) {
if ((options.tls || options.ssl) && options.path) {
this.debugOut('Using TLS over Unix socket');
socket = this.socket = tls.connect({
path: options.path,
rejectUnauthorized: options.rejectUnauthorized,
key: options.client_certificate && options.client_certificate.private_key,
cert: options.client_certificate && options.client_certificate.certificate,
});
} else if (options.tls || options.ssl) {
socket = this.socket = tls.connect({
servername: sni,
host: ircd_host,
Expand All @@ -137,6 +145,12 @@ module.exports = class Connection extends EventEmitter {
localAddress: options.outgoing_addr,
family: this.getAddressFamily(options.outgoing_addr)
});
} else if (options.path) {
this.debugOut('Using path for socket');

socket = this.socket = net.connect({
path: options.path
});
} else {
socket = this.socket = net.connect({
host: ircd_host,
Expand Down
Loading