Compare commits

...

5 Commits

Author SHA1 Message Date
Pratik B.
ff8d462b62 Merge 17399da399 into 9432202fad 2025-02-25 14:54:06 +02:00
orignal
9432202fad check PeerTest buffer size 2025-02-24 13:58:10 -05:00
orignal
bf050ac465 fixed typo 2025-02-22 19:01:20 -05:00
orignal
81dae1997d replace boost::lexical_cast by std::from_chars and std::to_string 2025-02-21 20:34:53 -05:00
imdef
17399da399 Added example docker-compose.yml 2024-09-25 16:55:29 +00:00
4 changed files with 44 additions and 45 deletions

View File

@@ -0,0 +1,13 @@
services:
i2pd:
container_name: i2pd2
image: purplei2p/i2pd
#optional
entrypoint: ["./entrypoint.sh", "--loglevel error"]
ports:
- 127.0.0.1:7656:7656
- 127.0.0.1:7070:7070
- 127.0.0.1:4444:4444
volumes:
- /path/to/i2pd/data:/home/i2pd/data # make sure data directory and it's contents are owned by 100:65533
- /path/to/i2pd/i2pd_certificates:/i2pd_certificates # make sure i2pd_certificates is owned by root:root and 755 permissions on the directory

View File

@@ -12,7 +12,6 @@
#include <fstream>
#include <memory>
#include <charconv>
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp> // for boost::to_lower
#ifndef __cpp_lib_atomic_shared_ptr
#include <boost/atomic.hpp>
@@ -263,27 +262,17 @@ namespace data
}
else if (key == "port")
{
try
{
address->port = boost::lexical_cast<int>(value);
}
catch (std::exception& ex)
{
LogPrint (eLogWarning, "RouterInfo: 'port' exception ", ex.what ());
}
auto res = std::from_chars(value.data(), value.data() + value.size(), address->port);
if (res.ec != std::errc())
LogPrint (eLogWarning, "RouterInfo: 'port' conversion error: ", std::make_error_code (res.ec).message ());
}
else if (key == "mtu")
{
if (address->ssu)
{
try
{
address->ssu->mtu = boost::lexical_cast<int>(value);
}
catch (std::exception& ex)
{
LogPrint (eLogWarning, "RouterInfo: 'mtu' exception ", ex.what ());
}
auto res = std::from_chars(value.data(), value.data() + value.size(), address->ssu->mtu);
if (res.ec != std::errc())
LogPrint (eLogWarning, "RouterInfo: 'mtu' conversion error: ", std::make_error_code (res.ec).message ());
}
else
LogPrint (eLogWarning, "RouterInfo: Unexpected field 'mtu' for NTCP2");
@@ -349,27 +338,17 @@ namespace data
auto key1 = key.substr(0, key.length () - 1);
if (key1 == "itag")
{
try
{
introducer.iTag = boost::lexical_cast<uint32_t>(value);
}
catch (std::exception& ex)
{
LogPrint (eLogWarning, "RouterInfo: 'itag' exception ", ex.what ());
}
auto res = std::from_chars(value.data(), value.data() + value.size(), introducer.iTag);
if (res.ec != std::errc())
LogPrint (eLogWarning, "RouterInfo: 'itag' conversion error: ", std::make_error_code (res.ec).message ());
}
else if (key1 == "ih")
Base64ToByteStream (value.data (), value.length (), introducer.iH, 32);
else if (key1 == "iexp")
{
try
{
introducer.iExp = boost::lexical_cast<uint32_t>(value);
}
catch (std::exception& ex)
{
LogPrint (eLogWarning, "RouterInfo: 'iexp' exception ", ex.what ());
}
auto res = std::from_chars(value.data(), value.data() + value.size(), introducer.iExp);
if (res.ec != std::errc())
LogPrint (eLogWarning, "RouterInfo: 'iexp' conversion error: ", std::make_error_code (res.ec).message ());
}
}
}
@@ -1402,9 +1381,9 @@ namespace data
if (!introducer.iTag) continue;
if (introducer.iExp) // expiration is specified
{
WriteString ("iexp" + boost::lexical_cast<std::string>(i), properties);
WriteString ("iexp" + std::to_string(i), properties);
properties << '=';
WriteString (boost::lexical_cast<std::string>(introducer.iExp), properties);
WriteString (std::to_string(introducer.iExp), properties);
properties << ';';
}
i++;
@@ -1413,7 +1392,7 @@ namespace data
for (const auto& introducer: address.ssu->introducers)
{
if (!introducer.iTag) continue;
WriteString ("ih" + boost::lexical_cast<std::string>(i), properties);
WriteString ("ih" + std::to_string(i), properties);
properties << '=';
char value[64];
size_t l = ByteStreamToBase64 (introducer.iH, 32, value, 64);
@@ -1426,9 +1405,9 @@ namespace data
for (const auto& introducer: address.ssu->introducers)
{
if (!introducer.iTag) continue;
WriteString ("itag" + boost::lexical_cast<std::string>(i), properties);
WriteString ("itag" + std::to_string(i), properties);
properties << '=';
WriteString (boost::lexical_cast<std::string>(introducer.iTag), properties);
WriteString (std::to_string(introducer.iTag), properties);
properties << ';';
i++;
}
@@ -1442,7 +1421,7 @@ namespace data
{
WriteString ("mtu", properties);
properties << '=';
WriteString (boost::lexical_cast<std::string>(address.ssu->mtu), properties);
WriteString (std::to_string(address.ssu->mtu), properties);
properties << ';';
}
}
@@ -1450,7 +1429,7 @@ namespace data
{
WriteString ("port", properties);
properties << '=';
WriteString (boost::lexical_cast<std::string>(address.port), properties);
WriteString (std::to_string(address.port), properties);
properties << ';';
}
if (address.IsNTCP2 () || address.IsSSU2 ())

