SSL support

This commit is contained in:
Ruud
2013-01-09 23:29:54 +01:00
parent 432852cf5d
commit cfaffe2bcb
2 changed files with 23 additions and 11 deletions
+10 -8
View File
@@ -23,20 +23,22 @@ config = [{
'default': '',
'type': 'password',
},
{
'name': 'host',
'advanced': True,
'default': '0.0.0.0',
'hidden': True,
'label': 'IP',
'description': 'Host that I should listen to. "0.0.0.0" listens to all ips.',
},
{
'name': 'port',
'default': 5050,
'type': 'int',
'description': 'The port I should listen to.',
},
{
'name': 'ssl_cert',
'description': 'Path to SSL server.crt',
'advanced': True,
},
{
'name': 'ssl_key',
'description': 'Path to SSL server.key',
'advanced': True,
},
{
'name': 'launch_browser',
'default': True,
+13 -3
View File
@@ -4,6 +4,7 @@ from couchpotato.api import api, NonBlockHandler
from couchpotato.core.event import fireEventAsync, fireEvent
from couchpotato.core.helpers.variable import getDataDir, tryInt
from logging import handlers
from tornado.httpserver import HTTPServer
from tornado.web import Application, FallbackHandler
from tornado.wsgi import WSGIContainer
from werkzeug.contrib.cache import FileSystemCache
@@ -210,8 +211,9 @@ def runCouchPotato(options, base_path, args, data_dir = None, log_dir = None, En
# app.debug = development
config = {
'use_reloader': reloader,
'host': Env.setting('host', default = '0.0.0.0'),
'port': tryInt(Env.setting('port', default = 5000))
'port': tryInt(Env.setting('port', default = 5000)),
'ssl_cert': Env.setting('ssl_cert', default = None),
'ssl_key': Env.setting('ssl_key', default = None),
}
# Static path
@@ -243,12 +245,20 @@ def runCouchPotato(options, base_path, args, data_dir = None, log_dir = None, En
debug = config['use_reloader']
)
if config['ssl_cert'] and config['ssl_key']:
server = HTTPServer(application, no_keep_alive = True, ssl_options = {
"certfile": config['ssl_cert'],
"keyfile": config['ssl_key'],
})
else:
server = HTTPServer(application, no_keep_alive = True)
try_restart = True
restart_tries = 5
while try_restart:
try:
application.listen(config['port'], config['host'], no_keep_alive = True)
server.listen(config['port'])
loop.start()
except Exception, e:
try: