mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-10 00:00:29 +03:00
add no ipv4 option in config
This commit is contained in:
parent
897cc7d355
commit
12c12a8ad1
@ -117,6 +117,7 @@ namespace config {
|
|||||||
("datadir", value<std::string>()->default_value(""), "Path to storage of i2pd data (RI, keys, peer profiles, ...)")
|
("datadir", value<std::string>()->default_value(""), "Path to storage of i2pd data (RI, keys, peer profiles, ...)")
|
||||||
("host", value<std::string>()->default_value("0.0.0.0"), "External IP")
|
("host", value<std::string>()->default_value("0.0.0.0"), "External IP")
|
||||||
("port", value<uint16_t>()->default_value(0), "Port to listen for incoming connections (default: auto)")
|
("port", value<uint16_t>()->default_value(0), "Port to listen for incoming connections (default: auto)")
|
||||||
|
("ipv4", value<bool>()->zero_tokens()->default_value(true), "Enable communication through ipv4")
|
||||||
("ipv6", value<bool>()->zero_tokens()->default_value(false), "Enable communication through ipv6")
|
("ipv6", value<bool>()->zero_tokens()->default_value(false), "Enable communication through ipv6")
|
||||||
("daemon", value<bool>()->zero_tokens()->default_value(false), "Router will go to background after start")
|
("daemon", value<bool>()->zero_tokens()->default_value(false), "Router will go to background after start")
|
||||||
("service", value<bool>()->zero_tokens()->default_value(false), "Router will use system folders like '/var/lib/i2pd'")
|
("service", value<bool>()->zero_tokens()->default_value(false), "Router will use system folders like '/var/lib/i2pd'")
|
||||||
|
@ -104,9 +104,11 @@ namespace i2p
|
|||||||
i2p::context.UpdateAddress (boost::asio::ip::address::from_string (host));
|
i2p::context.UpdateAddress (boost::asio::ip::address::from_string (host));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ipv6; i2p::config::GetOption("ipv6", ipv6);
|
bool ipv6; i2p::config::GetOption("ipv6", ipv6);
|
||||||
|
bool ipv4; i2p::config::GetOption("ipv4", ipv4);
|
||||||
bool transit; i2p::config::GetOption("notransit", transit);
|
bool transit; i2p::config::GetOption("notransit", transit);
|
||||||
i2p::context.SetSupportsV6 (ipv6);
|
i2p::context.SetSupportsV6 (ipv6);
|
||||||
|
i2p::context.SetSupportsV4 (ipv4);
|
||||||
i2p::context.SetAcceptsTunnels (!transit);
|
i2p::context.SetAcceptsTunnels (!transit);
|
||||||
|
|
||||||
bool isFloodfill; i2p::config::GetOption("floodfill", isFloodfill);
|
bool isFloodfill; i2p::config::GetOption("floodfill", isFloodfill);
|
||||||
|
@ -257,7 +257,17 @@ namespace i2p
|
|||||||
else
|
else
|
||||||
m_RouterInfo.DisableV6 ();
|
m_RouterInfo.DisableV6 ();
|
||||||
UpdateRouterInfo ();
|
UpdateRouterInfo ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RouterContext::SetSupportsV4 (bool supportsV4)
|
||||||
|
{
|
||||||
|
if (supportsV4)
|
||||||
|
m_RouterInfo.EnableV4 ();
|
||||||
|
else
|
||||||
|
m_RouterInfo.DisableV4 ();
|
||||||
|
UpdateRouterInfo ();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void RouterContext::UpdateNTCPV6Address (const boost::asio::ip::address& host)
|
void RouterContext::UpdateNTCPV6Address (const boost::asio::ip::address& host)
|
||||||
{
|
{
|
||||||
|
@ -64,7 +64,10 @@ namespace i2p
|
|||||||
bool AcceptsTunnels () const { return m_AcceptsTunnels; };
|
bool AcceptsTunnels () const { return m_AcceptsTunnels; };
|
||||||
void SetAcceptsTunnels (bool acceptsTunnels) { m_AcceptsTunnels = acceptsTunnels; };
|
void SetAcceptsTunnels (bool acceptsTunnels) { m_AcceptsTunnels = acceptsTunnels; };
|
||||||
bool SupportsV6 () const { return m_RouterInfo.IsV6 (); };
|
bool SupportsV6 () const { return m_RouterInfo.IsV6 (); };
|
||||||
|
bool SupportsV4 () const { return m_RouterInfo.IsV4 (); };
|
||||||
void SetSupportsV6 (bool supportsV6);
|
void SetSupportsV6 (bool supportsV6);
|
||||||
|
void SetSupportsV4 (bool supportsV4);
|
||||||
|
|
||||||
void UpdateNTCPV6Address (const boost::asio::ip::address& host); // called from NTCP session
|
void UpdateNTCPV6Address (const boost::asio::ip::address& host); // called from NTCP session
|
||||||
void UpdateStats ();
|
void UpdateStats ();
|
||||||
|
|
||||||
|
@ -651,12 +651,24 @@ namespace data
|
|||||||
return m_SupportedTransports & (eNTCPV6 | eSSUV6);
|
return m_SupportedTransports & (eNTCPV6 | eSSUV6);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool RouterInfo::IsV4 () const
|
||||||
|
{
|
||||||
|
return m_SupportedTransports & (eNTCPV4 | eSSUV4);
|
||||||
|
}
|
||||||
|
|
||||||
void RouterInfo::EnableV6 ()
|
void RouterInfo::EnableV6 ()
|
||||||
{
|
{
|
||||||
if (!IsV6 ())
|
if (!IsV6 ())
|
||||||
m_SupportedTransports |= eNTCPV6 | eSSUV6;
|
m_SupportedTransports |= eNTCPV6 | eSSUV6;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RouterInfo::EnableV4 ()
|
||||||
|
{
|
||||||
|
if (!IsV4 ())
|
||||||
|
m_SupportedTransports |= eNTCPV4 | eSSUV4;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void RouterInfo::DisableV6 ()
|
void RouterInfo::DisableV6 ()
|
||||||
{
|
{
|
||||||
if (IsV6 ())
|
if (IsV6 ())
|
||||||
@ -686,7 +698,38 @@ namespace data
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RouterInfo::DisableV4 ()
|
||||||
|
{
|
||||||
|
if (IsV4 ())
|
||||||
|
{
|
||||||
|
// NTCP
|
||||||
|
m_SupportedTransports &= ~eNTCPV4;
|
||||||
|
for (size_t i = 0; i < m_Addresses.size (); i++)
|
||||||
|
{
|
||||||
|
if (m_Addresses[i]->transportStyle == i2p::data::RouterInfo::eTransportNTCP &&
|
||||||
|
m_Addresses[i]->host.is_v4 ())
|
||||||
|
{
|
||||||
|
m_Addresses.erase (m_Addresses.begin () + i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// SSU
|
||||||
|
m_SupportedTransports &= ~eSSUV4;
|
||||||
|
for (size_t i = 0; i < m_Addresses.size (); i++)
|
||||||
|
{
|
||||||
|
if (m_Addresses[i]->transportStyle == i2p::data::RouterInfo::eTransportSSU &&
|
||||||
|
m_Addresses[i]->host.is_v4 ())
|
||||||
|
{
|
||||||
|
m_Addresses.erase (m_Addresses.begin () + i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool RouterInfo::UsesIntroducer () const
|
bool RouterInfo::UsesIntroducer () const
|
||||||
{
|
{
|
||||||
return m_Caps & Caps::eUnreachable; // non-reachable
|
return m_Caps & Caps::eUnreachable; // non-reachable
|
||||||
|
@ -133,8 +133,11 @@ namespace data
|
|||||||
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 IsV6 () const;
|
bool IsV6 () const;
|
||||||
|
bool IsV4 () const;
|
||||||
void EnableV6 ();
|
void EnableV6 ();
|
||||||
void DisableV6 ();
|
void DisableV6 ();
|
||||||
|
void EnableV4 ();
|
||||||
|
void DisableV4 ();
|
||||||
bool IsCompatible (const RouterInfo& other) const { return m_SupportedTransports & other.m_SupportedTransports; };
|
bool IsCompatible (const RouterInfo& other) const { return m_SupportedTransports & other.m_SupportedTransports; };
|
||||||
bool UsesIntroducer () const;
|
bool UsesIntroducer () const;
|
||||||
bool IsIntroducer () const { return m_Caps & eSSUIntroducer; };
|
bool IsIntroducer () const { return m_Caps & eSSUIntroducer; };
|
||||||
|
Loading…
Reference in New Issue
Block a user