Merge branch '55-self-signed-cert' into develop

This commit is contained in:
Sumner Evans
2019-10-27 19:38:43 -06:00
4 changed files with 21 additions and 2 deletions

View File

@@ -126,6 +126,7 @@ class CacheManager(metaclass=Singleton):
hostname=server_config.server_address,
username=server_config.username,
password=server_config.password,
disable_cert_verify=server_config.disable_cert_verify,
)
self.download_limiter_semaphore = threading.Semaphore(
self.app_config.concurrent_download_limit)

View File

@@ -12,6 +12,7 @@ class ServerConfiguration:
password: str
browse_by_tags: bool
sync_enabled: bool
disable_cert_verify: bool
def __init__(
self,
@@ -23,6 +24,7 @@ class ServerConfiguration:
password='',
browse_by_tags=False,
sync_enabled=True,
disable_cert_verify=False,
):
self.name = name
self.server_address = server_address
@@ -32,6 +34,7 @@ class ServerConfiguration:
self.password = password
self.browse_by_tags = browse_by_tags
self.sync_enabled = sync_enabled
self.disable_cert_verify = disable_cert_verify
class AppConfiguration:

View File

@@ -58,11 +58,19 @@ class Server:
* The ``server`` module is stateless. The only thing that it does is allow
the module's user to query the *sonic server via the API.
"""
def __init__(self, name: str, hostname: str, username: str, password: str):
def __init__(
self,
name: str,
hostname: str,
username: str,
password: str,
disable_cert_verify: bool,
):
self.name: str = name
self.hostname: str = hostname
self.username: str = username
self.password: str = password
self.disable_cert_verify: bool = disable_cert_verify
def _get_params(self) -> Dict[str, str]:
"""See Subsonic API Introduction for details."""
@@ -89,7 +97,11 @@ class Server:
if type(v) == datetime:
params[k] = int(cast(datetime, v).timestamp() * 1000)
result = requests.get(url, params=params)
result = requests.get(
url,
params=params,
verify=not self.disable_cert_verify,
)
# TODO make better
if result.status_code != 200:
raise Exception(f'[FAIL] get: {url} status={result.status_code}')

View File

@@ -23,6 +23,7 @@ class EditServerDialog(EditFormDialog):
boolean_fields = [
('Browse by tags', 'browse_by_tags'),
('Sync enabled', 'sync_enabled'),
('Do not verify certificate', 'disable_cert_verify'),
]
def __init__(self, *args, **kwargs):
@@ -209,6 +210,8 @@ class ConfigureServersDialog(Gtk.Dialog):
password=dialog.data['password'].get_text(),
browse_by_tags=dialog.data['browse_by_tags'].get_active(),
sync_enabled=dialog.data['sync_enabled'].get_active(),
disable_cert_verify=dialog.data['disable_cert_verify']
.get_active(),
)
if add: