| 554 | } |
| 555 | |
| 556 | void RouterContext::UpdateAddress (const boost::asio::ip::address& host) |
| 557 | { |
| 558 | auto addresses = m_RouterInfo.GetAddresses (); |
| 559 | if (!addresses) return; |
| 560 | bool updated = false; |
| 561 | if (host.is_v4 ()) |
| 562 | { |
| 563 | auto addr = (*addresses)[i2p::data::RouterInfo::eNTCP2V4Idx]; |
| 564 | if (addr && addr->host != host) |
| 565 | { |
| 566 | addr->host = host; |
| 567 | updated = true; |
| 568 | } |
| 569 | addr = (*addresses)[i2p::data::RouterInfo::eSSU2V4Idx]; |
| 570 | if (addr && addr->host != host) |
| 571 | { |
| 572 | addr->host = host; |
| 573 | updated = true; |
| 574 | } |
| 575 | } |
| 576 | else if (host.is_v6 ()) |
| 577 | { |
| 578 | auto addr = (*addresses)[i2p::data::RouterInfo::eNTCP2V6Idx]; |
| 579 | if (addr && addr->host != host) |
| 580 | { |
| 581 | addr->host = host; |
| 582 | updated = true; |
| 583 | } |
| 584 | addr = (*addresses)[i2p::data::RouterInfo::eSSU2V6Idx]; |
| 585 | if (addr && (addr->host != host || !addr->ssu->mtu)) |
| 586 | { |
| 587 | addr->host = host; |
| 588 | if (m_StatusV6 != eRouterStatusProxy) |
| 589 | { |
| 590 | // update MTU |
| 591 | auto mtu = i2p::util::net::GetMTU (host); |
| 592 | if (mtu) |
| 593 | { |
| 594 | LogPrint (eLogDebug, "Router: Our v6 MTU=", mtu); |
| 595 | int maxMTU = i2p::util::net::GetMaxMTU (host.to_v6 ()); |
| 596 | if (mtu > maxMTU) |
| 597 | { |
| 598 | mtu = maxMTU; |
| 599 | LogPrint(eLogWarning, "Router: MTU dropped to upper limit of ", maxMTU, " bytes"); |
| 600 | } |
| 601 | addr->ssu->mtu = mtu; |
| 602 | } |
| 603 | } |
| 604 | updated = true; |
| 605 | } |
| 606 | } |
| 607 | |
| 608 | auto ts = i2p::util::GetSecondsSinceEpoch (); |
| 609 | if (updated || ts > m_LastUpdateTime + ROUTER_INFO_UPDATE_INTERVAL) |
| 610 | UpdateRouterInfo (); |
| 611 | } |
| 612 | |
| 613 | bool RouterContext::AddSSU2Introducer (const i2p::data::RouterInfo::Introducer& introducer, bool v4) |
no test coverage detected