mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-10 08:00:38 +03:00
detect our ipv6 address
This commit is contained in:
parent
af33df3004
commit
354c9187db
@ -1076,6 +1076,15 @@ namespace data
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<const RouterInfo> NetDb::GetRandomSSUV6Router () const
|
||||||
|
{
|
||||||
|
return GetRandomRouter (
|
||||||
|
[](std::shared_ptr<const RouterInfo> router)->bool
|
||||||
|
{
|
||||||
|
return !router->IsHidden () && router->IsSSUV6 ();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
std::shared_ptr<const RouterInfo> NetDb::GetRandomIntroducer () const
|
std::shared_ptr<const RouterInfo> NetDb::GetRandomIntroducer () const
|
||||||
{
|
{
|
||||||
return GetRandomRouter (
|
return GetRandomRouter (
|
||||||
|
@ -72,6 +72,7 @@ namespace data
|
|||||||
std::shared_ptr<const RouterInfo> GetRandomRouter (std::shared_ptr<const RouterInfo> compatibleWith) const;
|
std::shared_ptr<const RouterInfo> GetRandomRouter (std::shared_ptr<const RouterInfo> compatibleWith) const;
|
||||||
std::shared_ptr<const RouterInfo> GetHighBandwidthRandomRouter (std::shared_ptr<const RouterInfo> compatibleWith) const;
|
std::shared_ptr<const RouterInfo> GetHighBandwidthRandomRouter (std::shared_ptr<const RouterInfo> compatibleWith) const;
|
||||||
std::shared_ptr<const RouterInfo> GetRandomPeerTestRouter (bool v4only = true) const;
|
std::shared_ptr<const RouterInfo> GetRandomPeerTestRouter (bool v4only = true) const;
|
||||||
|
std::shared_ptr<const RouterInfo> GetRandomSSUV6Router () const; // TODO: change to v6 peer test later
|
||||||
std::shared_ptr<const RouterInfo> GetRandomIntroducer () const;
|
std::shared_ptr<const RouterInfo> GetRandomIntroducer () 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,
|
||||||
|
@ -808,6 +808,11 @@ namespace data
|
|||||||
return m_SupportedTransports & (eSSUV4 | eSSUV6);
|
return m_SupportedTransports & (eSSUV4 | eSSUV6);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool RouterInfo::IsSSUV6 () const
|
||||||
|
{
|
||||||
|
return m_SupportedTransports & eSSUV6;
|
||||||
|
}
|
||||||
|
|
||||||
bool RouterInfo::IsNTCP2 (bool v4only) const
|
bool RouterInfo::IsNTCP2 (bool v4only) const
|
||||||
{
|
{
|
||||||
if (v4only)
|
if (v4only)
|
||||||
|
@ -161,6 +161,7 @@ namespace data
|
|||||||
bool IsReachable () const { return m_Caps & Caps::eReachable; };
|
bool IsReachable () const { return m_Caps & Caps::eReachable; };
|
||||||
bool IsNTCP (bool v4only = true) const;
|
bool IsNTCP (bool v4only = true) const;
|
||||||
bool IsSSU (bool v4only = true) const;
|
bool IsSSU (bool v4only = true) const;
|
||||||
|
bool IsSSUV6 () const;
|
||||||
bool IsNTCP2 (bool v4only = true) const;
|
bool IsNTCP2 (bool v4only = true) const;
|
||||||
bool IsV6 () const;
|
bool IsV6 () const;
|
||||||
bool IsV4 () const;
|
bool IsV4 () const;
|
||||||
|
@ -552,6 +552,20 @@ namespace transport
|
|||||||
m_SSUServer->CreateSession (router); // no peer test
|
m_SSUServer->CreateSession (router); // no peer test
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (i2p::context.SupportsV6 ())
|
||||||
|
{
|
||||||
|
// try to connect to few v6 addresses to get our address back
|
||||||
|
for (int i = 0; i < 3; i++)
|
||||||
|
{
|
||||||
|
auto router = i2p::data::netdb.GetRandomSSUV6Router ();
|
||||||
|
if (router)
|
||||||
|
{
|
||||||
|
auto addr = router->GetSSUV6Address ();
|
||||||
|
if (addr)
|
||||||
|
m_SSUServer->CreateDirectSession (router, { addr->host, (uint16_t)addr->port }, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
LogPrint (eLogError, "Transports: Can't detect external IP. SSU is not available");
|
LogPrint (eLogError, "Transports: Can't detect external IP. SSU is not available");
|
||||||
|
Loading…
Reference in New Issue
Block a user