mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-03-10 11:28:27 +01:00
enable SSU2 server
This commit is contained in:
parent
6d7d71bb16
commit
21c1ec9c8c
5 changed files with 31 additions and 11 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2020, The PurpleI2P Project
|
* Copyright (c) 2013-2022, The PurpleI2P Project
|
||||||
*
|
*
|
||||||
* This file is part of Purple i2pd project and licensed under BSD3
|
* This file is part of Purple i2pd project and licensed under BSD3
|
||||||
*
|
*
|
||||||
|
@ -377,6 +377,7 @@ namespace util
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ntcp2; i2p::config::GetOption("ntcp2.enabled", ntcp2);
|
bool ntcp2; i2p::config::GetOption("ntcp2.enabled", ntcp2);
|
||||||
|
bool ssu2; i2p::config::GetOption("ssu2.enabled", ssu2);
|
||||||
bool ssu; i2p::config::GetOption("ssu", ssu);
|
bool ssu; i2p::config::GetOption("ssu", ssu);
|
||||||
bool checkInReserved; i2p::config::GetOption("reservedrange", checkInReserved);
|
bool checkInReserved; i2p::config::GetOption("reservedrange", checkInReserved);
|
||||||
LogPrint(eLogInfo, "Daemon: Starting Transports");
|
LogPrint(eLogInfo, "Daemon: Starting Transports");
|
||||||
|
@ -384,7 +385,7 @@ namespace util
|
||||||
if(!ntcp2) LogPrint(eLogInfo, "Daemon: NTCP2 disabled");
|
if(!ntcp2) LogPrint(eLogInfo, "Daemon: NTCP2 disabled");
|
||||||
|
|
||||||
i2p::transport::transports.SetCheckReserved(checkInReserved);
|
i2p::transport::transports.SetCheckReserved(checkInReserved);
|
||||||
i2p::transport::transports.Start(ntcp2, ssu);
|
i2p::transport::transports.Start(ntcp2, ssu, ssu2);
|
||||||
if (i2p::transport::transports.IsBoundSSU() || i2p::transport::transports.IsBoundNTCP2())
|
if (i2p::transport::transports.IsBoundSSU() || i2p::transport::transports.IsBoundNTCP2())
|
||||||
LogPrint(eLogInfo, "Daemon: Transports started");
|
LogPrint(eLogInfo, "Daemon: Transports started");
|
||||||
else
|
else
|
||||||
|
|
|
@ -1223,11 +1223,12 @@ namespace data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (address.IsNTCP2 () && isPublished)
|
if ((address.IsNTCP2 () && isPublished) || address.IsSSU2 ())
|
||||||
{
|
{
|
||||||
// publish i for NTCP2
|
// publish i for NTCP2 or SSU2
|
||||||
WriteString ("i", properties); properties << '=';
|
WriteString ("i", properties); properties << '=';
|
||||||
WriteString (address.i.ToBase64 (16), properties); properties << ';';
|
size_t len = address.IsSSU2 () ? 32 : 16;
|
||||||
|
WriteString (address.i.ToBase64 (len), properties); properties << ';';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isPublished || address.ssu)
|
if (isPublished || address.ssu)
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
#include "RouterContext.h"
|
#include "RouterContext.h"
|
||||||
#include "Transports.h"
|
#include "Transports.h"
|
||||||
|
#include "Config.h"
|
||||||
#include "SSU2.h"
|
#include "SSU2.h"
|
||||||
|
|
||||||
namespace i2p
|
namespace i2p
|
||||||
|
@ -210,9 +211,23 @@ namespace transport
|
||||||
for (const auto& address: addresses)
|
for (const auto& address: addresses)
|
||||||
{
|
{
|
||||||
if (!address) continue;
|
if (!address) continue;
|
||||||
if (address->transportStyle == i2p::data::RouterInfo::eTransportSSU2 && address->port)
|
if (address->transportStyle == i2p::data::RouterInfo::eTransportSSU2)
|
||||||
{
|
{
|
||||||
OpenSocket (address->port);
|
auto port = address->port;
|
||||||
|
if (!port)
|
||||||
|
{
|
||||||
|
uint16_t ssu2Port; i2p::config::GetOption ("ssu2.port", ssu2Port);
|
||||||
|
if (ssu2Port) port = ssu2Port;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
uint16_t p; i2p::config::GetOption ("port", p);
|
||||||
|
if (p) port = p;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (port)
|
||||||
|
OpenSocket (port);
|
||||||
|
else
|
||||||
|
LogPrint (eLogError, "SSU2: Can't start server because port not specified ");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,7 +157,7 @@ namespace transport
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Transports::Start (bool enableNTCP2, bool enableSSU)
|
void Transports::Start (bool enableNTCP2, bool enableSSU, bool enableSSU2)
|
||||||
{
|
{
|
||||||
if (!m_Service)
|
if (!m_Service)
|
||||||
{
|
{
|
||||||
|
@ -217,6 +217,8 @@ namespace transport
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// create SSU2 server
|
||||||
|
if (enableSSU2) m_SSU2Server = new SSU2Server ();
|
||||||
|
|
||||||
// bind to interfaces
|
// bind to interfaces
|
||||||
bool ipv4; i2p::config::GetOption("ipv4", ipv4);
|
bool ipv4; i2p::config::GetOption("ipv4", ipv4);
|
||||||
|
@ -282,6 +284,7 @@ namespace transport
|
||||||
}
|
}
|
||||||
if (m_SSUServer) DetectExternalIP ();
|
if (m_SSUServer) DetectExternalIP ();
|
||||||
}
|
}
|
||||||
|
if (m_SSU2Server) m_SSU2Server->Start ();
|
||||||
|
|
||||||
m_PeerCleanupTimer->expires_from_now (boost::posix_time::seconds(5*SESSION_CREATION_TIMEOUT));
|
m_PeerCleanupTimer->expires_from_now (boost::posix_time::seconds(5*SESSION_CREATION_TIMEOUT));
|
||||||
m_PeerCleanupTimer->async_wait (std::bind (&Transports::HandlePeerCleanupTimer, this, std::placeholders::_1));
|
m_PeerCleanupTimer->async_wait (std::bind (&Transports::HandlePeerCleanupTimer, this, std::placeholders::_1));
|
||||||
|
|
|
@ -87,7 +87,7 @@ namespace transport
|
||||||
Transports ();
|
Transports ();
|
||||||
~Transports ();
|
~Transports ();
|
||||||
|
|
||||||
void Start (bool enableNTCP2=true, bool enableSSU=true);
|
void Start (bool enableNTCP2=true, bool enableSSU=true, bool enableSSU2=false);
|
||||||
void Stop ();
|
void Stop ();
|
||||||
|
|
||||||
bool IsBoundSSU() const { return m_SSUServer != nullptr; }
|
bool IsBoundSSU() const { return m_SSUServer != nullptr; }
|
||||||
|
|
Loading…
Add table
Reference in a new issue