1
0
mirror of https://github.com/PurpleI2P/i2pd.git synced 2025-01-22 08:14:15 +00:00

check if datagram destination exists before sending

This commit is contained in:
orignal 2022-08-10 11:28:59 -04:00
parent 8f5768f85b
commit e9e641afbe

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2013-2021, The PurpleI2P Project * Copyright (c) 2013-2022, The PurpleI2P Project
* *
* This file is part of Purple i2pd project and licensed under BSD3 * This file is part of Purple i2pd project and licensed under BSD3
* *
@ -1478,14 +1478,21 @@ namespace client
auto session = FindSession (sessionID); auto session = FindSession (sessionID);
if (session) if (session)
{ {
i2p::data::IdentityEx dest; auto localDest = session->GetLocalDestination ();
dest.FromBase64 (destination); auto datagramDest = localDest ? localDest->GetDatagramDestination () : nullptr;
if (session->Type == eSAMSessionTypeDatagram) if (datagramDest)
session->GetLocalDestination ()->GetDatagramDestination ()-> {
SendDatagramTo ((uint8_t *)eol, payloadLen, dest.GetIdentHash ()); i2p::data::IdentityEx dest;
else // raw dest.FromBase64 (destination);
session->GetLocalDestination ()->GetDatagramDestination ()-> if (session->Type == eSAMSessionTypeDatagram)
SendRawDatagramTo ((uint8_t *)eol, payloadLen, dest.GetIdentHash ()); datagramDest->SendDatagramTo ((uint8_t *)eol, payloadLen, dest.GetIdentHash ());
else if (session->Type == eSAMSessionTypeRaw)
datagramDest->SendRawDatagramTo ((uint8_t *)eol, payloadLen, dest.GetIdentHash ());
else
LogPrint (eLogError, "SAM: Unexpected session type ", (int)session->Type, "for session ", sessionID);
}
else
LogPrint (eLogError, "SAM: Datagram destination is not set for session ", sessionID);
} }
else else
LogPrint (eLogError, "SAM: Session ", sessionID, " not found"); LogPrint (eLogError, "SAM: Session ", sessionID, " not found");