changeset 06207bfa2cd8 in /home/hg/repos/gajim

author: Emmanuel Gil Peyrot <[email protected]>
branches: 
details:http://hg.gajim.org/gajim?cmd=changeset;node=06207bfa2cd8
description: Make the port optional in <streamhost/>

        XEP-0065 section 9.2 says “The "port" attribute specifies the port to
        connect to.  This attribute MAY be present.  The value MUST be a valid
        port number in decimal form.  If not specified, the port value is
        "1080" (in accordance with RFC 1928).”

        This fixes a traceback when a streamhost is advertised with the default
        port.

diffstat:

 src/common/proxy65_manager.py |  8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diffs (19 lines):

diff -r 1d8d3d27d84f -r 06207bfa2cd8 src/common/proxy65_manager.py
--- a/src/common/proxy65_manager.py     Mon Jul 18 22:15:24 2016 +0200
+++ b/src/common/proxy65_manager.py     Tue Aug 02 14:09:22 2016 +0100
@@ -84,9 +84,13 @@
         for item in query.getChildren():
             if item.getName() == 'streamhost':
                 host = item.getAttr('host')
+                jid = item.getAttr('jid')
                 port = item.getAttr('port')
-                jid = item.getAttr('jid')
-                if not host or not port or not jid:
+                try:
+                    port = int(port)
+                except ValueError, TypeError:
+                    port = 1080
+                if not host or not jid:
                     self.proxies[proxy]._on_connect_failure()
                 self.proxies[proxy].resolve_result(host, port, jid)
                 # we can have only one streamhost
_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits

Reply via email to