forked from I2P_Developers/i2p.i2p
i2ptunnel: Fixes and cleanups for command line testing;
catch IAE from getInstance() if i2ptunnel.config isn't found in app context; log tweaks; config command tweaks Unit tests: Fix several NPEs in LocalClientManager, implement HostLookup
This commit is contained in:
@@ -165,7 +165,9 @@ class ClientConnectionRunner {
|
||||
*/
|
||||
public synchronized void stopRunning() {
|
||||
if (_dead) return;
|
||||
if (_context.router().isAlive() && _log.shouldLog(Log.WARN))
|
||||
// router may be null in unit tests
|
||||
if ((_context.router() == null || _context.router().isAlive()) &&
|
||||
_log.shouldWarn())
|
||||
_log.warn("Stop the I2CP connection! current leaseSet: "
|
||||
+ _currentLeaseSet, new Exception("Stop client connection"));
|
||||
_dead = true;
|
||||
|
||||
@@ -15,6 +15,7 @@ import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
|
||||
import net.i2p.client.I2PClient;
|
||||
import net.i2p.router.Router;
|
||||
import net.i2p.router.RouterContext;
|
||||
import net.i2p.util.Log;
|
||||
|
||||
@@ -101,17 +102,17 @@ class ClientListenerRunner implements Runnable {
|
||||
} catch (IOException ioe) {}
|
||||
}
|
||||
} catch (IOException ioe) {
|
||||
if (_context.router().isAlive())
|
||||
if (isAlive())
|
||||
_log.error("Server error accepting", ioe);
|
||||
} catch (Throwable t) {
|
||||
if (_context.router().isAlive())
|
||||
if (isAlive())
|
||||
_log.error("Fatal error running client listener - killing the thread!", t);
|
||||
_listening = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
} catch (IOException ioe) {
|
||||
if (_context.router().isAlive())
|
||||
if (isAlive())
|
||||
_log.error("Error listening on port " + _port, ioe);
|
||||
}
|
||||
|
||||
@@ -121,7 +122,7 @@ class ClientListenerRunner implements Runnable {
|
||||
_socket = null;
|
||||
}
|
||||
|
||||
if (!_context.router().isAlive()) break;
|
||||
if (!isAlive()) break;
|
||||
|
||||
if (curDelay < 60*1000)
|
||||
_log.error("Error listening, waiting " + (curDelay/1000) + "s before we try again");
|
||||
@@ -131,11 +132,20 @@ class ClientListenerRunner implements Runnable {
|
||||
curDelay = Math.min(curDelay*3, 60*1000);
|
||||
}
|
||||
|
||||
if (_context.router().isAlive())
|
||||
if (isAlive())
|
||||
_log.error("CANCELING I2CP LISTEN", new Exception("I2CP Listen cancelled!!!"));
|
||||
_running = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Just so unit tests don't NPE, where router could be null.
|
||||
* @since 0.9.20
|
||||
*/
|
||||
private boolean isAlive() {
|
||||
Router r = _context.router();
|
||||
return r == null || r.isAlive();
|
||||
}
|
||||
|
||||
/** give the i2cp client 5 seconds to show that they're really i2cp clients */
|
||||
protected final static int CONNECT_TIMEOUT = 5*1000;
|
||||
private final static int LOOP_DELAY = 250;
|
||||
|
||||
Reference in New Issue
Block a user