Mercurial > libervia-backend
diff src/plugins/plugin_misc_ip.py @ 1668:a9e86f660653
plugin ip: fixed ip check (XEP-0279) use
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 25 Nov 2015 00:22:23 +0100 |
parents | d5f59ba166fe |
children | d17772b0fe22 |
line wrap: on
line diff
--- 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