diff options
author | Tomás Touceda <chiiph@leap.se> | 2013-10-18 09:34:47 -0300 |
---|---|---|
committer | Tomás Touceda <chiiph@leap.se> | 2013-10-18 09:34:47 -0300 |
commit | a06b5719f028e619a4b3800fb346ed3c984e4d25 (patch) | |
tree | b177a28201d647731797efb25c19fd9b3a311c9a /src/leap/bitmask/crypto | |
parent | 932dcf596177b93c0b0f9e876be74be314fb6037 (diff) | |
parent | f673b84a9a9b0fea3f6bbfefbb38cbd3d311cf3c (diff) |
Merge branch 'release-0.3.5'
Diffstat (limited to 'src/leap/bitmask/crypto')
-rw-r--r-- | src/leap/bitmask/crypto/srpauth.py | 18 |
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, |