Browse Source

set SSU2 port +1 if not specified

pull/1786/head
orignal 2 years ago
parent
commit
df92a85159
  1. 2
      daemon/Daemon.cpp
  2. 37
      libi2pd/RouterContext.cpp
  3. 1
      libi2pd/RouterInfo.cpp
  4. 3
      libi2pd/SSU2.cpp

2
daemon/Daemon.cpp

@ -257,7 +257,7 @@ namespace util
if (ssu2) if (ssu2)
{ {
uint16_t ssu2port; i2p::config::GetOption("ssu2.port", ssu2port); uint16_t ssu2port; i2p::config::GetOption("ssu2.port", ssu2port);
if (!ssu2port) ssu2port = port; if (!ssu2port) ssu2port = ssu ? (port + 1) : port;
bool published; i2p::config::GetOption("ssu2.published", published); bool published; i2p::config::GetOption("ssu2.published", published);
if (published) if (published)
i2p::context.PublishSSU2Address (ssu2port, true, ipv4, ipv6); // publish i2p::context.PublishSSU2Address (ssu2port, true, ipv4, ipv6); // publish

37
libi2pd/RouterContext.cpp

@ -121,7 +121,11 @@ namespace i2p
if (ssu2) if (ssu2)
{ {
if (ssu2Published) if (ssu2Published)
routerInfo.AddSSU2Address (m_SSU2Keys->staticPublicKey, m_SSU2Keys->intro, boost::asio::ip::address_v4::from_string (host), port); {
uint16_t ssu2Port; i2p::config::GetOption ("ssu2.port", ssu2Port);
if (!ssu2Port) ssu2Port = ssu ? (port + 1) : port;
routerInfo.AddSSU2Address (m_SSU2Keys->staticPublicKey, m_SSU2Keys->intro, boost::asio::ip::address_v4::from_string (host), ssu2Port);
}
else else
{ {
addressCaps |= i2p::data::RouterInfo::AddressCaps::eV4; addressCaps |= i2p::data::RouterInfo::AddressCaps::eV4;
@ -166,7 +170,11 @@ namespace i2p
if (ssu2) if (ssu2)
{ {
if (ssu2Published) if (ssu2Published)
routerInfo.AddSSU2Address (m_SSU2Keys->staticPublicKey, m_SSU2Keys->intro, boost::asio::ip::address_v6::from_string (host), port); {
uint16_t ssu2Port; i2p::config::GetOption ("ssu2.port", ssu2Port);
if (!ssu2Port) ssu2Port = ssu ? (port + 1) : port;
routerInfo.AddSSU2Address (m_SSU2Keys->staticPublicKey, m_SSU2Keys->intro, boost::asio::ip::address_v6::from_string (host), ssu2Port);
}
else else
{ {
if (!ipv4) // no other ssu2 addresses yet if (!ipv4) // no other ssu2 addresses yet
@ -734,14 +742,11 @@ namespace i2p
} }
if (!port) i2p::config::GetOption("port", port); if (!port) i2p::config::GetOption("port", port);
// SSU // SSU
if (!foundSSU) bool ssu; i2p::config::GetOption("ssu", ssu);
if (!foundSSU && ssu)
{ {
bool ssu; i2p::config::GetOption("ssu", ssu); std::string host = "::1"; // TODO: read host
if (ssu) m_RouterInfo.AddSSUAddress (host.c_str (), port, nullptr);
{
std::string host = "::1"; // TODO: read host
m_RouterInfo.AddSSUAddress (host.c_str (), port, nullptr);
}
} }
// NTCP2 // NTCP2
if (!foundNTCP2) if (!foundNTCP2)
@ -775,7 +780,7 @@ namespace i2p
if (ssu2Published) if (ssu2Published)
{ {
uint16_t ssu2Port; i2p::config::GetOption ("ssu2.port", ssu2Port); uint16_t ssu2Port; i2p::config::GetOption ("ssu2.port", ssu2Port);
if (!ssu2Port) ssu2Port = port; if (!ssu2Port) ssu2Port = ssu ? (port + 1) : port;
m_RouterInfo.AddSSU2Address (m_SSU2Keys->staticPublicKey, m_SSU2Keys->intro, boost::asio::ip::address::from_string ("::1"), ssu2Port); m_RouterInfo.AddSSU2Address (m_SSU2Keys->staticPublicKey, m_SSU2Keys->intro, boost::asio::ip::address::from_string ("::1"), ssu2Port);
} }
else else
@ -823,12 +828,10 @@ namespace i2p
} }
if (!port) i2p::config::GetOption("port", port); if (!port) i2p::config::GetOption("port", port);
// SSU // SSU
if (!foundSSU) bool ssu; i2p::config::GetOption("ssu", ssu);
{ if (!foundSSU && ssu)
bool ssu; i2p::config::GetOption("ssu", ssu); m_RouterInfo.AddSSUAddress (host.c_str (), port, nullptr);
if (ssu)
m_RouterInfo.AddSSUAddress (host.c_str (), port, nullptr);
}
// NTCP2 // NTCP2
if (!foundNTCP2) if (!foundNTCP2)
{ {
@ -856,7 +859,7 @@ namespace i2p
if (ssu2Published) if (ssu2Published)
{ {
uint16_t ssu2Port; i2p::config::GetOption ("ssu2.port", ssu2Port); uint16_t ssu2Port; i2p::config::GetOption ("ssu2.port", ssu2Port);
if (!ssu2Port) ssu2Port = port; if (!ssu2Port) ssu2Port = ssu ? (port + 1) : port;
m_RouterInfo.AddSSU2Address (m_SSU2Keys->staticPublicKey, m_SSU2Keys->intro, boost::asio::ip::address::from_string ("127.0.0.1"), ssu2Port); m_RouterInfo.AddSSU2Address (m_SSU2Keys->staticPublicKey, m_SSU2Keys->intro, boost::asio::ip::address::from_string ("127.0.0.1"), ssu2Port);
} }
else else

1
libi2pd/RouterInfo.cpp

@ -708,6 +708,7 @@ namespace data
{ {
auto addr = std::make_shared<Address>(); auto addr = std::make_shared<Address>();
addr->transportStyle = eTransportSSU2; addr->transportStyle = eTransportSSU2;
addr->port = 0;
addr->caps = caps; addr->caps = caps;
addr->date = 0; addr->date = 0;
addr->ssu.reset (new SSUExt ()); addr->ssu.reset (new SSUExt ());

3
libi2pd/SSU2.cpp

@ -49,8 +49,9 @@ namespace transport
if (ssu2Port) port = ssu2Port; if (ssu2Port) port = ssu2Port;
else else
{ {
bool ssu; i2p::config::GetOption("ssu", ssu);
uint16_t p; i2p::config::GetOption ("port", p); uint16_t p; i2p::config::GetOption ("port", p);
if (p) port = p; if (p) port = ssu ? (p + 1) : p;
} }
} }
if (port) if (port)

Loading…
Cancel
Save