mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-02-02 02:54:01 +01:00
I2CP option crypto.tagsToSend added for I2P tunnels
This commit is contained in:
parent
f545e6eb27
commit
f593802a51
|
@ -231,6 +231,7 @@ namespace client
|
||||||
options[I2CP_PARAM_OUTBOUND_TUNNEL_LENGTH] = GetI2CPOption (section, I2CP_PARAM_OUTBOUND_TUNNEL_LENGTH, DEFAULT_OUTBOUND_TUNNEL_LENGTH);
|
options[I2CP_PARAM_OUTBOUND_TUNNEL_LENGTH] = GetI2CPOption (section, I2CP_PARAM_OUTBOUND_TUNNEL_LENGTH, DEFAULT_OUTBOUND_TUNNEL_LENGTH);
|
||||||
options[I2CP_PARAM_INBOUND_TUNNELS_QUANTITY] = GetI2CPOption (section, I2CP_PARAM_INBOUND_TUNNELS_QUANTITY, DEFAULT_INBOUND_TUNNELS_QUANTITY);
|
options[I2CP_PARAM_INBOUND_TUNNELS_QUANTITY] = GetI2CPOption (section, I2CP_PARAM_INBOUND_TUNNELS_QUANTITY, DEFAULT_INBOUND_TUNNELS_QUANTITY);
|
||||||
options[I2CP_PARAM_OUTBOUND_TUNNELS_QUANTITY] = GetI2CPOption (section, I2CP_PARAM_OUTBOUND_TUNNELS_QUANTITY, DEFAULT_OUTBOUND_TUNNELS_QUANTITY);
|
options[I2CP_PARAM_OUTBOUND_TUNNELS_QUANTITY] = GetI2CPOption (section, I2CP_PARAM_OUTBOUND_TUNNELS_QUANTITY, DEFAULT_OUTBOUND_TUNNELS_QUANTITY);
|
||||||
|
options[I2CP_PARAM_TAGS_TO_SEND] = GetI2CPOption (section, I2CP_PARAM_TAGS_TO_SEND, DEFAULT_TAGS_TO_SEND);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientContext::ReadTunnels ()
|
void ClientContext::ReadTunnels ()
|
||||||
|
|
|
@ -27,6 +27,7 @@ namespace client
|
||||||
int outboundTunnelLen = DEFAULT_OUTBOUND_TUNNEL_LENGTH;
|
int outboundTunnelLen = DEFAULT_OUTBOUND_TUNNEL_LENGTH;
|
||||||
int inboundTunnelsQuantity = DEFAULT_INBOUND_TUNNELS_QUANTITY;
|
int inboundTunnelsQuantity = DEFAULT_INBOUND_TUNNELS_QUANTITY;
|
||||||
int outboundTunnelsQuantity = DEFAULT_OUTBOUND_TUNNELS_QUANTITY;
|
int outboundTunnelsQuantity = DEFAULT_OUTBOUND_TUNNELS_QUANTITY;
|
||||||
|
int numTags = DEFAULT_TAGS_TO_SEND;
|
||||||
std::shared_ptr<std::vector<i2p::data::IdentHash> > explicitPeers;
|
std::shared_ptr<std::vector<i2p::data::IdentHash> > explicitPeers;
|
||||||
if (params)
|
if (params)
|
||||||
{
|
{
|
||||||
|
@ -70,6 +71,16 @@ namespace client
|
||||||
LogPrint (eLogInfo, "Destination: Outbound tunnels quantity set to ", quantity);
|
LogPrint (eLogInfo, "Destination: Outbound tunnels quantity set to ", quantity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
it = params->find (I2CP_PARAM_TAGS_TO_SEND);
|
||||||
|
if (it != params->end ())
|
||||||
|
{
|
||||||
|
int tagsToSend = boost::lexical_cast<int>(it->second);
|
||||||
|
if (tagsToSend > 0)
|
||||||
|
{
|
||||||
|
numTags = tagsToSend;
|
||||||
|
LogPrint (eLogInfo, "Destination: Tags to send set to ", tagsToSend);
|
||||||
|
}
|
||||||
|
}
|
||||||
it = params->find (I2CP_PARAM_EXPLICIT_PEERS);
|
it = params->find (I2CP_PARAM_EXPLICIT_PEERS);
|
||||||
if (it != params->end ())
|
if (it != params->end ())
|
||||||
{
|
{
|
||||||
|
@ -85,6 +96,7 @@ namespace client
|
||||||
LogPrint (eLogInfo, "Destination: Explicit peers set to ", it->second);
|
LogPrint (eLogInfo, "Destination: Explicit peers set to ", it->second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
SetNumTags (numTags);
|
||||||
m_Pool = i2p::tunnel::tunnels.CreateTunnelPool (inboundTunnelLen, outboundTunnelLen, inboundTunnelsQuantity, outboundTunnelsQuantity);
|
m_Pool = i2p::tunnel::tunnels.CreateTunnelPool (inboundTunnelLen, outboundTunnelLen, inboundTunnelsQuantity, outboundTunnelsQuantity);
|
||||||
if (explicitPeers)
|
if (explicitPeers)
|
||||||
m_Pool->SetExplicitPeers (explicitPeers);
|
m_Pool->SetExplicitPeers (explicitPeers);
|
||||||
|
|
|
@ -42,7 +42,9 @@ namespace client
|
||||||
const int DEFAULT_OUTBOUND_TUNNELS_QUANTITY = 5;
|
const int DEFAULT_OUTBOUND_TUNNELS_QUANTITY = 5;
|
||||||
const char I2CP_PARAM_EXPLICIT_PEERS[] = "explicitPeers";
|
const char I2CP_PARAM_EXPLICIT_PEERS[] = "explicitPeers";
|
||||||
const int STREAM_REQUEST_TIMEOUT = 60; //in seconds
|
const int STREAM_REQUEST_TIMEOUT = 60; //in seconds
|
||||||
|
const char I2CP_PARAM_TAGS_TO_SEND[] = "crypto.tagsToSend";
|
||||||
|
const int DEFAULT_TAGS_TO_SEND = 40;
|
||||||
|
|
||||||
typedef std::function<void (std::shared_ptr<i2p::stream::Stream> stream)> StreamRequestComplete;
|
typedef std::function<void (std::shared_ptr<i2p::stream::Stream> stream)> StreamRequestComplete;
|
||||||
|
|
||||||
class ClientDestination: public i2p::garlic::GarlicDestination,
|
class ClientDestination: public i2p::garlic::GarlicDestination,
|
||||||
|
|
|
@ -546,7 +546,7 @@ namespace garlic
|
||||||
std::shared_ptr<I2NPMessage> GarlicDestination::WrapMessage (std::shared_ptr<const i2p::data::RoutingDestination> destination,
|
std::shared_ptr<I2NPMessage> GarlicDestination::WrapMessage (std::shared_ptr<const i2p::data::RoutingDestination> destination,
|
||||||
std::shared_ptr<I2NPMessage> msg, bool attachLeaseSet)
|
std::shared_ptr<I2NPMessage> msg, bool attachLeaseSet)
|
||||||
{
|
{
|
||||||
auto session = GetRoutingSession (destination, attachLeaseSet); // 32 tags by default
|
auto session = GetRoutingSession (destination, attachLeaseSet);
|
||||||
return session->WrapSingleMessage (msg);
|
return session->WrapSingleMessage (msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -560,7 +560,7 @@ namespace garlic
|
||||||
if (!session)
|
if (!session)
|
||||||
{
|
{
|
||||||
session = std::make_shared<GarlicRoutingSession> (this, destination,
|
session = std::make_shared<GarlicRoutingSession> (this, destination,
|
||||||
attachLeaseSet ? 40 : 4, attachLeaseSet); // 40 tags for connections and 4 for LS requests
|
attachLeaseSet ? m_NumTags : 4, attachLeaseSet); // specified num tags for connections and 4 for LS requests
|
||||||
std::unique_lock<std::mutex> l(m_SessionsMutex);
|
std::unique_lock<std::mutex> l(m_SessionsMutex);
|
||||||
m_Sessions[destination->GetIdentHash ()] = session;
|
m_Sessions[destination->GetIdentHash ()] = session;
|
||||||
}
|
}
|
||||||
|
|
4
Garlic.h
4
Garlic.h
|
@ -119,9 +119,10 @@ namespace garlic
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
GarlicDestination (): m_LastTagsCleanupTime (0) {};
|
GarlicDestination (): m_NumTags (32), m_LastTagsCleanupTime (0) {}; // 32 tags by default
|
||||||
~GarlicDestination ();
|
~GarlicDestination ();
|
||||||
|
|
||||||
|
void SetNumTags (int numTags) { m_NumTags = numTags; };
|
||||||
std::shared_ptr<GarlicRoutingSession> GetRoutingSession (std::shared_ptr<const i2p::data::RoutingDestination> destination, bool attachLeaseSet);
|
std::shared_ptr<GarlicRoutingSession> GetRoutingSession (std::shared_ptr<const i2p::data::RoutingDestination> destination, bool attachLeaseSet);
|
||||||
void CleanupRoutingSessions ();
|
void CleanupRoutingSessions ();
|
||||||
void RemoveCreatedSession (uint32_t msgID);
|
void RemoveCreatedSession (uint32_t msgID);
|
||||||
|
@ -154,6 +155,7 @@ namespace garlic
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// outgoing sessions
|
// outgoing sessions
|
||||||
|
int m_NumTags;
|
||||||
std::mutex m_SessionsMutex;
|
std::mutex m_SessionsMutex;
|
||||||
std::map<i2p::data::IdentHash, std::shared_ptr<GarlicRoutingSession> > m_Sessions;
|
std::map<i2p::data::IdentHash, std::shared_ptr<GarlicRoutingSession> > m_Sessions;
|
||||||
// incoming
|
// incoming
|
||||||
|
|
Loading…
Reference in a new issue