From 94bc33f61cec29257d6fb3bdafed4a989147f5b9 Mon Sep 17 00:00:00 2001 From: saber28 Date: Sat, 5 May 2018 09:58:14 +0800 Subject: [PATCH] Improve Orbot Compatibility Use password auth first to work with orbot --- src/Tor/TorManager.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Tor/TorManager.py b/src/Tor/TorManager.py index ac48143d..20d0a259 100644 --- a/src/Tor/TorManager.py +++ b/src/Tor/TorManager.py @@ -183,12 +183,13 @@ class TorManager(object): # Auth cookie file res_protocol = self.send("PROTOCOLINFO", conn) cookie_match = re.search('COOKIEFILE="(.*?)"', res_protocol) - if cookie_match: + + if config.tor_password: + res_auth = self.send('AUTHENTICATE "%s"' % config.tor_password, conn) + elif cookie_match: cookie_file = cookie_match.group(1).decode("string-escape") auth_hex = binascii.b2a_hex(open(cookie_file, "rb").read()) res_auth = self.send("AUTHENTICATE %s" % auth_hex, conn) - elif config.tor_password: - res_auth = self.send('AUTHENTICATE "%s"' % config.tor_password, conn) else: res_auth = self.send("AUTHENTICATE", conn)