View File

@@ -2277,8 +2277,11 @@ namespace transport
case 2: // Charlie from Bob
{
// sign with Charlie's key
if (len < offset + 9) return;
uint8_t asz = buf[offset + 9];
std::vector<uint8_t> newSignedData (asz + 10 + i2p::context.GetIdentity ()->GetSignatureLen ());
size_t l = asz + 10 + i2p::context.GetIdentity ()->GetSignatureLen ();
if (len < offset + l) return;
std::vector<uint8_t> newSignedData (l);
memcpy (newSignedData.data (), buf + offset, asz + 10);
SignedData<128> s;
s.Insert ((const uint8_t *)"PeerTestValidate", 16); // prologue
@@ -2388,9 +2391,15 @@ namespace transport
if (GetRouterStatus () == eRouterStatusUnknown)
SetTestingState (true);
auto r = i2p::data::netdb.FindRouter (buf + 3); // find Charlie
if (r)
if (r && len >= offset + 9)
{
uint8_t asz = buf[offset + 9];
if (len < offset + asz + 10 + r->GetIdentity ()->GetSignatureLen ())
{
LogPrint (eLogWarning, "Malformed PeerTest 4 len=", len);
session->Done ();
return;
}
SignedData<128> s;
s.Insert ((const uint8_t *)"PeerTestValidate", 16); // prologue
s.Insert (GetRemoteIdentity ()->GetIdentHash (), 32); // bhash

View File

@@ -613,10 +613,8 @@ namespace stream
if (wasInitial)
ScheduleResend ();
}
if (m_IsClientChoked && ackThrough > m_DropWindowDelaySequenceNumber)
{
if (m_IsClientChoked && ackThrough >= m_DropWindowDelaySequenceNumber)
m_IsClientChoked = false;
}
if (m_IsWinDropped && ackThrough > m_DropWindowDelaySequenceNumber)
{
m_IsFirstRttSample = true;