mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-26 20:55:29 +00:00
webui https
This commit is contained in:
parent
b3cda61961
commit
f2b057bd30
6 changed files with 93 additions and 44 deletions
|
@ -34,6 +34,7 @@
|
|||
from deluge.ui.client import sclient as proxy
|
||||
from deluge.log import LOG as log
|
||||
|
||||
|
||||
import utils
|
||||
import lib.newforms_plus as forms
|
||||
import config_forms
|
||||
|
@ -61,12 +62,28 @@ class Template(config_forms.WebCfgForm):
|
|||
|
||||
class Server(config_forms.WebCfgForm):
|
||||
title = _("Server")
|
||||
info = _("Manually restart webui to apply changes.")
|
||||
|
||||
port = forms.IntegerField(label = _("Port"),min_value=80)
|
||||
https = forms.CheckBox(_("Https"))
|
||||
|
||||
def validate(self, data):
|
||||
import os
|
||||
from deluge.common import get_default_config_dir
|
||||
|
||||
if data.https:
|
||||
cert_path = os.path.join(get_default_config_dir("ssl") ,"deluge.cert.pem" )
|
||||
if not os.path.exists (cert_path):
|
||||
raise forms.ValidationError(_("Certificate not found at '%s'" % cert_path))
|
||||
key_path = os.path.join(get_default_config_dir("ssl") ,"deluge.key.pem" )
|
||||
if not os.path.exists (key_path):
|
||||
raise forms.ValidationError(_("Key not found at '%s'" % key_path))
|
||||
|
||||
|
||||
def post_save(self):
|
||||
pass
|
||||
#raise forms.ValidationError(
|
||||
# _("Manually restart server to apply these changes."))
|
||||
# )
|
||||
|
||||
class Password(forms.Form):
|
||||
title = _("Password")
|
||||
|
|
|
@ -38,6 +38,7 @@ from deluge.ui.client import sclient
|
|||
import components
|
||||
from deluge.log import LOG as log
|
||||
|
||||
|
||||
# Initialize gettext
|
||||
if deluge.common.windows_check() or deluge.common.osx_check():
|
||||
locale.setlocale(locale.LC_ALL, '')
|
||||
|
@ -121,6 +122,20 @@ def create_webserver(debug = False, base_url =None):
|
|||
server_address=("0.0.0.0", int(config.get('port')))
|
||||
server = CherryPyWSGIServer(server_address, wsgi_app, server_name="localhost")
|
||||
|
||||
https = False
|
||||
if config.get("https"):
|
||||
import os
|
||||
from deluge.common import get_default_config_dir
|
||||
cert_path = os.path.join(get_default_config_dir("ssl") ,"deluge.cert.pem" )
|
||||
key_path = os.path.join(get_default_config_dir("ssl") ,"deluge.key.pem" )
|
||||
if os.path.exists (key_path) and os.path.exists (cert_path):
|
||||
server.ssl_certificate = cert_path
|
||||
server.ssl_private_key = key_path
|
||||
https = True
|
||||
|
||||
if https:
|
||||
log.info("https://%s:%d/" % server_address)
|
||||
else:
|
||||
log.info("http://%s:%d/" % server_address)
|
||||
return server
|
||||
|
||||
|
|
|
@ -259,7 +259,13 @@ def _load(env):
|
|||
ctx.output = ''
|
||||
ctx.environ = ctx.env = env
|
||||
ctx.host = env.get('HTTP_HOST')
|
||||
ctx.homedomain = 'http://' + env.get('HTTP_HOST', '[unknown]')
|
||||
|
||||
#http://groups.google.com/group/webpy/browse_thread/thread/2a4665e54b07c991?pli=1
|
||||
if env.get('HTTPS'):
|
||||
ctx.protocol = "https"
|
||||
else:
|
||||
ctx.protocol = "http"
|
||||
ctx.homedomain = ctx.protocol + "://" + env.get('HTTP_HOST','[unknown]')
|
||||
ctx.homepath = os.environ.get('REAL_SCRIPT_NAME', env.get('SCRIPT_NAME', ''))
|
||||
ctx.home = ctx.homedomain + ctx.homepath
|
||||
ctx.ip = env.get('REMOTE_ADDR')
|
||||
|
|
|
@ -5,6 +5,15 @@ $def with (title, active_tab="NONE")
|
|||
<link rel="icon" href="$base/static/images/deluge-icon.png" type="image/png" />
|
||||
<link rel="shortcut icon" href="$base/static/images/deluge-icon.png" type="image/png" />
|
||||
<link rel="stylesheet" type="text/css" href="$base/static/simple_site_style.css" />
|
||||
<!--javascript is only used for plugins in the classic-ui
|
||||
classic ui should function without js.
|
||||
-->
|
||||
<script language="javascript" src="$base/gettext.js"></script>
|
||||
<script language="javascript" src="$base/static/mootools-1.2-core.js"></script>
|
||||
<script language="javascript" src="$base/static/mootools-1.2-more.js"></script>
|
||||
<script language="javascript" src="$base/static/mooui.js"></script>
|
||||
$for js in include_javascript:
|
||||
<script language="javascript" src="$base$js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="page">
|
||||
|
|
|
@ -7,6 +7,7 @@ $def with (title, active_tab="NONE")
|
|||
<link rel="icon" href="$base/static/images/deluge-icon.png" type="image/png" />
|
||||
<link rel="shortcut icon" href="$base/static/images/deluge-icon.png" type="image/png" />
|
||||
<link rel="stylesheet" type="text/css" href="$base/template_style.css" />
|
||||
<script language="javascript" src="$base/gettext.js"></script>
|
||||
<script language="javascript" src="$base/static/deluge.js"></script>
|
||||
<script language="javascript" src="$base/static/mootools-1.2-core.js"></script>
|
||||
<script language="javascript" src="$base/static/mootools-1.2-more.js"></script>
|
||||
|
|
|
@ -65,5 +65,6 @@ CONFIG_DEFAULTS = {
|
|||
"sidebar_show_zero":False,
|
||||
"sidebar_show_trackers":False,
|
||||
"show_keyword_search":False,
|
||||
"show_sidebar":True
|
||||
"show_sidebar":True,
|
||||
"https":False
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue