From 30e4905ffde574a47b7a16929fb4c74dd1cd5626 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 8 Sep 2014 06:02:12 -0400 Subject: [PATCH] feature(cloudcmd) drop ssl suport --- HELP.md | 2 -- cloudcmd.js | 12 ------------ html/config.html | 2 -- json/config.json | 4 +--- lib/server.js | 49 ++++++------------------------------------------ 5 files changed, 7 insertions(+), 62 deletions(-) diff --git a/HELP.md b/HELP.md index 2a88a347..e4ae0787 100644 --- a/HELP.md +++ b/HELP.md @@ -244,9 +244,7 @@ All main configuration could be done via `json/config.json`. "server" : true, /* server mode or testing mode */ "socket" : true, /* enable web sockets */ "port" : 8000, /* http port */ - "sslPort" : 443, /* https port */ "ip" : null, /* ip or null(default) */ - "ssl" : false /* should use https? */ } ``` diff --git a/cloudcmd.js b/cloudcmd.js index a5a90338..cb1d645f 100644 --- a/cloudcmd.js +++ b/cloudcmd.js @@ -25,9 +25,6 @@ Config = main.config, - KEY = DIR + 'ssl/ssl.key', - CERT = DIR + 'ssl/ssl.crt', - PATH_INDEX = DIR_FS + 'index.html', TMPL_PATH = [ @@ -144,9 +141,6 @@ return path; }); - if (Config.ssl) - filesList.push(KEY, CERT); - files.read(filesList, 'utf8', function(error, files) { var status, msg, names; @@ -161,12 +155,6 @@ Template[name] = files[path]; }); - if (Config.ssl) - params.ssl = { - key : files[KEY], - cert : files[CERT] - }; - names = TMPL_PATH.map(function(item) { return item + '.html'; }); diff --git a/html/config.html b/html/config.html index a824bb36..937b2c90 100644 --- a/html/config.html +++ b/html/config.html @@ -16,6 +16,4 @@
  • -
  • -
  • diff --git a/json/config.json b/json/config.json index 40872dd9..fe83894a 100644 --- a/json/config.json +++ b/json/config.json @@ -17,7 +17,5 @@ "server": true, "socket": true, "port": 8000, - "sslPort": 4430, - "ip": null, - "ssl": false + "ip": null } diff --git a/lib/server.js b/lib/server.js index aeb41438..b7725229 100644 --- a/lib/server.js +++ b/lib/server.js @@ -20,7 +20,6 @@ URL = require('url'), path = require('path'), http = require('http'), - https = require('https'), Util = require(DIR_LIB + 'util'), CloudFunc = require(DIR_LIB + 'cloudfunc'), @@ -64,9 +63,8 @@ * @param options */ function start(options) { - var redirectServer, port, ip, ssl, sslPort, + var port, ip, HTTP = 'http://', - HTTPS = 'https://', config = main.config; if (!options) @@ -78,48 +76,16 @@ port = process.env.PORT || /* c9 */ process.env.VCAP_APP_PORT || /* cloudfoundry */ config.port, + ip = process.env.IP || /* c9 */ config.ip || - '0.0.0.0', - - ssl = options.ssl, - sslPort = config.sslPort; + '0.0.0.0'; if (config.server) - if (!ssl) - createServer(port, ip, HTTP); - else { - createRedirect(port, ip, HTTPS, sslPort); - - createServer(sslPort, ip, HTTP, ssl, function() { - Util.log('Could not use https port: ' + sslPort); - redirectServer.close(); - Util.log('* Redirection http -> https removed'); - createServer(port, ip); - }); - } + createServer(port, ip, HTTP); } - function createRedirect(port, ip, protocol, sslPort) { - var server = function(req, res) { - var url, - host = req.headers.host, - parsed = URL.parse(host), - hostName = parsed.protocol; - - url = protocol + hostName + sslPort + req.url; - - ponse.redirect(url, res); - }; - - Util.log('* Redirection http -> https is setted up'); - logServer(port, ip, protocol); - - http.createServer(server) - .listen(port, ip); - } - - function createServer(port, ip, protocol, ssl, callback) { + function createServer(port, ip, protocol, callback) { var server, app, respondApp, config = main.config, @@ -163,10 +129,7 @@ app = respondApp; } - if (ssl) - server = https.createServer(ssl, app); - else - server = http.createServer(app); + server = http.createServer(app); server.on('error', function(error) { Util.log(error);