mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-02-08 22:13:48 +01:00
removed SSU and NTCP transports
This commit is contained in:
parent
a298588943
commit
fb8be32c28
8 changed files with 29 additions and 134 deletions
|
@ -311,12 +311,9 @@ namespace http {
|
||||||
s << "<tr>\r\n<td>";
|
s << "<tr>\r\n<td>";
|
||||||
switch (address->transportStyle)
|
switch (address->transportStyle)
|
||||||
{
|
{
|
||||||
case i2p::data::RouterInfo::eTransportNTCP:
|
case i2p::data::RouterInfo::eTransportNTCP2:
|
||||||
s << "NTCP2";
|
s << "NTCP2";
|
||||||
break;
|
break;
|
||||||
case i2p::data::RouterInfo::eTransportSSU:
|
|
||||||
s << "SSU";
|
|
||||||
break;
|
|
||||||
case i2p::data::RouterInfo::eTransportSSU2:
|
case i2p::data::RouterInfo::eTransportSSU2:
|
||||||
s << "SSU2";
|
s << "SSU2";
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -628,8 +628,8 @@ namespace data
|
||||||
(it.second->IsFloodfill () && totalFloodfills - deletedFloodfillsCount < NETDB_MIN_FLOODFILLS)))
|
(it.second->IsFloodfill () && totalFloodfills - deletedFloodfillsCount < NETDB_MIN_FLOODFILLS)))
|
||||||
it.second->SetUnreachable (false);
|
it.second->SetUnreachable (false);
|
||||||
// find & mark expired routers
|
// find & mark expired routers
|
||||||
if (!it.second->IsReachable () && (it.second->GetCompatibleTransports (true) & (RouterInfo::eSSUV4 | RouterInfo::eSSU2V4)))
|
if (!it.second->IsReachable () && (it.second->GetCompatibleTransports (true) & RouterInfo::eSSU2V4))
|
||||||
// non-reachable router, but reachable by ipv4 SSU or SSU2 means introducers
|
// non-reachable router, but reachable by ipv4 SSU2 means introducers
|
||||||
{
|
{
|
||||||
if (ts > it.second->GetTimestamp () + NETDB_INTRODUCEE_EXPIRATION_TIMEOUT*1000LL)
|
if (ts > it.second->GetTimestamp () + NETDB_INTRODUCEE_EXPIRATION_TIMEOUT*1000LL)
|
||||||
// RouterInfo expires after 1 hour if uses introducer
|
// RouterInfo expires after 1 hour if uses introducer
|
||||||
|
@ -1209,16 +1209,6 @@ namespace data
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<const RouterInfo> NetDb::GetRandomPeerTestRouter (bool v4, const std::set<IdentHash>& excluded) const
|
|
||||||
{
|
|
||||||
return GetRandomRouter (
|
|
||||||
[v4, &excluded](std::shared_ptr<const RouterInfo> router)->bool
|
|
||||||
{
|
|
||||||
return !router->IsHidden () && router->IsECIES () &&
|
|
||||||
router->IsPeerTesting (v4) && !excluded.count (router->GetIdentHash ());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
std::shared_ptr<const RouterInfo> NetDb::GetRandomSSU2PeerTestRouter (bool v4, const std::set<IdentHash>& excluded) const
|
std::shared_ptr<const RouterInfo> NetDb::GetRandomSSU2PeerTestRouter (bool v4, const std::set<IdentHash>& excluded) const
|
||||||
{
|
{
|
||||||
return GetRandomRouter (
|
return GetRandomRouter (
|
||||||
|
@ -1229,16 +1219,6 @@ namespace data
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<const RouterInfo> NetDb::GetRandomIntroducer (bool v4, const std::set<IdentHash>& excluded) const
|
|
||||||
{
|
|
||||||
return GetRandomRouter (
|
|
||||||
[v4, &excluded](std::shared_ptr<const RouterInfo> 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<const RouterInfo> NetDb::GetRandomSSU2Introducer (bool v4, const std::set<IdentHash>& excluded) const
|
std::shared_ptr<const RouterInfo> NetDb::GetRandomSSU2Introducer (bool v4, const std::set<IdentHash>& excluded) const
|
||||||
{
|
{
|
||||||
return GetRandomRouter (
|
return GetRandomRouter (
|
||||||
|
|
|
@ -89,9 +89,7 @@ namespace data
|
||||||
std::shared_ptr<const RouterInfo> GetRandomRouter () const;
|
std::shared_ptr<const RouterInfo> GetRandomRouter () const;
|
||||||
std::shared_ptr<const RouterInfo> GetRandomRouter (std::shared_ptr<const RouterInfo> compatibleWith, bool reverse) const;
|
std::shared_ptr<const RouterInfo> GetRandomRouter (std::shared_ptr<const RouterInfo> compatibleWith, bool reverse) const;
|
||||||
std::shared_ptr<const RouterInfo> GetHighBandwidthRandomRouter (std::shared_ptr<const RouterInfo> compatibleWith, bool reverse) const;
|
std::shared_ptr<const RouterInfo> GetHighBandwidthRandomRouter (std::shared_ptr<const RouterInfo> compatibleWith, bool reverse) const;
|
||||||
std::shared_ptr<const RouterInfo> GetRandomPeerTestRouter (bool v4, const std::set<IdentHash>& excluded) const;
|
|
||||||
std::shared_ptr<const RouterInfo> GetRandomSSU2PeerTestRouter (bool v4, const std::set<IdentHash>& excluded) const;
|
std::shared_ptr<const RouterInfo> GetRandomSSU2PeerTestRouter (bool v4, const std::set<IdentHash>& excluded) const;
|
||||||
std::shared_ptr<const RouterInfo> GetRandomIntroducer (bool v4, const std::set<IdentHash>& excluded) const;
|
|
||||||
std::shared_ptr<const RouterInfo> GetRandomSSU2Introducer (bool v4, const std::set<IdentHash>& excluded) const;
|
std::shared_ptr<const RouterInfo> GetRandomSSU2Introducer (bool v4, const std::set<IdentHash>& excluded) const;
|
||||||
std::shared_ptr<const RouterInfo> GetClosestFloodfill (const IdentHash& destination, const std::set<IdentHash>& excluded, bool closeThanUsOnly = false) const;
|
std::shared_ptr<const RouterInfo> GetClosestFloodfill (const IdentHash& destination, const std::set<IdentHash>& excluded, bool closeThanUsOnly = false) const;
|
||||||
std::vector<IdentHash> GetClosestFloodfills (const IdentHash& destination, size_t num,
|
std::vector<IdentHash> GetClosestFloodfills (const IdentHash& destination, size_t num,
|
||||||
|
|
|
@ -583,44 +583,6 @@ namespace i2p
|
||||||
return m_RouterInfo.GetCaps () & i2p::data::RouterInfo::eUnreachable;
|
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)
|
void RouterContext::SetUnreachable (bool v4, bool v6)
|
||||||
{
|
{
|
||||||
if (v4 || (v6 && !SupportsV4 ()))
|
if (v4 || (v6 && !SupportsV4 ()))
|
||||||
|
@ -708,7 +670,7 @@ namespace i2p
|
||||||
{
|
{
|
||||||
switch (addr->transportStyle)
|
switch (addr->transportStyle)
|
||||||
{
|
{
|
||||||
case i2p::data::RouterInfo::eTransportNTCP:
|
case i2p::data::RouterInfo::eTransportNTCP2:
|
||||||
foundNTCP2 = true;
|
foundNTCP2 = true;
|
||||||
break;
|
break;
|
||||||
case i2p::data::RouterInfo::eTransportSSU2:
|
case i2p::data::RouterInfo::eTransportSSU2:
|
||||||
|
@ -788,7 +750,7 @@ namespace i2p
|
||||||
{
|
{
|
||||||
switch (addr->transportStyle)
|
switch (addr->transportStyle)
|
||||||
{
|
{
|
||||||
case i2p::data::RouterInfo::eTransportNTCP:
|
case i2p::data::RouterInfo::eTransportNTCP2:
|
||||||
foundNTCP2 = true;
|
foundNTCP2 = true;
|
||||||
break;
|
break;
|
||||||
case i2p::data::RouterInfo::eTransportSSU2:
|
case i2p::data::RouterInfo::eTransportSSU2:
|
||||||
|
|
|
@ -119,8 +119,6 @@ namespace garlic
|
||||||
void UpdateNTCP2Address (bool enable);
|
void UpdateNTCP2Address (bool enable);
|
||||||
void PublishSSU2Address (int port, bool publish, bool v4, bool v6);
|
void PublishSSU2Address (int port, bool publish, bool v4, bool v6);
|
||||||
void UpdateSSU2Address (bool enable);
|
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);
|
bool AddSSU2Introducer (const i2p::data::RouterInfo::Introducer& introducer, bool v4);
|
||||||
void RemoveSSU2Introducer (const i2p::data::IdentHash& h, bool v4);
|
void RemoveSSU2Introducer (const i2p::data::IdentHash& h, bool v4);
|
||||||
void ClearSSU2Introducers (bool v4);
|
void ClearSSU2Introducers (bool v4);
|
||||||
|
|
|
@ -221,7 +221,7 @@ namespace data
|
||||||
char transportStyle[6];
|
char transportStyle[6];
|
||||||
ReadString (transportStyle, 6, s);
|
ReadString (transportStyle, 6, s);
|
||||||
if (!strncmp (transportStyle, "NTCP", 4)) // NTCP or NTCP2
|
if (!strncmp (transportStyle, "NTCP", 4)) // NTCP or NTCP2
|
||||||
address->transportStyle = eTransportNTCP;
|
address->transportStyle = eTransportNTCP2;
|
||||||
else if (!strncmp (transportStyle, "SSU", 3)) // SSU or SSU2
|
else if (!strncmp (transportStyle, "SSU", 3)) // SSU or SSU2
|
||||||
{
|
{
|
||||||
address->transportStyle = eTransportSSU2;
|
address->transportStyle = eTransportSSU2;
|
||||||
|
@ -363,7 +363,7 @@ namespace data
|
||||||
}
|
}
|
||||||
if (!s) return;
|
if (!s) return;
|
||||||
}
|
}
|
||||||
if (address->transportStyle == eTransportNTCP)
|
if (address->transportStyle == eTransportNTCP2)
|
||||||
{
|
{
|
||||||
if (isStaticKey)
|
if (isStaticKey)
|
||||||
{
|
{
|
||||||
|
@ -550,10 +550,10 @@ namespace data
|
||||||
case CAPS_FLAG_V6:
|
case CAPS_FLAG_V6:
|
||||||
caps |= AddressCaps::eV6;
|
caps |= AddressCaps::eV6;
|
||||||
break;
|
break;
|
||||||
case CAPS_FLAG_SSU_TESTING:
|
case CAPS_FLAG_SSU2_TESTING:
|
||||||
caps |= AddressCaps::eSSUTesting;
|
caps |= AddressCaps::eSSUTesting;
|
||||||
break;
|
break;
|
||||||
case CAPS_FLAG_SSU_INTRODUCER:
|
case CAPS_FLAG_SSU2_INTRODUCER:
|
||||||
caps |= AddressCaps::eSSUIntroducer;
|
caps |= AddressCaps::eSSUIntroducer;
|
||||||
break;
|
break;
|
||||||
default: ;
|
default: ;
|
||||||
|
@ -622,7 +622,7 @@ namespace data
|
||||||
auto addr = std::make_shared<Address>();
|
auto addr = std::make_shared<Address>();
|
||||||
addr->host = host;
|
addr->host = host;
|
||||||
addr->port = port;
|
addr->port = port;
|
||||||
addr->transportStyle = eTransportNTCP;
|
addr->transportStyle = eTransportNTCP2;
|
||||||
addr->caps = caps;
|
addr->caps = caps;
|
||||||
addr->date = 0;
|
addr->date = 0;
|
||||||
if (port) addr->published = true;
|
if (port) addr->published = true;
|
||||||
|
@ -790,15 +790,6 @@ namespace data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<const RouterInfo::Address> RouterInfo::GetSSUV6Address () const
|
|
||||||
{
|
|
||||||
return GetAddress (
|
|
||||||
[](std::shared_ptr<const RouterInfo::Address> address)->bool
|
|
||||||
{
|
|
||||||
return (address->transportStyle == eTransportSSU) && address->IsV6();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
std::shared_ptr<const RouterInfo::Address> RouterInfo::GetSSU2V4Address () const
|
std::shared_ptr<const RouterInfo::Address> RouterInfo::GetSSU2V4Address () const
|
||||||
{
|
{
|
||||||
return GetAddress (
|
return GetAddress (
|
||||||
|
@ -913,21 +904,10 @@ namespace data
|
||||||
bool RouterInfo::IsEligibleFloodfill () const
|
bool RouterInfo::IsEligibleFloodfill () const
|
||||||
{
|
{
|
||||||
// floodfill must be reachable by ipv4, >= 0.9.38 and not DSA
|
// 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;
|
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<const RouterInfo::Address> address)->bool
|
|
||||||
{
|
|
||||||
return (address->transportStyle == eTransportSSU) && address->IsPeerTesting () &&
|
|
||||||
((v4 && address->IsV4 ()) || (!v4 && address->IsV6 ())) && address->IsReachableSSU ();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
bool RouterInfo::IsSSU2PeerTesting (bool v4) const
|
bool RouterInfo::IsSSU2PeerTesting (bool v4) const
|
||||||
{
|
{
|
||||||
if (!(m_SupportedTransports & (v4 ? eSSU2V4 : eSSU2V6))) return false;
|
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<const RouterInfo::Address> address)->bool
|
|
||||||
{
|
|
||||||
return (address->transportStyle == eTransportSSU) && address->IsIntroducer () &&
|
|
||||||
((v4 && address->IsV4 ()) || (!v4 && address->IsV6 ())) && !address->host.is_unspecified ();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
bool RouterInfo::IsSSU2Introducer (bool v4) const
|
bool RouterInfo::IsSSU2Introducer (bool v4) const
|
||||||
{
|
{
|
||||||
if (!(m_SupportedTransports & (v4 ? eSSU2V4 : eSSU2V6))) return false;
|
if (!(m_SupportedTransports & (v4 ? eSSU2V4 : eSSU2V6))) return false;
|
||||||
|
@ -965,7 +934,7 @@ namespace data
|
||||||
{
|
{
|
||||||
for (auto& addr: *m_Addresses)
|
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 &= ~(eV4 | eV6);
|
||||||
addr->caps |= transports;
|
addr->caps |= transports;
|
||||||
|
@ -982,7 +951,7 @@ namespace data
|
||||||
uint8_t transports = 0;
|
uint8_t transports = 0;
|
||||||
switch (addr->transportStyle)
|
switch (addr->transportStyle)
|
||||||
{
|
{
|
||||||
case eTransportNTCP:
|
case eTransportNTCP2:
|
||||||
if (addr->IsV4 ()) transports |= eNTCP2V4;
|
if (addr->IsV4 ()) transports |= eNTCP2V4;
|
||||||
if (addr->IsV6 ())
|
if (addr->IsV6 ())
|
||||||
transports |= (i2p::util::net::IsYggdrasilAddress (addr->host) ? eNTCP2V6Mesh : eNTCP2V6);
|
transports |= (i2p::util::net::IsYggdrasilAddress (addr->host) ? eNTCP2V6Mesh : eNTCP2V6);
|
||||||
|
@ -1088,15 +1057,17 @@ namespace data
|
||||||
const Address& address = *addr_ptr;
|
const Address& address = *addr_ptr;
|
||||||
// calculate cost
|
// calculate cost
|
||||||
uint8_t cost = 0x7f;
|
uint8_t cost = 0x7f;
|
||||||
if (address.transportStyle == eTransportNTCP)
|
if (address.transportStyle == eTransportNTCP2)
|
||||||
cost = address.published ? COST_NTCP2_PUBLISHED : COST_NTCP2_NON_PUBLISHED;
|
cost = address.published ? COST_NTCP2_PUBLISHED : COST_NTCP2_NON_PUBLISHED;
|
||||||
else if (address.transportStyle == eTransportSSU2)
|
else if (address.transportStyle == eTransportSSU2)
|
||||||
cost = address.published ? COST_SSU2_DIRECT : COST_SSU2_NON_PUBLISHED;
|
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 *)&cost, sizeof (cost));
|
||||||
s.write ((const char *)&address.date, sizeof (address.date));
|
s.write ((const char *)&address.date, sizeof (address.date));
|
||||||
std::stringstream properties;
|
std::stringstream properties;
|
||||||
bool isPublished = false;
|
bool isPublished = false;
|
||||||
if (address.transportStyle == eTransportNTCP)
|
if (address.transportStyle == eTransportNTCP2)
|
||||||
{
|
{
|
||||||
if (address.IsNTCP2 ())
|
if (address.IsNTCP2 ())
|
||||||
{
|
{
|
||||||
|
@ -1126,8 +1097,8 @@ namespace data
|
||||||
if (address.published)
|
if (address.published)
|
||||||
{
|
{
|
||||||
isPublished = true;
|
isPublished = true;
|
||||||
if (address.IsPeerTesting ()) caps += CAPS_FLAG_SSU_TESTING;
|
if (address.IsPeerTesting ()) caps += CAPS_FLAG_SSU2_TESTING;
|
||||||
if (address.IsIntroducer ()) caps += CAPS_FLAG_SSU_INTRODUCER;
|
if (address.IsIntroducer ()) caps += CAPS_FLAG_SSU2_INTRODUCER;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -47,14 +47,12 @@ namespace data
|
||||||
|
|
||||||
const char CAPS_FLAG_V4 = '4';
|
const char CAPS_FLAG_V4 = '4';
|
||||||
const char CAPS_FLAG_V6 = '6';
|
const char CAPS_FLAG_V6 = '6';
|
||||||
const char CAPS_FLAG_SSU_TESTING = 'B';
|
const char CAPS_FLAG_SSU2_TESTING = 'B';
|
||||||
const char CAPS_FLAG_SSU_INTRODUCER = 'C';
|
const char CAPS_FLAG_SSU2_INTRODUCER = 'C';
|
||||||
|
|
||||||
const uint8_t COST_NTCP2_PUBLISHED = 3;
|
const uint8_t COST_NTCP2_PUBLISHED = 3;
|
||||||
const uint8_t COST_NTCP2_NON_PUBLISHED = 14;
|
const uint8_t COST_NTCP2_NON_PUBLISHED = 14;
|
||||||
const uint8_t COST_SSU2_DIRECT = 8;
|
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 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
|
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,
|
eNTCP2V4 = 0x01,
|
||||||
eNTCP2V6 = 0x02,
|
eNTCP2V6 = 0x02,
|
||||||
eSSUV4 = 0x04,
|
eSSU2V4 = 0x04,
|
||||||
eSSUV6 = 0x08,
|
eSSU2V6 = 0x08,
|
||||||
eNTCP2V6Mesh = 0x10,
|
eNTCP2V6Mesh = 0x10,
|
||||||
eSSU2V4 = 0x20,
|
|
||||||
eSSU2V6 = 0x40,
|
|
||||||
eAllTransports = 0xFF
|
eAllTransports = 0xFF
|
||||||
};
|
};
|
||||||
typedef uint8_t CompatibleTransports;
|
typedef uint8_t CompatibleTransports;
|
||||||
|
@ -96,17 +92,16 @@ namespace data
|
||||||
enum TransportStyle
|
enum TransportStyle
|
||||||
{
|
{
|
||||||
eTransportUnknown = 0,
|
eTransportUnknown = 0,
|
||||||
eTransportNTCP,
|
eTransportNTCP2,
|
||||||
eTransportSSU,
|
|
||||||
eTransportSSU2
|
eTransportSSU2
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Introducer
|
struct Introducer
|
||||||
{
|
{
|
||||||
Introducer (): iTag (0), iExp (0), isH (false) {};
|
Introducer (): iTag (0), iExp (0), isH (false) {};
|
||||||
|
IdentHash iH;
|
||||||
uint32_t iTag;
|
uint32_t iTag;
|
||||||
uint32_t iExp;
|
uint32_t iExp;
|
||||||
IdentHash iH;
|
|
||||||
bool isH; // TODO: remove later
|
bool isH; // TODO: remove later
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -144,7 +139,7 @@ namespace data
|
||||||
return !(*this == other);
|
return !(*this == other);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsNTCP2 () const { return transportStyle == eTransportNTCP; };
|
bool IsNTCP2 () const { return transportStyle == eTransportNTCP2; };
|
||||||
bool IsSSU2 () const { return transportStyle == eTransportSSU2; };
|
bool IsSSU2 () const { return transportStyle == eTransportSSU2; };
|
||||||
bool IsPublishedNTCP2 () const { return IsNTCP2 () && published; };
|
bool IsPublishedNTCP2 () const { return IsNTCP2 () && published; };
|
||||||
bool IsReachableSSU () const { return (bool)ssu && (published || UsesIntroducer ()); };
|
bool IsReachableSSU () const { return (bool)ssu && (published || UsesIntroducer ()); };
|
||||||
|
@ -186,7 +181,6 @@ namespace data
|
||||||
std::shared_ptr<const Address> GetSSU2AddressWithStaticKey (const uint8_t * key, bool isV6) const;
|
std::shared_ptr<const Address> GetSSU2AddressWithStaticKey (const uint8_t * key, bool isV6) const;
|
||||||
std::shared_ptr<const Address> GetPublishedNTCP2V4Address () const;
|
std::shared_ptr<const Address> GetPublishedNTCP2V4Address () const;
|
||||||
std::shared_ptr<const Address> GetPublishedNTCP2V6Address () const;
|
std::shared_ptr<const Address> GetPublishedNTCP2V6Address () const;
|
||||||
std::shared_ptr<const Address> GetSSUV6Address () const;
|
|
||||||
std::shared_ptr<const Address> GetYggdrasilAddress () const;
|
std::shared_ptr<const Address> GetYggdrasilAddress () const;
|
||||||
std::shared_ptr<const Address> GetSSU2V4Address () const;
|
std::shared_ptr<const Address> GetSSU2V4Address () const;
|
||||||
std::shared_ptr<const Address> GetSSU2V6Address () const;
|
std::shared_ptr<const Address> GetSSU2V6Address () const;
|
||||||
|
@ -206,8 +200,8 @@ namespace data
|
||||||
bool IsNTCP2V6 () const { return m_SupportedTransports & eNTCP2V6; };
|
bool IsNTCP2V6 () const { return m_SupportedTransports & eNTCP2V6; };
|
||||||
bool IsSSU2V4 () const { return m_SupportedTransports & eSSU2V4; };
|
bool IsSSU2V4 () const { return m_SupportedTransports & eSSU2V4; };
|
||||||
bool IsSSU2V6 () const { return m_SupportedTransports & eSSU2V6; };
|
bool IsSSU2V6 () const { return m_SupportedTransports & eSSU2V6; };
|
||||||
bool IsV6 () const { return m_SupportedTransports & (eSSUV6 | eNTCP2V6 | eSSU2V6); };
|
bool IsV6 () const { return m_SupportedTransports & (eNTCP2V6 | eSSU2V6); };
|
||||||
bool IsV4 () const { return m_SupportedTransports & (eSSUV4 | eNTCP2V4 | eSSU2V4); };
|
bool IsV4 () const { return m_SupportedTransports & (eNTCP2V4 | eSSU2V4); };
|
||||||
bool IsMesh () const { return m_SupportedTransports & eNTCP2V6Mesh; };
|
bool IsMesh () const { return m_SupportedTransports & eNTCP2V6Mesh; };
|
||||||
void EnableV6 ();
|
void EnableV6 ();
|
||||||
void DisableV6 ();
|
void DisableV6 ();
|
||||||
|
@ -224,9 +218,7 @@ namespace data
|
||||||
bool IsHighBandwidth () const { return m_Caps & RouterInfo::eHighBandwidth; };
|
bool IsHighBandwidth () const { return m_Caps & RouterInfo::eHighBandwidth; };
|
||||||
bool IsExtraBandwidth () const { return m_Caps & RouterInfo::eExtraBandwidth; };
|
bool IsExtraBandwidth () const { return m_Caps & RouterInfo::eExtraBandwidth; };
|
||||||
bool IsEligibleFloodfill () const;
|
bool IsEligibleFloodfill () const;
|
||||||
bool IsPeerTesting (bool v4) const;
|
|
||||||
bool IsSSU2PeerTesting (bool v4) const;
|
bool IsSSU2PeerTesting (bool v4) const;
|
||||||
bool IsIntroducer (bool v4) const;
|
|
||||||
bool IsSSU2Introducer (bool v4) const;
|
bool IsSSU2Introducer (bool v4) const;
|
||||||
|
|
||||||
uint8_t GetCaps () const { return m_Caps; };
|
uint8_t GetCaps () const { return m_Caps; };
|
||||||
|
|
|
@ -958,7 +958,6 @@ namespace transport
|
||||||
i2p::context.SetSupportsV4 (ipv4);
|
i2p::context.SetSupportsV4 (ipv4);
|
||||||
i2p::context.SetSupportsMesh (ygg, yggaddr);
|
i2p::context.SetSupportsMesh (ygg, yggaddr);
|
||||||
|
|
||||||
i2p::context.RemoveNTCPAddress (!ipv6); // TODO: remove later
|
|
||||||
bool ntcp2; i2p::config::GetOption("ntcp2.enabled", ntcp2);
|
bool ntcp2; i2p::config::GetOption("ntcp2.enabled", ntcp2);
|
||||||
if (ntcp2)
|
if (ntcp2)
|
||||||
{
|
{
|
||||||
|
@ -991,15 +990,13 @@ namespace transport
|
||||||
if (!ipv4 && !ipv6)
|
if (!ipv4 && !ipv6)
|
||||||
i2p::context.SetStatus (eRouterStatusMesh);
|
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);
|
bool ssu2; i2p::config::GetOption("ssu2.enabled", ssu2);
|
||||||
if (ssu2 && i2p::config::IsDefault ("ssu2.enabled") && !ipv4 && !ipv6)
|
if (ssu2 && i2p::config::IsDefault ("ssu2.enabled") && !ipv4 && !ipv6)
|
||||||
ssu2 = false; // don't enable ssu2 for yggdrasil only router
|
ssu2 = false; // don't enable ssu2 for yggdrasil only router
|
||||||
if (ssu2)
|
if (ssu2)
|
||||||
{
|
{
|
||||||
uint16_t ssu2port; i2p::config::GetOption("ssu2.port", ssu2port);
|
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);
|
bool published; i2p::config::GetOption("ssu2.published", published);
|
||||||
if (published)
|
if (published)
|
||||||
i2p::context.PublishSSU2Address (ssu2port, true, ipv4, ipv6); // publish
|
i2p::context.PublishSSU2Address (ssu2port, true, ipv4, ipv6); // publish
|
||||||
|
|
Loading…
Add table
Reference in a new issue