summaryrefslogtreecommitdiffstats
path: root/pyload/api
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-12-15 14:00:42 +0100
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-12-15 14:00:42 +0100
commit8fbde7a43b4f838df0379fdb4acd791713b639b7 (patch)
treebb7e78afc6a34823e078ab64c6965321c6866e85 /pyload/api
parentadded new file states (diff)
downloadpyload-8fbde7a43b4f838df0379fdb4acd791713b639b7.tar.xz
more options to get webUI through proxy working
Diffstat (limited to 'pyload/api')
-rw-r--r--pyload/api/CoreApi.py21
1 files changed, 18 insertions, 3 deletions
diff --git a/pyload/api/CoreApi.py b/pyload/api/CoreApi.py
index ebb194134..187286b48 100644
--- a/pyload/api/CoreApi.py
+++ b/pyload/api/CoreApi.py
@@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
from pyload.Api import Api, RequirePerm, Permission, ServerStatus, Interaction
-from pyload.utils.fs import join, free_space
+from pyload.utils.fs import join, free_space, exists
from pyload.utils import compare_time
from ApiComponent import ApiComponent
@@ -15,11 +15,26 @@ class CoreApi(ApiComponent):
"""pyLoad Core version """
return self.core.version
+ def isWSSecure(self):
+ # needs to use TLS when either requested or webUI is also using encryption
+ if not self.core.config['ssl']['activated'] or self.core.config['webUI']['https']:
+ return False
+
+ if not exists(self.core.config['ssl']['cert']) or not exists(self.core.config['ssl']['key']):
+ self.core.log.warning(_('SSL key or certificate not found'))
+ return False
+
+ return True
+
@RequirePerm(Permission.All)
def getWSAddress(self):
"""Gets and address for the websocket based on configuration"""
- # TODO SSL (wss)
- return "ws://%%s:%d" % self.core.config['remote']['port']
+ if self.isWSSecure():
+ ws = "wss"
+ else:
+ ws = "ws"
+
+ return "%s://%%s:%d" % (ws, self.core.config['webUI']['wsPort'])
@RequirePerm(Permission.All)
def getServerStatus(self):