aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@frugalware.org>2008-11-16 02:16:54 +0100
committerMiklos Vajna <vmiklos@frugalware.org>2008-11-16 02:16:54 +0100
commit6b9cab1b2a6e9fa743ff3528090bb3a00ce14f71 (patch)
tree5a67a119d002ba2d7472c7e2be44bf6eb617f22a
parentc1bf7c5f9041f99934d1932fdd62457b88d4ac36 (diff)
skyped: handle the case when even reading the user/pass fails
ideally this is rare, i never got a network error right after connect, but you can never be sure.. ;)
-rw-r--r--skype/skyped.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/skype/skyped.py b/skype/skyped.py
index f61583f3..56cdc498 100644
--- a/skype/skyped.py
+++ b/skype/skyped.py
@@ -117,12 +117,17 @@ def listener(sock, *args):
dprint("Warning, handshake failed, closing connection.")
return False
ret = 0
- line = options.conn.recv(1024)
- if line.startswith("USERNAME") and line.split(' ')[1].strip() == options.config.username:
- ret += 1
- line = options.conn.recv(1024)
- if line.startswith("PASSWORD") and sha.sha(line.split(' ')[1].strip()).hexdigest() == options.config.password:
- ret += 1
+ try:
+ line = options.conn.recv(1024)
+ if line.startswith("USERNAME") and line.split(' ')[1].strip() == options.config.username:
+ ret += 1
+ line = options.conn.recv(1024)
+ if line.startswith("PASSWORD") and sha.sha(line.split(' ')[1].strip()).hexdigest() == options.config.password:
+ ret += 1
+ except Exception, s:
+ dprint("Warning, receiving 1024 bytes failed (%s)." % s)
+ options.conn.close()
+ return False
if ret == 2:
dprint("Username and password OK.")
options.conn.send("PASSWORD OK\n")