- debug('[KiwiProxy] Proxied connection to: ' + this.meta.host + ':' + this.meta.port.toString());
- this.irc_socket = this.meta.ssl ?
- tls.connect(parseInt(this.meta.port, 10), this.meta.host, this._onSocketConnect.bind(this)) :
- net.connect(parseInt(this.meta.port, 10), this.meta.host, this._onSocketConnect.bind(this));
+ debug('[KiwiProxy] Opening proxied connection to: ' + this.meta.host + ':' + this.meta.port.toString());
+
+ var local_address = this.meta.interface ?
+ this.meta.interface :
+ '0.0.0.0';
+
+ if (this.meta.ssl) {
+ this.irc_socket = tls.connect({
+ port: parseInt(this.meta.port, 10),
+ host: this.meta.host,
+ rejectUnauthorized: global.config.reject_unauthorised_certificates,
+ localAddress: local_address
+ }, this._onSocketConnect.bind(this));
+
+ } else {
+ this.irc_socket = net.connect({
+ port: parseInt(this.meta.port, 10),
+ host: this.meta.host,
+ localAddress: local_address
+ }, this._onSocketConnect.bind(this));
+ }