# HG changeset patch # User Goffi # Date 1448407343 -3600 # Node ID a9e86f660653ae350049ca406cbf194a3f9cb16b # Parent bf67dc424784d33bea036cf513a1a6b1ba4ce16a plugin ip: fixed ip check (XEP-0279) use diff -r bf67dc424784 -r a9e86f660653 src/plugins/plugin_misc_ip.py --- a/src/plugins/plugin_misc_ip.py Tue Nov 24 23:42:49 2015 +0100 +++ b/src/plugins/plugin_misc_ip.py Wed Nov 25 00:22:23 2015 +0100 @@ -31,6 +31,7 @@ from zope.interface import implements from wokkel import disco, iwokkel from twisted.words.protocols.jabber.xmlstream import XMPPHandler +from twisted.words.protocols.jabber.error import StanzaError import urlparse try: import netifaces @@ -252,17 +253,20 @@ defer.returnValue(self._external_ip_cache) # we first try with XEP-0279 - if self.host.hasFeature(NS_IP_CHECK, profile=profile): + ip_check = yield self.host.hasFeature(NS_IP_CHECK, profile=profile) + if ip_check: log.debug(u"Server IP Check available, we use it to retrieve our IP") client = self.host.getClient(profile) iq_elt = client.IQ("get") iq_elt.addElement((NS_IP_CHECK, 'address')) - result_elt = yield iq_elt.send() try: + result_elt = yield iq_elt.send() address_elt = result_elt.elements(NS_IP_CHECK, 'address').next() ip_elt = address_elt.elements(NS_IP_CHECK,'ip').next() except StopIteration: log.warning(u"Server returned invalid result on XEP-0279 request, we ignore it") + except StanzaError as e: + log.warning(u"error while requesting ip to server: {}".format(e)) else: # FIXME: server IP may not be the same as external IP (server can be on local machine or network) # IP should be checked to see if we have a local one, and rejected in this case