|
|
|
@ -33,6 +33,23 @@ namespace datagram
@@ -33,6 +33,23 @@ namespace datagram
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void DatagramDestination::SendDatagramTo(const uint8_t * payload, size_t len, const i2p::data::IdentHash & identity, uint16_t fromPort, uint16_t toPort) |
|
|
|
|
{ |
|
|
|
|
SendDatagram (ObtainSession(identity), payload, len, fromPort, toPort); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void DatagramDestination::SendRawDatagramTo(const uint8_t * payload, size_t len, const i2p::data::IdentHash & identity, uint16_t fromPort, uint16_t toPort) |
|
|
|
|
{ |
|
|
|
|
SendRawDatagram (ObtainSession(identity), payload, len, fromPort, toPort); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::shared_ptr<DatagramSession> DatagramDestination::GetSession(const i2p::data::IdentHash & ident) |
|
|
|
|
{ |
|
|
|
|
return ObtainSession(ident); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void DatagramDestination::SendDatagram (std::shared_ptr<DatagramSession> session, const uint8_t * payload, size_t len, uint16_t fromPort, uint16_t toPort) |
|
|
|
|
{ |
|
|
|
|
if (session) |
|
|
|
|
{ |
|
|
|
|
if (m_Owner->GetIdentity ()->GetSigningKeyType () == i2p::data::SIGNING_KEY_TYPE_DSA_SHA1) |
|
|
|
|
{ |
|
|
|
@ -43,22 +60,22 @@ namespace datagram
@@ -43,22 +60,22 @@ namespace datagram
|
|
|
|
|
else |
|
|
|
|
m_Owner->Sign (payload, len, m_Signature.data ()); |
|
|
|
|
|
|
|
|
|
auto session = ObtainSession(identity); |
|
|
|
|
auto msg = CreateDataMessage ({{m_From.data (), m_From.size ()}, {m_Signature.data (), m_Signature.size ()}, {payload, len}}, |
|
|
|
|
fromPort, toPort, false, !session->IsRatchets ()); // datagram
|
|
|
|
|
session->SendMsg(msg); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void DatagramDestination::SendRawDatagramTo(const uint8_t * payload, size_t len, const i2p::data::IdentHash & identity, uint16_t fromPort, uint16_t toPort) |
|
|
|
|
void DatagramDestination::SendRawDatagram (std::shared_ptr<DatagramSession> session, const uint8_t * payload, size_t len, uint16_t fromPort, uint16_t toPort) |
|
|
|
|
{ |
|
|
|
|
auto session = ObtainSession(identity); |
|
|
|
|
auto msg = CreateDataMessage ({{payload, len}}, fromPort, toPort, true, !session->IsRatchets ()); // raw
|
|
|
|
|
session->SendMsg(msg); |
|
|
|
|
if (session) |
|
|
|
|
session->SendMsg(CreateDataMessage ({{payload, len}}, fromPort, toPort, true, !session->IsRatchets ())); // raw
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void DatagramDestination::FlushSendQueue (const i2p::data::IdentHash & ident) |
|
|
|
|
void DatagramDestination::FlushSendQueue (std::shared_ptr<DatagramSession> session) |
|
|
|
|
{ |
|
|
|
|
ObtainSession(ident)->FlushSendQueue (); |
|
|
|
|
if (session) |
|
|
|
|
session->FlushSendQueue (); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void DatagramDestination::HandleDatagram (uint16_t fromPort, uint16_t toPort,uint8_t * const &buf, size_t len) |
|
|
|
|