Try to fix non-english Tor error messages

This commit is contained in:
HelloZeroNet 2016-03-18 19:17:15 +01:00
parent 0ee1448e13
commit 0ccc81f46b
1 changed files with 10 additions and 9 deletions

View File

@ -168,11 +168,11 @@ class TorManager:
res_auth = self.send("AUTHENTICATE", conn) res_auth = self.send("AUTHENTICATE", conn)
assert "250 OK" in res_auth, "Authenticate error %s" % res_auth assert "250 OK" in res_auth, "Authenticate error %s" % res_auth
self.status = "Connected (%s)" % res_auth self.status = u"Connected (%s)" % res_auth
self.conn = conn self.conn = conn
except Exception, err: except Exception, err:
self.conn = None self.conn = None
self.status = "Error (%s)" % err self.status = u"Error (%s)" % err
self.log.error("Tor controller connect error: %s" % Debug.formatException(err)) self.log.error("Tor controller connect error: %s" % Debug.formatException(err))
self.enabled = False self.enabled = False
return self.conn return self.conn
@ -182,14 +182,15 @@ class TorManager:
self.conn = None self.conn = None
def startOnions(self): def startOnions(self):
self.log.debug("Start onions") if self.enabled:
self.start_onions = True self.log.debug("Start onions")
self.start_onions = True
# Get new exit node ip # Get new exit node ip
def resetCircuits(self): def resetCircuits(self):
res = self.request("SIGNAL NEWNYM") res = self.request("SIGNAL NEWNYM")
if "250 OK" not in res: if "250 OK" not in res:
self.status = "Reset circuits error (%s)" % res self.status = u"Reset circuits error (%s)" % res
self.log.error("Tor reset circuits error: %s" % res) self.log.error("Tor reset circuits error: %s" % res)
def addOnion(self): def addOnion(self):
@ -198,11 +199,11 @@ class TorManager:
if match: if match:
onion_address, onion_privatekey = match.groups() onion_address, onion_privatekey = match.groups()
self.privatekeys[onion_address] = onion_privatekey self.privatekeys[onion_address] = onion_privatekey
self.status = "OK (%s onion running)" % len(self.privatekeys) self.status = u"OK (%s onion running)" % len(self.privatekeys)
SiteManager.peer_blacklist.append((onion_address + ".onion", self.fileserver_port)) SiteManager.peer_blacklist.append((onion_address + ".onion", self.fileserver_port))
return onion_address return onion_address
else: else:
self.status = "AddOnion error (%s)" % res self.status = u"AddOnion error (%s)" % res
self.log.error("Tor addOnion error: %s" % res) self.log.error("Tor addOnion error: %s" % res)
return False return False
@ -213,7 +214,7 @@ class TorManager:
self.status = "OK (%s onion running)" % len(self.privatekeys) self.status = "OK (%s onion running)" % len(self.privatekeys)
return True return True
else: else:
self.status = "DelOnion error (%s)" % res self.status = u"DelOnion error (%s)" % res
self.log.error("Tor delOnion error: %s" % res) self.log.error("Tor delOnion error: %s" % res)
self.disconnect() self.disconnect()
return False return False
@ -232,7 +233,7 @@ class TorManager:
conn = self.conn conn = self.conn
self.log.debug("> %s" % cmd) self.log.debug("> %s" % cmd)
conn.send("%s\r\n" % cmd) conn.send("%s\r\n" % cmd)
back = conn.recv(1024 * 64) back = conn.recv(1024 * 64).decode("utf8", "ignore")
self.log.debug("< %s" % back.strip()) self.log.debug("< %s" % back.strip())
return back return back