Patched tor and jtorctl for improved hidden service performance.

Two changes have been made to Tor:

1. Set can_complete_circuit to false when the network is disabled, and
don't try to build introduction circuits while can_complete_circuit is
false. This avoids a situation where Tor tries to build introduction
circuits as soon as the network is re-enabled, all the circuits fail,
and then Tor waits 5 minutes before trying to build more.

2. Added a FORGETHS command to the control protocol which clears any
cached client state relating to a specified hidden service. This can be
used to flush state that's likely to be stale before trying to connect
to a hidden service with an unstable network connection.

Support for the FORGETHS command was also added to jtorctl.
This commit is contained in:
akwizgran
2014-10-06 18:57:57 +01:00
parent 3051d8811e
commit 9e5e2e2df2
5 changed files with 205 additions and 6 deletions

View File

@@ -525,6 +525,7 @@ class TorPlugin implements DuplexPlugin, EventHandler {
}
try {
if(LOG.isLoggable(INFO)) LOG.info("Connecting to " + onion);
controlConnection.forgetHiddenService(onion.substring(0, 16));
Socks5Proxy proxy = new Socks5Proxy("127.0.0.1", SOCKS_PORT);
proxy.resolveAddrLocally(false);
Socket s = new SocksSocket(proxy, onion, 80);
@@ -546,7 +547,6 @@ class TorPlugin implements DuplexPlugin, EventHandler {
}
public void circuitStatus(String status, String id, String path) {
if(LOG.isLoggable(INFO)) LOG.info("Circuit " + id + " " + status);
if(status.equals("BUILT") && !circuitBuilt.getAndSet(true)) {
LOG.info("First circuit built");
if(isRunning()) callback.pollNow();
@@ -571,9 +571,7 @@ class TorPlugin implements DuplexPlugin, EventHandler {
}
}
public void unrecognized(String type, String msg) {
if(LOG.isLoggable(INFO)) LOG.info(type + " " + msg);
}
public void unrecognized(String type, String msg) {}
private static class WriteObserver extends FileObserver {