MCPcopy Create free account
hub / github.com/PurpleI2P/i2pd / SetUnreachable

Method SetUnreachable

libi2pd/RouterContext.cpp:762–801  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

760 }
761
762 void RouterContext::SetUnreachable (bool v4, bool v6)
763 {
764 if (v4 || (v6 && !SupportsV4 ()))
765 {
766 // set caps
767 uint8_t caps = m_RouterInfo.GetCaps ();
768 caps &= ~i2p::data::RouterInfo::eReachable;
769 caps |= i2p::data::RouterInfo::eUnreachable;
770 if (v6 || !SupportsV6 ())
771 caps &= ~i2p::data::RouterInfo::eFloodfill; // can't be floodfill
772 m_RouterInfo.UpdateCaps (caps);
773 }
774 uint16_t port = 0;
775 // delete previous introducers
776 auto addresses = m_RouterInfo.GetAddresses ();
777 if (addresses)
778 {
779 for (auto& addr : *addresses)
780 if (addr && addr->ssu && ((v4 && addr->IsV4 ()) || (v6 && addr->IsV6 ())))
781 {
782 addr->published = false;
783 UpdateSSU2AddressCapsIntroducer (addr, false); // can't be introducer
784 addr->ssu->introducers.clear ();
785 port = addr->port;
786 }
787 }
788 // unpublish NTCP2 addreeses
789 bool ntcp2; i2p::config::GetOption("ntcp2.enabled", ntcp2);
790 if (ntcp2)
791 {
792 int ntcp2version = 2;
793#if OPENSSL_PQ
794 i2p::config::GetOption("ntcp2.version", ntcp2version);
795#endif
796 PublishNTCP2Address (port, false, v4, v6, false, ntcp2version);
797 }
798 // update
799 m_RouterInfo.UpdateSupportedTransports ();
800 UpdateRouterInfo ();
801 }
802
803 void RouterContext::SetReachable (bool v4, bool v6)
804 {

Callers 1

NewRouterInfoMethod · 0.45

Calls 7

GetOptionFunction · 0.85
GetCapsMethod · 0.80
UpdateCapsMethod · 0.80
GetAddressesMethod · 0.80
IsV4Method · 0.45
IsV6Method · 0.45

Tested by

no test coverage detected