From d625659cc6657dd96bd1e52e6b6a5d0e58aa36c4 Mon Sep 17 00:00:00 2001 From: Peter Surda Date: Sat, 26 Mar 2016 18:42:22 +0100 Subject: [PATCH] User agent parser fix --- src/class_receiveDataThread.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/class_receiveDataThread.py b/src/class_receiveDataThread.py index a8854e47..d63b19eb 100644 --- a/src/class_receiveDataThread.py +++ b/src/class_receiveDataThread.py @@ -707,14 +707,24 @@ class receiveDataThread(threading.Thread): useragent = data[readPosition:readPosition + useragentLength] # version check - userAgentName, userAgentVersion = useragent[1:-1].split(":") + try: + userAgentName, userAgentVersion = useragent[1:-1].split(":", 2) + except: + userAgentName = useragent + userAgentVersion = "0.0.0" if userAgentName == "PyBitmessage": myVersion = [int(n) for n in shared.softwareVersion.split(".")] - remoteVersion = [int(n) for n in userAgentVersion.split(".")] + try: + remoteVersion = [int(n) for n in userAgentVersion.split(".")] + except: + remoteVersion = 0 # remote is newer, but do not cross between stable and unstable - if cmp(remoteVersion, myVersion) > 0 and \ - (myVersion[1] % 2 == remoteVersion[1] % 2): - shared.UISignalQueue.put(('newVersionAvailable', remoteVersion)) + try: + if cmp(remoteVersion, myVersion) > 0 and \ + (myVersion[1] % 2 == remoteVersion[1] % 2): + shared.UISignalQueue.put(('newVersionAvailable', remoteVersion)) + except: + pass readPosition += useragentLength numberOfStreamsInVersionMessage, lengthOfNumberOfStreamsInVersionMessage = decodeVarint(