Run private server by default
Use `shout start --public` or edit your `config.json` to override.
This commit is contained in:
parent
43b6310481
commit
eb7c40276e
@ -1,5 +1,5 @@
|
||||
{
|
||||
"port": 9000,
|
||||
"theme": "themes/example.css",
|
||||
"public": true
|
||||
"public": false
|
||||
}
|
||||
|
6
index.js
6
index.js
@ -8,14 +8,14 @@ var program = require("commander");
|
||||
var shout = require("./src/server.js");
|
||||
|
||||
program
|
||||
.option("-p, --port <port>");
|
||||
.option("-p, --port <port>")
|
||||
.option("-P, --public");
|
||||
|
||||
program
|
||||
.command("start")
|
||||
.description("Start the server")
|
||||
.action(function() {
|
||||
var port = program.port || config.port;
|
||||
shout(port);
|
||||
shout(program.port, program.public);
|
||||
});
|
||||
|
||||
program
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "shout",
|
||||
"description": "A web IRC client",
|
||||
"version": "0.9.2",
|
||||
"version": "0.9.3",
|
||||
"homepage": "http://github.com/erming/shout",
|
||||
"author": "Mattias Erming",
|
||||
"preferGlobal": true,
|
||||
|
@ -4,9 +4,19 @@ var Client = require("./client");
|
||||
module.exports = ClientManager;
|
||||
|
||||
function ClientManager() {
|
||||
this.clients = {};
|
||||
this.clients = [];
|
||||
}
|
||||
|
||||
ClientManager.prototype.findClient = function(name) {
|
||||
for (var i in this.clients) {
|
||||
var client = this.clients[i];
|
||||
if (client.name == name) {
|
||||
return client;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
ClientManager.prototype.loadUsers = function(sockets) {
|
||||
var users = this.getUsers();
|
||||
for (var i in users) {
|
||||
@ -18,11 +28,11 @@ ClientManager.prototype.loadUsers = function(sockets) {
|
||||
if (!json) {
|
||||
continue;
|
||||
}
|
||||
if (!this.clients[name]) {
|
||||
this.clients[name] = new Client(
|
||||
if (!this.findClient(name)) {
|
||||
this.clients.push(new Client(
|
||||
sockets,
|
||||
json
|
||||
);
|
||||
));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -26,12 +26,14 @@ var inputs = [
|
||||
"whois"
|
||||
];
|
||||
|
||||
module.exports = function(port) {
|
||||
var port = port || config.port || 9000;
|
||||
module.exports = function(port, public) {
|
||||
config.port = port || config.port,
|
||||
config.public = public || config.public
|
||||
|
||||
var app = http()
|
||||
.use(index)
|
||||
.use(http.static("client"))
|
||||
.listen(port);
|
||||
.listen(config.port);
|
||||
|
||||
sockets = io(app);
|
||||
sockets.on("connect", function(socket) {
|
||||
@ -43,7 +45,7 @@ module.exports = function(port) {
|
||||
});
|
||||
|
||||
console.log("");
|
||||
console.log("Shout is now running on port " + port);
|
||||
console.log("Shout is now running on port " + config.port);
|
||||
console.log("Press ctrl-c to stop");
|
||||
console.log("");
|
||||
|
||||
@ -100,9 +102,9 @@ function auth(data) {
|
||||
var socket = this;
|
||||
if (config.public) {
|
||||
var client = new Client(sockets);
|
||||
clients.push(client);
|
||||
manager.clients.push(client);
|
||||
socket.on("disconnect", function() {
|
||||
clients = _.without(clients, client);
|
||||
manager.clients = _.without(manager.clients, client);
|
||||
client.quit();
|
||||
});
|
||||
init(socket, client);
|
||||
|
Loading…
Reference in New Issue
Block a user