Improve Orbot Compatibility

Use password auth first to work with orbot
This commit is contained in:
saber28 2018-05-05 09:58:14 +08:00 committed by GitHub
parent e874730679
commit 94bc33f61c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 3 deletions

View File

@ -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)