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. 27
      libi2pd/RouterContext.cpp
  3. 1
      libi2pd/RouterInfo.cpp
  4. 3
      libi2pd/SSU2.cpp

2
daemon/Daemon.cpp

@ -257,7 +257,7 @@ namespace util @@ -257,7 +257,7 @@ namespace util
if (ssu2)
{
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);
if (published)
i2p::context.PublishSSU2Address (ssu2port, true, ipv4, ipv6); // publish

27
libi2pd/RouterContext.cpp

@ -121,7 +121,11 @@ namespace i2p @@ -121,7 +121,11 @@ namespace i2p
if (ssu2)
{
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
{
addressCaps |= i2p::data::RouterInfo::AddressCaps::eV4;
@ -166,7 +170,11 @@ namespace i2p @@ -166,7 +170,11 @@ namespace i2p
if (ssu2)
{
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
{
if (!ipv4) // no other ssu2 addresses yet
@ -734,15 +742,12 @@ namespace i2p @@ -734,15 +742,12 @@ namespace i2p
}
if (!port) i2p::config::GetOption("port", port);
// SSU
if (!foundSSU)
{
bool ssu; i2p::config::GetOption("ssu", ssu);
if (ssu)
if (!foundSSU && ssu)
{
std::string host = "::1"; // TODO: read host
m_RouterInfo.AddSSUAddress (host.c_str (), port, nullptr);
}
}
// NTCP2
if (!foundNTCP2)
{
@ -775,7 +780,7 @@ namespace i2p @@ -775,7 +780,7 @@ namespace i2p
if (ssu2Published)
{
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);
}
else
@ -823,12 +828,10 @@ namespace i2p @@ -823,12 +828,10 @@ namespace i2p
}
if (!port) i2p::config::GetOption("port", port);
// SSU
if (!foundSSU)
{
bool ssu; i2p::config::GetOption("ssu", ssu);
if (ssu)
if (!foundSSU && ssu)
m_RouterInfo.AddSSUAddress (host.c_str (), port, nullptr);
}
// NTCP2
if (!foundNTCP2)
{
@ -856,7 +859,7 @@ namespace i2p @@ -856,7 +859,7 @@ namespace i2p
if (ssu2Published)
{
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);
}
else

1
libi2pd/RouterInfo.cpp

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

3
libi2pd/SSU2.cpp

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

Loading…
Cancel
Save