propagate from branch 'i2p.i2p' (head 79d0ad4538a0adc4ced6ac26cb725abe3d5ccee3)

to branch 'i2p.i2p.zzz.test2' (head 73032545b42f6f9caffffca08d0a8b97f5cf7e3a)
This commit is contained in:
zzz
2014-07-22 14:38:28 +00:00
28 changed files with 496 additions and 228 deletions

View File

@@ -18,7 +18,7 @@ public class RouterVersion {
/** deprecated */
public final static String ID = "Monotone";
public final static String VERSION = CoreVersion.VERSION;
public final static long BUILD = 14;
public final static long BUILD = 19;
/** for example "-test" */
public final static String EXTRA = "";

View File

@@ -64,7 +64,9 @@ class ClientListenerRunner implements Runnable {
return new ServerSocket(_port, 0, InetAddress.getByName(listenInterface));
}
}
public void run() { runServer(); }
/**
* Start up the socket listener, listens for connections, and
* fires those connections off via {@link #runConnection runConnection}.
@@ -72,7 +74,7 @@ class ClientListenerRunner implements Runnable {
* failure.
*
*/
public void runServer() {
protected void runServer() {
_running = true;
int curDelay = 1000;
while (_running) {
@@ -173,5 +175,4 @@ class ClientListenerRunner implements Runnable {
_socket = null;
} catch (IOException ioe) {}
}
public void run() { runServer(); }
}

View File

@@ -10,8 +10,10 @@ package net.i2p.router.client;
import java.io.IOException;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.LinkedBlockingQueue;
@@ -37,6 +39,7 @@ import net.i2p.router.JobImpl;
import net.i2p.router.RouterContext;
import net.i2p.util.I2PThread;
import net.i2p.util.Log;
import net.i2p.util.SystemVersion;
/**
* Coordinate connections and various tasks
@@ -45,7 +48,7 @@ import net.i2p.util.Log;
*/
class ClientManager {
private final Log _log;
protected ClientListenerRunner _listener;
protected final List<ClientListenerRunner> _listeners;
// Destination --> ClientConnectionRunner
// Locked for adds/removes but not lookups
private final Map<Destination, ClientConnectionRunner> _runners;
@@ -87,6 +90,7 @@ class ClientManager {
// "How large are messages received by the client?",
// "ClientMessages",
// new long[] { 60*1000l, 60*60*1000l, 24*60*60*1000l });
_listeners = new ArrayList<ClientListenerRunner>();
_runners = new ConcurrentHashMap<Destination, ClientConnectionRunner>();
_runnersByHash = new ConcurrentHashMap<Hash, ClientConnectionRunner>();
_pendingRunners = new HashSet<ClientConnectionRunner>();
@@ -105,14 +109,22 @@ class ClientManager {
/** Todo: Start a 3rd listener for IPV6? */
protected void startListeners() {
ClientListenerRunner listener;
if (SystemVersion.isAndroid()) {
listener = new DomainClientListenerRunner(_ctx, this);
Thread t = new I2PThread(listener, "DomainClientListener", true);
t.start();
_listeners.add(listener);
}
if (!_ctx.getBooleanProperty(PROP_DISABLE_EXTERNAL)) {
// there's no option to start both an SSL and non-SSL listener
if (_ctx.getBooleanProperty(PROP_ENABLE_SSL))
_listener = new SSLClientListenerRunner(_ctx, this, _port);
listener = new SSLClientListenerRunner(_ctx, this, _port);
else
_listener = new ClientListenerRunner(_ctx, this, _port);
Thread t = new I2PThread(_listener, "ClientListener:" + _port, true);
listener = new ClientListenerRunner(_ctx, this, _port);
Thread t = new I2PThread(listener, "ClientListener:" + _port, true);
t.start();
_listeners.add(listener);
}
_isStarted = true;
}
@@ -132,8 +144,9 @@ class ClientManager {
public synchronized void shutdown(String msg) {
_isStarted = false;
_log.info("Shutting down the ClientManager");
if (_listener != null)
_listener.stopListening();
for (ClientListenerRunner listener : _listeners)
listener.stopListening();
_listeners.clear();
Set<ClientConnectionRunner> runners = new HashSet<ClientConnectionRunner>();
synchronized (_runners) {
for (ClientConnectionRunner runner : _runners.values()) {
@@ -169,8 +182,13 @@ class ClientManager {
return hisQueue;
}
public boolean isAlive() {
return _isStarted && (_listener == null || _listener.isListening());
public synchronized boolean isAlive() {
boolean listening = true;
if (!_listeners.isEmpty()) {
for (ClientListenerRunner listener : _listeners)
listening = listening && listener.isListening();
}
return _isStarted && (_listeners.isEmpty() || listening);
}
public void registerConnection(ClientConnectionRunner runner) {

View File

@@ -0,0 +1,31 @@
package net.i2p.router.client;
import java.io.IOException;
import java.net.ServerSocket;
import net.i2p.client.DomainSocketFactory;
import net.i2p.router.RouterContext;
/**
* Unix domain socket version of ClientListenerRunner.
* <p/>
* This is a stub that does nothing.
* This class is replaced in the Android build.
*
* @author str4d
* @since 0.9.14
*/
public class DomainClientListenerRunner extends ClientListenerRunner {
public DomainClientListenerRunner(RouterContext context, ClientManager manager) {
super(context, manager, -1);
}
/**
* @throws IOException
*/
@Override
protected ServerSocket getServerSocket() throws IOException {
final DomainSocketFactory fact = new DomainSocketFactory(_context);
return fact.createServerSocket(DomainSocketFactory.I2CP_SOCKET_ADDRESS);
}
}

View File

@@ -181,7 +181,7 @@ class SSLClientListenerRunner extends ClientListenerRunner {
* Create (if necessary) and load the key store, then run.
*/
@Override
public void runServer() {
protected void runServer() {
File keyStore = new File(_context.getConfigDir(), "keystore/i2cp.ks");
if (verifyKeyStore(keyStore) && initializeFactory(keyStore)) {
super.runServer();

View File

@@ -534,7 +534,9 @@ public class Reseeder {
break;
}
} catch (Throwable t) {
_log.warn("Error reseeding", t);
System.err.println("Error reseeding: " + t);
_log.error("Error reseeding", t);
errors++;
} finally {
if (contentRaw != null)
contentRaw.delete();

View File

@@ -10,6 +10,9 @@
Classes in this package, sub-packages, and others in router.jar are
not for use by apps, clients or plugins (except for routerconsole).
Subject to change. Not necessarily maintained as a stable API.
</p><p>
For applications bundling the I2P router, instantiate Router and call runRouter(), or use Router.main() or RouterLaunch.
Most public methods in Router are maintained as a stable I2P for those bundling the router.
</p>
</body>
</html>

View File

@@ -36,9 +36,10 @@ class LocalClientManager extends ClientManager {
@Override
protected void startListeners() {
_listener = new LocalClientListenerRunner(_ctx, this, _port);
Thread t = new I2PThread(_listener, "ClientListener:" + _port, true);
ClientListenerRunner listener = new LocalClientListenerRunner(_ctx, this, _port);
Thread t = new I2PThread(listener, "ClientListener:" + _port, true);
t.start();
_listeners.add(listener);
_isStarted = true;
}