mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-08-26 10:10:24 +01:00
datagramversion param for UDP client tunnel
This commit is contained in:
parent
e47cc8495b
commit
c554f47c4d
8 changed files with 36 additions and 21 deletions
|
@ -18,8 +18,10 @@ namespace i2p
|
|||
{
|
||||
namespace datagram
|
||||
{
|
||||
DatagramDestination::DatagramDestination (std::shared_ptr<i2p::client::ClientDestination> owner, bool gzip):
|
||||
m_Owner (owner), m_DefaultReceiver (nullptr), m_DefaultRawReceiver (nullptr), m_Gzip (gzip)
|
||||
DatagramDestination::DatagramDestination (std::shared_ptr<i2p::client::ClientDestination> owner,
|
||||
bool gzip, DatagramVersion version):
|
||||
m_Owner (owner), m_DefaultReceiver (nullptr), m_DefaultRawReceiver (nullptr),
|
||||
m_Gzip (gzip), m_Version (version)
|
||||
{
|
||||
if (m_Gzip)
|
||||
m_Deflator.reset (new i2p::data::GzipDeflator);
|
||||
|
@ -431,14 +433,16 @@ namespace datagram
|
|||
std::shared_ptr<DatagramSession> session = nullptr;
|
||||
std::lock_guard<std::mutex> lock(m_SessionsMutex);
|
||||
auto itr = m_Sessions.find(identity);
|
||||
if (itr == m_Sessions.end()) {
|
||||
if (itr == m_Sessions.end())
|
||||
{
|
||||
// not found, create new session
|
||||
session = std::make_shared<DatagramSession>(m_Owner, identity);
|
||||
session->SetVersion (m_Version);
|
||||
session->Start ();
|
||||
m_Sessions[identity] = session;
|
||||
} else {
|
||||
m_Sessions.emplace (identity, session);
|
||||
}
|
||||
else
|
||||
session = itr->second;
|
||||
}
|
||||
return session;
|
||||
}
|
||||
|
||||
|
|
|
@ -129,7 +129,7 @@ namespace datagram
|
|||
|
||||
public:
|
||||
|
||||
DatagramDestination (std::shared_ptr<i2p::client::ClientDestination> owner, bool gzip);
|
||||
DatagramDestination (std::shared_ptr<i2p::client::ClientDestination> owner, bool gzip, DatagramVersion version);
|
||||
~DatagramDestination ();
|
||||
|
||||
void SendDatagramTo (const uint8_t * payload, size_t len, const i2p::data::IdentHash & ident, uint16_t fromPort = 0, uint16_t toPort = 0);
|
||||
|
@ -190,6 +190,7 @@ namespace datagram
|
|||
std::unordered_map<uint16_t, RawReceiver> m_RawReceiversByPorts;
|
||||
|
||||
bool m_Gzip; // gzip compression of data messages
|
||||
DatagramVersion m_Version; // default for destination
|
||||
i2p::data::GzipInflator m_Inflator;
|
||||
std::unique_ptr<i2p::data::GzipDeflator> m_Deflator;
|
||||
std::vector<uint8_t> m_From, m_Signature;
|
||||
|
|
|
@ -1397,10 +1397,11 @@ namespace client
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
i2p::datagram::DatagramDestination * ClientDestination::CreateDatagramDestination (bool gzip)
|
||||
i2p::datagram::DatagramDestination * ClientDestination::CreateDatagramDestination (bool gzip,
|
||||
i2p::datagram::DatagramVersion version)
|
||||
{
|
||||
if (m_DatagramDestination == nullptr)
|
||||
m_DatagramDestination = new i2p::datagram::DatagramDestination (GetSharedFromThis (), gzip);
|
||||
if (!m_DatagramDestination)
|
||||
m_DatagramDestination = new i2p::datagram::DatagramDestination (GetSharedFromThis (), gzip, version);
|
||||
return m_DatagramDestination;
|
||||
}
|
||||
|
||||
|
|
|
@ -274,7 +274,8 @@ namespace client
|
|||
|
||||
// datagram
|
||||
i2p::datagram::DatagramDestination * GetDatagramDestination () const { return m_DatagramDestination; };
|
||||
i2p::datagram::DatagramDestination * CreateDatagramDestination (bool gzip = true);
|
||||
i2p::datagram::DatagramDestination * CreateDatagramDestination (bool gzip = true,
|
||||
i2p::datagram::DatagramVersion version = i2p::datagram::eDatagramV1);
|
||||
|
||||
// implements LocalDestination
|
||||
bool Decrypt (const uint8_t * encrypted, uint8_t * data, i2p::data::CryptoKeyType preferredCrypto) const override;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue