feature(cloudcmd) drop ssl suport

This commit is contained in:
coderaiser 2014-09-08 06:02:12 -04:00
parent 4e59f4c16e
commit 30e4905ffd
5 changed files with 7 additions and 62 deletions

View file

@ -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? */
}
```

View file

@ -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';
});

View file

@ -16,6 +16,4 @@
<li><span><input type="checkbox" id="showKeysPanel" {{ showKeysPanel }}></input></span><label for="showKeysPanel"> Show keys panel</label></li>
<li><span><input type="checkbox" id="socket" {{ socket }} ></input></span><label for="socket"> Socket</label></li>
<li><input type="number" min="0" max="65535" class="form-control" placeholder="Port" id="port" value="{{ port }}" title="Port"></input></li>
<li><input type="number" min="0" max="65535" class="form-control" placeholder="Ssl Port" id="sslPort" value="{{ sslPort }}" title="SSL Port"></input></li>
<li><span><input type="checkbox" id="ssl" {{ ssl }} ></input></span><label for="ssl"> SSL</label></li>
</div>

View file

@ -17,7 +17,5 @@
"server": true,
"socket": true,
"port": 8000,
"sslPort": 4430,
"ip": null,
"ssl": false
"ip": null
}

View file

@ -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);