mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-03-07 06:09:42 +00:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ebee6c5f13 | ||
|
|
3adff82d4a | ||
|
|
200ad5524d | ||
|
|
82ac0aa492 | ||
|
|
b8a99878b6 | ||
|
|
eaca435a5b | ||
|
|
ce05cce331 | ||
|
|
e190dab7d6 | ||
|
|
289c308600 | ||
|
|
bff12b06f4 | ||
|
|
b8590075e6 |
@@ -1,6 +1,13 @@
|
||||
# for this file format description,
|
||||
# see https://github.com/olivierlacan/keep-a-changelog
|
||||
|
||||
## [2.46.1] - 2023-02-20
|
||||
### Fixed
|
||||
- Race condition while getting router's peer profile
|
||||
- Creation of new router.info
|
||||
- Displaying LeaseSets in the webconsole
|
||||
- Crash when processing ACK request
|
||||
|
||||
## [2.46.0] - 2023-02-15
|
||||
### Added
|
||||
- Limit number of acked SSU2 packets to 511
|
||||
|
||||
@@ -129,7 +129,8 @@ port = 7070
|
||||
# pass = changeme
|
||||
## Select webconsole language
|
||||
## Currently supported english (default), afrikaans, armenian, chinese, czech, french,
|
||||
## german, italian, russian, spanish, turkmen, ukrainian and uzbek languages
|
||||
## german, italian, polish, portuguese, russian, spanish, turkish, turkmen, ukrainian
|
||||
## and uzbek languages
|
||||
# lang = english
|
||||
|
||||
[httpproxy]
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
%define git_hash %(git rev-parse HEAD | cut -c -7)
|
||||
|
||||
Name: i2pd-git
|
||||
Version: 2.46.0
|
||||
Version: 2.46.1
|
||||
Release: git%{git_hash}%{?dist}
|
||||
Summary: I2P router written in C++
|
||||
Conflicts: i2pd
|
||||
@@ -158,6 +158,9 @@ getent passwd i2pd >/dev/null || \
|
||||
|
||||
|
||||
%changelog
|
||||
* Mon Feb 20 2023 r4sas <r4sas@i2pmail.org> - 2.46.1
|
||||
- update to 2.46.1
|
||||
|
||||
* Wed Feb 15 2023 orignal <orignal@i2pmail.org> - 2.46.0
|
||||
- update to 2.46.0
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Name: i2pd
|
||||
Version: 2.46.0
|
||||
Release: 1%{?dist}
|
||||
Version: 2.46.1
|
||||
Release: 2%{?dist}
|
||||
Summary: I2P router written in C++
|
||||
Conflicts: i2pd-git
|
||||
|
||||
@@ -155,6 +155,9 @@ getent passwd i2pd >/dev/null || \
|
||||
|
||||
|
||||
%changelog
|
||||
* Mon Feb 20 2023 r4sas <r4sas@i2pmail.org> - 2.46.1
|
||||
- update to 2.46.1
|
||||
|
||||
* Wed Feb 15 2023 orignal <orignal@i2pmail.org> - 2.46.0
|
||||
- update to 2.46.0
|
||||
|
||||
|
||||
@@ -625,7 +625,10 @@ namespace http {
|
||||
if (storeType == i2p::data::NETDB_STORE_TYPE_LEASESET)
|
||||
ls.reset (new i2p::data::LeaseSet (leaseSet->GetBuffer(), leaseSet->GetBufferLen()));
|
||||
else
|
||||
ls.reset (new i2p::data::LeaseSet2 (storeType, leaseSet->GetBuffer(), leaseSet->GetBufferLen()));
|
||||
{
|
||||
ls.reset (new i2p::data::LeaseSet2 (storeType));
|
||||
ls->Update (leaseSet->GetBuffer(), leaseSet->GetBufferLen(), false);
|
||||
}
|
||||
if (!ls) return;
|
||||
s << "<div class=\"leaseset listitem";
|
||||
if (ls->IsExpired())
|
||||
|
||||
12
debian/changelog
vendored
12
debian/changelog
vendored
@@ -1,3 +1,15 @@
|
||||
i2pd (2.46.1-2) unstable; urgency=critical
|
||||
|
||||
* re-pushed release due to new critical bug
|
||||
|
||||
-- r4sas <r4sas@i2pmail.org> Mon, 20 Feb 2023 23:40:00 +0000
|
||||
|
||||
i2pd (2.46.1-1) unstable; urgency=high
|
||||
|
||||
* updated to version 2.46.1/0.9.57
|
||||
|
||||
-- r4sas <r4sas@i2pmail.org> Mon, 20 Feb 2023 02:45:00 +0000
|
||||
|
||||
i2pd (2.46.0-1) unstable; urgency=high
|
||||
|
||||
* updated to version 2.46.0/0.9.57
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2021, The PurpleI2P Project
|
||||
* Copyright (c) 2013-2023, The PurpleI2P Project
|
||||
*
|
||||
* This file is part of Purple i2pd project and licensed under BSD3
|
||||
*
|
||||
@@ -335,7 +335,8 @@ namespace garlic
|
||||
case eECIESx25519BlkAckRequest:
|
||||
{
|
||||
LogPrint (eLogDebug, "Garlic: Ack request");
|
||||
m_AckRequests.push_back ({receiveTagset->GetTagSetID (), index});
|
||||
if (receiveTagset)
|
||||
m_AckRequests.push_back ({receiveTagset->GetTagSetID (), index});
|
||||
break;
|
||||
}
|
||||
case eECIESx25519BlkTermination:
|
||||
|
||||
271
libi2pd/KadDHT.cpp
Normal file
271
libi2pd/KadDHT.cpp
Normal file
@@ -0,0 +1,271 @@
|
||||
/*
|
||||
* Copyright (c) 2023, The PurpleI2P Project
|
||||
*
|
||||
* This file is part of Purple i2pd project and licensed under BSD3
|
||||
*
|
||||
* See full license text in LICENSE file at top of project tree
|
||||
*
|
||||
*/
|
||||
|
||||
#include "KadDHT.h"
|
||||
|
||||
namespace i2p
|
||||
{
|
||||
namespace data
|
||||
{
|
||||
DHTNode::DHTNode ():
|
||||
zero (nullptr), one (nullptr), hash (nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
DHTNode::~DHTNode ()
|
||||
{
|
||||
if (zero) delete zero;
|
||||
if (one) delete one;
|
||||
if (hash) delete hash;
|
||||
}
|
||||
|
||||
void DHTNode::MoveHashUp (bool fromOne)
|
||||
{
|
||||
DHTNode *& side = fromOne ? one : zero;
|
||||
if (side)
|
||||
{
|
||||
if (hash) delete hash; // shouldn't happen
|
||||
hash = side->hash;
|
||||
side->hash = nullptr;
|
||||
delete side;
|
||||
side = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
DHTTable::DHTTable ():
|
||||
m_Size (0)
|
||||
{
|
||||
m_Root = new DHTNode;
|
||||
}
|
||||
|
||||
DHTTable::~DHTTable ()
|
||||
{
|
||||
delete m_Root;
|
||||
}
|
||||
|
||||
DHTNode * DHTTable::Insert (const IdentHash& h)
|
||||
{
|
||||
return Insert (new IdentHash (h), m_Root, 0);
|
||||
}
|
||||
|
||||
DHTNode * DHTTable::Insert (IdentHash * h, DHTNode * root, int level)
|
||||
{
|
||||
if (root->hash)
|
||||
{
|
||||
if (*(root->hash) == *h)
|
||||
{
|
||||
delete h;
|
||||
return root;
|
||||
}
|
||||
auto h2 = root->hash;
|
||||
root->hash = nullptr; m_Size--;
|
||||
int bit1, bit2;
|
||||
do
|
||||
{
|
||||
bit1 = h->GetBit (level);
|
||||
bit2 = h2->GetBit (level);
|
||||
if (bit1 == bit2)
|
||||
{
|
||||
if (bit1)
|
||||
{
|
||||
if (root->one) return nullptr; // someting wrong
|
||||
root->one = new DHTNode;
|
||||
root = root->one;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (root->zero) return nullptr; // someting wrong
|
||||
root->zero = new DHTNode;
|
||||
root = root->zero;
|
||||
}
|
||||
level++;
|
||||
}
|
||||
}
|
||||
while (bit1 == bit2);
|
||||
|
||||
if (!root->zero)
|
||||
root->zero = new DHTNode;
|
||||
if (!root->one)
|
||||
root->one = new DHTNode;
|
||||
if (bit1)
|
||||
{
|
||||
Insert (h2, root->zero, level + 1);
|
||||
return Insert (h, root->one, level + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
Insert (h2, root->one, level + 1);
|
||||
return Insert (h, root->zero, level + 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!root->zero && !root->one)
|
||||
{
|
||||
root->hash = h; m_Size++;
|
||||
return root;
|
||||
}
|
||||
int bit = h->GetBit (level);
|
||||
if (bit)
|
||||
{
|
||||
if (!root->one)
|
||||
root->one = new DHTNode;
|
||||
return Insert (h, root->one, level + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!root->zero)
|
||||
root->zero = new DHTNode;
|
||||
return Insert (h, root->zero, level + 1);
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool DHTTable::Remove (const IdentHash& h)
|
||||
{
|
||||
return Remove (h, m_Root, 0);
|
||||
}
|
||||
|
||||
bool DHTTable::Remove (const IdentHash& h, DHTNode * root, int level)
|
||||
{
|
||||
if (root)
|
||||
{
|
||||
if (root->hash && *(root->hash) == h)
|
||||
{
|
||||
delete root->hash; root->hash = nullptr;
|
||||
m_Size--;
|
||||
return true;
|
||||
}
|
||||
int bit = h.GetBit (level);
|
||||
if (bit)
|
||||
{
|
||||
if (root->one && Remove (h, root->one, level + 1))
|
||||
{
|
||||
if (root->one->IsEmpty ())
|
||||
{
|
||||
delete root->one;
|
||||
root->one = nullptr;
|
||||
if (root->zero && root->zero->hash)
|
||||
root->MoveHashUp (false);
|
||||
}
|
||||
else if (root->one->hash && !root->zero)
|
||||
root->MoveHashUp (true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (root->zero && Remove (h, root->zero, level + 1))
|
||||
{
|
||||
if (root->zero->IsEmpty ())
|
||||
{
|
||||
delete root->zero;
|
||||
root->zero = nullptr;
|
||||
if (root->one && root->one->hash)
|
||||
root->MoveHashUp (true);
|
||||
}
|
||||
else if (root->zero->hash && !root->one)
|
||||
root->MoveHashUp (false);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
IdentHash * DHTTable::FindClosest (const IdentHash& h)
|
||||
{
|
||||
return FindClosest (h, m_Root, 0);
|
||||
}
|
||||
|
||||
IdentHash * DHTTable::FindClosest (const IdentHash& h, DHTNode * root, int level)
|
||||
{
|
||||
if (root->hash) return root->hash;
|
||||
int bit = h.GetBit (level);
|
||||
if (bit)
|
||||
{
|
||||
if (root->one)
|
||||
return FindClosest (h, root->one, level + 1);
|
||||
if (root->zero)
|
||||
return FindClosest (h, root->zero, level + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (root->zero)
|
||||
return FindClosest (h, root->zero, level + 1);
|
||||
if (root->one)
|
||||
return FindClosest (h, root->one, level + 1);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::vector<IdentHash *> DHTTable::FindClosest (const IdentHash& h, size_t num)
|
||||
{
|
||||
std::vector<IdentHash *> vec;
|
||||
if (num > 0)
|
||||
FindClosest (h, num, m_Root, 0, vec);
|
||||
return vec;
|
||||
}
|
||||
|
||||
void DHTTable::FindClosest (const IdentHash& h, size_t num, DHTNode * root, int level, std::vector<IdentHash *>& hashes)
|
||||
{
|
||||
if (hashes.size () >= num) return;
|
||||
if (root->hash)
|
||||
{
|
||||
hashes.push_back (root->hash);
|
||||
return;
|
||||
}
|
||||
int bit = h.GetBit (level);
|
||||
if (bit)
|
||||
{
|
||||
if (root->one)
|
||||
FindClosest (h, num, root->one, level + 1, hashes);
|
||||
if (hashes.size () < num && root->zero)
|
||||
FindClosest (h, num, root->zero, level + 1, hashes);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (root->zero)
|
||||
FindClosest (h, num, root->zero, level + 1, hashes);
|
||||
if (hashes.size () < num && root->one)
|
||||
FindClosest (h, num, root->one, level + 1, hashes);
|
||||
}
|
||||
}
|
||||
|
||||
void DHTTable::Print (std::stringstream& s)
|
||||
{
|
||||
Print (s, m_Root, 0);
|
||||
}
|
||||
|
||||
void DHTTable::Print (std::stringstream& s, DHTNode * root, int level)
|
||||
{
|
||||
if (!root) return;
|
||||
s << std::string (level, '-');
|
||||
if (root->hash)
|
||||
{
|
||||
if (!root->zero && !root->one)
|
||||
s << '>' << GetIdentHashAbbreviation (*(root->hash));
|
||||
else
|
||||
s << "error";
|
||||
}
|
||||
s << std::endl;
|
||||
if (root->zero)
|
||||
{
|
||||
s << std::string (level, '-') << "0" << std::endl;
|
||||
Print (s, root->zero, level + 1);
|
||||
}
|
||||
if (root->one)
|
||||
{
|
||||
s << std::string (level, '-') << "1" << std::endl;
|
||||
Print (s, root->one, level + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
67
libi2pd/KadDHT.h
Normal file
67
libi2pd/KadDHT.h
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (c) 2023, The PurpleI2P Project
|
||||
*
|
||||
* This file is part of Purple i2pd project and licensed under BSD3
|
||||
*
|
||||
* See full license text in LICENSE file at top of project tree
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef KADDHT_H__
|
||||
#define KADDHT_H__
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
#include "Identity.h"
|
||||
|
||||
// Kademlia DHT (XOR distance)
|
||||
|
||||
namespace i2p
|
||||
{
|
||||
namespace data
|
||||
{
|
||||
struct DHTNode
|
||||
{
|
||||
DHTNode * zero, * one;
|
||||
IdentHash * hash;
|
||||
|
||||
DHTNode ();
|
||||
~DHTNode ();
|
||||
|
||||
bool IsEmpty () const { return !zero && !one && !hash; };
|
||||
void MoveHashUp (bool fromOne);
|
||||
};
|
||||
|
||||
class DHTTable
|
||||
{
|
||||
public:
|
||||
|
||||
DHTTable ();
|
||||
~DHTTable ();
|
||||
|
||||
DHTNode * Insert (const IdentHash& h);
|
||||
bool Remove (const IdentHash& h);
|
||||
IdentHash * FindClosest (const IdentHash& h);
|
||||
std::vector<IdentHash *> FindClosest (const IdentHash& h, size_t num);
|
||||
|
||||
void Print (std::stringstream& s);
|
||||
size_t GetSize () const { return m_Size; };
|
||||
|
||||
private:
|
||||
|
||||
DHTNode * Insert (IdentHash * h, DHTNode * root, int level); // recursive
|
||||
bool Remove (const IdentHash& h, DHTNode * root, int level);
|
||||
IdentHash * FindClosest (const IdentHash& h, DHTNode * root, int level);
|
||||
void FindClosest (const IdentHash& h, size_t num, DHTNode * root, int level, std::vector<IdentHash *>& hashes);
|
||||
void Print (std::stringstream& s, DHTNode * root, int level);
|
||||
|
||||
private:
|
||||
|
||||
DHTNode * m_Root;
|
||||
size_t m_Size;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2022, The PurpleI2P Project
|
||||
* Copyright (c) 2013-2023, The PurpleI2P Project
|
||||
*
|
||||
* This file is part of Purple i2pd project and licensed under BSD3
|
||||
*
|
||||
@@ -315,7 +315,7 @@ namespace data
|
||||
{
|
||||
// standard LS2 header
|
||||
std::shared_ptr<const IdentityEx> identity;
|
||||
if (readIdentity)
|
||||
if (readIdentity || !GetIdentity ())
|
||||
{
|
||||
identity = std::make_shared<IdentityEx>(buf, len);
|
||||
SetIdentity (identity);
|
||||
@@ -366,6 +366,8 @@ namespace data
|
||||
VerifySignature (identity, buf, len, offset);
|
||||
SetIsValid (verified);
|
||||
}
|
||||
else
|
||||
SetIsValid (true);
|
||||
offset += m_TransientVerifier ? m_TransientVerifier->GetSignatureLen () : identity->GetSignatureLen ();
|
||||
if (offset > len) {
|
||||
LogPrint (eLogWarning, "LeaseSet2: short buffer: wanted ", int(offset), "bytes, have ", int(len));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2021, The PurpleI2P Project
|
||||
* Copyright (c) 2013-2023, The PurpleI2P Project
|
||||
*
|
||||
* This file is part of Purple i2pd project and licensed under BSD3
|
||||
*
|
||||
@@ -145,6 +145,7 @@ namespace data
|
||||
{
|
||||
public:
|
||||
|
||||
LeaseSet2 (uint8_t storeType): LeaseSet (true), m_StoreType (storeType) {}; // for update
|
||||
LeaseSet2 (uint8_t storeType, const uint8_t * buf, size_t len, bool storeLeases = true, CryptoKeyType preferredCrypto = CRYPTO_KEY_TYPE_ELGAMAL);
|
||||
LeaseSet2 (const uint8_t * buf, size_t len, std::shared_ptr<const BlindedPublicKey> key, const uint8_t * secret = nullptr, CryptoKeyType preferredCrypto = CRYPTO_KEY_TYPE_ELGAMAL); // store type 5, called from local netdb only
|
||||
uint8_t GetStoreType () const { return m_StoreType; };
|
||||
|
||||
@@ -315,7 +315,7 @@ namespace data
|
||||
else
|
||||
{
|
||||
r = std::make_shared<RouterInfo> (buf, len);
|
||||
if (!r->IsUnreachable () && r->HasValidAddresses () && !r->GetProfile ()->IsUnreachable () &&
|
||||
if (!r->IsUnreachable () && r->HasValidAddresses () && (!r->IsFloodfill () || !r->GetProfile ()->IsUnreachable ()) &&
|
||||
i2p::util::GetMillisecondsSinceEpoch () + NETDB_EXPIRATION_TIMEOUT_THRESHOLD*1000LL > r->GetTimestamp ())
|
||||
{
|
||||
bool inserted = false;
|
||||
@@ -1398,7 +1398,7 @@ namespace data
|
||||
std::unique_lock<std::mutex> l(m_FloodfillsMutex);
|
||||
for (const auto& it: m_Floodfills)
|
||||
{
|
||||
if (!it->IsUnreachable ())
|
||||
if (!it->IsUnreachable () && !it->GetProfile ()->IsUnreachable ())
|
||||
{
|
||||
XORMetric m = destKey ^ it->GetIdentHash ();
|
||||
if (closeThanUsOnly && ourMetric < m) continue;
|
||||
|
||||
@@ -661,11 +661,16 @@ namespace data
|
||||
addr->host = host;
|
||||
addr->port = port;
|
||||
addr->transportStyle = eTransportNTCP2;
|
||||
addr->caps = 0;
|
||||
addr->date = 0;
|
||||
addr->published = true;
|
||||
memcpy (addr->s, staticKey, 32);
|
||||
memcpy (addr->i, iv, 16);
|
||||
addr->caps = 0;
|
||||
if (host.is_unspecified ())
|
||||
{
|
||||
if (host.is_v4 ()) addr->caps |= eV4;
|
||||
if (host.is_v6 ()) addr->caps |= eV6;
|
||||
}
|
||||
if (addr->IsV4 ())
|
||||
{
|
||||
m_SupportedTransports |= eNTCP2V4;
|
||||
@@ -737,12 +742,19 @@ namespace data
|
||||
addr->host = host;
|
||||
addr->port = port;
|
||||
addr->published = true;
|
||||
addr->caps = i2p::data::RouterInfo::eSSUTesting | i2p::data::RouterInfo::eSSUIntroducer; // BC;
|
||||
addr->date = 0;
|
||||
addr->ssu.reset (new SSUExt ());
|
||||
addr->ssu->mtu = 0;
|
||||
memcpy (addr->s, staticKey, 32);
|
||||
memcpy (addr->i, introKey, 32);
|
||||
if (!host.is_unspecified ())
|
||||
addr->caps = i2p::data::RouterInfo::eSSUTesting | i2p::data::RouterInfo::eSSUIntroducer; // BC;
|
||||
else
|
||||
{
|
||||
addr->caps = 0;
|
||||
if (host.is_v4 ()) addr->caps |= eV4;
|
||||
if (host.is_v6 ()) addr->caps |= eV6;
|
||||
}
|
||||
if (addr->IsV4 ())
|
||||
{
|
||||
m_SupportedTransports |= eSSU2V4;
|
||||
@@ -945,9 +957,13 @@ namespace data
|
||||
|
||||
std::shared_ptr<RouterProfile> RouterInfo::GetProfile () const
|
||||
{
|
||||
if (!m_Profile)
|
||||
m_Profile = GetRouterProfile (GetIdentHash ());
|
||||
return m_Profile;
|
||||
auto profile = m_Profile;
|
||||
if (!profile)
|
||||
{
|
||||
profile = GetRouterProfile (GetIdentHash ());
|
||||
m_Profile = profile;
|
||||
}
|
||||
return profile;
|
||||
}
|
||||
|
||||
void RouterInfo::Encrypt (const uint8_t * data, uint8_t * encrypted) const
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
#define I2PD_VERSION_MAJOR 2
|
||||
#define I2PD_VERSION_MINOR 46
|
||||
#define I2PD_VERSION_MICRO 0
|
||||
#define I2PD_VERSION_MICRO 1
|
||||
#define I2PD_VERSION_PATCH 0
|
||||
#ifdef GITVER
|
||||
#define I2PD_VERSION GITVER
|
||||
|
||||
Reference in New Issue
Block a user