plugin XEP-0260: better proxy error handling:
- display a better message in logs
- fixed fallback to IBB
This commit is contained in:
parent
691b881fdc
commit
bb82cfc78a
1 changed files with 19 additions and 3 deletions
|
|
@ -50,7 +50,9 @@ PLUGIN_INFO = {
|
|||
|
||||
|
||||
class ProxyError(Exception):
|
||||
pass
|
||||
|
||||
def __str__(self):
|
||||
return "an error happened while trying to use the proxy"
|
||||
|
||||
|
||||
class XEP_0260(object):
|
||||
|
|
@ -157,7 +159,8 @@ class XEP_0260(object):
|
|||
iq_elt, transport_elt = self._j.buildAction(self._j.A_TRANSPORT_INFO, session, content_name, profile)
|
||||
transport_elt.addElement('proxy-error')
|
||||
iq_elt.send()
|
||||
log.warning(u"Can't activate proxy, we need to fallback to IBB")
|
||||
log.warning(u"Can't activate proxy, we need to fallback to IBB: {reason}"
|
||||
.format(reason = stanza_error.value.condition))
|
||||
client = self.host.getClient(profile)
|
||||
self.doFallback(session, content_name, client)
|
||||
|
||||
|
|
@ -264,6 +267,19 @@ class XEP_0260(object):
|
|||
if content_data['senders'] == session['role']:
|
||||
# we can now start the file transfer (or start it after proxy activation)
|
||||
d.addCallback(lambda dummy: choosed_candidate.startTransfer(transport_data['session_hash']))
|
||||
d.addErrback(self._startEb, session, content_name, client)
|
||||
|
||||
def _startEb(self, fail, session, content_name, client):
|
||||
"""Called when it's not possible to start the transfer
|
||||
|
||||
Will try to fallback to IBB
|
||||
"""
|
||||
try:
|
||||
reason = unicode(fail.value)
|
||||
except AttributeError:
|
||||
reason = unicode(fail)
|
||||
log.warning(u"Cant start transfert, we'll try fallback method: {}".format(reason))
|
||||
self.doFallback(session, content_name, client)
|
||||
|
||||
def _candidateInfo(self, candidate_elt, session, content_name, transport_data, client):
|
||||
"""Called when best candidate has been received from peer (or if none is working)
|
||||
|
|
@ -320,7 +336,7 @@ class XEP_0260(object):
|
|||
if proxy_elt.name == 'activated':
|
||||
activation_d.callback(None)
|
||||
else:
|
||||
activation_d.errback(ProxyError)
|
||||
activation_d.errback(ProxyError())
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def jingleHandler(self, action, session, content_name, transport_elt, profile):
|
||||
|
|
|
|||
Loading…
Reference in a new issue