forked from I2P_Developers/i2p.i2p
I2CP: Fix error message for config errors (ticket #2639)
This commit is contained in:
@ -34,6 +34,11 @@ public class SessionStatusMessage extends I2CPMessageImpl {
|
|||||||
public final static int STATUS_INVALID = 3;
|
public final static int STATUS_INVALID = 3;
|
||||||
/** @since 0.9.12 */
|
/** @since 0.9.12 */
|
||||||
public final static int STATUS_REFUSED = 4;
|
public final static int STATUS_REFUSED = 4;
|
||||||
|
/**
|
||||||
|
* Used internally, not in spec, will be remapped to STATUS_INVALID before being sent.
|
||||||
|
* @since 0.9.44
|
||||||
|
*/
|
||||||
|
public final static int STATUS_DUP_DEST = 5;
|
||||||
|
|
||||||
public SessionStatusMessage() {
|
public SessionStatusMessage() {
|
||||||
setStatus(STATUS_INVALID);
|
setStatus(STATUS_INVALID);
|
||||||
|
@ -552,7 +552,7 @@ class ClientConnectionRunner {
|
|||||||
sp.config = config;
|
sp.config = config;
|
||||||
SessionParams old = _sessions.putIfAbsent(destHash, sp);
|
SessionParams old = _sessions.putIfAbsent(destHash, sp);
|
||||||
if (old != null)
|
if (old != null)
|
||||||
return SessionStatusMessage.STATUS_INVALID;
|
return SessionStatusMessage.STATUS_DUP_DEST;
|
||||||
// We process a few options here, but most are handled by the tunnel manager.
|
// We process a few options here, but most are handled by the tunnel manager.
|
||||||
// The ones here can't be changed later.
|
// The ones here can't be changed later.
|
||||||
Properties opts = config.getOptions();
|
Properties opts = config.getOptions();
|
||||||
|
@ -325,7 +325,7 @@ class ClientManager {
|
|||||||
synchronized (_runners) {
|
synchronized (_runners) {
|
||||||
boolean fail = _runnersByHash.containsKey(dest.calculateHash());
|
boolean fail = _runnersByHash.containsKey(dest.calculateHash());
|
||||||
if (fail) {
|
if (fail) {
|
||||||
rv = SessionStatusMessage.STATUS_INVALID;
|
rv = SessionStatusMessage.STATUS_DUP_DEST;
|
||||||
} else {
|
} else {
|
||||||
SessionId id = locked_getNextSessionId();
|
SessionId id = locked_getNextSessionId();
|
||||||
if (id != null) {
|
if (id != null) {
|
||||||
@ -339,7 +339,7 @@ class ClientManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (rv == SessionStatusMessage.STATUS_INVALID) {
|
if (rv == SessionStatusMessage.STATUS_DUP_DEST) {
|
||||||
_log.log(Log.CRIT, "Client attempted to register duplicate destination " + dest.toBase32());
|
_log.log(Log.CRIT, "Client attempted to register duplicate destination " + dest.toBase32());
|
||||||
} else if (rv == SessionStatusMessage.STATUS_REFUSED) {
|
} else if (rv == SessionStatusMessage.STATUS_REFUSED) {
|
||||||
_log.error("Max sessions exceeded " + dest.toBase32());
|
_log.error("Max sessions exceeded " + dest.toBase32());
|
||||||
|
@ -326,12 +326,17 @@ class ClientMessageEventListener implements I2CPMessageReader.I2CPMessageEventLi
|
|||||||
if (_log.shouldLog(Log.ERROR))
|
if (_log.shouldLog(Log.ERROR))
|
||||||
_log.error("Session establish failed: code = " + status);
|
_log.error("Session establish failed: code = " + status);
|
||||||
String msg;
|
String msg;
|
||||||
if (status == SessionStatusMessage.STATUS_INVALID)
|
if (status == SessionStatusMessage.STATUS_DUP_DEST) {
|
||||||
msg = "duplicate destination";
|
msg = "duplicate destination";
|
||||||
else if (status == SessionStatusMessage.STATUS_REFUSED)
|
// not in spec, change to INVALID if we send it
|
||||||
|
// status = SessionStatusMessage.STATUS_INVALID
|
||||||
|
} else if (status == SessionStatusMessage.STATUS_INVALID) {
|
||||||
|
msg = "bad session configuration parameters";
|
||||||
|
} else if (status == SessionStatusMessage.STATUS_REFUSED) {
|
||||||
msg = "session limit exceeded";
|
msg = "session limit exceeded";
|
||||||
else
|
} else {
|
||||||
msg = "unknown error";
|
msg = "unknown error";
|
||||||
|
}
|
||||||
_runner.disconnectClient(msg);
|
_runner.disconnectClient(msg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user