mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-10 08:00:38 +03:00
publish NTCP2 address
This commit is contained in:
parent
c8f51380e6
commit
1a38e925bf
@ -146,7 +146,7 @@ namespace i2p
|
|||||||
bool updated = false;
|
bool updated = false;
|
||||||
for (auto& address : m_RouterInfo.GetAddresses ())
|
for (auto& address : m_RouterInfo.GetAddresses ())
|
||||||
{
|
{
|
||||||
if (address->port != port)
|
if (!address->IsNTCP2 () && address->port != port)
|
||||||
{
|
{
|
||||||
address->port = port;
|
address->port = port;
|
||||||
updated = true;
|
updated = true;
|
||||||
@ -156,6 +156,22 @@ namespace i2p
|
|||||||
UpdateRouterInfo ();
|
UpdateRouterInfo ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RouterContext::PublishNTCP2Address (int port)
|
||||||
|
{
|
||||||
|
bool updated = false;
|
||||||
|
for (auto& address : m_RouterInfo.GetAddresses ())
|
||||||
|
{
|
||||||
|
if (address->IsNTCP2 () && address->port != port)
|
||||||
|
{
|
||||||
|
address->port = port;
|
||||||
|
address->ntcp2->isPublished = true;
|
||||||
|
updated = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (updated)
|
||||||
|
UpdateRouterInfo ();
|
||||||
|
}
|
||||||
|
|
||||||
void RouterContext::UpdateAddress (const boost::asio::ip::address& host)
|
void RouterContext::UpdateAddress (const boost::asio::ip::address& host)
|
||||||
{
|
{
|
||||||
bool updated = false;
|
bool updated = false;
|
||||||
|
@ -78,6 +78,7 @@ namespace i2p
|
|||||||
|
|
||||||
void UpdatePort (int port); // called from Daemon
|
void UpdatePort (int port); // called from Daemon
|
||||||
void UpdateAddress (const boost::asio::ip::address& host); // called from SSU or Daemon
|
void UpdateAddress (const boost::asio::ip::address& host); // called from SSU or Daemon
|
||||||
|
void PublishNTCP2Address (int port);
|
||||||
bool AddIntroducer (const i2p::data::RouterInfo::Introducer& introducer);
|
bool AddIntroducer (const i2p::data::RouterInfo::Introducer& introducer);
|
||||||
void RemoveIntroducer (const boost::asio::ip::udp::endpoint& e);
|
void RemoveIntroducer (const boost::asio::ip::udp::endpoint& e);
|
||||||
bool IsUnreachable () const;
|
bool IsUnreachable () const;
|
||||||
|
@ -456,7 +456,7 @@ namespace data
|
|||||||
else
|
else
|
||||||
WriteString ("", s);
|
WriteString ("", s);
|
||||||
|
|
||||||
if (!address.IsNTCP2 ()) // we don't publish NTCP2 address fow now. TODO: implement
|
if (!address.IsNTCP2 () || address.IsPublishedNTCP2 ())
|
||||||
{
|
{
|
||||||
WriteString ("host", properties);
|
WriteString ("host", properties);
|
||||||
properties << '=';
|
properties << '=';
|
||||||
@ -538,7 +538,7 @@ namespace data
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!address.IsNTCP2 ()) // we don't publish NTCP2 address fow now. TODO: implement
|
if (!address.IsNTCP2 () || address.IsPublishedNTCP2 ())
|
||||||
{
|
{
|
||||||
WriteString ("port", properties);
|
WriteString ("port", properties);
|
||||||
properties << '=';
|
properties << '=';
|
||||||
@ -552,7 +552,11 @@ namespace data
|
|||||||
WriteString (address.ntcp2->staticKey.ToBase64 (), properties); properties << ';';
|
WriteString (address.ntcp2->staticKey.ToBase64 (), properties); properties << ';';
|
||||||
WriteString ("v", properties); properties << '=';
|
WriteString ("v", properties); properties << '=';
|
||||||
WriteString ("2", properties); properties << ';';
|
WriteString ("2", properties); properties << ';';
|
||||||
// TODO: publish "i"
|
if (address.IsPublishedNTCP2 ())
|
||||||
|
{
|
||||||
|
WriteString ("i", properties); properties << '=';
|
||||||
|
WriteString (address.ntcp2->iv.ToBase64 (), properties); properties << ';';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t size = htobe16 (properties.str ().size ());
|
uint16_t size = htobe16 (properties.str ().size ());
|
||||||
|
Loading…
Reference in New Issue
Block a user