SSL support

This commit is contained in:
Ruud committed 2013-01-09 23:29:54 +01:00
1 parent 432852cf5d
commit cfaffe2bcb
2 files changed
+23 -11

No files matched your search

+10 -8
View File
@@ -23,20 +23,22 @@ config = [{
'default': '', 'default': '',
'type': 'password', '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', 'name': 'port',
'default': 5050, 'default': 5050,
'type': 'int', 'type': 'int',
'description': 'The port I should listen to.', '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', 'name': 'launch_browser',
'default': True, '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.event import fireEventAsync, fireEvent
from couchpotato.core.helpers.variable import getDataDir, tryInt from couchpotato.core.helpers.variable import getDataDir, tryInt
from logging import handlers from logging import handlers
from tornado.httpserver import HTTPServer
from tornado.web import Application, FallbackHandler from tornado.web import Application, FallbackHandler
from tornado.wsgi import WSGIContainer from tornado.wsgi import WSGIContainer
from werkzeug.contrib.cache import FileSystemCache 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 # app.debug = development
config = { config = {
'use_reloader': reloader, '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 # Static path
@@ -243,12 +245,20 @@ def runCouchPotato(options, base_path, args, data_dir = None, log_dir = None, En
debug = config['use_reloader'] 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 try_restart = True
restart_tries = 5 restart_tries = 5
while try_restart: while try_restart:
try: try:
application.listen(config['port'], config['host'], no_keep_alive = True) server.listen(config['port'])
loop.start() loop.start()
except Exception, e: except Exception, e:
try: try: