Skip to content

Commit

Permalink
Tunnels: Remove unnecessary casts in IMD
Browse files Browse the repository at this point in the history
since setReceivedBy() was promoted to super
  • Loading branch information
zzzi2p committed Dec 3, 2024
1 parent ddfa8ef commit 6ffdb70
Showing 1 changed file with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ public void distribute(I2NPMessage msg, Hash target, TunnelId tunnel) {

case DatabaseStoreMessage.MESSAGE_TYPE:
DatabaseStoreMessage dsm = (DatabaseStoreMessage) msg;
if (dsm.getEntry().getType() == DatabaseEntry.KEY_TYPE_ROUTERINFO) {
DatabaseEntry dbe = dsm.getEntry();
if (dbe.getType() == DatabaseEntry.KEY_TYPE_ROUTERINFO) {
// FVSJ may result in an unsolicited RI store if the peer went non-ff.
// We handle this safely, so we don't ask him again.
// Todo: if peer was ff and RI is not ff, queue for exploration in netdb (but that isn't part of the facade now)
Expand All @@ -125,7 +126,7 @@ public void distribute(I2NPMessage msg, Hash target, TunnelId tunnel) {
Hash key = dsm.getKey();
if (_context.routerHash().equals(key))
return;
RouterInfo ri = (RouterInfo) dsm.getEntry();
RouterInfo ri = (RouterInfo) dbe;
if (!key.equals(ri.getIdentity().getHash()))
return;
if (!ri.isValid())
Expand All @@ -148,7 +149,7 @@ public void distribute(I2NPMessage msg, Hash target, TunnelId tunnel) {
// allow DSM of our own key (used by FloodfillVerifyStoreJob)
// or other keys (used by IterativeSearchJob)
// as long as there's no reply token (we will never set a reply token but an attacker might)
((LeaseSet)dsm.getEntry()).setReceivedBy(_client);
dbe.setReceivedBy(_client);
}
break;

Expand Down Expand Up @@ -178,8 +179,9 @@ public void distribute(I2NPMessage msg, Hash target, TunnelId tunnel) {
_log.error("Dropping DSM w/ reply token down a expl. tunnel: " + msg);
return;
}
if (dsm.getEntry().isLeaseSet())
((LeaseSet)dsm.getEntry()).setReceivedBy(_client);
DatabaseEntry dbe = dsm.getEntry();
if (dbe.isLeaseSet())
dbe.setReceivedBy(_client);
break;

case DatabaseSearchReplyMessage.MESSAGE_TYPE:
Expand Down Expand Up @@ -277,7 +279,8 @@ public void handleClove(DeliveryInstructions instructions, I2NPMessage data) {
dsm.setReplyTunnel(null);
dsm.setReplyGateway(null);

if (dsm.getEntry().isLeaseSet()) {
DatabaseEntry dbe = dsm.getEntry();
if (dbe.isLeaseSet()) {
// Case 1:
// store of our own LS.
// This is almost certainly a response to a FloodfillVerifyStoreJob search.
Expand All @@ -292,7 +295,7 @@ public void handleClove(DeliveryInstructions instructions, I2NPMessage data) {
// Or, it's a normal LS bundled with data and a MessageStatusMessage.

// ... and inject it.
((LeaseSet)dsm.getEntry()).setReceivedBy(_client);
dbe.setReceivedBy(_client);
if (_log.shouldLog(Log.INFO))
_log.info("Storing garlic LS down tunnel for: " + dsm.getKey() + " sent to: "
+ _clientNickname + " ("
Expand Down

0 comments on commit 6ffdb70

Please sign in to comment.