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

Method PublishSSU2Address

libi2pd/RouterContext.cpp:475–517  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

473 }
474
475 void RouterContext::PublishSSU2Address (int port, bool publish, bool v4, bool v6, int version)
476 {
477 if (!m_SSU2Keys) return;
478 auto addresses = m_RouterInfo.GetAddresses ();
479 if (!addresses) return;
480 int newPort = 0;
481 if (!port)
482 {
483 for (const auto& address : *addresses)
484 if (address && address->port)
485 {
486 newPort = address->port;
487 break;
488 }
489 if (!newPort) newPort = SelectRandomPort ();
490 }
491 bool updated = false;
492 for (auto& address : *addresses)
493 {
494 if (address && address->IsSSU2 () && (!address->port || address->port != port ||
495 address->published != publish || address->v != version) &&
496 ((v4 && address->IsV4 ()) || (v6 && address->IsV6 ())))
497 {
498 if (port) address->port = port;
499 else if (!address->port) address->port = newPort;
500 address->published = publish;
501 address->v = version;
502 if (publish)
503 {
504 UpdateSSU2AddressCapsTesting (address, true);
505 UpdateSSU2AddressCapsIntroducer (address, !m_IsFloodfill);
506 }
507 else
508 {
509 UpdateSSU2AddressCapsTesting (address, false);
510 UpdateSSU2AddressCapsIntroducer (address, false);
511 }
512 updated = true;
513 }
514 }
515 if (updated)
516 UpdateRouterInfo ();
517 }
518
519 void RouterContext::UpdateSSU2AddressCapsIntroducer (std::shared_ptr<i2p::data::RouterInfo::Address> address, bool isIntroducer) const
520 {

Callers 2

InitTransportsFunction · 0.80
HandleAddressMethod · 0.80

Calls 4

GetAddressesMethod · 0.80
IsSSU2Method · 0.80
IsV4Method · 0.45
IsV6Method · 0.45

Tested by

no test coverage detected