added ability to degradate to http from https

This commit is contained in:
coderaiser 2013-03-10 05:59:40 -04:00
parent 6a9d8289a6
commit e8edb83d14
3 changed files with 46 additions and 30 deletions

View file

@ -19,6 +19,8 @@ and get them out to file system.
* Added ability to move files.
* Added ability to degradate to http from https.
2012.03.01, Version 0.1.9

View file

@ -13,6 +13,7 @@
"server" : true,
"socket" : true,
"port" : 80,
"sslPort" : 443,
"ip" : null,
"ssl" : false,
"rest" : true

View file

@ -27,7 +27,7 @@
https = main.https,
Util = main.util,
Server, Rest, Route, Minimize, Port, IP;
Server, Rest, Route, Minimize;
/* базовая инициализация */
function init(pAppCachProcessing){
@ -59,47 +59,60 @@
if(!pProcessing)
pProcessing = {};
Rest = pProcessing.rest;
Route = pProcessing.route;
Minimize = pProcessing.minimize;
var lSSL = pProcessing.ssl;
Rest = pProcessing.rest;
Route = pProcessing.route;
Minimize = pProcessing.minimize;
init(pProcessing.appcache);
Port = process.env.PORT || /* c9 */
process.env.app_port || /* nodester */
process.env.VCAP_APP_PORT || /* cloudfoundry */
lConfig.port;
var lPort = process.env.PORT || /* c9 */
process.env.app_port || /* nodester */
process.env.VCAP_APP_PORT || /* cloudfoundry */
lConfig.port,
IP = process.env.IP || /* c9 */
lConfig.ip ||
(main.WIN32 ? '127.0.0.1' : '0.0.0.0');
lIP = process.env.IP || /* c9 */
lConfig.ip ||
(main.WIN32 ? '127.0.0.1' : '0.0.0.0'),
lSSL = pProcessing.ssl,
lSSLPort= lConfig.sslPort,
lHTTP = 'http',
lRet;
/* server mode or testing mode */
if (lConfig.server) {
var lError = Util.tryCatchLog(function(){
var lHTTP = 'http';
if(!lSSL)
Server = http.createServer( controller );
else{
Server = https.createServer( lSSL, controller );
Port = 443;
if(lSSL){
lRet = Util.tryCatchLog(function(){
Server = https.createServer( lSSL, controller );
Server.listen(lSSLPort, lIP);
});
if(!lRet){
var lRedirectServer = http.createServer( function(){
});
lRedirectServer.listen(lPort, lIP);
lHTTP += 's';
}
Server.listen(Port, IP);
var lListen;
if(lConfig.socket && Socket)
lListen = Socket.listen(Server);
Util.log('* Sockets ' + (lListen ? 'running' : 'disabled'));
Util.log('* Server running at ' + lHTTP + '://' + IP + ':' + Port);
});
}
if(!lSSL || lRet){
Util.log(lRet);
Server = http.createServer( controller );
Server.listen(lPort, lIP);
}
if(lError){
var lListen;
if(lConfig.socket && Socket)
lListen = Socket.listen(Server);
Util.log('* Sockets ' + (lListen ? 'running' : 'disabled'));
Util.log('* Server running at ' + lHTTP + '://' + lIP + ':' + lPort);
if(lRet){
Util.log('Cloud Commander server could not started');
Util.log(lError);
Util.log(lRet);
}
}else
Util.log('Cloud Commander testing mode');