mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-03-13 04:46:38 +01:00
publish NTCP2 address
This commit is contained in:
parent
c8f51380e6
commit
1a38e925bf
3 changed files with 26 additions and 5 deletions
|
@ -146,7 +146,7 @@ namespace i2p
|
|||
bool updated = false;
|
||||
for (auto& address : m_RouterInfo.GetAddresses ())
|
||||
{
|
||||
if (address->port != port)
|
||||
if (!address->IsNTCP2 () && address->port != port)
|
||||
{
|
||||
address->port = port;
|
||||
updated = true;
|
||||
|
@ -156,6 +156,22 @@ namespace i2p
|
|||
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)
|
||||
{
|
||||
bool updated = false;
|
||||
|
|
|
@ -76,8 +76,9 @@ namespace i2p
|
|||
void SetNetID (int netID) { m_NetID = netID; };
|
||||
bool DecryptTunnelBuildRecord (const uint8_t * encrypted, uint8_t * data, BN_CTX * ctx) const;
|
||||
|
||||
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 PublishNTCP2Address (int port);
|
||||
bool AddIntroducer (const i2p::data::RouterInfo::Introducer& introducer);
|
||||
void RemoveIntroducer (const boost::asio::ip::udp::endpoint& e);
|
||||
bool IsUnreachable () const;
|
||||
|
|
|
@ -456,7 +456,7 @@ namespace data
|
|||
else
|
||||
WriteString ("", s);
|
||||
|
||||
if (!address.IsNTCP2 ()) // we don't publish NTCP2 address fow now. TODO: implement
|
||||
if (!address.IsNTCP2 () || address.IsPublishedNTCP2 ())
|
||||
{
|
||||
WriteString ("host", 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);
|
||||
properties << '=';
|
||||
|
@ -552,7 +552,11 @@ namespace data
|
|||
WriteString (address.ntcp2->staticKey.ToBase64 (), properties); properties << ';';
|
||||
WriteString ("v", 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 ());
|
||||
|
|
Loading…
Add table
Reference in a new issue