forked from I2P_Developers/i2p.i2p
Cleanup to combine checking and removing a property
This commit is contained in:
@ -230,13 +230,12 @@ class SAMv1Handler extends SAMHandler implements SAMRawReceiver, SAMDatagramRece
|
|||||||
return writeString("SESSION STATUS RESULT=I2P_ERROR MESSAGE=\"No parameters for SESSION CREATE\"\n");
|
return writeString("SESSION STATUS RESULT=I2P_ERROR MESSAGE=\"No parameters for SESSION CREATE\"\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
dest = props.getProperty("DESTINATION");
|
dest = (String) props.remove("DESTINATION");
|
||||||
if (dest == null) {
|
if (dest == null) {
|
||||||
if (_log.shouldLog(Log.DEBUG))
|
if (_log.shouldLog(Log.DEBUG))
|
||||||
_log.debug("SESSION DESTINATION parameter not specified");
|
_log.debug("SESSION DESTINATION parameter not specified");
|
||||||
return writeString("SESSION STATUS RESULT=I2P_ERROR MESSAGE=\"DESTINATION not specified\"\n");
|
return writeString("SESSION STATUS RESULT=I2P_ERROR MESSAGE=\"DESTINATION not specified\"\n");
|
||||||
}
|
}
|
||||||
props.remove("DESTINATION");
|
|
||||||
|
|
||||||
String destKeystream = null;
|
String destKeystream = null;
|
||||||
|
|
||||||
@ -261,13 +260,12 @@ class SAMv1Handler extends SAMHandler implements SAMRawReceiver, SAMDatagramRece
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String style = props.getProperty("STYLE");
|
String style = (String) props.remove("STYLE");
|
||||||
if (style == null) {
|
if (style == null) {
|
||||||
if (_log.shouldLog(Log.DEBUG))
|
if (_log.shouldLog(Log.DEBUG))
|
||||||
_log.debug("SESSION STYLE parameter not specified");
|
_log.debug("SESSION STYLE parameter not specified");
|
||||||
return writeString("SESSION STATUS RESULT=I2P_ERROR MESSAGE=\"No SESSION STYLE specified\"\n");
|
return writeString("SESSION STATUS RESULT=I2P_ERROR MESSAGE=\"No SESSION STYLE specified\"\n");
|
||||||
}
|
}
|
||||||
props.remove("STYLE");
|
|
||||||
|
|
||||||
// Unconditionally override what the client may have set
|
// Unconditionally override what the client may have set
|
||||||
// (iMule sets BestEffort) as None is more efficient
|
// (iMule sets BestEffort) as None is more efficient
|
||||||
@ -279,7 +277,7 @@ class SAMv1Handler extends SAMHandler implements SAMRawReceiver, SAMDatagramRece
|
|||||||
} else if (style.equals("DATAGRAM")) {
|
} else if (style.equals("DATAGRAM")) {
|
||||||
datagramSession = new SAMDatagramSession(destKeystream, props,this);
|
datagramSession = new SAMDatagramSession(destKeystream, props,this);
|
||||||
} else if (style.equals("STREAM")) {
|
} else if (style.equals("STREAM")) {
|
||||||
String dir = props.getProperty("DIRECTION");
|
String dir = (String) props.remove("DIRECTION");
|
||||||
if (dir == null) {
|
if (dir == null) {
|
||||||
if (_log.shouldLog(Log.DEBUG))
|
if (_log.shouldLog(Log.DEBUG))
|
||||||
_log.debug("No DIRECTION parameter in STREAM session, defaulting to BOTH");
|
_log.debug("No DIRECTION parameter in STREAM session, defaulting to BOTH");
|
||||||
@ -289,8 +287,6 @@ class SAMv1Handler extends SAMHandler implements SAMRawReceiver, SAMDatagramRece
|
|||||||
if (_log.shouldLog(Log.DEBUG))
|
if (_log.shouldLog(Log.DEBUG))
|
||||||
_log.debug("Unknown DIRECTION parameter value: [" + dir + "]");
|
_log.debug("Unknown DIRECTION parameter value: [" + dir + "]");
|
||||||
return writeString("SESSION STATUS RESULT=I2P_ERROR MESSAGE=\"Unknown DIRECTION parameter\"\n");
|
return writeString("SESSION STATUS RESULT=I2P_ERROR MESSAGE=\"Unknown DIRECTION parameter\"\n");
|
||||||
} else {
|
|
||||||
props.remove("DIRECTION");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
streamSession = newSAMStreamSession(destKeystream, dir,props);
|
streamSession = newSAMStreamSession(destKeystream, dir,props);
|
||||||
@ -732,7 +728,7 @@ class SAMv1Handler extends SAMHandler implements SAMRawReceiver, SAMDatagramRece
|
|||||||
|
|
||||||
int id;
|
int id;
|
||||||
{
|
{
|
||||||
String strid = props.getProperty("ID");
|
String strid = (String) props.remove("ID");
|
||||||
if (strid == null) {
|
if (strid == null) {
|
||||||
if (_log.shouldLog(Log.DEBUG))
|
if (_log.shouldLog(Log.DEBUG))
|
||||||
_log.debug("ID not specified in STREAM SEND message");
|
_log.debug("ID not specified in STREAM SEND message");
|
||||||
@ -750,15 +746,13 @@ class SAMv1Handler extends SAMHandler implements SAMRawReceiver, SAMDatagramRece
|
|||||||
_log.debug("Invalid STREAM CONNECT ID specified: " +strid);
|
_log.debug("Invalid STREAM CONNECT ID specified: " +strid);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
props.remove("ID");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String dest = props.getProperty("DESTINATION");
|
String dest = (String) props.remove("DESTINATION");
|
||||||
if (dest == null) {
|
if (dest == null) {
|
||||||
_log.debug("Destination not specified in RAW SEND message");
|
_log.debug("Destination not specified in RAW SEND message");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
props.remove("DESTINATION");
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
try {
|
try {
|
||||||
|
@ -509,18 +509,17 @@ class SAMv3Handler extends SAMv1Handler
|
|||||||
return writeString("SESSION STATUS RESULT=I2P_ERROR MESSAGE=\"No parameters for SESSION CREATE\"\n");
|
return writeString("SESSION STATUS RESULT=I2P_ERROR MESSAGE=\"No parameters for SESSION CREATE\"\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
dest = props.getProperty("DESTINATION");
|
dest = (String) props.remove("DESTINATION");
|
||||||
if (dest == null) {
|
if (dest == null) {
|
||||||
if (_log.shouldLog(Log.DEBUG))
|
if (_log.shouldLog(Log.DEBUG))
|
||||||
_log.debug("SESSION DESTINATION parameter not specified");
|
_log.debug("SESSION DESTINATION parameter not specified");
|
||||||
return writeString("SESSION STATUS RESULT=I2P_ERROR MESSAGE=\"DESTINATION not specified\"\n");
|
return writeString("SESSION STATUS RESULT=I2P_ERROR MESSAGE=\"DESTINATION not specified\"\n");
|
||||||
}
|
}
|
||||||
props.remove("DESTINATION");
|
|
||||||
|
|
||||||
if (dest.equals("TRANSIENT")) {
|
if (dest.equals("TRANSIENT")) {
|
||||||
if (_log.shouldLog(Log.DEBUG))
|
if (_log.shouldLog(Log.DEBUG))
|
||||||
_log.debug("TRANSIENT destination requested");
|
_log.debug("TRANSIENT destination requested");
|
||||||
String sigTypeStr = props.getProperty("SIGNATURE_TYPE");
|
String sigTypeStr = (String) props.remove("SIGNATURE_TYPE");
|
||||||
SigType sigType;
|
SigType sigType;
|
||||||
if (sigTypeStr != null) {
|
if (sigTypeStr != null) {
|
||||||
sigType = SigType.parseSigType(sigTypeStr);
|
sigType = SigType.parseSigType(sigTypeStr);
|
||||||
@ -528,7 +527,6 @@ class SAMv3Handler extends SAMv1Handler
|
|||||||
return writeString("SESSION STATUS RESULT=I2P_ERROR MESSAGE=\"SIGNATURE_TYPE "
|
return writeString("SESSION STATUS RESULT=I2P_ERROR MESSAGE=\"SIGNATURE_TYPE "
|
||||||
+ sigTypeStr + " unsupported\"\n");
|
+ sigTypeStr + " unsupported\"\n");
|
||||||
}
|
}
|
||||||
props.remove("SIGNATURE_TYPE");
|
|
||||||
} else {
|
} else {
|
||||||
sigType = SigType.DSA_SHA1;
|
sigType = SigType.DSA_SHA1;
|
||||||
}
|
}
|
||||||
@ -544,22 +542,20 @@ class SAMv3Handler extends SAMv1Handler
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
nick = props.getProperty("ID");
|
nick = (String) props.remove("ID");
|
||||||
if (nick == null) {
|
if (nick == null) {
|
||||||
if (_log.shouldLog(Log.DEBUG))
|
if (_log.shouldLog(Log.DEBUG))
|
||||||
_log.debug("SESSION ID parameter not specified");
|
_log.debug("SESSION ID parameter not specified");
|
||||||
return writeString("SESSION STATUS RESULT=I2P_ERROR MESSAGE=\"ID not specified\"\n");
|
return writeString("SESSION STATUS RESULT=I2P_ERROR MESSAGE=\"ID not specified\"\n");
|
||||||
}
|
}
|
||||||
props.remove("ID");
|
|
||||||
|
|
||||||
|
|
||||||
String style = props.getProperty("STYLE");
|
String style = (String) props.remove("STYLE");
|
||||||
if (style == null) {
|
if (style == null) {
|
||||||
if (_log.shouldLog(Log.DEBUG))
|
if (_log.shouldLog(Log.DEBUG))
|
||||||
_log.debug("SESSION STYLE parameter not specified");
|
_log.debug("SESSION STYLE parameter not specified");
|
||||||
return writeString("SESSION STATUS RESULT=I2P_ERROR MESSAGE=\"No SESSION STYLE specified\"\n");
|
return writeString("SESSION STATUS RESULT=I2P_ERROR MESSAGE=\"No SESSION STYLE specified\"\n");
|
||||||
}
|
}
|
||||||
props.remove("STYLE");
|
|
||||||
|
|
||||||
// Unconditionally override what the client may have set
|
// Unconditionally override what the client may have set
|
||||||
// (iMule sets BestEffort) as None is more efficient
|
// (iMule sets BestEffort) as None is more efficient
|
||||||
@ -663,7 +659,7 @@ class SAMv3Handler extends SAMv1Handler
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
nick = props.getProperty("ID");
|
nick = (String) props.remove("ID");
|
||||||
if (nick == null) {
|
if (nick == null) {
|
||||||
if (_log.shouldLog(Log.DEBUG))
|
if (_log.shouldLog(Log.DEBUG))
|
||||||
_log.debug("SESSION ID parameter not specified");
|
_log.debug("SESSION ID parameter not specified");
|
||||||
@ -672,7 +668,6 @@ class SAMv3Handler extends SAMv1Handler
|
|||||||
} catch (IOException e) {}
|
} catch (IOException e) {}
|
||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
props.remove("ID");
|
|
||||||
|
|
||||||
rec = sSessionsHash.get(nick);
|
rec = sSessionsHash.get(nick);
|
||||||
|
|
||||||
@ -733,14 +728,13 @@ class SAMv3Handler extends SAMv1Handler
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
String dest = props.getProperty("DESTINATION");
|
String dest = (String) props.remove("DESTINATION");
|
||||||
if (dest == null) {
|
if (dest == null) {
|
||||||
notifyStreamResult(verbose, "I2P_ERROR", "Destination not specified in STREAM CONNECT message");
|
notifyStreamResult(verbose, "I2P_ERROR", "Destination not specified in STREAM CONNECT message");
|
||||||
if (_log.shouldLog(Log.DEBUG))
|
if (_log.shouldLog(Log.DEBUG))
|
||||||
_log.debug("Destination not specified in STREAM CONNECT message");
|
_log.debug("Destination not specified in STREAM CONNECT message");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
props.remove("DESTINATION");
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
((SAMv3StreamSession)streamSession).connect( this, dest, props );
|
((SAMv3StreamSession)streamSession).connect( this, dest, props );
|
||||||
|
Reference in New Issue
Block a user