mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 13:27:17 +01:00
Compare commits
6 commits
ca5115c657
...
6a6fd8ddab
Author | SHA1 | Date | |
---|---|---|---|
6a6fd8ddab | |||
5a4ce66d42 | |||
76190ea365 | |||
f90386803f | |||
29d77113cc | |||
32a70562c4 |
|
@ -122,7 +122,7 @@ namespace transport
|
||||||
err = UPNP_GetValidIGD (m_Devlist, &m_upnpUrls, &m_upnpData, m_NetworkAddr, sizeof (m_NetworkAddr));
|
err = UPNP_GetValidIGD (m_Devlist, &m_upnpUrls, &m_upnpData, m_NetworkAddr, sizeof (m_NetworkAddr));
|
||||||
#endif
|
#endif
|
||||||
m_upnpUrlsInitialized=err!=0;
|
m_upnpUrlsInitialized=err!=0;
|
||||||
if (err == UPNP_IGD_VALID_CONNECTED)
|
if (err == UPNP_IGD_VALID_CONNECTED || err == UPNP_IGD_VALID_NOT_CONNECTED)
|
||||||
{
|
{
|
||||||
#if (MINIUPNPC_API_VERSION < 18)
|
#if (MINIUPNPC_API_VERSION < 18)
|
||||||
err = UPNP_GetExternalIPAddress (m_upnpUrls.controlURL, m_upnpData.first.servicetype, m_externalIPAddress);
|
err = UPNP_GetExternalIPAddress (m_upnpUrls.controlURL, m_upnpData.first.servicetype, m_externalIPAddress);
|
||||||
|
|
2
debian/changelog
vendored
2
debian/changelog
vendored
|
@ -2,7 +2,7 @@ i2pd (2.54.0-1) unstable; urgency=medium
|
||||||
|
|
||||||
* updated to version 2.54.0/0.9.64
|
* updated to version 2.54.0/0.9.64
|
||||||
|
|
||||||
-- orignal <orignal@i2pmail.org> Sun, 6 Oct 2024 16:00:00 +0000
|
-- orignal <orignal@i2pmail.org> Sun, 6 Oct 2024 16:00:00 +0000
|
||||||
|
|
||||||
i2pd (2.53.1-1) unstable; urgency=medium
|
i2pd (2.53.1-1) unstable; urgency=medium
|
||||||
|
|
||||||
|
|
|
@ -337,13 +337,14 @@ namespace transport
|
||||||
SetTerminationTimeout (SSU2_TERMINATION_TIMEOUT);
|
SetTerminationTimeout (SSU2_TERMINATION_TIMEOUT);
|
||||||
SendQueue ();
|
SendQueue ();
|
||||||
transports.PeerConnected (shared_from_this ());
|
transports.PeerConnected (shared_from_this ());
|
||||||
|
|
||||||
|
LogPrint(eLogDebug, "SSU2: Session with ", GetRemoteEndpoint (),
|
||||||
|
" (", i2p::data::GetIdentHashAbbreviation (GetRemoteIdentity ()->GetIdentHash ()), ") established");
|
||||||
if (m_OnEstablished)
|
if (m_OnEstablished)
|
||||||
{
|
{
|
||||||
m_OnEstablished ();
|
m_OnEstablished ();
|
||||||
m_OnEstablished = nullptr;
|
m_OnEstablished = nullptr;
|
||||||
}
|
}
|
||||||
LogPrint(eLogDebug, "SSU2: Session with ", GetRemoteEndpoint (),
|
|
||||||
" (", i2p::data::GetIdentHashAbbreviation (GetRemoteIdentity ()->GetIdentHash ()), ") established");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SSU2Session::Done ()
|
void SSU2Session::Done ()
|
||||||
|
@ -1944,21 +1945,28 @@ namespace transport
|
||||||
void SSU2Session::HandleRelayRequest (const uint8_t * buf, size_t len)
|
void SSU2Session::HandleRelayRequest (const uint8_t * buf, size_t len)
|
||||||
{
|
{
|
||||||
// we are Bob
|
// we are Bob
|
||||||
|
auto mts = i2p::util::GetMillisecondsSinceEpoch ();
|
||||||
|
uint32_t nonce = bufbe32toh (buf + 1); // nonce
|
||||||
uint32_t relayTag = bufbe32toh (buf + 5); // relay tag
|
uint32_t relayTag = bufbe32toh (buf + 5); // relay tag
|
||||||
auto session = m_Server.FindRelaySession (relayTag);
|
auto session = m_Server.FindRelaySession (relayTag);
|
||||||
if (!session)
|
if (!session)
|
||||||
{
|
{
|
||||||
LogPrint (eLogWarning, "SSU2: RelayRequest session with relay tag ", relayTag, " not found");
|
LogPrint (eLogWarning, "SSU2: RelayRequest session with relay tag ", relayTag, " not found");
|
||||||
// send relay response back to Alice
|
// send relay response back to Alice
|
||||||
uint8_t payload[SSU2_MAX_PACKET_SIZE];
|
auto packet = m_Server.GetSentPacketsPool ().AcquireShared ();
|
||||||
size_t payloadSize = CreateRelayResponseBlock (payload, m_MaxPayloadSize,
|
packet->payloadSize = CreateAckBlock (packet->payload, m_MaxPayloadSize);
|
||||||
eSSU2RelayResponseCodeBobRelayTagNotFound, bufbe32toh (buf + 1), 0, false);
|
packet->payloadSize += CreateRelayResponseBlock (packet->payload + packet->payloadSize, m_MaxPayloadSize - packet->payloadSize,
|
||||||
payloadSize += CreatePaddingBlock (payload + payloadSize, m_MaxPayloadSize - payloadSize);
|
eSSU2RelayResponseCodeBobRelayTagNotFound, nonce, 0, false);
|
||||||
SendData (payload, payloadSize);
|
packet->payloadSize += CreatePaddingBlock (packet->payload + packet->payloadSize, m_MaxPayloadSize - packet->payloadSize);
|
||||||
|
uint32_t packetNum = SendData (packet->payload, packet->payloadSize);
|
||||||
|
if (m_RemoteVersion >= SSU2_MIN_RELAY_RESPONSE_RESEND_VERSION)
|
||||||
|
{
|
||||||
|
// sometimes Alice doesn't ack this RelayResponse in older versions
|
||||||
|
packet->sendTime = mts;
|
||||||
|
m_SentPackets.emplace (packetNum, packet);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto mts = i2p::util::GetMillisecondsSinceEpoch ();
|
|
||||||
uint32_t nonce = bufbe32toh (buf + 1);
|
|
||||||
if (session->m_RelaySessions.emplace (nonce, std::make_pair (shared_from_this (), mts/1000)).second)
|
if (session->m_RelaySessions.emplace (nonce, std::make_pair (shared_from_this (), mts/1000)).second)
|
||||||
{
|
{
|
||||||
// send relay intro to Charlie
|
// send relay intro to Charlie
|
||||||
|
|
|
@ -25,7 +25,7 @@ namespace transport
|
||||||
{
|
{
|
||||||
template<typename Keys>
|
template<typename Keys>
|
||||||
EphemeralKeysSupplier<Keys>::EphemeralKeysSupplier (int size):
|
EphemeralKeysSupplier<Keys>::EphemeralKeysSupplier (int size):
|
||||||
m_QueueSize (size), m_IsRunning (false), m_Thread (nullptr)
|
m_QueueSize (size), m_IsRunning (false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ namespace transport
|
||||||
void EphemeralKeysSupplier<Keys>::Start ()
|
void EphemeralKeysSupplier<Keys>::Start ()
|
||||||
{
|
{
|
||||||
m_IsRunning = true;
|
m_IsRunning = true;
|
||||||
m_Thread = new std::thread (std::bind (&EphemeralKeysSupplier<Keys>::Run, this));
|
m_Thread.reset (new std::thread (std::bind (&EphemeralKeysSupplier<Keys>::Run, this)));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Keys>
|
template<typename Keys>
|
||||||
|
@ -53,8 +53,7 @@ namespace transport
|
||||||
if (m_Thread)
|
if (m_Thread)
|
||||||
{
|
{
|
||||||
m_Thread->join ();
|
m_Thread->join ();
|
||||||
delete m_Thread;
|
m_Thread = nullptr;
|
||||||
m_Thread = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,6 +77,7 @@ namespace transport
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
m_KeysPool.CleanUpMt ();
|
||||||
std::unique_lock<std::mutex> l(m_AcquiredMutex);
|
std::unique_lock<std::mutex> l(m_AcquiredMutex);
|
||||||
if (!m_IsRunning) break;
|
if (!m_IsRunning) break;
|
||||||
m_Acquired.wait (l); // wait for element gets acquired
|
m_Acquired.wait (l); // wait for element gets acquired
|
||||||
|
@ -92,7 +92,7 @@ namespace transport
|
||||||
{
|
{
|
||||||
for (int i = 0; i < num; i++)
|
for (int i = 0; i < num; i++)
|
||||||
{
|
{
|
||||||
auto pair = std::make_shared<Keys> ();
|
auto pair = m_KeysPool.AcquireSharedMt ();
|
||||||
pair->GenerateKeys ();
|
pair->GenerateKeys ();
|
||||||
std::unique_lock<std::mutex> l(m_AcquiredMutex);
|
std::unique_lock<std::mutex> l(m_AcquiredMutex);
|
||||||
m_Queue.push (pair);
|
m_Queue.push (pair);
|
||||||
|
@ -114,7 +114,7 @@ namespace transport
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// queue is empty, create new
|
// queue is empty, create new
|
||||||
auto pair = std::make_shared<Keys> ();
|
auto pair = m_KeysPool.AcquireSharedMt ();
|
||||||
pair->GenerateKeys ();
|
pair->GenerateKeys ();
|
||||||
return pair;
|
return pair;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include "RouterInfo.h"
|
#include "RouterInfo.h"
|
||||||
#include "I2NPProtocol.h"
|
#include "I2NPProtocol.h"
|
||||||
#include "Identity.h"
|
#include "Identity.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
namespace i2p
|
namespace i2p
|
||||||
{
|
{
|
||||||
|
@ -53,9 +54,10 @@ namespace transport
|
||||||
|
|
||||||
const int m_QueueSize;
|
const int m_QueueSize;
|
||||||
std::queue<std::shared_ptr<Keys> > m_Queue;
|
std::queue<std::shared_ptr<Keys> > m_Queue;
|
||||||
|
i2p::util::MemoryPoolMt<Keys> m_KeysPool;
|
||||||
|
|
||||||
bool m_IsRunning;
|
bool m_IsRunning;
|
||||||
std::thread * m_Thread;
|
std::unique_ptr<std::thread> m_Thread;
|
||||||
std::condition_variable m_Acquired;
|
std::condition_variable m_Acquired;
|
||||||
std::mutex m_AcquiredMutex;
|
std::mutex m_AcquiredMutex;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue