Browse Source

return relay tag for ipv6 introducer

pull/1645/head
orignal 4 years ago
parent
commit
25eae3c116
  1. 2
      libi2pd/NetDb.cpp
  2. 13
      libi2pd/RouterInfo.cpp
  3. 2
      libi2pd/RouterInfo.h
  4. 4
      libi2pd/SSUSession.cpp

2
libi2pd/NetDb.cpp

@ -1172,7 +1172,7 @@ namespace data @@ -1172,7 +1172,7 @@ namespace data
return GetRandomRouter (
[](std::shared_ptr<const RouterInfo> router)->bool
{
return router->IsIntroducer () && !router->IsHidden () && !router->IsFloodfill (); // floodfills don't send relay tag
return router->IsIntroducer (true) && !router->IsHidden () && !router->IsFloodfill (); // floodfills don't send relay tag
});
}

13
libi2pd/RouterInfo.cpp

@ -1105,8 +1105,7 @@ namespace data @@ -1105,8 +1105,7 @@ namespace data
bool RouterInfo::IsPeerTesting (bool v4) const
{
auto supportedTransports = m_SupportedTransports & (v4 ? eSSUV4 : eSSUV6);
if (!supportedTransports) return false;
if (!(m_SupportedTransports & (v4 ? eSSUV4 : eSSUV6))) return false;
return (bool)GetAddress (
[v4](std::shared_ptr<const RouterInfo::Address> address)->bool
{
@ -1115,14 +1114,14 @@ namespace data @@ -1115,14 +1114,14 @@ namespace data
});
}
bool RouterInfo::IsIntroducer () const
bool RouterInfo::IsIntroducer (bool v4) const
{
// TODO: support ipv6
if (!(m_SupportedTransports & eSSUV4)) return false;
if (!(m_SupportedTransports & (v4 ? eSSUV4 : eSSUV6))) return false;
return (bool)GetAddress (
[](std::shared_ptr<const RouterInfo::Address> address)->bool
[v4](std::shared_ptr<const RouterInfo::Address> address)->bool
{
return (address->transportStyle == eTransportSSU) && address->IsIntroducer ();
return (address->transportStyle == eTransportSSU) && address->IsIntroducer () &&
((v4 && address->IsV4 ()) || (!v4 && address->IsV6 ()));
});
}

2
libi2pd/RouterInfo.h

@ -210,7 +210,7 @@ namespace data @@ -210,7 +210,7 @@ namespace data
bool IsExtraBandwidth () const { return m_Caps & RouterInfo::eExtraBandwidth; };
bool IsEligibleFloodfill () const;
bool IsPeerTesting (bool v4) const;
bool IsIntroducer () const;
bool IsIntroducer (bool v4) const;
uint8_t GetCaps () const { return m_Caps; };
void SetCaps (uint8_t caps);

4
libi2pd/SSUSession.cpp

@ -212,7 +212,7 @@ namespace transport @@ -212,7 +212,7 @@ namespace transport
{
uint8_t extendedOptionsLen = buf[headerSize];
headerSize++;
if (extendedOptionsLen >= 3) // options are presented
if (extendedOptionsLen >= 2) // options are presented
{
uint16_t flags = bufbe16toh (buf + headerSize);
sendRelayTag = flags & EXTENDED_OPTIONS_FLAG_REQUEST_RELAY_TAG;
@ -464,7 +464,7 @@ namespace transport @@ -464,7 +464,7 @@ namespace transport
else
s.Insert (address->host.to_v6 ().to_bytes ().data (), 16); // our IP V6
s.Insert<uint16_t> (htobe16 (address->port)); // our port
if (sendRelayTag && i2p::context.GetRouterInfo ().IsIntroducer () && !IsV6 ())
if (sendRelayTag && i2p::context.GetRouterInfo ().IsIntroducer (!IsV6 ()))
{
RAND_bytes((uint8_t *)&m_SentRelayTag, 4);
if (!m_SentRelayTag) m_SentRelayTag = 1;

Loading…
Cancel
Save