SAM: Improve checks for unset tunnel nickname

This commit is contained in:
zzz
2021-03-20 12:12:21 -04:00
parent 005ac38742
commit 838295c014
2 changed files with 14 additions and 6 deletions

View File

@@ -261,10 +261,14 @@ abstract class SAMMessageSession implements SAMMessageSess {
_log.debug("Instantiating new SAM message-based session handler");
I2PClient client = I2PClientFactory.createClient();
if (!props.containsKey("inbound.nickname") && !props.containsKey("outbound.nickname")) {
props.setProperty("inbound.nickname", "SAM UDP Client");
props.setProperty("outbound.nickname", "SAM UDP Client");
String name = props.getProperty("inbound.nickname");
if (name == null || name.trim().isEmpty()) {
name = "SAM UDP Client";
props.setProperty("inbound.nickname", name);
}
String name2 = props.getProperty("outbound.nickname");
if (name2 == null || name2.trim().isEmpty())
props.setProperty("outbound.nickname", name);
_session = client.createSession(destStream, props);
if (_log.shouldLog(Log.DEBUG))

View File

@@ -162,10 +162,14 @@ class SAMStreamSession implements SAMMessageSess {
}
if (!canReceive)
allprops.setProperty("i2cp.dontPublishLeaseSet", "true");
if (!allprops.containsKey("inbound.nickname") && !allprops.containsKey("outbound.nickname")) {
allprops.setProperty("inbound.nickname", "SAM TCP Client");
allprops.setProperty("outbound.nickname", "SAM TCP Client");
String name = allprops.getProperty("inbound.nickname");
if (name == null || name.trim().isEmpty()) {
name = "SAM TCP Client";
allprops.setProperty("inbound.nickname", name);
}
String name2 = allprops.getProperty("outbound.nickname");
if (name2 == null || name2.trim().isEmpty())
allprops.setProperty("outbound.nickname", name);
_isOwnSession = true;
if (_log.shouldLog(Log.DEBUG))