summaryrefslogtreecommitdiff
path: root/src/leap
diff options
context:
space:
mode:
authorTomás Touceda <chiiph@leap.se>2013-10-07 14:53:42 -0300
committerTomás Touceda <chiiph@leap.se>2013-10-07 15:55:55 -0300
commitbf76ffa48a7d8e8993b9a61a259cc56829e1130f (patch)
tree304e33bddce8493983d822daecea2ee4576f8c81 /src/leap
parent5548a0d9bcd2e49606a7c09f8ec1c3bc71287943 (diff)
Increase the max retries for the sessions in SRPAuth
Diffstat (limited to 'src/leap')
-rw-r--r--src/leap/bitmask/crypto/srpauth.py18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/leap/bitmask/crypto/srpauth.py b/src/leap/bitmask/crypto/srpauth.py
index cbff4b49..47ed21b0 100644
--- a/src/leap/bitmask/crypto/srpauth.py
+++ b/src/leap/bitmask/crypto/srpauth.py
@@ -25,6 +25,7 @@ import json
#this error is raised from requests
from simplejson.decoder import JSONDecodeError
from functools import partial
+from requests.adapters import HTTPAdapter
from PySide import QtCore
from twisted.internet import threads
@@ -154,7 +155,8 @@ class SRPAuth(QtCore.QObject):
self._ng = self._srp.NG_1024
# **************************************************** #
- self._session = self._fetcher.session()
+ self._reset_session()
+
self._session_id = None
self._session_id_lock = QtCore.QMutex()
self._uid = None
@@ -172,6 +174,18 @@ class SRPAuth(QtCore.QObject):
self._username = None
self._password = None
+ def _reset_session(self):
+ """
+ Resets the current session and sets max retries to 30.
+ """
+ self._session = self._fetcher.session()
+ # We need to bump the default retries, otherwise logout
+ # fails most of the times
+ # NOTE: This is a workaround for the moment, the server
+ # side seems to return correctly every time, but it fails
+ # on the client end.
+ self._session.mount('https://', HTTPAdapter(max_retries=30))
+
def _safe_unhexlify(self, val):
"""
Rounds the val to a multiple of 2 and returns the
@@ -508,7 +522,7 @@ class SRPAuth(QtCore.QObject):
self._username = username
self._password = password
- self._session = self._fetcher.session()
+ self._reset_session()
d = threads.deferToThread(self._authentication_preprocessing,
username=username,