mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-11-10 04:06:11 +00:00
Prepare connect ssl support
This commit is contained in:
parent
0fa91e1f5d
commit
afacc8b978
1 changed files with 16 additions and 12 deletions
|
@ -172,8 +172,8 @@ class ConnectionManager(object):
|
|||
raise AttributeError("Request cannot be null")
|
||||
|
||||
self._getHeaders(request)
|
||||
request['timeout'] = request.get('timeout') or self.default_timeout
|
||||
request['verify'] = False
|
||||
request['timeout'] = request.get('timeout', self.default_timeout)
|
||||
request['verify'] = request.get('ssl') or False
|
||||
|
||||
action = request['type']
|
||||
request.pop('type')
|
||||
|
@ -307,7 +307,7 @@ class ConnectionManager(object):
|
|||
return self._resolveFailure()
|
||||
|
||||
try:
|
||||
publicInfo = self._tryConnect(address)
|
||||
publicInfo = self._tryConnect(address, options)
|
||||
except Exception:
|
||||
return _onFail()
|
||||
else:
|
||||
|
@ -343,7 +343,7 @@ class ConnectionManager(object):
|
|||
self._saveUserInfoIntoCredentials(server, result['User'])
|
||||
self.credentialProvider.getCredentials(credentials)
|
||||
|
||||
def _tryConnect(self, url, timeout=None):
|
||||
def _tryConnect(self, url, timeout=None, options={}):
|
||||
|
||||
url = self.getEmbyServerUrl(url, "system/info/public")
|
||||
log.info("tryConnect url: %s" % url)
|
||||
|
@ -353,7 +353,8 @@ class ConnectionManager(object):
|
|||
'type': "GET",
|
||||
'url': url,
|
||||
'dataType': "json",
|
||||
'timeout': timeout
|
||||
'timeout': timeout,
|
||||
'ssl': options.get('ssl')
|
||||
})
|
||||
|
||||
def _addAppInfoToConnectRequest(self):
|
||||
|
@ -536,7 +537,7 @@ class ConnectionManager(object):
|
|||
|
||||
log.info("testing connection mode %s with server %s" % (mode, server['Name']))
|
||||
try:
|
||||
result = self._tryConnect(address, timeout)
|
||||
result = self._tryConnect(address, timeout, options)
|
||||
|
||||
except Exception:
|
||||
log.error("test failed for connection mode %s with server %s" % (mode, server['Name']))
|
||||
|
@ -569,7 +570,7 @@ class ConnectionManager(object):
|
|||
|
||||
if server.get('ExchangeToken'):
|
||||
|
||||
self._addAuthenticationInfoFromConnect(server, connectionMode, credentials)
|
||||
self._addAuthenticationInfoFromConnect(server, connectionMode, credentials, options)
|
||||
|
||||
return self._afterConnectValidated(server, credentials, systemInfo, connectionMode, True, options)
|
||||
|
||||
|
@ -582,10 +583,10 @@ class ConnectionManager(object):
|
|||
elif (verifyLocalAuthentication and server.get('AccessToken') and
|
||||
options.get('enableAutoLogin') is not False):
|
||||
|
||||
if self._validateAuthentication(server, connectionMode) is not False:
|
||||
if self._validateAuthentication(server, connectionMode, options) is not False:
|
||||
return self._afterConnectValidated(server, credentials, systemInfo, connectionMode, False, options)
|
||||
|
||||
return self._resolveFailure()
|
||||
return
|
||||
|
||||
self._updateServerInfo(server, systemInfo)
|
||||
server['LastConnectionMode'] = connectionMode
|
||||
|
@ -606,13 +607,14 @@ class ConnectionManager(object):
|
|||
# Connected
|
||||
return result
|
||||
|
||||
def _validateAuthentication(self, server, connectionMode):
|
||||
def _validateAuthentication(self, server, connectionMode, options={}):
|
||||
|
||||
url = getServerAddress(server, connectionMode)
|
||||
request = {
|
||||
|
||||
'type': "GET",
|
||||
'url': self.getEmbyServerUrl(url, "System/Info"),
|
||||
'ssl': options.get('ssl'),
|
||||
'dataType': "json",
|
||||
'headers': {
|
||||
'X-MediaBrowser-Token': server['AccessToken']
|
||||
|
@ -627,6 +629,7 @@ class ConnectionManager(object):
|
|||
|
||||
'type': "GET",
|
||||
'url': self.getEmbyServerUrl(url, "users/%s" % server['UserId']),
|
||||
'ssl': options.get('ssl'),
|
||||
'dataType': "json",
|
||||
'headers': {
|
||||
'X-MediaBrowser-Token': server['AccessToken']
|
||||
|
@ -696,7 +699,7 @@ class ConnectionManager(object):
|
|||
}
|
||||
})
|
||||
|
||||
def _addAuthenticationInfoFromConnect(self, server, connectionMode, credentials):
|
||||
def _addAuthenticationInfoFromConnect(self, server, connectionMode, credentials, options={}):
|
||||
|
||||
if not server.get('ExchangeToken'):
|
||||
raise KeyError("server['ExchangeToken'] cannot be null")
|
||||
|
@ -714,6 +717,7 @@ class ConnectionManager(object):
|
|||
'url': url,
|
||||
'type': "GET",
|
||||
'dataType': "json",
|
||||
'ssl': options.get('ssl'),
|
||||
'params': {
|
||||
'ConnectUserId': credentials['ConnectUserId']
|
||||
},
|
||||
|
@ -759,7 +763,7 @@ class ConnectionManager(object):
|
|||
|
||||
if len(servers) == 1:
|
||||
result = self.connectToServer(servers[0], options)
|
||||
if result.get('State') == ConnectionState['Unavailable']:
|
||||
if result and result.get('State') == ConnectionState['Unavailable']:
|
||||
result['State'] = ConnectionState['ConnectSignIn'] if result['ConnectUser'] == None else ConnectionState['ServerSelection']
|
||||
|
||||
log.info("resolving connectToServers with result['State']: %s" % result)
|
||||
|
|
Loading…
Reference in a new issue