forked from I2P_Developers/i2p.i2p
i2ptunnel: Log correct server host/port on error when there are multiple targets configured
This commit is contained in:
@@ -583,6 +583,7 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
|
||||
", start runners: " + (afterHandle-afterSocket) +
|
||||
"]");
|
||||
} catch (SocketException ex) {
|
||||
int port = socket.getLocalPort();
|
||||
try {
|
||||
// Send a 503, so the user doesn't get an HTTP Proxy error message
|
||||
// and blame his router or the network.
|
||||
@@ -594,7 +595,7 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
|
||||
// Don't complain too early, Jetty may not be ready.
|
||||
int level = getTunnel().getContext().clock().now() - _startedOn > START_INTERVAL ? Log.ERROR : Log.WARN;
|
||||
if (_log.shouldLog(level))
|
||||
_log.log(level, "Error connecting to HTTP server " + remoteHost + ':' + remotePort, ex);
|
||||
_log.log(level, "Error connecting to HTTP server " + getSocketString(port));
|
||||
} catch (IOException ex) {
|
||||
try {
|
||||
socket.close();
|
||||
|
||||
@@ -804,11 +804,12 @@ public class I2PTunnelServer extends I2PTunnelTask implements Runnable {
|
||||
_log.warn("Took a while to handle the request for " + remoteHost + ':' + remotePort +
|
||||
" [" + timeToHandle + ", socket create: " + (afterSocket-afterAccept) + "]");
|
||||
} catch (SocketException ex) {
|
||||
int port = socket.getLocalPort();
|
||||
try {
|
||||
socket.reset();
|
||||
} catch (IOException ioe) {}
|
||||
if (_log.shouldLog(Log.ERROR))
|
||||
_log.error("Error connecting to server " + remoteHost + ':' + remotePort, ex);
|
||||
_log.error("Error connecting to server " + getSocketString(port));
|
||||
} catch (IOException ex) {
|
||||
_log.error("Error while waiting for I2PConnections", ex);
|
||||
}
|
||||
@@ -839,6 +840,21 @@ public class I2PTunnelServer extends I2PTunnelTask implements Runnable {
|
||||
return getSocket(from, host, port, force);
|
||||
}
|
||||
|
||||
/**
|
||||
* Only for logging, to correctly show where we were trying to get to
|
||||
* after getSocket() throws a SocketException
|
||||
*
|
||||
* @since 0.9.62
|
||||
*/
|
||||
protected String getSocketString(int incomingPort) {
|
||||
if (incomingPort != 0 && !_socketMap.isEmpty()) {
|
||||
InetSocketAddress isa = _socketMap.get(Integer.valueOf(incomingPort));
|
||||
if (isa != null)
|
||||
return isa.toString();
|
||||
}
|
||||
return remoteHost.toString() + ':' + remotePort;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a regular or SSL socket depending on config.
|
||||
* The SSL config applies to all hosts/ports.
|
||||
|
||||
Reference in New Issue
Block a user