diff --git a/daemon/HTTPServer.cpp b/daemon/HTTPServer.cpp
index cfd33aab..77254e61 100644
--- a/daemon/HTTPServer.cpp
+++ b/daemon/HTTPServer.cpp
@@ -311,12 +311,9 @@ namespace http {
s << "
\r\n";
switch (address->transportStyle)
{
- case i2p::data::RouterInfo::eTransportNTCP:
+ case i2p::data::RouterInfo::eTransportNTCP2:
s << "NTCP2";
break;
- case i2p::data::RouterInfo::eTransportSSU:
- s << "SSU";
- break;
case i2p::data::RouterInfo::eTransportSSU2:
s << "SSU2";
break;
diff --git a/libi2pd/NetDb.cpp b/libi2pd/NetDb.cpp
index 440833b6..29f9ff78 100644
--- a/libi2pd/NetDb.cpp
+++ b/libi2pd/NetDb.cpp
@@ -628,8 +628,8 @@ namespace data
(it.second->IsFloodfill () && totalFloodfills - deletedFloodfillsCount < NETDB_MIN_FLOODFILLS)))
it.second->SetUnreachable (false);
// find & mark expired routers
- if (!it.second->IsReachable () && (it.second->GetCompatibleTransports (true) & (RouterInfo::eSSUV4 | RouterInfo::eSSU2V4)))
- // non-reachable router, but reachable by ipv4 SSU or SSU2 means introducers
+ if (!it.second->IsReachable () && (it.second->GetCompatibleTransports (true) & RouterInfo::eSSU2V4))
+ // non-reachable router, but reachable by ipv4 SSU2 means introducers
{
if (ts > it.second->GetTimestamp () + NETDB_INTRODUCEE_EXPIRATION_TIMEOUT*1000LL)
// RouterInfo expires after 1 hour if uses introducer
@@ -1209,16 +1209,6 @@ namespace data
});
}
- std::shared_ptr NetDb::GetRandomPeerTestRouter (bool v4, const std::set& excluded) const
- {
- return GetRandomRouter (
- [v4, &excluded](std::shared_ptr router)->bool
- {
- return !router->IsHidden () && router->IsECIES () &&
- router->IsPeerTesting (v4) && !excluded.count (router->GetIdentHash ());
- });
- }
-
std::shared_ptr NetDb::GetRandomSSU2PeerTestRouter (bool v4, const std::set& excluded) const
{
return GetRandomRouter (
@@ -1229,16 +1219,6 @@ namespace data
});
}
- std::shared_ptr NetDb::GetRandomIntroducer (bool v4, const std::set& excluded) const
- {
- return GetRandomRouter (
- [v4, &excluded](std::shared_ptr router)->bool
- {
- return !router->IsHidden () && router->IsECIES () && !router->IsFloodfill () && // floodfills don't send relay tag
- router->IsIntroducer (v4) && !excluded.count (router->GetIdentHash ());
- });
- }
-
std::shared_ptr NetDb::GetRandomSSU2Introducer (bool v4, const std::set& excluded) const
{
return GetRandomRouter (
diff --git a/libi2pd/NetDb.hpp b/libi2pd/NetDb.hpp
index 0d234e9f..6d73fb38 100644
--- a/libi2pd/NetDb.hpp
+++ b/libi2pd/NetDb.hpp
@@ -89,9 +89,7 @@ namespace data
std::shared_ptr GetRandomRouter () const;
std::shared_ptr GetRandomRouter (std::shared_ptr compatibleWith, bool reverse) const;
std::shared_ptr GetHighBandwidthRandomRouter (std::shared_ptr compatibleWith, bool reverse) const;
- std::shared_ptr GetRandomPeerTestRouter (bool v4, const std::set& excluded) const;
std::shared_ptr GetRandomSSU2PeerTestRouter (bool v4, const std::set& excluded) const;
- std::shared_ptr GetRandomIntroducer (bool v4, const std::set& excluded) const;
std::shared_ptr GetRandomSSU2Introducer (bool v4, const std::set& excluded) const;
std::shared_ptr GetClosestFloodfill (const IdentHash& destination, const std::set& excluded, bool closeThanUsOnly = false) const;
std::vector GetClosestFloodfills (const IdentHash& destination, size_t num,
diff --git a/libi2pd/RouterContext.cpp b/libi2pd/RouterContext.cpp
index 6c55c1e0..c8000e2e 100644
--- a/libi2pd/RouterContext.cpp
+++ b/libi2pd/RouterContext.cpp
@@ -583,44 +583,6 @@ namespace i2p
return m_RouterInfo.GetCaps () & i2p::data::RouterInfo::eUnreachable;
}
- void RouterContext::RemoveNTCPAddress (bool v4only)
- {
- bool updated = false;
- auto& addresses = m_RouterInfo.GetAddresses ();
- for (auto it = addresses.begin (); it != addresses.end ();)
- {
- if ((*it)->transportStyle == i2p::data::RouterInfo::eTransportNTCP && !(*it)->IsNTCP2 () &&
- (!v4only || (*it)->host.is_v4 ()))
- {
- it = addresses.erase (it);
- updated = true;
- if (v4only) break; // otherwise might be more than one address
- }
- else
- ++it;
- }
- if (updated)
- m_RouterInfo.UpdateSupportedTransports ();
- }
-
- void RouterContext::RemoveSSUAddress ()
- {
- bool updated = false;
- auto& addresses = m_RouterInfo.GetAddresses ();
- for (auto it = addresses.begin (); it != addresses.end ();)
- {
- if ((*it)->transportStyle == i2p::data::RouterInfo::eTransportSSU)
- {
- it = addresses.erase (it);
- updated = true;
- }
- else
- ++it;
- }
- if (updated)
- m_RouterInfo.UpdateSupportedTransports ();
- }
-
void RouterContext::SetUnreachable (bool v4, bool v6)
{
if (v4 || (v6 && !SupportsV4 ()))
@@ -708,7 +670,7 @@ namespace i2p
{
switch (addr->transportStyle)
{
- case i2p::data::RouterInfo::eTransportNTCP:
+ case i2p::data::RouterInfo::eTransportNTCP2:
foundNTCP2 = true;
break;
case i2p::data::RouterInfo::eTransportSSU2:
@@ -788,7 +750,7 @@ namespace i2p
{
switch (addr->transportStyle)
{
- case i2p::data::RouterInfo::eTransportNTCP:
+ case i2p::data::RouterInfo::eTransportNTCP2:
foundNTCP2 = true;
break;
case i2p::data::RouterInfo::eTransportSSU2:
diff --git a/libi2pd/RouterContext.h b/libi2pd/RouterContext.h
index 6ee2be4f..f115f026 100644
--- a/libi2pd/RouterContext.h
+++ b/libi2pd/RouterContext.h
@@ -119,8 +119,6 @@ namespace garlic
void UpdateNTCP2Address (bool enable);
void PublishSSU2Address (int port, bool publish, bool v4, bool v6);
void UpdateSSU2Address (bool enable);
- void RemoveNTCPAddress (bool v4only = true); // delete NTCP address for older routers. TODO: remove later
- void RemoveSSUAddress (); // delete SSU address for older routers
bool AddSSU2Introducer (const i2p::data::RouterInfo::Introducer& introducer, bool v4);
void RemoveSSU2Introducer (const i2p::data::IdentHash& h, bool v4);
void ClearSSU2Introducers (bool v4);
diff --git a/libi2pd/RouterInfo.cpp b/libi2pd/RouterInfo.cpp
index 9cfbf47e..8772bae7 100644
--- a/libi2pd/RouterInfo.cpp
+++ b/libi2pd/RouterInfo.cpp
@@ -221,7 +221,7 @@ namespace data
char transportStyle[6];
ReadString (transportStyle, 6, s);
if (!strncmp (transportStyle, "NTCP", 4)) // NTCP or NTCP2
- address->transportStyle = eTransportNTCP;
+ address->transportStyle = eTransportNTCP2;
else if (!strncmp (transportStyle, "SSU", 3)) // SSU or SSU2
{
address->transportStyle = eTransportSSU2;
@@ -363,7 +363,7 @@ namespace data
}
if (!s) return;
}
- if (address->transportStyle == eTransportNTCP)
+ if (address->transportStyle == eTransportNTCP2)
{
if (isStaticKey)
{
@@ -550,10 +550,10 @@ namespace data
case CAPS_FLAG_V6:
caps |= AddressCaps::eV6;
break;
- case CAPS_FLAG_SSU_TESTING:
+ case CAPS_FLAG_SSU2_TESTING:
caps |= AddressCaps::eSSUTesting;
break;
- case CAPS_FLAG_SSU_INTRODUCER:
+ case CAPS_FLAG_SSU2_INTRODUCER:
caps |= AddressCaps::eSSUIntroducer;
break;
default: ;
@@ -622,7 +622,7 @@ namespace data
auto addr = std::make_shared();
addr->host = host;
addr->port = port;
- addr->transportStyle = eTransportNTCP;
+ addr->transportStyle = eTransportNTCP2;
addr->caps = caps;
addr->date = 0;
if (port) addr->published = true;
@@ -790,15 +790,6 @@ namespace data
}
}
- std::shared_ptr RouterInfo::GetSSUV6Address () const
- {
- return GetAddress (
- [](std::shared_ptr address)->bool
- {
- return (address->transportStyle == eTransportSSU) && address->IsV6();
- });
- }
-
std::shared_ptr RouterInfo::GetSSU2V4Address () const
{
return GetAddress (
@@ -913,21 +904,10 @@ namespace data
bool RouterInfo::IsEligibleFloodfill () const
{
// floodfill must be reachable by ipv4, >= 0.9.38 and not DSA
- return IsReachableBy (eNTCP2V4 | eSSUV4) && m_Version >= NETDB_MIN_FLOODFILL_VERSION &&
+ return IsReachableBy (eNTCP2V4 | eSSU2V4) && m_Version >= NETDB_MIN_FLOODFILL_VERSION &&
GetIdentity ()->GetSigningKeyType () != SIGNING_KEY_TYPE_DSA_SHA1;
}
- bool RouterInfo::IsPeerTesting (bool v4) const
- {
- if (!(m_SupportedTransports & (v4 ? eSSUV4 : eSSUV6))) return false;
- return (bool)GetAddress (
- [v4](std::shared_ptr address)->bool
- {
- return (address->transportStyle == eTransportSSU) && address->IsPeerTesting () &&
- ((v4 && address->IsV4 ()) || (!v4 && address->IsV6 ())) && address->IsReachableSSU ();
- });
- }
-
bool RouterInfo::IsSSU2PeerTesting (bool v4) const
{
if (!(m_SupportedTransports & (v4 ? eSSU2V4 : eSSU2V6))) return false;
@@ -939,17 +919,6 @@ namespace data
});
}
- bool RouterInfo::IsIntroducer (bool v4) const
- {
- if (!(m_SupportedTransports & (v4 ? eSSUV4 : eSSUV6))) return false;
- return (bool)GetAddress (
- [v4](std::shared_ptr address)->bool
- {
- return (address->transportStyle == eTransportSSU) && address->IsIntroducer () &&
- ((v4 && address->IsV4 ()) || (!v4 && address->IsV6 ())) && !address->host.is_unspecified ();
- });
- }
-
bool RouterInfo::IsSSU2Introducer (bool v4) const
{
if (!(m_SupportedTransports & (v4 ? eSSU2V4 : eSSU2V6))) return false;
@@ -965,7 +934,7 @@ namespace data
{
for (auto& addr: *m_Addresses)
{
- if (!addr->published && (addr->transportStyle == eTransportNTCP || addr->transportStyle == eTransportSSU2))
+ if (!addr->published && (addr->transportStyle == eTransportNTCP2 || addr->transportStyle == eTransportSSU2))
{
addr->caps &= ~(eV4 | eV6);
addr->caps |= transports;
@@ -982,7 +951,7 @@ namespace data
uint8_t transports = 0;
switch (addr->transportStyle)
{
- case eTransportNTCP:
+ case eTransportNTCP2:
if (addr->IsV4 ()) transports |= eNTCP2V4;
if (addr->IsV6 ())
transports |= (i2p::util::net::IsYggdrasilAddress (addr->host) ? eNTCP2V6Mesh : eNTCP2V6);
@@ -1088,15 +1057,17 @@ namespace data
const Address& address = *addr_ptr;
// calculate cost
uint8_t cost = 0x7f;
- if (address.transportStyle == eTransportNTCP)
+ if (address.transportStyle == eTransportNTCP2)
cost = address.published ? COST_NTCP2_PUBLISHED : COST_NTCP2_NON_PUBLISHED;
else if (address.transportStyle == eTransportSSU2)
cost = address.published ? COST_SSU2_DIRECT : COST_SSU2_NON_PUBLISHED;
+ else
+ continue; // skip unknown address
s.write ((const char *)&cost, sizeof (cost));
s.write ((const char *)&address.date, sizeof (address.date));
std::stringstream properties;
bool isPublished = false;
- if (address.transportStyle == eTransportNTCP)
+ if (address.transportStyle == eTransportNTCP2)
{
if (address.IsNTCP2 ())
{
@@ -1126,8 +1097,8 @@ namespace data
if (address.published)
{
isPublished = true;
- if (address.IsPeerTesting ()) caps += CAPS_FLAG_SSU_TESTING;
- if (address.IsIntroducer ()) caps += CAPS_FLAG_SSU_INTRODUCER;
+ if (address.IsPeerTesting ()) caps += CAPS_FLAG_SSU2_TESTING;
+ if (address.IsIntroducer ()) caps += CAPS_FLAG_SSU2_INTRODUCER;
}
else
{
diff --git a/libi2pd/RouterInfo.h b/libi2pd/RouterInfo.h
index e7eb0e7c..740acb9a 100644
--- a/libi2pd/RouterInfo.h
+++ b/libi2pd/RouterInfo.h
@@ -47,14 +47,12 @@ namespace data
const char CAPS_FLAG_V4 = '4';
const char CAPS_FLAG_V6 = '6';
- const char CAPS_FLAG_SSU_TESTING = 'B';
- const char CAPS_FLAG_SSU_INTRODUCER = 'C';
+ const char CAPS_FLAG_SSU2_TESTING = 'B';
+ const char CAPS_FLAG_SSU2_INTRODUCER = 'C';
const uint8_t COST_NTCP2_PUBLISHED = 3;
const uint8_t COST_NTCP2_NON_PUBLISHED = 14;
const uint8_t COST_SSU2_DIRECT = 8;
- const uint8_t COST_SSU_DIRECT = 9;
- const uint8_t COST_SSU_THROUGH_INTRODUCERS = 11;
const uint8_t COST_SSU2_NON_PUBLISHED = 15;
const size_t MAX_RI_BUFFER_SIZE = 3072; // if RouterInfo exceeds 3K we consider it as malformed, might extend later
@@ -66,11 +64,9 @@ namespace data
{
eNTCP2V4 = 0x01,
eNTCP2V6 = 0x02,
- eSSUV4 = 0x04,
- eSSUV6 = 0x08,
+ eSSU2V4 = 0x04,
+ eSSU2V6 = 0x08,
eNTCP2V6Mesh = 0x10,
- eSSU2V4 = 0x20,
- eSSU2V6 = 0x40,
eAllTransports = 0xFF
};
typedef uint8_t CompatibleTransports;
@@ -96,17 +92,16 @@ namespace data
enum TransportStyle
{
eTransportUnknown = 0,
- eTransportNTCP,
- eTransportSSU,
+ eTransportNTCP2,
eTransportSSU2
};
struct Introducer
{
Introducer (): iTag (0), iExp (0), isH (false) {};
+ IdentHash iH;
uint32_t iTag;
uint32_t iExp;
- IdentHash iH;
bool isH; // TODO: remove later
};
@@ -144,7 +139,7 @@ namespace data
return !(*this == other);
}
- bool IsNTCP2 () const { return transportStyle == eTransportNTCP; };
+ bool IsNTCP2 () const { return transportStyle == eTransportNTCP2; };
bool IsSSU2 () const { return transportStyle == eTransportSSU2; };
bool IsPublishedNTCP2 () const { return IsNTCP2 () && published; };
bool IsReachableSSU () const { return (bool)ssu && (published || UsesIntroducer ()); };
@@ -186,7 +181,6 @@ namespace data
std::shared_ptr GetSSU2AddressWithStaticKey (const uint8_t * key, bool isV6) const;
std::shared_ptr GetPublishedNTCP2V4Address () const;
std::shared_ptr GetPublishedNTCP2V6Address () const;
- std::shared_ptr GetSSUV6Address () const;
std::shared_ptr GetYggdrasilAddress () const;
std::shared_ptr GetSSU2V4Address () const;
std::shared_ptr GetSSU2V6Address () const;
@@ -206,8 +200,8 @@ namespace data
bool IsNTCP2V6 () const { return m_SupportedTransports & eNTCP2V6; };
bool IsSSU2V4 () const { return m_SupportedTransports & eSSU2V4; };
bool IsSSU2V6 () const { return m_SupportedTransports & eSSU2V6; };
- bool IsV6 () const { return m_SupportedTransports & (eSSUV6 | eNTCP2V6 | eSSU2V6); };
- bool IsV4 () const { return m_SupportedTransports & (eSSUV4 | eNTCP2V4 | eSSU2V4); };
+ bool IsV6 () const { return m_SupportedTransports & (eNTCP2V6 | eSSU2V6); };
+ bool IsV4 () const { return m_SupportedTransports & (eNTCP2V4 | eSSU2V4); };
bool IsMesh () const { return m_SupportedTransports & eNTCP2V6Mesh; };
void EnableV6 ();
void DisableV6 ();
@@ -224,9 +218,7 @@ namespace data
bool IsHighBandwidth () const { return m_Caps & RouterInfo::eHighBandwidth; };
bool IsExtraBandwidth () const { return m_Caps & RouterInfo::eExtraBandwidth; };
bool IsEligibleFloodfill () const;
- bool IsPeerTesting (bool v4) const;
bool IsSSU2PeerTesting (bool v4) const;
- bool IsIntroducer (bool v4) const;
bool IsSSU2Introducer (bool v4) const;
uint8_t GetCaps () const { return m_Caps; };
diff --git a/libi2pd/Transports.cpp b/libi2pd/Transports.cpp
index 9d37b0a0..0256e3d9 100644
--- a/libi2pd/Transports.cpp
+++ b/libi2pd/Transports.cpp
@@ -958,7 +958,6 @@ namespace transport
i2p::context.SetSupportsV4 (ipv4);
i2p::context.SetSupportsMesh (ygg, yggaddr);
- i2p::context.RemoveNTCPAddress (!ipv6); // TODO: remove later
bool ntcp2; i2p::config::GetOption("ntcp2.enabled", ntcp2);
if (ntcp2)
{
@@ -991,15 +990,13 @@ namespace transport
if (!ipv4 && !ipv6)
i2p::context.SetStatus (eRouterStatusMesh);
}
- bool ssu; i2p::config::GetOption("ssu", ssu);
- if (!ssu) i2p::context.RemoveSSUAddress (); // TODO: remove later
bool ssu2; i2p::config::GetOption("ssu2.enabled", ssu2);
if (ssu2 && i2p::config::IsDefault ("ssu2.enabled") && !ipv4 && !ipv6)
ssu2 = false; // don't enable ssu2 for yggdrasil only router
if (ssu2)
{
uint16_t ssu2port; i2p::config::GetOption("ssu2.port", ssu2port);
- if (!ssu2port && port) ssu2port = ssu ? (port + 1) : port;
+ if (!ssu2port && port) ssu2port = port;
bool published; i2p::config::GetOption("ssu2.published", published);
if (published)
i2p::context.PublishSSU2Address (ssu2port, true, ipv4, ipv6); // publish
|