Added https support

This commit is contained in:
Mattias Erming 2014-09-26 16:26:21 -07:00
parent 4c94a67d49
commit 3e22b6e88a
3 changed files with 53 additions and 5 deletions

View File

@ -159,5 +159,39 @@ module.exports = {
// @default "#foo, #shout-irc"
//
join: "#foo, #shout-irc"
},
//
// Run Shout with HTTPS support.
//
// @type object
// @default {}
//
https: {
//
// Enable HTTPS support.
//
// @type boolean
// @default false
//
enable: false,
//
// Path to the key.
//
// @type string
// @example "sslcert/key.pem"
// @default ""
//
key: "",
//
// Path to the certificate.
//
// @type string
// @example "sslcert/key-cert.pem"
// @default ""
//
certificate: ""
}
};

View File

@ -1,7 +1,7 @@
{
"name": "shout",
"description": "The self-hosted web IRC client",
"version": "0.36.0",
"version": "0.37.0",
"author": "Mattias Erming",
"preferGlobal": true,
"bin": {

View File

@ -19,10 +19,24 @@ module.exports = function(port, host, isPublic) {
var app = express()
.use(index)
.use(express.static("client"))
.use(express.static(Helper.resolveHomePath("cache")))
.listen(config.port, config.host);
.use(express.static(Helper.resolveHomePath("cache")));
sockets = io(app);
var server = null;
var https = config.https || {};
var protocol = https.enable ? "https" : "http";
if (!https.enable){
server = require("http");
server = server.createServer(app).listen(port, host);
} else {
server = require("https");
server = server.createServer({
key: fs.readFileSync(https.key),
cert: fs.readFileSync(https.certificate)
}, app).listen(port, host)
}
sockets = io(server);
sockets.on("connect", function(socket) {
if (config.public) {
auth.call(socket);
@ -34,7 +48,7 @@ module.exports = function(port, host, isPublic) {
manager.sockets = sockets;
console.log("");
console.log("Shout is now running on http://" + config.host + ":" + config.port + "/");
console.log("Shout is now running on " + protocol + "://" + config.host + ":" + config.port + "/");
console.log("Press ctrl-c to stop");
console.log("");