mirror of
https://github.com/thelounge/thelounge
synced 2024-11-26 22:10:22 +00:00
Merge pull request #225 from xeoncore/master
Allow binding to a local IP
This commit is contained in:
commit
9cc793ef9e
4 changed files with 24 additions and 2 deletions
|
@ -26,6 +26,14 @@ module.exports = {
|
|||
//
|
||||
port: 9000,
|
||||
|
||||
//
|
||||
// Set the local IP to bind to.
|
||||
//
|
||||
// @type string
|
||||
// @default "0.0.0.0"
|
||||
//
|
||||
bind: undefined,
|
||||
|
||||
//
|
||||
// Set the default theme.
|
||||
//
|
||||
|
|
|
@ -116,6 +116,7 @@ Client.prototype.find = function(id) {
|
|||
};
|
||||
|
||||
Client.prototype.connect = function(args) {
|
||||
var config = Helper.getConfig();
|
||||
var client = this;
|
||||
var server = {
|
||||
host: args.host || "irc.freenode.org",
|
||||
|
@ -124,7 +125,17 @@ Client.prototype.connect = function(args) {
|
|||
rejectUnauthorized: false
|
||||
};
|
||||
|
||||
if(config.bind) {
|
||||
server.localAddress = config.bind;
|
||||
|
||||
if(args.tls) {
|
||||
var socket = net.connect(server);
|
||||
server.socket = socket;
|
||||
}
|
||||
}
|
||||
|
||||
var stream = args.tls ? tls.connect(server) : net.connect(server);
|
||||
|
||||
stream.on("error", function(e) {
|
||||
console.log("Client#connect():\n" + e);
|
||||
stream.end();
|
||||
|
|
|
@ -6,6 +6,7 @@ var Helper = require("../helper");
|
|||
program
|
||||
.option("-H, --host <ip>", "host")
|
||||
.option("-p, --port <port>", "port")
|
||||
.option("-B, --bind <ip>", "bind")
|
||||
.option(" --public", "mode")
|
||||
.option(" --private", "mode")
|
||||
.command("start")
|
||||
|
@ -27,6 +28,7 @@ program
|
|||
} else {
|
||||
var host = program.host || process.env.IP || config.host;
|
||||
var port = program.port || process.env.PORT || config.port;
|
||||
shout(port, host, mode);
|
||||
var bind = program.bind || process.env.BIND || config.bind;
|
||||
shout(port, host, mode, bind);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -11,11 +11,12 @@ var config = {};
|
|||
var sockets = null;
|
||||
var manager = new ClientManager();
|
||||
|
||||
module.exports = function(port, host, isPublic) {
|
||||
module.exports = function(port, host, isPublic, localIp) {
|
||||
config = Helper.getConfig();
|
||||
config.port = port;
|
||||
config.host = host;
|
||||
config.public = isPublic;
|
||||
config.bind = localIp;
|
||||
|
||||
var app = express()
|
||||
.use(index)
|
||||
|
|
Loading…
Reference in a new issue