mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-03-07 06:09:42 +00:00
Compare commits
10 Commits
2.55.0
...
079199c17f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
079199c17f | ||
|
|
3e3e0e0a62 | ||
|
|
c023051fe4 | ||
|
|
0b788de627 | ||
|
|
fce4fab071 | ||
|
|
3236de0d5a | ||
|
|
18707dd844 | ||
|
|
fc16a70f7b | ||
|
|
619ec5d9c1 | ||
|
|
32a70562c4 |
2
.github/workflows/build-windows.yml
vendored
2
.github/workflows/build-windows.yml
vendored
@@ -133,6 +133,8 @@ jobs:
|
|||||||
git clone https://github.com/msys2/MINGW-packages
|
git clone https://github.com/msys2/MINGW-packages
|
||||||
cd MINGW-packages
|
cd MINGW-packages
|
||||||
git checkout 4cbb366edf2f268ac3146174b40ce38604646fc5 mingw-w64-boost
|
git checkout 4cbb366edf2f268ac3146174b40ce38604646fc5 mingw-w64-boost
|
||||||
|
cd mingw-w64-boost
|
||||||
|
sed -i 's/boostorg.jfrog.io\/artifactory\/main/archives.boost.io/' PKGBUILD
|
||||||
|
|
||||||
# headers
|
# headers
|
||||||
- name: Get headers package version
|
- name: Get headers package version
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2024, The PurpleI2P Project
|
* Copyright (c) 2013-2025, 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
|
||||||
*
|
*
|
||||||
@@ -154,6 +154,17 @@ namespace config {
|
|||||||
("socksproxy.i2p.streaming.profile", value<std::string>()->default_value("1"), "SOCKS Proxy bandwidth usage profile. 1 - bulk(high), 2- interactive(low)")
|
("socksproxy.i2p.streaming.profile", value<std::string>()->default_value("1"), "SOCKS Proxy bandwidth usage profile. 1 - bulk(high), 2- interactive(low)")
|
||||||
;
|
;
|
||||||
|
|
||||||
|
options_description shareddest("Shared local destination options");
|
||||||
|
shareddest.add_options()
|
||||||
|
("shareddest.inbound.length", value<std::string>()->default_value("3"), "Shared local destination inbound tunnel length")
|
||||||
|
("shareddest.outbound.length", value<std::string>()->default_value("3"), "Shared local destination outbound tunnel length")
|
||||||
|
("shareddest.inbound.quantity", value<std::string>()->default_value("3"), "Shared local destination inbound tunnels quantity")
|
||||||
|
("shareddest.outbound.quantity", value<std::string>()->default_value("3"), "Shared local destination outbound tunnels quantity")
|
||||||
|
("shareddest.i2cp.leaseSetType", value<std::string>()->default_value("3"), "Shared local destination's LeaseSet type")
|
||||||
|
("shareddest.i2cp.leaseSetEncType", value<std::string>()->default_value("0,4"), "Shared local destination's LeaseSet encryption type")
|
||||||
|
("shareddest.i2p.streaming.profile", value<std::string>()->default_value("2"), "Shared local destination bandwidth usage profile. 1 - bulk(high), 2- interactive(low)")
|
||||||
|
;
|
||||||
|
|
||||||
options_description sam("SAM bridge options");
|
options_description sam("SAM bridge options");
|
||||||
sam.add_options()
|
sam.add_options()
|
||||||
("sam.enabled", value<bool>()->default_value(true), "Enable or disable SAM Application bridge")
|
("sam.enabled", value<bool>()->default_value(true), "Enable or disable SAM Application bridge")
|
||||||
@@ -341,6 +352,7 @@ namespace config {
|
|||||||
.add(httpserver)
|
.add(httpserver)
|
||||||
.add(httpproxy)
|
.add(httpproxy)
|
||||||
.add(socksproxy)
|
.add(socksproxy)
|
||||||
|
.add(shareddest)
|
||||||
.add(sam)
|
.add(sam)
|
||||||
.add(bob)
|
.add(bob)
|
||||||
.add(i2cp)
|
.add(i2cp)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2024, The PurpleI2P Project
|
* Copyright (c) 2013-2025, 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
|
||||||
*
|
*
|
||||||
@@ -104,8 +104,7 @@ namespace datagram
|
|||||||
|
|
||||||
if (verified)
|
if (verified)
|
||||||
{
|
{
|
||||||
auto h = identity.GetIdentHash();
|
auto session = ObtainSession (identity.GetIdentHash());
|
||||||
auto session = ObtainSession(h);
|
|
||||||
session->Ack();
|
session->Ack();
|
||||||
auto r = FindReceiver(toPort);
|
auto r = FindReceiver(toPort);
|
||||||
if(r)
|
if(r)
|
||||||
@@ -381,8 +380,12 @@ namespace datagram
|
|||||||
if (!found)
|
if (!found)
|
||||||
{
|
{
|
||||||
m_RoutingSession = m_LocalDestination->GetRoutingSession(m_RemoteLeaseSet, true);
|
m_RoutingSession = m_LocalDestination->GetRoutingSession(m_RemoteLeaseSet, true);
|
||||||
if (!m_RoutingSession->GetOwner () || !m_RoutingSession->IsReadyToSend ())
|
if (m_RoutingSession)
|
||||||
m_PendingRoutingSessions.push_back (m_RoutingSession);
|
{
|
||||||
|
m_RoutingSession->SetAckRequestInterval (DATAGRAM_SESSION_ACK_REQUEST_INTERVAL);
|
||||||
|
if (!m_RoutingSession->GetOwner () || !m_RoutingSession->IsReadyToSend ())
|
||||||
|
m_PendingRoutingSessions.push_back (m_RoutingSession);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2024, The PurpleI2P Project
|
* Copyright (c) 2013-2025, 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
|
||||||
*
|
*
|
||||||
@@ -44,6 +44,7 @@ namespace datagram
|
|||||||
// max 64 messages buffered in send queue for each datagram session
|
// max 64 messages buffered in send queue for each datagram session
|
||||||
const size_t DATAGRAM_SEND_QUEUE_MAX_SIZE = 64;
|
const size_t DATAGRAM_SEND_QUEUE_MAX_SIZE = 64;
|
||||||
const uint64_t DATAGRAM_MAX_FLUSH_INTERVAL = 5; // in milliseconds
|
const uint64_t DATAGRAM_MAX_FLUSH_INTERVAL = 5; // in milliseconds
|
||||||
|
const int DATAGRAM_SESSION_ACK_REQUEST_INTERVAL = 5500; // in milliseconds
|
||||||
|
|
||||||
class DatagramSession : public std::enable_shared_from_this<DatagramSession>
|
class DatagramSession : public std::enable_shared_from_this<DatagramSession>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2024, The PurpleI2P Project
|
* Copyright (c) 2013-2025, 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
|
||||||
*
|
*
|
||||||
@@ -597,7 +597,8 @@ namespace client
|
|||||||
m_ExcludedFloodfills.clear ();
|
m_ExcludedFloodfills.clear ();
|
||||||
m_PublishReplyToken = 0;
|
m_PublishReplyToken = 0;
|
||||||
// schedule verification
|
// schedule verification
|
||||||
m_PublishVerificationTimer.expires_from_now (boost::posix_time::seconds(PUBLISH_VERIFICATION_TIMEOUT));
|
m_PublishVerificationTimer.expires_from_now (boost::posix_time::seconds(PUBLISH_VERIFICATION_TIMEOUT +
|
||||||
|
(m_Pool ? m_Pool->GetRng ()() % PUBLISH_VERIFICATION_TIMEOUT_VARIANCE : 0)));
|
||||||
m_PublishVerificationTimer.async_wait (std::bind (&LeaseSetDestination::HandlePublishVerificationTimer,
|
m_PublishVerificationTimer.async_wait (std::bind (&LeaseSetDestination::HandlePublishVerificationTimer,
|
||||||
shared_from_this (), std::placeholders::_1));
|
shared_from_this (), std::placeholders::_1));
|
||||||
}
|
}
|
||||||
@@ -676,8 +677,8 @@ namespace client
|
|||||||
m_ExcludedFloodfills.clear ();
|
m_ExcludedFloodfills.clear ();
|
||||||
m_PublishReplyToken = 1; // dummy non-zero value
|
m_PublishReplyToken = 1; // dummy non-zero value
|
||||||
// try again after a while
|
// try again after a while
|
||||||
LogPrint (eLogInfo, "Destination: Can't publish LeasetSet because destination is not ready. Try publishing again after ", PUBLISH_CONFIRMATION_TIMEOUT, " seconds");
|
LogPrint (eLogInfo, "Destination: Can't publish LeasetSet because destination is not ready. Try publishing again after ", PUBLISH_CONFIRMATION_TIMEOUT, " milliseconds");
|
||||||
m_PublishConfirmationTimer.expires_from_now (boost::posix_time::seconds(PUBLISH_CONFIRMATION_TIMEOUT));
|
m_PublishConfirmationTimer.expires_from_now (boost::posix_time::milliseconds(PUBLISH_CONFIRMATION_TIMEOUT));
|
||||||
m_PublishConfirmationTimer.async_wait (std::bind (&LeaseSetDestination::HandlePublishConfirmationTimer,
|
m_PublishConfirmationTimer.async_wait (std::bind (&LeaseSetDestination::HandlePublishConfirmationTimer,
|
||||||
shared_from_this (), std::placeholders::_1));
|
shared_from_this (), std::placeholders::_1));
|
||||||
return;
|
return;
|
||||||
@@ -696,7 +697,7 @@ namespace client
|
|||||||
s->HandlePublishConfirmationTimer (boost::system::error_code());
|
s->HandlePublishConfirmationTimer (boost::system::error_code());
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
m_PublishConfirmationTimer.expires_from_now (boost::posix_time::seconds(PUBLISH_CONFIRMATION_TIMEOUT));
|
m_PublishConfirmationTimer.expires_from_now (boost::posix_time::milliseconds(PUBLISH_CONFIRMATION_TIMEOUT));
|
||||||
m_PublishConfirmationTimer.async_wait (std::bind (&LeaseSetDestination::HandlePublishConfirmationTimer,
|
m_PublishConfirmationTimer.async_wait (std::bind (&LeaseSetDestination::HandlePublishConfirmationTimer,
|
||||||
shared_from_this (), std::placeholders::_1));
|
shared_from_this (), std::placeholders::_1));
|
||||||
outbound->SendTunnelDataMsgTo (floodfill->GetIdentHash (), 0, msg);
|
outbound->SendTunnelDataMsgTo (floodfill->GetIdentHash (), 0, msg);
|
||||||
@@ -712,15 +713,15 @@ namespace client
|
|||||||
m_PublishReplyToken = 0;
|
m_PublishReplyToken = 0;
|
||||||
if (GetIdentity ()->GetCryptoKeyType () == i2p::data::CRYPTO_KEY_TYPE_ELGAMAL)
|
if (GetIdentity ()->GetCryptoKeyType () == i2p::data::CRYPTO_KEY_TYPE_ELGAMAL)
|
||||||
{
|
{
|
||||||
LogPrint (eLogWarning, "Destination: Publish confirmation was not received in ", PUBLISH_CONFIRMATION_TIMEOUT, " seconds or failed. will try again");
|
LogPrint (eLogWarning, "Destination: Publish confirmation was not received in ", PUBLISH_CONFIRMATION_TIMEOUT, " milliseconds or failed. will try again");
|
||||||
Publish ();
|
Publish ();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogPrint (eLogWarning, "Destination: Publish confirmation was not received in ", PUBLISH_CONFIRMATION_TIMEOUT, " seconds from Java floodfill for crypto type ", (int)GetIdentity ()->GetCryptoKeyType ());
|
LogPrint (eLogWarning, "Destination: Publish confirmation was not received in ", PUBLISH_CONFIRMATION_TIMEOUT, " milliseconds from Java floodfill for crypto type ", (int)GetIdentity ()->GetCryptoKeyType ());
|
||||||
// Java floodfill never sends confirmation back for unknown crypto type
|
// Java floodfill never sends confirmation back for unknown crypto type
|
||||||
// assume it successive and try to verify
|
// assume it successive and try to verify
|
||||||
m_PublishVerificationTimer.expires_from_now (boost::posix_time::seconds(PUBLISH_VERIFICATION_TIMEOUT));
|
m_PublishVerificationTimer.expires_from_now (boost::posix_time::seconds(PUBLISH_VERIFICATION_TIMEOUT + PUBLISH_VERIFICATION_TIMEOUT_VARIANCE)); // always max
|
||||||
m_PublishVerificationTimer.async_wait (std::bind (&LeaseSetDestination::HandlePublishVerificationTimer,
|
m_PublishVerificationTimer.async_wait (std::bind (&LeaseSetDestination::HandlePublishVerificationTimer,
|
||||||
shared_from_this (), std::placeholders::_1));
|
shared_from_this (), std::placeholders::_1));
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2024, The PurpleI2P Project
|
* Copyright (c) 2013-2025, 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
|
||||||
*
|
*
|
||||||
@@ -36,8 +36,9 @@ namespace client
|
|||||||
const uint8_t PROTOCOL_TYPE_STREAMING = 6;
|
const uint8_t PROTOCOL_TYPE_STREAMING = 6;
|
||||||
const uint8_t PROTOCOL_TYPE_DATAGRAM = 17;
|
const uint8_t PROTOCOL_TYPE_DATAGRAM = 17;
|
||||||
const uint8_t PROTOCOL_TYPE_RAW = 18;
|
const uint8_t PROTOCOL_TYPE_RAW = 18;
|
||||||
const int PUBLISH_CONFIRMATION_TIMEOUT = 5; // in seconds
|
const int PUBLISH_CONFIRMATION_TIMEOUT = 1800; // in milliseconds
|
||||||
const int PUBLISH_VERIFICATION_TIMEOUT = 10; // in seconds after successful publish
|
const int PUBLISH_VERIFICATION_TIMEOUT = 5; // in seconds after successful publish
|
||||||
|
const int PUBLISH_VERIFICATION_TIMEOUT_VARIANCE = 3; // in seconds
|
||||||
const int PUBLISH_MIN_INTERVAL = 20; // in seconds
|
const int PUBLISH_MIN_INTERVAL = 20; // in seconds
|
||||||
const int PUBLISH_REGULAR_VERIFICATION_INTERNAL = 100; // in seconds periodically
|
const int PUBLISH_REGULAR_VERIFICATION_INTERNAL = 100; // in seconds periodically
|
||||||
const int LEASESET_REQUEST_TIMEOUT = 1600; // in milliseconds
|
const int LEASESET_REQUEST_TIMEOUT = 1600; // in milliseconds
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2024, The PurpleI2P Project
|
* Copyright (c) 2013-2025, 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
|
||||||
*
|
*
|
||||||
@@ -913,7 +913,7 @@ namespace garlic
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!sendAckRequest && !first &&
|
if (!sendAckRequest && !first &&
|
||||||
((!m_AckRequestMsgID && ts > m_LastAckRequestSendTime + ECIESX25519_ACK_REQUEST_INTERVAL) || // regular request
|
((!m_AckRequestMsgID && ts > m_LastAckRequestSendTime + m_AckRequestInterval) || // regular request
|
||||||
(m_AckRequestMsgID && ts > m_LastAckRequestSendTime + LEASESET_CONFIRMATION_TIMEOUT))) // previous request failed. try again
|
(m_AckRequestMsgID && ts > m_LastAckRequestSendTime + LEASESET_CONFIRMATION_TIMEOUT))) // previous request failed. try again
|
||||||
{
|
{
|
||||||
// not LeaseSet
|
// not LeaseSet
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2024, The PurpleI2P Project
|
* Copyright (c) 2013-2025, 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
|
||||||
*
|
*
|
||||||
@@ -33,7 +33,7 @@ namespace garlic
|
|||||||
const int ECIESX25519_SESSION_CREATE_TIMEOUT = 3; // in seconds, NSR must be send after NS received
|
const int ECIESX25519_SESSION_CREATE_TIMEOUT = 3; // in seconds, NSR must be send after NS received
|
||||||
const int ECIESX25519_SESSION_ESTABLISH_TIMEOUT = 15; // in seconds
|
const int ECIESX25519_SESSION_ESTABLISH_TIMEOUT = 15; // in seconds
|
||||||
const int ECIESX25519_PREVIOUS_TAGSET_EXPIRATION_TIMEOUT = 180; // in seconds
|
const int ECIESX25519_PREVIOUS_TAGSET_EXPIRATION_TIMEOUT = 180; // in seconds
|
||||||
const int ECIESX25519_ACK_REQUEST_INTERVAL = 33000; // in milliseconds
|
const int ECIESX25519_DEFAULT_ACK_REQUEST_INTERVAL = 33000; // in milliseconds
|
||||||
const int ECIESX25519_ACK_REQUEST_MAX_NUM_ATTEMPTS = 3;
|
const int ECIESX25519_ACK_REQUEST_MAX_NUM_ATTEMPTS = 3;
|
||||||
const int ECIESX25519_TAGSET_MAX_NUM_TAGS = 8192; // number of tags we request new tagset after
|
const int ECIESX25519_TAGSET_MAX_NUM_TAGS = 8192; // number of tags we request new tagset after
|
||||||
const int ECIESX25519_MIN_NUM_GENERATED_TAGS = 24;
|
const int ECIESX25519_MIN_NUM_GENERATED_TAGS = 24;
|
||||||
@@ -164,7 +164,7 @@ namespace garlic
|
|||||||
~ECIESX25519AEADRatchetSession ();
|
~ECIESX25519AEADRatchetSession ();
|
||||||
|
|
||||||
bool HandleNextMessage (uint8_t * buf, size_t len, std::shared_ptr<ReceiveRatchetTagSet> receiveTagset, int index = 0);
|
bool HandleNextMessage (uint8_t * buf, size_t len, std::shared_ptr<ReceiveRatchetTagSet> receiveTagset, int index = 0);
|
||||||
std::shared_ptr<I2NPMessage> WrapSingleMessage (std::shared_ptr<const I2NPMessage> msg);
|
std::shared_ptr<I2NPMessage> WrapSingleMessage (std::shared_ptr<const I2NPMessage> msg) override;
|
||||||
std::shared_ptr<I2NPMessage> WrapOneTimeMessage (std::shared_ptr<const I2NPMessage> msg);
|
std::shared_ptr<I2NPMessage> WrapOneTimeMessage (std::shared_ptr<const I2NPMessage> msg);
|
||||||
|
|
||||||
const uint8_t * GetRemoteStaticKey () const { return m_RemoteStaticKey; }
|
const uint8_t * GetRemoteStaticKey () const { return m_RemoteStaticKey; }
|
||||||
@@ -180,11 +180,12 @@ namespace garlic
|
|||||||
bool CanBeRestarted (uint64_t ts) const { return ts > m_SessionCreatedTimestamp + ECIESX25519_RESTART_TIMEOUT; }
|
bool CanBeRestarted (uint64_t ts) const { return ts > m_SessionCreatedTimestamp + ECIESX25519_RESTART_TIMEOUT; }
|
||||||
bool IsInactive (uint64_t ts) const { return ts > m_LastActivityTimestamp + ECIESX25519_INACTIVITY_TIMEOUT && CanBeRestarted (ts); }
|
bool IsInactive (uint64_t ts) const { return ts > m_LastActivityTimestamp + ECIESX25519_INACTIVITY_TIMEOUT && CanBeRestarted (ts); }
|
||||||
|
|
||||||
bool IsRatchets () const { return true; };
|
bool IsRatchets () const override { return true; };
|
||||||
bool IsReadyToSend () const { return m_State != eSessionStateNewSessionSent; };
|
bool IsReadyToSend () const override { return m_State != eSessionStateNewSessionSent; };
|
||||||
bool IsTerminated () const { return m_IsTerminated; }
|
bool IsTerminated () const override { return m_IsTerminated; }
|
||||||
uint64_t GetLastActivityTimestamp () const { return m_LastActivityTimestamp; };
|
uint64_t GetLastActivityTimestamp () const override { return m_LastActivityTimestamp; };
|
||||||
bool CleanupUnconfirmedTags (); // return true if unaswered Ack requests, called from I2CP
|
void SetAckRequestInterval (int interval) override { m_AckRequestInterval = interval; };
|
||||||
|
bool CleanupUnconfirmedTags () override; // return true if unaswered Ack requests, called from I2CP
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
@@ -235,6 +236,7 @@ namespace garlic
|
|||||||
uint64_t m_LastAckRequestSendTime = 0; // milliseconds
|
uint64_t m_LastAckRequestSendTime = 0; // milliseconds
|
||||||
uint32_t m_AckRequestMsgID = 0;
|
uint32_t m_AckRequestMsgID = 0;
|
||||||
int m_AckRequestNumAttempts = 0;
|
int m_AckRequestNumAttempts = 0;
|
||||||
|
int m_AckRequestInterval = ECIESX25519_DEFAULT_ACK_REQUEST_INTERVAL; // milliseconds
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2024, The PurpleI2P Project
|
* Copyright (c) 2013-2025, 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
|
||||||
*
|
*
|
||||||
@@ -116,7 +116,8 @@ namespace garlic
|
|||||||
virtual bool IsReadyToSend () const { return true; };
|
virtual bool IsReadyToSend () const { return true; };
|
||||||
virtual bool IsTerminated () const { return !GetOwner (); };
|
virtual bool IsTerminated () const { return !GetOwner (); };
|
||||||
virtual uint64_t GetLastActivityTimestamp () const { return 0; }; // non-zero for rathets only
|
virtual uint64_t GetLastActivityTimestamp () const { return 0; }; // non-zero for rathets only
|
||||||
|
virtual void SetAckRequestInterval (int interval) {}; // in milliseconds, override in ECIESX25519AEADRatchetSession
|
||||||
|
|
||||||
void SetLeaseSetUpdated ()
|
void SetLeaseSetUpdated ()
|
||||||
{
|
{
|
||||||
if (m_LeaseSetUpdateStatus != eLeaseSetDoNotSend) m_LeaseSetUpdateStatus = eLeaseSetUpdated;
|
if (m_LeaseSetUpdateStatus != eLeaseSetDoNotSend) m_LeaseSetUpdateStatus = eLeaseSetUpdated;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2024, The PurpleI2P Project
|
* Copyright (c) 2013-2025, 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
|
||||||
*
|
*
|
||||||
@@ -1434,7 +1434,7 @@ namespace i2p
|
|||||||
i2p::garlic::WrapECIESX25519MessageForRouter (msg, floodfill->GetIdentity ()->GetEncryptionPublicKey ()));
|
i2p::garlic::WrapECIESX25519MessageForRouter (msg, floodfill->GetIdentity ()->GetEncryptionPublicKey ()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
LogPrint (eLogInfo, "Router: Can't publish our RouterInfo. No tunnles. Try again in ", ROUTER_INFO_CONFIRMATION_TIMEOUT, " seconds");
|
LogPrint (eLogInfo, "Router: Can't publish our RouterInfo. No tunnels. Try again in ", ROUTER_INFO_CONFIRMATION_TIMEOUT, " milliseconds");
|
||||||
}
|
}
|
||||||
m_PublishExcluded.insert (floodfill->GetIdentHash ());
|
m_PublishExcluded.insert (floodfill->GetIdentHash ());
|
||||||
m_PublishReplyToken = replyToken;
|
m_PublishReplyToken = replyToken;
|
||||||
@@ -1448,7 +1448,7 @@ namespace i2p
|
|||||||
if (m_PublishTimer)
|
if (m_PublishTimer)
|
||||||
{
|
{
|
||||||
m_PublishTimer->cancel ();
|
m_PublishTimer->cancel ();
|
||||||
m_PublishTimer->expires_from_now (boost::posix_time::seconds(ROUTER_INFO_CONFIRMATION_TIMEOUT));
|
m_PublishTimer->expires_from_now (boost::posix_time::milliseconds(ROUTER_INFO_CONFIRMATION_TIMEOUT));
|
||||||
m_PublishTimer->async_wait (std::bind (&RouterContext::HandlePublishResendTimer,
|
m_PublishTimer->async_wait (std::bind (&RouterContext::HandlePublishResendTimer,
|
||||||
this, std::placeholders::_1));
|
this, std::placeholders::_1));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2024, The PurpleI2P Project
|
* Copyright (c) 2013-2025, 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
|
||||||
*
|
*
|
||||||
@@ -34,7 +34,7 @@ namespace garlic
|
|||||||
const int ROUTER_INFO_PUBLISH_INTERVAL = 39*60; // in seconds
|
const int ROUTER_INFO_PUBLISH_INTERVAL = 39*60; // in seconds
|
||||||
const int ROUTER_INFO_INITIAL_PUBLISH_INTERVAL = 10; // in seconds
|
const int ROUTER_INFO_INITIAL_PUBLISH_INTERVAL = 10; // in seconds
|
||||||
const int ROUTER_INFO_PUBLISH_INTERVAL_VARIANCE = 105;// in seconds
|
const int ROUTER_INFO_PUBLISH_INTERVAL_VARIANCE = 105;// in seconds
|
||||||
const int ROUTER_INFO_CONFIRMATION_TIMEOUT = 5; // in seconds
|
const int ROUTER_INFO_CONFIRMATION_TIMEOUT = 1600; // in milliseconds
|
||||||
const int ROUTER_INFO_MAX_PUBLISH_EXCLUDED_FLOODFILLS = 15;
|
const int ROUTER_INFO_MAX_PUBLISH_EXCLUDED_FLOODFILLS = 15;
|
||||||
const int ROUTER_INFO_CONGESTION_UPDATE_INTERVAL = 12*60; // in seconds
|
const int ROUTER_INFO_CONGESTION_UPDATE_INTERVAL = 12*60; // in seconds
|
||||||
const int ROUTER_INFO_CLEANUP_INTERVAL = 102; // in seconds
|
const int ROUTER_INFO_CLEANUP_INTERVAL = 102; // in seconds
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2022-2024, The PurpleI2P Project
|
* Copyright (c) 2022-2025, 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
|
||||||
*
|
*
|
||||||
@@ -92,7 +92,7 @@ namespace transport
|
|||||||
m_RTO (SSU2_INITIAL_RTO), m_RelayTag (0),m_ConnectTimer (server.GetService ()),
|
m_RTO (SSU2_INITIAL_RTO), m_RelayTag (0),m_ConnectTimer (server.GetService ()),
|
||||||
m_TerminationReason (eSSU2TerminationReasonNormalClose),
|
m_TerminationReason (eSSU2TerminationReasonNormalClose),
|
||||||
m_MaxPayloadSize (SSU2_MIN_PACKET_SIZE - IPV6_HEADER_SIZE - UDP_HEADER_SIZE - 32), // min size
|
m_MaxPayloadSize (SSU2_MIN_PACKET_SIZE - IPV6_HEADER_SIZE - UDP_HEADER_SIZE - 32), // min size
|
||||||
m_LastResendTime (0), m_LastResendAttemptTime (0)
|
m_LastResendTime (0), m_LastResendAttemptTime (0), m_NumRanges (0)
|
||||||
{
|
{
|
||||||
if (noise)
|
if (noise)
|
||||||
m_NoiseState.reset (new i2p::crypto::NoiseSymmetricState);
|
m_NoiseState.reset (new i2p::crypto::NoiseSymmetricState);
|
||||||
@@ -1744,6 +1744,7 @@ namespace transport
|
|||||||
HandleAckRange (firstPacketNum, ackThrough, i2p::util::GetMillisecondsSinceEpoch ()); // acnt
|
HandleAckRange (firstPacketNum, ackThrough, i2p::util::GetMillisecondsSinceEpoch ()); // acnt
|
||||||
// ranges
|
// ranges
|
||||||
len -= 5;
|
len -= 5;
|
||||||
|
if (!len || m_SentPackets.empty ()) return; // don't handle ranges if nothing to acknowledge
|
||||||
const uint8_t * ranges = buf + 5;
|
const uint8_t * ranges = buf + 5;
|
||||||
while (len > 0 && firstPacketNum && ackThrough - firstPacketNum < SSU2_MAX_NUM_ACK_PACKETS)
|
while (len > 0 && firstPacketNum && ackThrough - firstPacketNum < SSU2_MAX_NUM_ACK_PACKETS)
|
||||||
{
|
{
|
||||||
@@ -2624,17 +2625,17 @@ namespace transport
|
|||||||
size_t SSU2Session::CreateAckBlock (uint8_t * buf, size_t len)
|
size_t SSU2Session::CreateAckBlock (uint8_t * buf, size_t len)
|
||||||
{
|
{
|
||||||
if (len < 8) return 0;
|
if (len < 8) return 0;
|
||||||
int maxNumRanges = (len - 8) >> 1;
|
|
||||||
if (maxNumRanges > SSU2_MAX_NUM_ACK_RANGES) maxNumRanges = SSU2_MAX_NUM_ACK_RANGES;
|
|
||||||
buf[0] = eSSU2BlkAck;
|
buf[0] = eSSU2BlkAck;
|
||||||
uint32_t ackThrough = m_OutOfSequencePackets.empty () ? m_ReceivePacketNum : *m_OutOfSequencePackets.rbegin ();
|
uint32_t ackThrough = m_OutOfSequencePackets.empty () ? m_ReceivePacketNum : *m_OutOfSequencePackets.rbegin ();
|
||||||
htobe32buf (buf + 3, ackThrough); // Ack Through
|
htobe32buf (buf + 3, ackThrough); // Ack Through
|
||||||
uint16_t acnt = 0;
|
uint16_t acnt = 0;
|
||||||
int numRanges = 0;
|
|
||||||
if (ackThrough)
|
if (ackThrough)
|
||||||
{
|
{
|
||||||
if (m_OutOfSequencePackets.empty ())
|
if (m_OutOfSequencePackets.empty ())
|
||||||
|
{
|
||||||
acnt = std::min ((int)ackThrough, SSU2_MAX_NUM_ACNT); // no gaps
|
acnt = std::min ((int)ackThrough, SSU2_MAX_NUM_ACNT); // no gaps
|
||||||
|
m_NumRanges = 0;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto it = m_OutOfSequencePackets.rbegin (); it++; // prev packet num
|
auto it = m_OutOfSequencePackets.rbegin (); it++; // prev packet num
|
||||||
@@ -2647,87 +2648,96 @@ namespace transport
|
|||||||
it++;
|
it++;
|
||||||
}
|
}
|
||||||
// ranges
|
// ranges
|
||||||
uint32_t lastNum = ackThrough - acnt;
|
if (!m_NumRanges)
|
||||||
if (acnt > SSU2_MAX_NUM_ACNT)
|
{
|
||||||
{
|
int maxNumRanges = (len - 8) >> 1;
|
||||||
auto d = std::div (acnt - SSU2_MAX_NUM_ACNT, SSU2_MAX_NUM_ACNT);
|
if (maxNumRanges > SSU2_MAX_NUM_ACK_RANGES) maxNumRanges = SSU2_MAX_NUM_ACK_RANGES;
|
||||||
acnt = SSU2_MAX_NUM_ACNT;
|
int numRanges = 0;
|
||||||
if (d.quot > maxNumRanges)
|
uint32_t lastNum = ackThrough - acnt;
|
||||||
|
if (acnt > SSU2_MAX_NUM_ACNT)
|
||||||
{
|
{
|
||||||
d.quot = maxNumRanges;
|
auto d = std::div (acnt - SSU2_MAX_NUM_ACNT, SSU2_MAX_NUM_ACNT);
|
||||||
d.rem = 0;
|
acnt = SSU2_MAX_NUM_ACNT;
|
||||||
}
|
if (d.quot > maxNumRanges)
|
||||||
// Acks only ranges for acnt
|
|
||||||
for (int i = 0; i < d.quot; i++)
|
|
||||||
{
|
|
||||||
buf[8 + numRanges*2] = 0; buf[8 + numRanges*2 + 1] = SSU2_MAX_NUM_ACNT; // NACKs 0, Acks 255
|
|
||||||
numRanges++;
|
|
||||||
}
|
|
||||||
if (d.rem > 0)
|
|
||||||
{
|
|
||||||
buf[8 + numRanges*2] = 0; buf[8 + numRanges*2 + 1] = d.rem;
|
|
||||||
numRanges++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
int numPackets = acnt + numRanges*SSU2_MAX_NUM_ACNT;
|
|
||||||
while (it != m_OutOfSequencePackets.rend () &&
|
|
||||||
numRanges < maxNumRanges && numPackets < SSU2_MAX_NUM_ACK_PACKETS)
|
|
||||||
{
|
|
||||||
if (lastNum - (*it) > SSU2_MAX_NUM_ACNT)
|
|
||||||
{
|
|
||||||
// NACKs only ranges
|
|
||||||
if (lastNum > (*it) + SSU2_MAX_NUM_ACNT*(maxNumRanges - numRanges)) break; // too many NACKs
|
|
||||||
while (lastNum - (*it) > SSU2_MAX_NUM_ACNT)
|
|
||||||
{
|
{
|
||||||
buf[8 + numRanges*2] = SSU2_MAX_NUM_ACNT; buf[8 + numRanges*2 + 1] = 0; // NACKs 255, Acks 0
|
d.quot = maxNumRanges;
|
||||||
lastNum -= SSU2_MAX_NUM_ACNT;
|
d.rem = 0;
|
||||||
|
}
|
||||||
|
// Acks only ranges for acnt
|
||||||
|
for (int i = 0; i < d.quot; i++)
|
||||||
|
{
|
||||||
|
m_Ranges[numRanges*2] = 0; m_Ranges[numRanges*2 + 1] = SSU2_MAX_NUM_ACNT; // NACKs 0, Acks 255
|
||||||
|
numRanges++;
|
||||||
|
}
|
||||||
|
if (d.rem > 0)
|
||||||
|
{
|
||||||
|
m_Ranges[numRanges*2] = 0; m_Ranges[numRanges*2 + 1] = d.rem;
|
||||||
numRanges++;
|
numRanges++;
|
||||||
numPackets += SSU2_MAX_NUM_ACNT;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// NACKs and Acks ranges
|
int numPackets = acnt + numRanges*SSU2_MAX_NUM_ACNT;
|
||||||
buf[8 + numRanges*2] = lastNum - (*it) - 1; // NACKs
|
while (it != m_OutOfSequencePackets.rend () &&
|
||||||
numPackets += buf[8 + numRanges*2];
|
numRanges < maxNumRanges && numPackets < SSU2_MAX_NUM_ACK_PACKETS)
|
||||||
lastNum = *it; it++;
|
|
||||||
int numAcks = 1;
|
|
||||||
while (it != m_OutOfSequencePackets.rend () && lastNum > 0 && *it == lastNum - 1)
|
|
||||||
{
|
{
|
||||||
numAcks++; lastNum--;
|
if (lastNum - (*it) > SSU2_MAX_NUM_ACNT)
|
||||||
it++;
|
{
|
||||||
}
|
// NACKs only ranges
|
||||||
while (numAcks > SSU2_MAX_NUM_ACNT)
|
if (lastNum > (*it) + SSU2_MAX_NUM_ACNT*(maxNumRanges - numRanges)) break; // too many NACKs
|
||||||
{
|
while (lastNum - (*it) > SSU2_MAX_NUM_ACNT)
|
||||||
// Acks only ranges
|
{
|
||||||
buf[8 + numRanges*2 + 1] = SSU2_MAX_NUM_ACNT; // Acks 255
|
m_Ranges[numRanges*2] = SSU2_MAX_NUM_ACNT; m_Ranges[numRanges*2 + 1] = 0; // NACKs 255, Acks 0
|
||||||
numAcks -= SSU2_MAX_NUM_ACNT;
|
lastNum -= SSU2_MAX_NUM_ACNT;
|
||||||
numRanges++;
|
numRanges++;
|
||||||
numPackets += SSU2_MAX_NUM_ACNT;
|
numPackets += SSU2_MAX_NUM_ACNT;
|
||||||
buf[8 + numRanges*2] = 0; // NACKs 0
|
}
|
||||||
if (numRanges >= maxNumRanges || numPackets >= SSU2_MAX_NUM_ACK_PACKETS) break;
|
}
|
||||||
}
|
// NACKs and Acks ranges
|
||||||
if (numAcks > SSU2_MAX_NUM_ACNT) numAcks = SSU2_MAX_NUM_ACNT;
|
m_Ranges[numRanges*2] = lastNum - (*it) - 1; // NACKs
|
||||||
buf[8 + numRanges*2 + 1] = (uint8_t)numAcks; // Acks
|
numPackets += m_Ranges[numRanges*2];
|
||||||
numPackets += numAcks;
|
lastNum = *it; it++;
|
||||||
numRanges++;
|
int numAcks = 1;
|
||||||
}
|
while (it != m_OutOfSequencePackets.rend () && lastNum > 0 && *it == lastNum - 1)
|
||||||
if (it == m_OutOfSequencePackets.rend () &&
|
{
|
||||||
numRanges < maxNumRanges && numPackets < SSU2_MAX_NUM_ACK_PACKETS)
|
numAcks++; lastNum--;
|
||||||
{
|
it++;
|
||||||
// add range between out-of-sequence and received
|
}
|
||||||
int nacks = *m_OutOfSequencePackets.begin () - m_ReceivePacketNum - 1;
|
while (numAcks > SSU2_MAX_NUM_ACNT)
|
||||||
if (nacks > 0)
|
{
|
||||||
{
|
// Acks only ranges
|
||||||
if (nacks > SSU2_MAX_NUM_ACNT) nacks = SSU2_MAX_NUM_ACNT;
|
m_Ranges[numRanges*2 + 1] = SSU2_MAX_NUM_ACNT; // Acks 255
|
||||||
buf[8 + numRanges*2] = nacks;
|
numAcks -= SSU2_MAX_NUM_ACNT;
|
||||||
buf[8 + numRanges*2 + 1] = std::min ((int)m_ReceivePacketNum + 1, SSU2_MAX_NUM_ACNT);
|
numRanges++;
|
||||||
|
numPackets += SSU2_MAX_NUM_ACNT;
|
||||||
|
m_Ranges[numRanges*2] = 0; // NACKs 0
|
||||||
|
if (numRanges >= maxNumRanges || numPackets >= SSU2_MAX_NUM_ACK_PACKETS) break;
|
||||||
|
}
|
||||||
|
if (numAcks > SSU2_MAX_NUM_ACNT) numAcks = SSU2_MAX_NUM_ACNT;
|
||||||
|
m_Ranges[numRanges*2 + 1] = (uint8_t)numAcks; // Acks
|
||||||
|
numPackets += numAcks;
|
||||||
numRanges++;
|
numRanges++;
|
||||||
}
|
}
|
||||||
}
|
if (it == m_OutOfSequencePackets.rend () &&
|
||||||
|
numRanges < maxNumRanges && numPackets < SSU2_MAX_NUM_ACK_PACKETS)
|
||||||
|
{
|
||||||
|
// add range between out-of-sequence and received
|
||||||
|
int nacks = *m_OutOfSequencePackets.begin () - m_ReceivePacketNum - 1;
|
||||||
|
if (nacks > 0)
|
||||||
|
{
|
||||||
|
if (nacks > SSU2_MAX_NUM_ACNT) nacks = SSU2_MAX_NUM_ACNT;
|
||||||
|
m_Ranges[numRanges*2] = nacks;
|
||||||
|
m_Ranges[numRanges*2 + 1] = std::min ((int)m_ReceivePacketNum + 1, SSU2_MAX_NUM_ACNT);
|
||||||
|
numRanges++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_NumRanges = numRanges;
|
||||||
|
}
|
||||||
|
if (m_NumRanges)
|
||||||
|
memcpy (buf + 8, m_Ranges, m_NumRanges*2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
buf[7] = (uint8_t)acnt; // acnt
|
buf[7] = (uint8_t)acnt; // acnt
|
||||||
htobe16buf (buf + 1, 5 + numRanges*2);
|
htobe16buf (buf + 1, 5 + m_NumRanges*2);
|
||||||
return 8 + numRanges*2;
|
return 8 + m_NumRanges*2;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t SSU2Session::CreatePaddingBlock (uint8_t * buf, size_t len, size_t minSize)
|
size_t SSU2Session::CreatePaddingBlock (uint8_t * buf, size_t len, size_t minSize)
|
||||||
@@ -2961,11 +2971,17 @@ namespace transport
|
|||||||
}
|
}
|
||||||
m_OutOfSequencePackets.erase (m_OutOfSequencePackets.begin (), it);
|
m_OutOfSequencePackets.erase (m_OutOfSequencePackets.begin (), it);
|
||||||
}
|
}
|
||||||
|
m_NumRanges = 0; // recalculate ranges when create next Ack
|
||||||
}
|
}
|
||||||
m_ReceivePacketNum = packetNum;
|
m_ReceivePacketNum = packetNum;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
if (m_NumRanges && (m_OutOfSequencePackets.empty () ||
|
||||||
|
packetNum != (*m_OutOfSequencePackets.rbegin ()) + 1))
|
||||||
|
m_NumRanges = 0; // reset ranges if received packet is not next
|
||||||
m_OutOfSequencePackets.insert (packetNum);
|
m_OutOfSequencePackets.insert (packetNum);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2022-2024, The PurpleI2P Project
|
* Copyright (c) 2022-2025, 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
|
||||||
*
|
*
|
||||||
@@ -397,6 +397,8 @@ namespace transport
|
|||||||
std::unique_ptr<i2p::data::IdentHash> m_PathChallenge;
|
std::unique_ptr<i2p::data::IdentHash> m_PathChallenge;
|
||||||
std::unordered_map<uint32_t, uint32_t> m_ReceivedI2NPMsgIDs; // msgID -> timestamp in seconds
|
std::unordered_map<uint32_t, uint32_t> m_ReceivedI2NPMsgIDs; // msgID -> timestamp in seconds
|
||||||
uint64_t m_LastResendTime, m_LastResendAttemptTime; // in milliseconds
|
uint64_t m_LastResendTime, m_LastResendAttemptTime; // in milliseconds
|
||||||
|
int m_NumRanges;
|
||||||
|
uint8_t m_Ranges[SSU2_MAX_NUM_ACK_RANGES*2]; // ranges sent with previous Ack if any
|
||||||
};
|
};
|
||||||
|
|
||||||
inline uint64_t CreateHeaderMask (const uint8_t * kh, const uint8_t * nonce)
|
inline uint64_t CreateHeaderMask (const uint8_t * kh, const uint8_t * nonce)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2024, The PurpleI2P Project
|
* Copyright (c) 2013-2025, 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
|
||||||
*
|
*
|
||||||
@@ -416,15 +416,10 @@ namespace client
|
|||||||
|
|
||||||
void ClientContext::CreateNewSharedLocalDestination ()
|
void ClientContext::CreateNewSharedLocalDestination ()
|
||||||
{
|
{
|
||||||
std::map<std::string, std::string> params
|
std::map<std::string, std::string> params;
|
||||||
{
|
ReadI2CPOptionsFromConfig ("shareddest.", params);
|
||||||
{ I2CP_PARAM_INBOUND_TUNNELS_QUANTITY, "3" },
|
params[I2CP_PARAM_OUTBOUND_NICKNAME] = "SharedDest";
|
||||||
{ I2CP_PARAM_OUTBOUND_TUNNELS_QUANTITY, "3" },
|
|
||||||
{ I2CP_PARAM_LEASESET_TYPE, "3" },
|
|
||||||
{ I2CP_PARAM_LEASESET_ENCRYPTION_TYPE, "0,4" },
|
|
||||||
{ I2CP_PARAM_OUTBOUND_NICKNAME, "SharedDest" },
|
|
||||||
{ I2CP_PARAM_STREAMING_PROFILE, "2" }
|
|
||||||
};
|
|
||||||
m_SharedLocalDestination = CreateNewLocalDestination (false, i2p::data::SIGNING_KEY_TYPE_EDDSA_SHA512_ED25519,
|
m_SharedLocalDestination = CreateNewLocalDestination (false, i2p::data::SIGNING_KEY_TYPE_EDDSA_SHA512_ED25519,
|
||||||
i2p::data::CRYPTO_KEY_TYPE_ELGAMAL, ¶ms); // non-public, EDDSA
|
i2p::data::CRYPTO_KEY_TYPE_ELGAMAL, ¶ms); // non-public, EDDSA
|
||||||
m_SharedLocalDestination->Acquire ();
|
m_SharedLocalDestination->Acquire ();
|
||||||
|
|||||||
@@ -43,18 +43,20 @@ uint8_t encrypted[114] =
|
|||||||
int main ()
|
int main ()
|
||||||
{
|
{
|
||||||
uint8_t buf[114+16];
|
uint8_t buf[114+16];
|
||||||
|
i2p::crypto::AEADChaCha20Poly1305Encryptor encryptor;
|
||||||
// test encryption
|
// test encryption
|
||||||
i2p::crypto::AEADChaCha20Poly1305 ((uint8_t *)text, 114, ad, 12, key, nonce, buf, 114 + 16, true);
|
encryptor.Encrypt ((uint8_t *)text, 114, ad, 12, key, nonce, buf, 114 + 16);
|
||||||
assert (memcmp (buf, encrypted, 114) == 0);
|
assert (memcmp (buf, encrypted, 114) == 0);
|
||||||
assert (memcmp (buf + 114, tag, 16) == 0);
|
assert (memcmp (buf + 114, tag, 16) == 0);
|
||||||
// test decryption
|
// test decryption
|
||||||
uint8_t buf1[114];
|
uint8_t buf1[114];
|
||||||
assert (i2p::crypto::AEADChaCha20Poly1305 (buf, 114, ad, 12, key, nonce, buf1, 114, false));
|
i2p::crypto::AEADChaCha20Poly1305Decryptor decryptor;
|
||||||
|
assert (decryptor.Decrypt (buf, 114, ad, 12, key, nonce, buf1, 114));
|
||||||
assert (memcmp (buf1, text, 114) == 0);
|
assert (memcmp (buf1, text, 114) == 0);
|
||||||
// test encryption of multiple buffers
|
// test encryption of multiple buffers
|
||||||
memcpy (buf, text, 114);
|
memcpy (buf, text, 114);
|
||||||
std::vector<std::pair<uint8_t*, std::size_t> > bufs{ std::make_pair (buf, 20), std::make_pair (buf + 20, 10), std::make_pair (buf + 30, 70), std::make_pair (buf + 100, 14) };
|
std::vector<std::pair<uint8_t*, std::size_t> > bufs{ std::make_pair (buf, 20), std::make_pair (buf + 20, 10), std::make_pair (buf + 30, 70), std::make_pair (buf + 100, 14) };
|
||||||
i2p::crypto::AEADChaCha20Poly1305Encrypt (bufs, key, nonce, buf + 114);
|
encryptor.Encrypt (bufs, key, nonce, buf + 114);
|
||||||
i2p::crypto::AEADChaCha20Poly1305 (buf, 114, nullptr, 0, key, nonce, buf1, 114, false);
|
decryptor.Decrypt (buf, 114, nullptr, 0, key, nonce, buf1, 114);
|
||||||
assert (memcmp (buf1, text, 114) == 0);
|
assert (memcmp (buf1, text, 114) == 0);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user