mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 13:27:17 +01:00
fix code syle(spaces->tabs, tabulations)
Signed-off-by: R4SAS <r4sas@i2pmail.org>
This commit is contained in:
parent
9633c247f0
commit
7a5146ea74
|
@ -172,10 +172,13 @@ namespace i2p
|
||||||
SetMaxNumTransitTunnels (transitTunnels);
|
SetMaxNumTransitTunnels (transitTunnels);
|
||||||
|
|
||||||
bool isFloodfill; i2p::config::GetOption("floodfill", isFloodfill);
|
bool isFloodfill; i2p::config::GetOption("floodfill", isFloodfill);
|
||||||
if (isFloodfill) {
|
if (isFloodfill)
|
||||||
|
{
|
||||||
LogPrint(eLogInfo, "Daemon: router will be floodfill");
|
LogPrint(eLogInfo, "Daemon: router will be floodfill");
|
||||||
i2p::context.SetFloodfill (true);
|
i2p::context.SetFloodfill (true);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
i2p::context.SetFloodfill (false);
|
i2p::context.SetFloodfill (false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,7 +246,8 @@ namespace i2p
|
||||||
i2p::transport::transports.RestrictRoutesToFamilies(fams);
|
i2p::transport::transports.RestrictRoutesToFamilies(fams);
|
||||||
restricted = fams.size() > 0;
|
restricted = fams.size() > 0;
|
||||||
}
|
}
|
||||||
if (routers.length() > 0) {
|
if (routers.length() > 0)
|
||||||
|
{
|
||||||
std::set<i2p::data::IdentHash> idents;
|
std::set<i2p::data::IdentHash> idents;
|
||||||
size_t pos = 0, comma;
|
size_t pos = 0, comma;
|
||||||
do
|
do
|
||||||
|
@ -279,7 +283,8 @@ namespace i2p
|
||||||
i2p::data::netdb.Start();
|
i2p::data::netdb.Start();
|
||||||
|
|
||||||
bool upnp; i2p::config::GetOption("upnp.enabled", upnp);
|
bool upnp; i2p::config::GetOption("upnp.enabled", upnp);
|
||||||
if (upnp) {
|
if (upnp)
|
||||||
|
{
|
||||||
d.UPnP = std::unique_ptr<i2p::transport::UPnP>(new i2p::transport::UPnP);
|
d.UPnP = std::unique_ptr<i2p::transport::UPnP>(new i2p::transport::UPnP);
|
||||||
d.UPnP->Start ();
|
d.UPnP->Start ();
|
||||||
}
|
}
|
||||||
|
@ -310,7 +315,8 @@ namespace i2p
|
||||||
}
|
}
|
||||||
|
|
||||||
bool http; i2p::config::GetOption("http.enabled", http);
|
bool http; i2p::config::GetOption("http.enabled", http);
|
||||||
if (http) {
|
if (http)
|
||||||
|
{
|
||||||
std::string httpAddr; i2p::config::GetOption("http.address", httpAddr);
|
std::string httpAddr; i2p::config::GetOption("http.address", httpAddr);
|
||||||
uint16_t httpPort; i2p::config::GetOption("http.port", httpPort);
|
uint16_t httpPort; i2p::config::GetOption("http.port", httpPort);
|
||||||
LogPrint(eLogInfo, "Daemon: starting webconsole at ", httpAddr, ":", httpPort);
|
LogPrint(eLogInfo, "Daemon: starting webconsole at ", httpAddr, ":", httpPort);
|
||||||
|
@ -326,7 +332,6 @@ namespace i2p
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LogPrint(eLogInfo, "Daemon: starting Tunnels");
|
LogPrint(eLogInfo, "Daemon: starting Tunnels");
|
||||||
i2p::tunnel::tunnels.Start();
|
i2p::tunnel::tunnels.Start();
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ namespace util
|
||||||
class Daemon_Singleton
|
class Daemon_Singleton
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual bool init(int argc, char* argv[], std::shared_ptr<std::ostream> logstream);
|
virtual bool init(int argc, char* argv[], std::shared_ptr<std::ostream> logstream);
|
||||||
virtual bool init(int argc, char* argv[]);
|
virtual bool init(int argc, char* argv[]);
|
||||||
virtual bool start();
|
virtual bool start();
|
||||||
|
@ -23,6 +24,7 @@ namespace util
|
||||||
bool running;
|
bool running;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
Daemon_Singleton();
|
Daemon_Singleton();
|
||||||
virtual ~Daemon_Singleton();
|
virtual ~Daemon_Singleton();
|
||||||
|
|
||||||
|
@ -39,6 +41,7 @@ namespace util
|
||||||
class DaemonQT: public i2p::util::Daemon_Singleton
|
class DaemonQT: public i2p::util::Daemon_Singleton
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static DaemonQT& Instance()
|
static DaemonQT& Instance()
|
||||||
{
|
{
|
||||||
static DaemonQT instance;
|
static DaemonQT instance;
|
||||||
|
@ -51,6 +54,7 @@ namespace util
|
||||||
class DaemonWin32 : public Daemon_Singleton
|
class DaemonWin32 : public Daemon_Singleton
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static DaemonWin32& Instance()
|
static DaemonWin32& Instance()
|
||||||
{
|
{
|
||||||
static DaemonWin32 instance;
|
static DaemonWin32 instance;
|
||||||
|
@ -72,6 +76,7 @@ namespace util
|
||||||
class DaemonAndroid: public i2p::util::Daemon_Singleton
|
class DaemonAndroid: public i2p::util::Daemon_Singleton
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static DaemonAndroid& Instance()
|
static DaemonAndroid& Instance()
|
||||||
{
|
{
|
||||||
static DaemonAndroid instance;
|
static DaemonAndroid instance;
|
||||||
|
@ -83,6 +88,7 @@ namespace util
|
||||||
class DaemonLinux : public Daemon_Singleton
|
class DaemonLinux : public Daemon_Singleton
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static DaemonLinux& Instance()
|
static DaemonLinux& Instance()
|
||||||
{
|
{
|
||||||
static DaemonLinux instance;
|
static DaemonLinux instance;
|
||||||
|
@ -94,10 +100,12 @@ namespace util
|
||||||
void run ();
|
void run ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::string pidfile;
|
std::string pidfile;
|
||||||
int pidFH;
|
int pidFH;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
int gracefulShutdownInterval; // in seconds
|
int gracefulShutdownInterval; // in seconds
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -80,8 +80,7 @@ namespace client
|
||||||
m_RouterInfoHandlers["i2p.router.net.bw.outbound.1s"] = &I2PControlService::OutboundBandwidth1S;
|
m_RouterInfoHandlers["i2p.router.net.bw.outbound.1s"] = &I2PControlService::OutboundBandwidth1S;
|
||||||
m_RouterInfoHandlers["i2p.router.net.status"] = &I2PControlService::NetStatusHandler;
|
m_RouterInfoHandlers["i2p.router.net.status"] = &I2PControlService::NetStatusHandler;
|
||||||
m_RouterInfoHandlers["i2p.router.net.tunnels.participating"] = &I2PControlService::TunnelsParticipatingHandler;
|
m_RouterInfoHandlers["i2p.router.net.tunnels.participating"] = &I2PControlService::TunnelsParticipatingHandler;
|
||||||
m_RouterInfoHandlers["i2p.router.net.tunnels.successrate"] =
|
m_RouterInfoHandlers["i2p.router.net.tunnels.successrate"] = &I2PControlService::TunnelsSuccessRateHandler;
|
||||||
&I2PControlService::TunnelsSuccessRateHandler;
|
|
||||||
m_RouterInfoHandlers["i2p.router.net.total.received.bytes"] = &I2PControlService::NetTotalReceivedBytes;
|
m_RouterInfoHandlers["i2p.router.net.total.received.bytes"] = &I2PControlService::NetTotalReceivedBytes;
|
||||||
m_RouterInfoHandlers["i2p.router.net.total.sent.bytes"] = &I2PControlService::NetTotalSentBytes;
|
m_RouterInfoHandlers["i2p.router.net.total.sent.bytes"] = &I2PControlService::NetTotalSentBytes;
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@ namespace client
|
||||||
class I2PControlService
|
class I2PControlService
|
||||||
{
|
{
|
||||||
typedef boost::asio::ssl::stream<boost::asio::ip::tcp::socket> ssl_socket;
|
typedef boost::asio::ssl::stream<boost::asio::ip::tcp::socket> ssl_socket;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
I2PControlService (const std::string& address, int port);
|
I2PControlService (const std::string& address, int port);
|
||||||
|
|
|
@ -196,5 +196,4 @@ namespace i2p
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
#include "Daemon.h"
|
#include "Daemon.h"
|
||||||
|
|
||||||
#if defined(QT_GUI_LIB)
|
#if defined(QT_GUI_LIB)
|
||||||
|
|
||||||
namespace i2p
|
namespace i2p
|
||||||
{
|
{
|
||||||
namespace qt
|
namespace qt
|
||||||
|
@ -10,11 +9,11 @@ namespace qt
|
||||||
int RunQT (int argc, char* argv[]);
|
int RunQT (int argc, char* argv[]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main( int argc, char* argv[] )
|
int main( int argc, char* argv[] )
|
||||||
{
|
{
|
||||||
return i2p::qt::RunQT (argc, argv);
|
return i2p::qt::RunQT (argc, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
int main( int argc, char* argv[] )
|
int main( int argc, char* argv[] )
|
||||||
{
|
{
|
||||||
|
|
|
@ -7,7 +7,8 @@ namespace i2p
|
||||||
{
|
{
|
||||||
namespace data
|
namespace data
|
||||||
{
|
{
|
||||||
static const char T32[32] = {
|
static const char T32[32] =
|
||||||
|
{
|
||||||
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
|
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
|
||||||
'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',
|
'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',
|
||||||
'q', 'r', 's', 't', 'u', 'v', 'w', 'x',
|
'q', 'r', 's', 't', 'u', 'v', 'w', 'x',
|
||||||
|
@ -29,7 +30,8 @@ namespace data
|
||||||
* Direct Substitution Table
|
* Direct Substitution Table
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static const char T64[64] = {
|
static const char T64[64] =
|
||||||
|
{
|
||||||
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
|
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
|
||||||
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
|
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
|
||||||
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
|
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
|
||||||
|
@ -67,14 +69,12 @@ namespace data
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
size_t /* Number of bytes in the encoded buffer */
|
size_t ByteStreamToBase64 ( /* Number of bytes in the encoded buffer */
|
||||||
ByteStreamToBase64 (
|
|
||||||
const uint8_t * InBuffer, /* Input buffer, binary data */
|
const uint8_t * InBuffer, /* Input buffer, binary data */
|
||||||
size_t InCount, /* Number of bytes in the input buffer */
|
size_t InCount, /* Number of bytes in the input buffer */
|
||||||
char * OutBuffer, /* output buffer */
|
char * OutBuffer, /* output buffer */
|
||||||
size_t len /* length of output buffer */
|
size_t len /* length of output buffer */
|
||||||
)
|
)
|
||||||
|
|
||||||
{
|
{
|
||||||
unsigned char * ps;
|
unsigned char * ps;
|
||||||
unsigned char * pd;
|
unsigned char * pd;
|
||||||
|
@ -92,9 +92,12 @@ namespace data
|
||||||
outCount = 4 * n;
|
outCount = 4 * n;
|
||||||
else
|
else
|
||||||
outCount = 4 * (n + 1);
|
outCount = 4 * (n + 1);
|
||||||
|
|
||||||
if (outCount > len) return 0;
|
if (outCount > len) return 0;
|
||||||
|
|
||||||
pd = (unsigned char *)OutBuffer;
|
pd = (unsigned char *)OutBuffer;
|
||||||
for ( i = 0; i<n; i++ ){
|
for ( i = 0; i < n; i++ )
|
||||||
|
{
|
||||||
acc_1 = *ps++;
|
acc_1 = *ps++;
|
||||||
acc_2 = (acc_1 << 4) & 0x30;
|
acc_2 = (acc_1 << 4) & 0x30;
|
||||||
acc_1 >>= 2; /* base64 digit #1 */
|
acc_1 >>= 2; /* base64 digit #1 */
|
||||||
|
@ -110,7 +113,8 @@ namespace data
|
||||||
acc_2 &= 0x3f; /* base64 digit #4 */
|
acc_2 &= 0x3f; /* base64 digit #4 */
|
||||||
*pd++ = T64[acc_2];
|
*pd++ = T64[acc_2];
|
||||||
}
|
}
|
||||||
if ( m == 1 ){
|
if ( m == 1 )
|
||||||
|
{
|
||||||
acc_1 = *ps++;
|
acc_1 = *ps++;
|
||||||
acc_2 = (acc_1 << 4) & 0x3f; /* base64 digit #2 */
|
acc_2 = (acc_1 << 4) & 0x3f; /* base64 digit #2 */
|
||||||
acc_1 >>= 2; /* base64 digit #1 */
|
acc_1 >>= 2; /* base64 digit #1 */
|
||||||
|
@ -120,7 +124,8 @@ namespace data
|
||||||
*pd++ = P64;
|
*pd++ = P64;
|
||||||
|
|
||||||
}
|
}
|
||||||
else if ( m == 2 ){
|
else if ( m == 2 )
|
||||||
|
{
|
||||||
acc_1 = *ps++;
|
acc_1 = *ps++;
|
||||||
acc_2 = (acc_1 << 4) & 0x3f;
|
acc_2 = (acc_1 << 4) & 0x3f;
|
||||||
acc_1 >>= 2; /* base64 digit #1 */
|
acc_1 >>= 2; /* base64 digit #1 */
|
||||||
|
@ -147,8 +152,7 @@ namespace data
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
size_t /* Number of output bytes */
|
size_t Base64ToByteStream ( /* Number of output bytes */
|
||||||
Base64ToByteStream (
|
|
||||||
const char * InBuffer, /* BASE64 encoded buffer */
|
const char * InBuffer, /* BASE64 encoded buffer */
|
||||||
size_t InCount, /* Number of input bytes */
|
size_t InCount, /* Number of input bytes */
|
||||||
uint8_t * OutBuffer, /* output buffer length */
|
uint8_t * OutBuffer, /* output buffer length */
|
||||||
|
@ -164,36 +168,46 @@ namespace data
|
||||||
int m;
|
int m;
|
||||||
size_t outCount;
|
size_t outCount;
|
||||||
|
|
||||||
if (isFirstTime) iT64Build();
|
if (isFirstTime)
|
||||||
|
iT64Build();
|
||||||
|
|
||||||
n = InCount / 4;
|
n = InCount / 4;
|
||||||
m = InCount % 4;
|
m = InCount % 4;
|
||||||
|
|
||||||
if (InCount && !m)
|
if (InCount && !m)
|
||||||
outCount = 3 * n;
|
outCount = 3 * n;
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
outCount = 0;
|
outCount = 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ps = (unsigned char *)(InBuffer + InCount - 1);
|
ps = (unsigned char *)(InBuffer + InCount - 1);
|
||||||
while ( *ps-- == P64 ) outCount--;
|
while ( *ps-- == P64 )
|
||||||
|
outCount--;
|
||||||
ps = (unsigned char *)InBuffer;
|
ps = (unsigned char *)InBuffer;
|
||||||
|
|
||||||
if (outCount > len) return -1;
|
if (outCount > len)
|
||||||
|
return -1;
|
||||||
|
|
||||||
pd = OutBuffer;
|
pd = OutBuffer;
|
||||||
auto endOfOutBuffer = OutBuffer + outCount;
|
auto endOfOutBuffer = OutBuffer + outCount;
|
||||||
for ( i = 0; i < n; i++ ){
|
for ( i = 0; i < n; i++ )
|
||||||
|
{
|
||||||
acc_1 = iT64[*ps++];
|
acc_1 = iT64[*ps++];
|
||||||
acc_2 = iT64[*ps++];
|
acc_2 = iT64[*ps++];
|
||||||
acc_1 <<= 2;
|
acc_1 <<= 2;
|
||||||
acc_1 |= acc_2 >> 4;
|
acc_1 |= acc_2 >> 4;
|
||||||
*pd++ = acc_1;
|
*pd++ = acc_1;
|
||||||
if (pd >= endOfOutBuffer) break;
|
if (pd >= endOfOutBuffer)
|
||||||
|
break;
|
||||||
|
|
||||||
acc_2 <<= 4;
|
acc_2 <<= 4;
|
||||||
acc_1 = iT64[*ps++];
|
acc_1 = iT64[*ps++];
|
||||||
acc_2 |= acc_1 >> 2;
|
acc_2 |= acc_1 >> 2;
|
||||||
*pd++ = acc_2;
|
*pd++ = acc_2;
|
||||||
if (pd >= endOfOutBuffer) break;
|
if (pd >= endOfOutBuffer)
|
||||||
|
break;
|
||||||
|
|
||||||
acc_2 = iT64[*ps++];
|
acc_2 = iT64[*ps++];
|
||||||
acc_2 |= acc_1 << 6;
|
acc_2 |= acc_1 << 6;
|
||||||
|
@ -206,7 +220,9 @@ namespace data
|
||||||
size_t Base64EncodingBufferSize (const size_t input_size)
|
size_t Base64EncodingBufferSize (const size_t input_size)
|
||||||
{
|
{
|
||||||
auto d = div (input_size, 3);
|
auto d = div (input_size, 3);
|
||||||
if (d.rem) d.quot++;
|
if (d.rem)
|
||||||
|
d.quot++;
|
||||||
|
|
||||||
return 4 * d.quot;
|
return 4 * d.quot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,8 +234,11 @@ namespace data
|
||||||
str[l] = 0;
|
str[l] = 0;
|
||||||
// replace '-' by '+' and '~' by '/'
|
// replace '-' by '+' and '~' by '/'
|
||||||
for (size_t i = 0; i < l; i++)
|
for (size_t i = 0; i < l; i++)
|
||||||
if (str[i] == '-') str[i] = '+';
|
if (str[i] == '-')
|
||||||
else if (str[i] == '~') str[i] = '/';
|
str[i] = '+';
|
||||||
|
else if (str[i] == '~')
|
||||||
|
str[i] = '/';
|
||||||
|
|
||||||
std::string s(str);
|
std::string s(str);
|
||||||
delete[] str;
|
delete[] str;
|
||||||
return s;
|
return s;
|
||||||
|
@ -302,4 +321,3 @@ namespace data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -314,4 +314,3 @@ namespace data
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -78,7 +78,6 @@ void block (Chacha20State &input, int rounds)
|
||||||
}
|
}
|
||||||
x += input;
|
x += input;
|
||||||
input.block << x;
|
input.block << x;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Chacha20Init (Chacha20State& state, const uint8_t * nonce, const uint8_t * key, uint32_t counter)
|
void Chacha20Init (Chacha20State& state, const uint8_t * nonce, const uint8_t * key, uint32_t counter)
|
||||||
|
@ -130,9 +129,9 @@ void Chacha20Encrypt (Chacha20State& state, uint8_t * buf, size_t sz)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace chacha
|
} // namespace chacha
|
||||||
|
} // namespace crypto
|
||||||
|
} // namespace i2p
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -64,9 +64,9 @@ namespace chacha
|
||||||
void Chacha20Init (Chacha20State& state, const uint8_t * nonce, const uint8_t * key, uint32_t counter);
|
void Chacha20Init (Chacha20State& state, const uint8_t * nonce, const uint8_t * key, uint32_t counter);
|
||||||
void Chacha20SetCounter (Chacha20State& state, uint32_t counter);
|
void Chacha20SetCounter (Chacha20State& state, uint32_t counter);
|
||||||
void Chacha20Encrypt (Chacha20State& state, uint8_t * buf, size_t sz); // encrypt buf in place
|
void Chacha20Encrypt (Chacha20State& state, uint8_t * buf, size_t sz); // encrypt buf in place
|
||||||
}
|
} // namespace chacha
|
||||||
}
|
} // namespace crypto
|
||||||
}
|
} // namespace i2p
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
|
@ -63,7 +63,8 @@ namespace config {
|
||||||
*/
|
*/
|
||||||
void Finalize();
|
void Finalize();
|
||||||
|
|
||||||
/* @brief Accessor to parameters by name
|
/**
|
||||||
|
* @brief Accessor to parameters by name
|
||||||
* @param name Name of the requested parameter
|
* @param name Name of the requested parameter
|
||||||
* @param value Variable where to store option
|
* @param value Variable where to store option
|
||||||
* @return this function returns false if parameter not found
|
* @return this function returns false if parameter not found
|
||||||
|
@ -71,7 +72,8 @@ namespace config {
|
||||||
* Example: uint16_t port; GetOption("sam.port", port);
|
* Example: uint16_t port; GetOption("sam.port", port);
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool GetOption(const char *name, T& value) {
|
bool GetOption(const char *name, T& value)
|
||||||
|
{
|
||||||
if (!m_Options.count(name))
|
if (!m_Options.count(name))
|
||||||
return false;
|
return false;
|
||||||
value = m_Options[name].as<T>();
|
value = m_Options[name].as<T>();
|
||||||
|
@ -96,7 +98,8 @@ namespace config {
|
||||||
* Example: uint16_t port = 2827; SetOption("bob.port", port);
|
* Example: uint16_t port = 2827; SetOption("bob.port", port);
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool SetOption(const char *name, const T& value) {
|
bool SetOption(const char *name, const T& value)
|
||||||
|
{
|
||||||
if (!m_Options.count(name))
|
if (!m_Options.count(name))
|
||||||
return false;
|
return false;
|
||||||
m_Options.at(name).value() = value;
|
m_Options.at(name).value() = value;
|
||||||
|
|
|
@ -884,7 +884,6 @@ namespace crypto
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CBCEncryption::Encrypt (int numBlocks, const ChipherBlock * in, ChipherBlock * out)
|
void CBCEncryption::Encrypt (int numBlocks, const ChipherBlock * in, ChipherBlock * out)
|
||||||
{
|
{
|
||||||
#ifdef __AES__
|
#ifdef __AES__
|
||||||
|
@ -1364,4 +1363,3 @@ namespace crypto
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -178,4 +178,3 @@ namespace crypto
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -153,4 +153,3 @@ namespace crypto
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -77,5 +77,4 @@ namespace worker
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -114,7 +114,6 @@ namespace datagram
|
||||||
LogPrint (eLogWarning, "Datagram: decompression failed");
|
LogPrint (eLogWarning, "Datagram: decompression failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::shared_ptr<I2NPMessage> DatagramDestination::CreateDataMessage (
|
std::shared_ptr<I2NPMessage> DatagramDestination::CreateDataMessage (
|
||||||
const std::vector<std::pair<const uint8_t *, size_t> >& payloads,
|
const std::vector<std::pair<const uint8_t *, size_t> >& payloads,
|
||||||
uint16_t fromPort, uint16_t toPort, bool isRaw, bool checksum)
|
uint16_t fromPort, uint16_t toPort, bool isRaw, bool checksum)
|
||||||
|
@ -384,4 +383,3 @@ namespace datagram
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,9 @@ namespace datagram
|
||||||
|
|
||||||
class DatagramSession : public std::enable_shared_from_this<DatagramSession>
|
class DatagramSession : public std::enable_shared_from_this<DatagramSession>
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DatagramSession(std::shared_ptr<i2p::client::ClientDestination> localDestination, const i2p::data::IdentHash & remoteIdent);
|
DatagramSession(std::shared_ptr<i2p::client::ClientDestination> localDestination, const i2p::data::IdentHash & remoteIdent);
|
||||||
|
|
||||||
void Start ();
|
void Start ();
|
||||||
|
@ -84,6 +86,7 @@ namespace datagram
|
||||||
void HandleLeaseSetUpdated(std::shared_ptr<i2p::data::LeaseSet> ls);
|
void HandleLeaseSetUpdated(std::shared_ptr<i2p::data::LeaseSet> ls);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::shared_ptr<i2p::client::ClientDestination> m_LocalDestination;
|
std::shared_ptr<i2p::client::ClientDestination> m_LocalDestination;
|
||||||
i2p::data::IdentHash m_RemoteIdent;
|
i2p::data::IdentHash m_RemoteIdent;
|
||||||
std::shared_ptr<const i2p::data::LeaseSet> m_RemoteLeaseSet;
|
std::shared_ptr<const i2p::data::LeaseSet> m_RemoteLeaseSet;
|
||||||
|
@ -104,10 +107,8 @@ namespace datagram
|
||||||
typedef std::function<void (const i2p::data::IdentityEx& from, uint16_t fromPort, uint16_t toPort, const uint8_t * buf, size_t len)> Receiver;
|
typedef std::function<void (const i2p::data::IdentityEx& from, uint16_t fromPort, uint16_t toPort, const uint8_t * buf, size_t len)> Receiver;
|
||||||
typedef std::function<void (uint16_t fromPort, uint16_t toPort, const uint8_t * buf, size_t len)> RawReceiver;
|
typedef std::function<void (uint16_t fromPort, uint16_t toPort, const uint8_t * buf, size_t len)> RawReceiver;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
||||||
DatagramDestination (std::shared_ptr<i2p::client::ClientDestination> owner, bool gzip);
|
DatagramDestination (std::shared_ptr<i2p::client::ClientDestination> owner, bool gzip);
|
||||||
~DatagramDestination ();
|
~DatagramDestination ();
|
||||||
|
|
||||||
|
|
|
@ -160,7 +160,6 @@ namespace client
|
||||||
|
|
||||||
bool LeaseSetDestination::Reconfigure(std::map<std::string, std::string> params)
|
bool LeaseSetDestination::Reconfigure(std::map<std::string, std::string> params)
|
||||||
{
|
{
|
||||||
|
|
||||||
auto itr = params.find("i2cp.dontPublishLeaseSet");
|
auto itr = params.find("i2cp.dontPublishLeaseSet");
|
||||||
if (itr != params.end())
|
if (itr != params.end())
|
||||||
{
|
{
|
||||||
|
|
|
@ -94,7 +94,6 @@ namespace client
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
LeaseSetDestination (boost::asio::io_service& service, bool isPublic, const std::map<std::string, std::string> * params = nullptr);
|
LeaseSetDestination (boost::asio::io_service& service, bool isPublic, const std::map<std::string, std::string> * params = nullptr);
|
||||||
|
|
|
@ -432,7 +432,7 @@ namespace garlic
|
||||||
i2p::crypto::HKDF (m_CK, sharedSecret, 32, "", m_CK); // [chainKey, key] = HKDF(chainKey, sharedSecret, "", 64)
|
i2p::crypto::HKDF (m_CK, sharedSecret, 32, "", m_CK); // [chainKey, key] = HKDF(chainKey, sharedSecret, "", 64)
|
||||||
uint8_t nonce[12];
|
uint8_t nonce[12];
|
||||||
CreateNonce (0, nonce);
|
CreateNonce (0, nonce);
|
||||||
// calulate hash for zero length
|
// calculate hash for zero length
|
||||||
if (!i2p::crypto::AEADChaCha20Poly1305 (nonce /* can be anything */, 0, m_H, 32, m_CK + 32, nonce, out + offset, 16, true)) // encrypt, ciphertext = ENCRYPT(k, n, ZEROLEN, ad)
|
if (!i2p::crypto::AEADChaCha20Poly1305 (nonce /* can be anything */, 0, m_H, 32, m_CK + 32, nonce, out + offset, 16, true)) // encrypt, ciphertext = ENCRYPT(k, n, ZEROLEN, ad)
|
||||||
{
|
{
|
||||||
LogPrint (eLogWarning, "Garlic: Reply key section AEAD encryption failed");
|
LogPrint (eLogWarning, "Garlic: Reply key section AEAD encryption failed");
|
||||||
|
@ -469,7 +469,7 @@ namespace garlic
|
||||||
uint64_t tag = m_NSRTagset->GetNextSessionTag (); // next tag
|
uint64_t tag = m_NSRTagset->GetNextSessionTag (); // next tag
|
||||||
memcpy (out, &tag, 8);
|
memcpy (out, &tag, 8);
|
||||||
memcpy (out + 8, m_NSREncodedKey, 32);
|
memcpy (out + 8, m_NSREncodedKey, 32);
|
||||||
// recalculte h with new tag
|
// recalculate h with new tag
|
||||||
memcpy (m_H, m_NSRH, 32);
|
memcpy (m_H, m_NSRH, 32);
|
||||||
MixHash ((const uint8_t *)&tag, 8); // h = SHA256(h || tag)
|
MixHash ((const uint8_t *)&tag, 8); // h = SHA256(h || tag)
|
||||||
MixHash (m_EphemeralKeys.GetPublicKey (), 32); // h = SHA256(h || bepk)
|
MixHash (m_EphemeralKeys.GetPublicKey (), 32); // h = SHA256(h || bepk)
|
||||||
|
@ -518,8 +518,8 @@ namespace garlic
|
||||||
}
|
}
|
||||||
uint8_t nonce[12];
|
uint8_t nonce[12];
|
||||||
CreateNonce (0, nonce);
|
CreateNonce (0, nonce);
|
||||||
// calulate hash for zero length
|
// calculate hash for zero length
|
||||||
if (!i2p::crypto::AEADChaCha20Poly1305 (buf, 0, m_H, 32, m_CK + 32, nonce, sharedSecret/* can be anyting */, 0, false)) // decrypt, DECRYPT(k, n, ZEROLEN, ad) verification only
|
if (!i2p::crypto::AEADChaCha20Poly1305 (buf, 0, m_H, 32, m_CK + 32, nonce, sharedSecret/* can be anything */, 0, false)) // decrypt, DECRYPT(k, n, ZEROLEN, ad) verification only
|
||||||
{
|
{
|
||||||
LogPrint (eLogWarning, "Garlic: Reply key section AEAD decryption failed");
|
LogPrint (eLogWarning, "Garlic: Reply key section AEAD decryption failed");
|
||||||
return false;
|
return false;
|
||||||
|
@ -909,5 +909,3 @@ namespace garlic
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -597,4 +597,3 @@ namespace crypto
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -128,6 +128,4 @@ namespace crypto
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -204,4 +204,3 @@ namespace crypto
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,5 +35,3 @@ namespace crypto
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -35,8 +35,10 @@ namespace fs {
|
||||||
* std::vector<std::string> files;
|
* std::vector<std::string> files;
|
||||||
* h.Traverse(files); <- finds all files in storage and saves in given vector
|
* h.Traverse(files); <- finds all files in storage and saves in given vector
|
||||||
*/
|
*/
|
||||||
class HashedStorage {
|
class HashedStorage
|
||||||
|
{
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
std::string root; /**< path to storage with it's name included */
|
std::string root; /**< path to storage with it's name included */
|
||||||
std::string name; /**< name of the storage */
|
std::string name; /**< name of the storage */
|
||||||
std::string prefix1; /**< hashed directory prefix */
|
std::string prefix1; /**< hashed directory prefix */
|
||||||
|
@ -44,6 +46,7 @@ namespace fs {
|
||||||
std::string suffix; /**< suffix of file in storage (extension) */
|
std::string suffix; /**< suffix of file in storage (extension) */
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef std::function<void(const std::string &)> FilenameVisitor;
|
typedef std::function<void(const std::string &)> FilenameVisitor;
|
||||||
HashedStorage(const char *n, const char *p1, const char *p2, const char *s):
|
HashedStorage(const char *n, const char *p1, const char *p2, const char *s):
|
||||||
name(n), prefix1(p1), prefix2(p2), suffix(s) {};
|
name(n), prefix1(p1), prefix2(p2), suffix(s) {};
|
||||||
|
|
|
@ -179,4 +179,3 @@ namespace data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -143,6 +143,7 @@ namespace garlic
|
||||||
std::shared_ptr<GarlicRoutingPath> m_SharedRoutingPath;
|
std::shared_ptr<GarlicRoutingPath> m_SharedRoutingPath;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// for HTTP only
|
// for HTTP only
|
||||||
virtual size_t GetNumOutgoingTags () const { return 0; };
|
virtual size_t GetNumOutgoingTags () const { return 0; };
|
||||||
};
|
};
|
||||||
|
@ -196,6 +197,7 @@ namespace garlic
|
||||||
i2p::crypto::CBCEncryption m_Encryption;
|
i2p::crypto::CBCEncryption m_Encryption;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// for HTTP only
|
// for HTTP only
|
||||||
size_t GetNumOutgoingTags () const { return m_SessionTags.size (); };
|
size_t GetNumOutgoingTags () const { return m_SessionTags.size (); };
|
||||||
};
|
};
|
||||||
|
|
|
@ -45,7 +45,6 @@ namespace data
|
||||||
|
|
||||||
size_t GzipNoCompression (const uint8_t * in, uint16_t inLen, uint8_t * out, size_t outLen); // for < 64K
|
size_t GzipNoCompression (const uint8_t * in, uint16_t inLen, uint8_t * out, size_t outLen); // for < 64K
|
||||||
size_t GzipNoCompression (const std::vector<std::pair<const uint8_t *, size_t> >& bufs, uint8_t * out, size_t outLen); // for total size < 64K
|
size_t GzipNoCompression (const std::vector<std::pair<const uint8_t *, size_t> >& bufs, uint8_t * out, size_t outLen); // for total size < 64K
|
||||||
|
|
||||||
} // data
|
} // data
|
||||||
} // i2p
|
} // i2p
|
||||||
|
|
||||||
|
|
|
@ -204,7 +204,7 @@ namespace data
|
||||||
IdentHash CreateRoutingKey (const IdentHash& ident);
|
IdentHash CreateRoutingKey (const IdentHash& ident);
|
||||||
XORMetric operator^(const IdentHash& key1, const IdentHash& key2);
|
XORMetric operator^(const IdentHash& key1, const IdentHash& key2);
|
||||||
|
|
||||||
// destination for delivery instuctions
|
// destination for delivery instructions
|
||||||
class RoutingDestination
|
class RoutingDestination
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -235,5 +235,4 @@ namespace data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -12,7 +12,6 @@ namespace i2p
|
||||||
{
|
{
|
||||||
namespace data
|
namespace data
|
||||||
{
|
{
|
||||||
|
|
||||||
LeaseSet::LeaseSet (bool storeLeases):
|
LeaseSet::LeaseSet (bool storeLeases):
|
||||||
m_IsValid (false), m_StoreLeases (storeLeases), m_ExpirationTime (0), m_EncryptionKey (nullptr),
|
m_IsValid (false), m_StoreLeases (storeLeases), m_ExpirationTime (0), m_EncryptionKey (nullptr),
|
||||||
m_Buffer (nullptr), m_BufferLen (0)
|
m_Buffer (nullptr), m_BufferLen (0)
|
||||||
|
@ -771,8 +770,7 @@ namespace data
|
||||||
}
|
}
|
||||||
|
|
||||||
LocalLeaseSet2::LocalLeaseSet2 (uint8_t storeType, const i2p::data::PrivateKeys& keys,
|
LocalLeaseSet2::LocalLeaseSet2 (uint8_t storeType, const i2p::data::PrivateKeys& keys,
|
||||||
const KeySections& encryptionKeys,
|
const KeySections& encryptionKeys, std::vector<std::shared_ptr<i2p::tunnel::InboundTunnel> > tunnels,
|
||||||
std::vector<std::shared_ptr<i2p::tunnel::InboundTunnel> > tunnels,
|
|
||||||
bool isPublic, bool isPublishedEncrypted):
|
bool isPublic, bool isPublishedEncrypted):
|
||||||
LocalLeaseSet (keys.GetPublic (), nullptr, 0)
|
LocalLeaseSet (keys.GetPublic (), nullptr, 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -245,6 +245,7 @@ namespace data
|
||||||
const KeySections& encryptionKeys,
|
const KeySections& encryptionKeys,
|
||||||
std::vector<std::shared_ptr<i2p::tunnel::InboundTunnel> > tunnels,
|
std::vector<std::shared_ptr<i2p::tunnel::InboundTunnel> > tunnels,
|
||||||
bool isPublic, bool isPublishedEncrypted = false);
|
bool isPublic, bool isPublishedEncrypted = false);
|
||||||
|
|
||||||
LocalLeaseSet2 (uint8_t storeType, std::shared_ptr<const IdentityEx> identity, const uint8_t * buf, size_t len); // from I2CP
|
LocalLeaseSet2 (uint8_t storeType, std::shared_ptr<const IdentityEx> identity, const uint8_t * buf, size_t len); // from I2CP
|
||||||
|
|
||||||
virtual ~LocalLeaseSet2 () { delete[] m_Buffer; };
|
virtual ~LocalLeaseSet2 () { delete[] m_Buffer; };
|
||||||
|
|
|
@ -157,7 +157,7 @@ namespace log {
|
||||||
ThrowFunction GetThrowFunction ();
|
ThrowFunction GetThrowFunction ();
|
||||||
void SetThrowFunction (ThrowFunction f);
|
void SetThrowFunction (ThrowFunction f);
|
||||||
} // log
|
} // log
|
||||||
}
|
} // i2p
|
||||||
|
|
||||||
/** internal usage only -- folding args array to single string */
|
/** internal usage only -- folding args array to single string */
|
||||||
template<typename TValue>
|
template<typename TValue>
|
||||||
|
|
|
@ -1200,7 +1200,7 @@ namespace transport
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogPrint (eLogInfo, "NTCP2: Start listening v6 TCP port ", address->port);
|
LogPrint (eLogInfo, "NTCP2: Start listening v4 TCP port ", address->port);
|
||||||
auto conn = std::make_shared<NTCP2Session>(*this);
|
auto conn = std::make_shared<NTCP2Session>(*this);
|
||||||
m_NTCP2Acceptor->async_accept(conn->GetSocket (), std::bind (&NTCP2Server::HandleAccept, this, conn, std::placeholders::_1));
|
m_NTCP2Acceptor->async_accept(conn->GetSocket (), std::bind (&NTCP2Server::HandleAccept, this, conn, std::placeholders::_1));
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,7 +126,6 @@ namespace transport
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
||||||
NTCP2Session (NTCP2Server& server, std::shared_ptr<const i2p::data::RouterInfo> in_RemoteRouter = nullptr);
|
NTCP2Session (NTCP2Server& server, std::shared_ptr<const i2p::data::RouterInfo> in_RemoteRouter = nullptr);
|
||||||
~NTCP2Session ();
|
~NTCP2Session ();
|
||||||
void Terminate ();
|
void Terminate ();
|
||||||
|
|
|
@ -736,13 +736,11 @@ namespace transport
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void NTCPSession::SendTimeSyncMessage ()
|
void NTCPSession::SendTimeSyncMessage ()
|
||||||
{
|
{
|
||||||
Send (nullptr);
|
Send (nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void NTCPSession::SendI2NPMessages (const std::vector<std::shared_ptr<I2NPMessage> >& msgs)
|
void NTCPSession::SendI2NPMessages (const std::vector<std::shared_ptr<I2NPMessage> >& msgs)
|
||||||
{
|
{
|
||||||
m_Server.GetService ().post (std::bind (&NTCPSession::PostI2NPMessages, shared_from_this (), msgs));
|
m_Server.GetService ().post (std::bind (&NTCPSession::PostI2NPMessages, shared_from_this (), msgs));
|
||||||
|
@ -904,7 +902,6 @@ namespace transport
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void NTCPServer::Run ()
|
void NTCPServer::Run ()
|
||||||
{
|
{
|
||||||
while (m_IsRunning)
|
while (m_IsRunning)
|
||||||
|
|
|
@ -123,6 +123,7 @@ namespace data
|
||||||
|
|
||||||
std::shared_ptr<const RouterInfo> AddRouterInfo (const uint8_t * buf, int len, bool& updated);
|
std::shared_ptr<const RouterInfo> AddRouterInfo (const uint8_t * buf, int len, bool& updated);
|
||||||
std::shared_ptr<const RouterInfo> AddRouterInfo (const IdentHash& ident, const uint8_t * buf, int len, bool& updated);
|
std::shared_ptr<const RouterInfo> AddRouterInfo (const IdentHash& ident, const uint8_t * buf, int len, bool& updated);
|
||||||
|
|
||||||
template<typename Filter>
|
template<typename Filter>
|
||||||
std::shared_ptr<const RouterInfo> GetRandomRouter (Filter filter) const;
|
std::shared_ptr<const RouterInfo> GetRandomRouter (Filter filter) const;
|
||||||
|
|
||||||
|
|
|
@ -158,4 +158,3 @@ namespace data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,4 +66,3 @@ namespace data
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,6 @@ namespace i2p
|
||||||
{
|
{
|
||||||
namespace crypto
|
namespace crypto
|
||||||
{
|
{
|
||||||
|
|
||||||
void Poly1305HMAC(uint64_t * out, const uint64_t * key, const uint8_t * buf, std::size_t sz)
|
void Poly1305HMAC(uint64_t * out, const uint64_t * key, const uint8_t * buf, std::size_t sz)
|
||||||
{
|
{
|
||||||
Poly1305 p(key);
|
Poly1305 p(key);
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
/**
|
/**
|
||||||
This code is licensed under the MCGSI Public License
|
* This code is licensed under the MCGSI Public License
|
||||||
Copyright 2018 Jeff Becker
|
* Copyright 2018 Jeff Becker
|
||||||
|
*
|
||||||
Kovri go write your own code
|
* Kovri go write your own code
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
#ifndef LIBI2PD_POLY1305_H
|
#ifndef LIBI2PD_POLY1305_H
|
||||||
#define LIBI2PD_POLY1305_H
|
#define LIBI2PD_POLY1305_H
|
||||||
|
@ -24,7 +24,6 @@ namespace crypto
|
||||||
|
|
||||||
namespace poly1305
|
namespace poly1305
|
||||||
{
|
{
|
||||||
|
|
||||||
struct LongBlock
|
struct LongBlock
|
||||||
{
|
{
|
||||||
unsigned long data[17];
|
unsigned long data[17];
|
||||||
|
@ -252,8 +251,8 @@ namespace crypto
|
||||||
poly1305::LongBlock m_HR;
|
poly1305::LongBlock m_HR;
|
||||||
uint8_t m_Final;
|
uint8_t m_Final;
|
||||||
};
|
};
|
||||||
|
|
||||||
void Poly1305HMAC(uint64_t * out, const uint64_t * key, const uint8_t * buf, std::size_t sz);
|
void Poly1305HMAC(uint64_t * out, const uint64_t * key, const uint8_t * buf, std::size_t sz);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -32,7 +32,8 @@ namespace data
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @brief tries to bootstrap into I2P network (from local files and servers, with respect of options)
|
/**
|
||||||
|
@brief tries to bootstrap into I2P network (from local files and servers, with respect of options)
|
||||||
*/
|
*/
|
||||||
void Reseeder::Bootstrap ()
|
void Reseeder::Bootstrap ()
|
||||||
{
|
{
|
||||||
|
@ -67,7 +68,8 @@ namespace data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @brief bootstrap from random server, retry 10 times
|
/**
|
||||||
|
* @brief bootstrap from random server, retry 10 times
|
||||||
* @return number of entries added to netDb
|
* @return number of entries added to netDb
|
||||||
*/
|
*/
|
||||||
int Reseeder::ReseedFromServers ()
|
int Reseeder::ReseedFromServers ()
|
||||||
|
@ -95,7 +97,8 @@ namespace data
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @brief bootstrap from HTTPS URL with SU3 file
|
/**
|
||||||
|
* @brief bootstrap from HTTPS URL with SU3 file
|
||||||
* @param url
|
* @param url
|
||||||
* @return number of entries added to netDb
|
* @return number of entries added to netDb
|
||||||
*/
|
*/
|
||||||
|
@ -702,4 +705,3 @@ namespace data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -173,7 +173,6 @@ namespace data
|
||||||
LogPrint (eLogError, "RouterInfo: malformed message");
|
LogPrint (eLogError, "RouterInfo: malformed message");
|
||||||
m_IsUnreachable = true;
|
m_IsUnreachable = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RouterInfo::ReadFromStream (std::istream& s)
|
void RouterInfo::ReadFromStream (std::istream& s)
|
||||||
|
@ -384,7 +383,8 @@ namespace data
|
||||||
SetUnreachable (true);
|
SetUnreachable (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RouterInfo::IsFamily(const std::string & fam) const {
|
bool RouterInfo::IsFamily(const std::string & fam) const
|
||||||
|
{
|
||||||
return m_Family == fam;
|
return m_Family == fam;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -826,4 +826,3 @@ namespace transport
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -135,4 +135,3 @@ namespace transport
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -504,4 +504,3 @@ namespace transport
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -128,4 +128,3 @@ namespace transport
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1206,4 +1206,3 @@ namespace transport
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -158,10 +158,7 @@ namespace transport
|
||||||
std::unique_ptr<SignedData> m_SignedData; // we need it for SessionConfirmed only
|
std::unique_ptr<SignedData> m_SignedData; // we need it for SessionConfirmed only
|
||||||
std::map<uint32_t, std::shared_ptr<const i2p::data::RouterInfo> > m_RelayRequests; // nonce->Charlie
|
std::map<uint32_t, std::shared_ptr<const i2p::data::RouterInfo> > m_RelayRequests; // nonce->Charlie
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -135,5 +135,3 @@ namespace crypto
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -527,4 +527,3 @@ namespace crypto
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
/**
|
/**
|
||||||
This code is licensed under the MCGSI Public License
|
* This code is licensed under the MCGSI Public License
|
||||||
Copyright 2018 Jeff Becker
|
* Copyright 2018 Jeff Becker
|
||||||
|
*
|
||||||
Kovri go write your own code
|
* Kovri go write your own code
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
#ifndef SIPHASH_H
|
#ifndef SIPHASH_H
|
||||||
#define SIPHASH_H
|
#define SIPHASH_H
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
|
|
||||||
namespace i2p {
|
namespace i2p {
|
||||||
namespace data {
|
namespace data {
|
||||||
|
|
||||||
template<size_t sz>
|
template<size_t sz>
|
||||||
class Tag
|
class Tag
|
||||||
{
|
{
|
||||||
|
@ -89,7 +88,6 @@ private:
|
||||||
uint64_t ll[sz/8];
|
uint64_t ll[sz/8];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
} // data
|
} // data
|
||||||
} // i2p
|
} // i2p
|
||||||
|
|
||||||
|
|
|
@ -200,4 +200,3 @@ namespace util
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,4 +46,3 @@ namespace util
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -64,8 +64,7 @@ namespace tunnel
|
||||||
m.hash = i2p::data::IdentHash (fragment);
|
m.hash = i2p::data::IdentHash (fragment);
|
||||||
fragment += 32; // to hash
|
fragment += 32; // to hash
|
||||||
break;
|
break;
|
||||||
default:
|
default: ;
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isFragmented = flag & 0x08;
|
bool isFragmented = flag & 0x08;
|
||||||
|
|
|
@ -219,4 +219,3 @@ namespace tunnel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,6 @@ namespace i2p
|
||||||
{
|
{
|
||||||
namespace tunnel
|
namespace tunnel
|
||||||
{
|
{
|
||||||
|
|
||||||
TunnelPool::TunnelPool (int numInboundHops, int numOutboundHops, int numInboundTunnels, int numOutboundTunnels):
|
TunnelPool::TunnelPool (int numInboundHops, int numOutboundHops, int numInboundTunnels, int numOutboundTunnels):
|
||||||
m_NumInboundHops (numInboundHops), m_NumOutboundHops (numOutboundHops),
|
m_NumInboundHops (numInboundHops), m_NumOutboundHops (numOutboundHops),
|
||||||
m_NumInboundTunnels (numInboundTunnels), m_NumOutboundTunnels (numOutboundTunnels), m_IsActive (true),
|
m_NumInboundTunnels (numInboundTunnels), m_NumOutboundTunnels (numOutboundTunnels), m_IsActive (true),
|
||||||
|
@ -67,7 +66,8 @@ namespace tunnel
|
||||||
m_Tests.clear ();
|
m_Tests.clear ();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TunnelPool::Reconfigure(int inHops, int outHops, int inQuant, int outQuant) {
|
bool TunnelPool::Reconfigure(int inHops, int outHops, int inQuant, int outQuant)
|
||||||
|
{
|
||||||
if( inHops >= 0 && outHops >= 0 && inQuant > 0 && outQuant > 0)
|
if( inHops >= 0 && outHops >= 0 && inQuant > 0 && outQuant > 0)
|
||||||
{
|
{
|
||||||
m_NumInboundHops = inHops;
|
m_NumInboundHops = inHops;
|
||||||
|
|
|
@ -133,4 +133,3 @@ namespace api
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,4 +35,3 @@ namespace api
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -261,7 +261,9 @@ namespace net
|
||||||
sockaddr_in6 inputAddress;
|
sockaddr_in6 inputAddress;
|
||||||
inetpton(AF_INET6, localAddressUniversal.c_str(), &(inputAddress.sin6_addr));
|
inetpton(AF_INET6, localAddressUniversal.c_str(), &(inputAddress.sin6_addr));
|
||||||
return GetMTUWindowsIpv6(inputAddress, fallback);
|
return GetMTUWindowsIpv6(inputAddress, fallback);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
LogPrint(eLogError, "NetIface: GetMTU(): address family is not supported");
|
LogPrint(eLogError, "NetIface: GetMTU(): address family is not supported");
|
||||||
return fallback;
|
return fallback;
|
||||||
}
|
}
|
||||||
|
@ -379,7 +381,6 @@ namespace net
|
||||||
LogPrint(eLogWarning, "NetIface: cannot find ipv4 address for interface ", ifname);
|
LogPrint(eLogWarning, "NetIface: cannot find ipv4 address for interface ", ifname);
|
||||||
}
|
}
|
||||||
return boost::asio::ip::address::from_string(fallback);
|
return boost::asio::ip::address::from_string(fallback);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -160,5 +160,3 @@ namespace client
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -624,8 +624,7 @@ namespace client
|
||||||
}
|
}
|
||||||
// trying to request
|
// trying to request
|
||||||
auto s = shared_from_this ();
|
auto s = shared_from_this ();
|
||||||
auto requstCallback =
|
auto requstCallback = [s](std::shared_ptr<i2p::data::LeaseSet> ls)
|
||||||
[s](std::shared_ptr<i2p::data::LeaseSet> ls)
|
|
||||||
{
|
{
|
||||||
if (ls)
|
if (ls)
|
||||||
s->SendReplyOK (ls->GetIdentity ()->ToBase64 ().c_str ());
|
s->SendReplyOK (ls->GetIdentity ()->ToBase64 ().c_str ());
|
||||||
|
@ -860,4 +859,3 @@ namespace client
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -269,4 +269,3 @@ namespace client
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -769,9 +769,9 @@ namespace client
|
||||||
std::string httpProxyKeys; i2p::config::GetOption("httpproxy.keys", httpProxyKeys);
|
std::string httpProxyKeys; i2p::config::GetOption("httpproxy.keys", httpProxyKeys);
|
||||||
std::string httpProxyAddr; i2p::config::GetOption("httpproxy.address", httpProxyAddr);
|
std::string httpProxyAddr; i2p::config::GetOption("httpproxy.address", httpProxyAddr);
|
||||||
uint16_t httpProxyPort; i2p::config::GetOption("httpproxy.port", httpProxyPort);
|
uint16_t httpProxyPort; i2p::config::GetOption("httpproxy.port", httpProxyPort);
|
||||||
i2p::data::SigningKeyType sigType; i2p::config::GetOption("httpproxy.signaturetype", sigType);
|
|
||||||
std::string httpOutProxyURL; i2p::config::GetOption("httpproxy.outproxy", httpOutProxyURL);
|
std::string httpOutProxyURL; i2p::config::GetOption("httpproxy.outproxy", httpOutProxyURL);
|
||||||
bool httpAddresshelper; i2p::config::GetOption("httpproxy.addresshelper", httpAddresshelper);
|
bool httpAddresshelper; i2p::config::GetOption("httpproxy.addresshelper", httpAddresshelper);
|
||||||
|
i2p::data::SigningKeyType sigType; i2p::config::GetOption("httpproxy.signaturetype", sigType);
|
||||||
LogPrint(eLogInfo, "Clients: starting HTTP Proxy at ", httpProxyAddr, ":", httpProxyPort);
|
LogPrint(eLogInfo, "Clients: starting HTTP Proxy at ", httpProxyAddr, ":", httpProxyPort);
|
||||||
if (httpProxyKeys.length () > 0)
|
if (httpProxyKeys.length () > 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -78,7 +78,8 @@ namespace client
|
||||||
std::shared_ptr<ClientDestination> CreateNewLocalDestination (boost::asio::io_service& service,
|
std::shared_ptr<ClientDestination> CreateNewLocalDestination (boost::asio::io_service& service,
|
||||||
const i2p::data::PrivateKeys& keys, bool isPublic = true,
|
const i2p::data::PrivateKeys& keys, bool isPublic = true,
|
||||||
const std::map<std::string, std::string> * params = nullptr); // same as previous but on external io_service
|
const std::map<std::string, std::string> * params = nullptr); // same as previous but on external io_service
|
||||||
std::shared_ptr<ClientDestination> CreateNewMatchedTunnelDestination(const i2p::data::PrivateKeys &keys, const std::string & name, const std::map<std::string, std::string> * params = nullptr);
|
std::shared_ptr<ClientDestination> CreateNewMatchedTunnelDestination(const i2p::data::PrivateKeys &keys,
|
||||||
|
const std::string & name, const std::map<std::string, std::string> * params = nullptr);
|
||||||
void DeleteLocalDestination (std::shared_ptr<ClientDestination> destination);
|
void DeleteLocalDestination (std::shared_ptr<ClientDestination> destination);
|
||||||
std::shared_ptr<ClientDestination> FindLocalDestination (const i2p::data::IdentHash& destination) const;
|
std::shared_ptr<ClientDestination> FindLocalDestination (const i2p::data::IdentHash& destination) const;
|
||||||
bool LoadPrivateKeys (i2p::data::PrivateKeys& keys, const std::string& filename,
|
bool LoadPrivateKeys (i2p::data::PrivateKeys& keys, const std::string& filename,
|
||||||
|
@ -141,6 +142,7 @@ namespace client
|
||||||
std::unique_ptr<boost::asio::deadline_timer> m_CleanupUDPTimer;
|
std::unique_ptr<boost::asio::deadline_timer> m_CleanupUDPTimer;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// for HTTP
|
// for HTTP
|
||||||
const decltype(m_Destinations)& GetDestinations () const { return m_Destinations; };
|
const decltype(m_Destinations)& GetDestinations () const { return m_Destinations; };
|
||||||
const decltype(m_ClientTunnels)& GetClientTunnels () const { return m_ClientTunnels; };
|
const decltype(m_ClientTunnels)& GetClientTunnels () const { return m_ClientTunnels; };
|
||||||
|
|
|
@ -406,7 +406,7 @@ namespace proxy {
|
||||||
void HTTPReqHandler::ForwardToUpstreamProxy()
|
void HTTPReqHandler::ForwardToUpstreamProxy()
|
||||||
{
|
{
|
||||||
LogPrint(eLogDebug, "HTTPProxy: forward to upstream");
|
LogPrint(eLogDebug, "HTTPProxy: forward to upstream");
|
||||||
// build http requset
|
// build http request
|
||||||
|
|
||||||
m_ClientRequestURL = m_RequestURL;
|
m_ClientRequestURL = m_RequestURL;
|
||||||
LogPrint(eLogDebug, "HTTPProxy: ", m_ClientRequestURL.host);
|
LogPrint(eLogDebug, "HTTPProxy: ", m_ClientRequestURL.host);
|
||||||
|
@ -562,14 +562,16 @@ namespace proxy {
|
||||||
if(m_ClientRequest.method == "CONNECT") {
|
if(m_ClientRequest.method == "CONNECT") {
|
||||||
m_ClientResponse.code = 200;
|
m_ClientResponse.code = 200;
|
||||||
m_send_buf = m_ClientResponse.to_string();
|
m_send_buf = m_ClientResponse.to_string();
|
||||||
boost::asio::async_write(*m_sock, boost::asio::buffer(m_send_buf), boost::asio::transfer_all(), [&] (const boost::system::error_code & ec, std::size_t transferred) {
|
boost::asio::async_write(*m_sock, boost::asio::buffer(m_send_buf), boost::asio::transfer_all(), [&] (const boost::system::error_code & ec, std::size_t transferred)
|
||||||
|
{
|
||||||
if(ec) GenericProxyError("socks proxy error", ec.message().c_str());
|
if(ec) GenericProxyError("socks proxy error", ec.message().c_str());
|
||||||
else HandoverToUpstreamProxy();
|
else HandoverToUpstreamProxy();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
m_send_buf = m_ClientRequestBuffer.str();
|
m_send_buf = m_ClientRequestBuffer.str();
|
||||||
LogPrint(eLogDebug, "HTTPProxy: send ", m_send_buf.size(), " bytes");
|
LogPrint(eLogDebug, "HTTPProxy: send ", m_send_buf.size(), " bytes");
|
||||||
boost::asio::async_write(*m_proxysock, boost::asio::buffer(m_send_buf), boost::asio::transfer_all(), [&](const boost::system::error_code & ec, std::size_t transferred) {
|
boost::asio::async_write(*m_proxysock, boost::asio::buffer(m_send_buf), boost::asio::transfer_all(), [&](const boost::system::error_code & ec, std::size_t transferred)
|
||||||
|
{
|
||||||
if(ec) GenericProxyError("failed to send request to upstream", ec.message().c_str());
|
if(ec) GenericProxyError("failed to send request to upstream", ec.message().c_str());
|
||||||
else HandoverToUpstreamProxy();
|
else HandoverToUpstreamProxy();
|
||||||
});
|
});
|
||||||
|
|
|
@ -6,6 +6,7 @@ namespace proxy {
|
||||||
class HTTPProxy: public i2p::client::TCPIPAcceptor
|
class HTTPProxy: public i2p::client::TCPIPAcceptor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
HTTPProxy(const std::string& name, const std::string& address, int port, const std::string & outproxy, bool addresshelper, std::shared_ptr<i2p::client::ClientDestination> localDestination);
|
HTTPProxy(const std::string& name, const std::string& address, int port, const std::string & outproxy, bool addresshelper, std::shared_ptr<i2p::client::ClientDestination> localDestination);
|
||||||
HTTPProxy(const std::string& name, const std::string& address, int port, std::shared_ptr<i2p::client::ClientDestination> localDestination = nullptr) :
|
HTTPProxy(const std::string& name, const std::string& address, int port, std::shared_ptr<i2p::client::ClientDestination> localDestination = nullptr) :
|
||||||
HTTPProxy(name, address, port, "", true, localDestination) {} ;
|
HTTPProxy(name, address, port, "", true, localDestination) {} ;
|
||||||
|
@ -15,11 +16,13 @@ namespace proxy {
|
||||||
bool GetHelperSupport() { return m_Addresshelper; }
|
bool GetHelperSupport() { return m_Addresshelper; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
// Implements TCPIPAcceptor
|
// Implements TCPIPAcceptor
|
||||||
std::shared_ptr<i2p::client::I2PServiceHandler> CreateHandler(std::shared_ptr<boost::asio::ip::tcp::socket> socket);
|
std::shared_ptr<i2p::client::I2PServiceHandler> CreateHandler(std::shared_ptr<boost::asio::ip::tcp::socket> socket);
|
||||||
const char* GetName() { return m_Name.c_str (); }
|
const char* GetName() { return m_Name.c_str (); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::string m_Name;
|
std::string m_Name;
|
||||||
std::string m_OutproxyUrl;
|
std::string m_OutproxyUrl;
|
||||||
bool m_Addresshelper;
|
bool m_Addresshelper;
|
||||||
|
|
|
@ -899,4 +899,3 @@ namespace client
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -220,4 +220,3 @@ namespace client
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -115,14 +115,16 @@ namespace client
|
||||||
{
|
{
|
||||||
if(m_ConnectTimeout && !m_LocalDestination->IsReady())
|
if(m_ConnectTimeout && !m_LocalDestination->IsReady())
|
||||||
{
|
{
|
||||||
AddReadyCallback([this, streamRequestComplete, address, port] (const boost::system::error_code & ec) {
|
AddReadyCallback([this, streamRequestComplete, address, port] (const boost::system::error_code & ec)
|
||||||
|
{
|
||||||
if(ec)
|
if(ec)
|
||||||
{
|
{
|
||||||
LogPrint(eLogWarning, "I2PService::CreateStream() ", ec.message());
|
LogPrint(eLogWarning, "I2PService::CreateStream() ", ec.message());
|
||||||
streamRequestComplete(nullptr);
|
streamRequestComplete(nullptr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ if (address->IsIdentHash ())
|
{
|
||||||
|
if (address->IsIdentHash ())
|
||||||
this->m_LocalDestination->CreateStream(streamRequestComplete, address->identHash, port);
|
this->m_LocalDestination->CreateStream(streamRequestComplete, address->identHash, port);
|
||||||
else
|
else
|
||||||
this->m_LocalDestination->CreateStream (streamRequestComplete, address->blindedPublicKey, port);
|
this->m_LocalDestination->CreateStream (streamRequestComplete, address->blindedPublicKey, port);
|
||||||
|
|
|
@ -18,9 +18,11 @@ namespace client
|
||||||
class I2PService : public std::enable_shared_from_this<I2PService>
|
class I2PService : public std::enable_shared_from_this<I2PService>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef std::function<void(const boost::system::error_code &)> ReadyCallback;
|
typedef std::function<void(const boost::system::error_code &)> ReadyCallback;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
I2PService (std::shared_ptr<ClientDestination> localDestination = nullptr);
|
I2PService (std::shared_ptr<ClientDestination> localDestination = nullptr);
|
||||||
I2PService (i2p::data::SigningKeyType kt);
|
I2PService (i2p::data::SigningKeyType kt);
|
||||||
virtual ~I2PService ();
|
virtual ~I2PService ();
|
||||||
|
@ -59,10 +61,12 @@ namespace client
|
||||||
virtual const char* GetName() { return "Generic I2P Service"; }
|
virtual const char* GetName() { return "Generic I2P Service"; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void TriggerReadyCheckTimer();
|
void TriggerReadyCheckTimer();
|
||||||
void HandleReadyCheckTimer(const boost::system::error_code & ec);
|
void HandleReadyCheckTimer(const boost::system::error_code & ec);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::shared_ptr<ClientDestination> m_LocalDestination;
|
std::shared_ptr<ClientDestination> m_LocalDestination;
|
||||||
std::unordered_set<std::shared_ptr<I2PServiceHandler> > m_Handlers;
|
std::unordered_set<std::shared_ptr<I2PServiceHandler> > m_Handlers;
|
||||||
std::mutex m_HandlersMutex;
|
std::mutex m_HandlersMutex;
|
||||||
|
@ -74,6 +78,7 @@ namespace client
|
||||||
const size_t NEVER_TIMES_OUT = 0;
|
const size_t NEVER_TIMES_OUT = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
bool isUpdated; // transient, used during reload only
|
bool isUpdated; // transient, used during reload only
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -81,6 +86,7 @@ namespace client
|
||||||
class I2PServiceHandler
|
class I2PServiceHandler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
I2PServiceHandler(I2PService * parent) : m_Service(parent), m_Dead(false) { }
|
I2PServiceHandler(I2PService * parent) : m_Service(parent), m_Dead(false) { }
|
||||||
virtual ~I2PServiceHandler() { }
|
virtual ~I2PServiceHandler() { }
|
||||||
//If you override this make sure you call it from the children
|
//If you override this make sure you call it from the children
|
||||||
|
@ -89,6 +95,7 @@ namespace client
|
||||||
void Terminate () { Kill (); };
|
void Terminate () { Kill (); };
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
// Call when terminating or handing over to avoid race conditions
|
// Call when terminating or handing over to avoid race conditions
|
||||||
inline bool Kill () { return m_Dead.exchange(true); }
|
inline bool Kill () { return m_Dead.exchange(true); }
|
||||||
// Call to know if the handler is dead
|
// Call to know if the handler is dead
|
||||||
|
@ -99,6 +106,7 @@ namespace client
|
||||||
inline I2PService * GetOwner() { return m_Service; }
|
inline I2PService * GetOwner() { return m_Service; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
I2PService *m_Service;
|
I2PService *m_Service;
|
||||||
std::atomic<bool> m_Dead; //To avoid cleaning up multiple times
|
std::atomic<bool> m_Dead; //To avoid cleaning up multiple times
|
||||||
};
|
};
|
||||||
|
@ -109,11 +117,13 @@ namespace client
|
||||||
class TCPIPPipe: public I2PServiceHandler, public std::enable_shared_from_this<TCPIPPipe>
|
class TCPIPPipe: public I2PServiceHandler, public std::enable_shared_from_this<TCPIPPipe>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
TCPIPPipe(I2PService * owner, std::shared_ptr<boost::asio::ip::tcp::socket> upstream, std::shared_ptr<boost::asio::ip::tcp::socket> downstream);
|
TCPIPPipe(I2PService * owner, std::shared_ptr<boost::asio::ip::tcp::socket> upstream, std::shared_ptr<boost::asio::ip::tcp::socket> downstream);
|
||||||
~TCPIPPipe();
|
~TCPIPPipe();
|
||||||
void Start();
|
void Start();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void Terminate();
|
void Terminate();
|
||||||
void AsyncReceiveUpstream();
|
void AsyncReceiveUpstream();
|
||||||
void AsyncReceiveDownstream();
|
void AsyncReceiveDownstream();
|
||||||
|
@ -125,6 +135,7 @@ namespace client
|
||||||
void DownstreamWrite(size_t len);
|
void DownstreamWrite(size_t len);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
uint8_t m_upstream_to_down_buf[TCP_IP_PIPE_BUFFER_SIZE], m_downstream_to_up_buf[TCP_IP_PIPE_BUFFER_SIZE];
|
uint8_t m_upstream_to_down_buf[TCP_IP_PIPE_BUFFER_SIZE], m_downstream_to_up_buf[TCP_IP_PIPE_BUFFER_SIZE];
|
||||||
uint8_t m_upstream_buf[TCP_IP_PIPE_BUFFER_SIZE], m_downstream_buf[TCP_IP_PIPE_BUFFER_SIZE];
|
uint8_t m_upstream_buf[TCP_IP_PIPE_BUFFER_SIZE], m_downstream_buf[TCP_IP_PIPE_BUFFER_SIZE];
|
||||||
std::shared_ptr<boost::asio::ip::tcp::socket> m_up, m_down;
|
std::shared_ptr<boost::asio::ip::tcp::socket> m_up, m_down;
|
||||||
|
@ -135,6 +146,7 @@ namespace client
|
||||||
class TCPIPAcceptor: public I2PService
|
class TCPIPAcceptor: public I2PService
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
TCPIPAcceptor (const std::string& address, int port, std::shared_ptr<ClientDestination> localDestination = nullptr) :
|
TCPIPAcceptor (const std::string& address, int port, std::shared_ptr<ClientDestination> localDestination = nullptr) :
|
||||||
I2PService(localDestination),
|
I2PService(localDestination),
|
||||||
m_LocalEndpoint (boost::asio::ip::address::from_string(address), port),
|
m_LocalEndpoint (boost::asio::ip::address::from_string(address), port),
|
||||||
|
@ -154,9 +166,11 @@ namespace client
|
||||||
virtual const char* GetName() { return "Generic TCP/IP accepting daemon"; }
|
virtual const char* GetName() { return "Generic TCP/IP accepting daemon"; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
virtual std::shared_ptr<I2PServiceHandler> CreateHandler(std::shared_ptr<boost::asio::ip::tcp::socket> socket) = 0;
|
virtual std::shared_ptr<I2PServiceHandler> CreateHandler(std::shared_ptr<boost::asio::ip::tcp::socket> socket) = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void Accept();
|
void Accept();
|
||||||
void HandleAccept(const boost::system::error_code& ecode, std::shared_ptr<boost::asio::ip::tcp::socket> socket);
|
void HandleAccept(const boost::system::error_code& ecode, std::shared_ptr<boost::asio::ip::tcp::socket> socket);
|
||||||
boost::asio::ip::tcp::endpoint m_LocalEndpoint;
|
boost::asio::ip::tcp::endpoint m_LocalEndpoint;
|
||||||
|
|
|
@ -30,6 +30,7 @@ namespace client
|
||||||
class I2PTunnelConnection: public I2PServiceHandler, public std::enable_shared_from_this<I2PTunnelConnection>
|
class I2PTunnelConnection: public I2PServiceHandler, public std::enable_shared_from_this<I2PTunnelConnection>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
I2PTunnelConnection (I2PService * owner, std::shared_ptr<boost::asio::ip::tcp::socket> socket,
|
I2PTunnelConnection (I2PService * owner, std::shared_ptr<boost::asio::ip::tcp::socket> socket,
|
||||||
std::shared_ptr<const i2p::data::LeaseSet> leaseSet, int port = 0); // to I2P
|
std::shared_ptr<const i2p::data::LeaseSet> leaseSet, int port = 0); // to I2P
|
||||||
I2PTunnelConnection (I2PService * owner, std::shared_ptr<boost::asio::ip::tcp::socket> socket,
|
I2PTunnelConnection (I2PService * owner, std::shared_ptr<boost::asio::ip::tcp::socket> socket,
|
||||||
|
@ -41,6 +42,7 @@ namespace client
|
||||||
void Connect (bool isUniqueLocal = true);
|
void Connect (bool isUniqueLocal = true);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void Terminate ();
|
void Terminate ();
|
||||||
|
|
||||||
void Receive ();
|
void Receive ();
|
||||||
|
@ -55,6 +57,7 @@ namespace client
|
||||||
std::shared_ptr<const boost::asio::ip::tcp::socket> GetSocket () const { return m_Socket; };
|
std::shared_ptr<const boost::asio::ip::tcp::socket> GetSocket () const { return m_Socket; };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
uint8_t m_Buffer[I2P_TUNNEL_CONNECTION_BUFFER_SIZE], m_StreamBuffer[I2P_TUNNEL_CONNECTION_BUFFER_SIZE];
|
uint8_t m_Buffer[I2P_TUNNEL_CONNECTION_BUFFER_SIZE], m_StreamBuffer[I2P_TUNNEL_CONNECTION_BUFFER_SIZE];
|
||||||
std::shared_ptr<boost::asio::ip::tcp::socket> m_Socket;
|
std::shared_ptr<boost::asio::ip::tcp::socket> m_Socket;
|
||||||
std::shared_ptr<i2p::stream::Stream> m_Stream;
|
std::shared_ptr<i2p::stream::Stream> m_Stream;
|
||||||
|
@ -65,15 +68,18 @@ namespace client
|
||||||
class I2PClientTunnelConnectionHTTP: public I2PTunnelConnection
|
class I2PClientTunnelConnectionHTTP: public I2PTunnelConnection
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
I2PClientTunnelConnectionHTTP (I2PService * owner, std::shared_ptr<boost::asio::ip::tcp::socket> socket,
|
I2PClientTunnelConnectionHTTP (I2PService * owner, std::shared_ptr<boost::asio::ip::tcp::socket> socket,
|
||||||
std::shared_ptr<i2p::stream::Stream> stream):
|
std::shared_ptr<i2p::stream::Stream> stream):
|
||||||
I2PTunnelConnection (owner, socket, stream), m_HeaderSent (false),
|
I2PTunnelConnection (owner, socket, stream), m_HeaderSent (false),
|
||||||
m_ConnectionSent (false), m_ProxyConnectionSent (false) {};
|
m_ConnectionSent (false), m_ProxyConnectionSent (false) {};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void Write (const uint8_t * buf, size_t len);
|
void Write (const uint8_t * buf, size_t len);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::stringstream m_InHeader, m_OutHeader;
|
std::stringstream m_InHeader, m_OutHeader;
|
||||||
bool m_HeaderSent, m_ConnectionSent, m_ProxyConnectionSent;
|
bool m_HeaderSent, m_ConnectionSent, m_ProxyConnectionSent;
|
||||||
};
|
};
|
||||||
|
@ -81,14 +87,17 @@ namespace client
|
||||||
class I2PServerTunnelConnectionHTTP: public I2PTunnelConnection
|
class I2PServerTunnelConnectionHTTP: public I2PTunnelConnection
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
I2PServerTunnelConnectionHTTP (I2PService * owner, std::shared_ptr<i2p::stream::Stream> stream,
|
I2PServerTunnelConnectionHTTP (I2PService * owner, std::shared_ptr<i2p::stream::Stream> stream,
|
||||||
std::shared_ptr<boost::asio::ip::tcp::socket> socket,
|
std::shared_ptr<boost::asio::ip::tcp::socket> socket,
|
||||||
const boost::asio::ip::tcp::endpoint& target, const std::string& host);
|
const boost::asio::ip::tcp::endpoint& target, const std::string& host);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void Write (const uint8_t * buf, size_t len);
|
void Write (const uint8_t * buf, size_t len);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::string m_Host;
|
std::string m_Host;
|
||||||
std::stringstream m_InHeader, m_OutHeader;
|
std::stringstream m_InHeader, m_OutHeader;
|
||||||
bool m_HeaderSent;
|
bool m_HeaderSent;
|
||||||
|
@ -98,14 +107,17 @@ namespace client
|
||||||
class I2PTunnelConnectionIRC: public I2PTunnelConnection
|
class I2PTunnelConnectionIRC: public I2PTunnelConnection
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
I2PTunnelConnectionIRC (I2PService * owner, std::shared_ptr<i2p::stream::Stream> stream,
|
I2PTunnelConnectionIRC (I2PService * owner, std::shared_ptr<i2p::stream::Stream> stream,
|
||||||
std::shared_ptr<boost::asio::ip::tcp::socket> socket,
|
std::shared_ptr<boost::asio::ip::tcp::socket> socket,
|
||||||
const boost::asio::ip::tcp::endpoint& target, const std::string& m_WebircPass);
|
const boost::asio::ip::tcp::endpoint& target, const std::string& m_WebircPass);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void Write (const uint8_t * buf, size_t len);
|
void Write (const uint8_t * buf, size_t len);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::shared_ptr<const i2p::data::IdentityEx> m_From;
|
std::shared_ptr<const i2p::data::IdentityEx> m_From;
|
||||||
std::stringstream m_OutPacket, m_InPacket;
|
std::stringstream m_OutPacket, m_InPacket;
|
||||||
bool m_NeedsWebIrc;
|
bool m_NeedsWebIrc;
|
||||||
|
@ -116,10 +128,12 @@ namespace client
|
||||||
class I2PClientTunnel: public TCPIPAcceptor
|
class I2PClientTunnel: public TCPIPAcceptor
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
// Implements TCPIPAcceptor
|
// Implements TCPIPAcceptor
|
||||||
std::shared_ptr<I2PServiceHandler> CreateHandler(std::shared_ptr<boost::asio::ip::tcp::socket> socket);
|
std::shared_ptr<I2PServiceHandler> CreateHandler(std::shared_ptr<boost::asio::ip::tcp::socket> socket);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
I2PClientTunnel (const std::string& name, const std::string& destination,
|
I2PClientTunnel (const std::string& name, const std::string& destination,
|
||||||
const std::string& address, int port, std::shared_ptr<ClientDestination> localDestination, int destinationPort = 0);
|
const std::string& address, int port, std::shared_ptr<ClientDestination> localDestination, int destinationPort = 0);
|
||||||
~I2PClientTunnel () {}
|
~I2PClientTunnel () {}
|
||||||
|
@ -130,9 +144,11 @@ namespace client
|
||||||
const char* GetName() { return m_Name.c_str (); }
|
const char* GetName() { return m_Name.c_str (); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::shared_ptr<const Address> GetAddress ();
|
std::shared_ptr<const Address> GetAddress ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::string m_Name, m_Destination;
|
std::string m_Name, m_Destination;
|
||||||
std::shared_ptr<const Address> m_Address;
|
std::shared_ptr<const Address> m_Address;
|
||||||
int m_DestinationPort;
|
int m_DestinationPort;
|
||||||
|
@ -195,6 +211,7 @@ namespace client
|
||||||
class I2PUDPServerTunnel
|
class I2PUDPServerTunnel
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
I2PUDPServerTunnel(const std::string & name,
|
I2PUDPServerTunnel(const std::string & name,
|
||||||
std::shared_ptr<i2p::client::ClientDestination> localDestination,
|
std::shared_ptr<i2p::client::ClientDestination> localDestination,
|
||||||
boost::asio::ip::address localAddress,
|
boost::asio::ip::address localAddress,
|
||||||
|
@ -210,10 +227,12 @@ namespace client
|
||||||
void SetUniqueLocal(bool isUniqueLocal = true) { m_IsUniqueLocal = isUniqueLocal; }
|
void SetUniqueLocal(bool isUniqueLocal = true) { m_IsUniqueLocal = isUniqueLocal; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void HandleRecvFromI2P(const i2p::data::IdentityEx& from, uint16_t fromPort, uint16_t toPort, const uint8_t * buf, size_t len);
|
void HandleRecvFromI2P(const i2p::data::IdentityEx& from, uint16_t fromPort, uint16_t toPort, const uint8_t * buf, size_t len);
|
||||||
UDPSessionPtr ObtainUDPSession(const i2p::data::IdentityEx& from, uint16_t localPort, uint16_t remotePort);
|
UDPSessionPtr ObtainUDPSession(const i2p::data::IdentityEx& from, uint16_t localPort, uint16_t remotePort);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool m_IsUniqueLocal;
|
bool m_IsUniqueLocal;
|
||||||
const std::string m_Name;
|
const std::string m_Name;
|
||||||
boost::asio::ip::address m_LocalAddress;
|
boost::asio::ip::address m_LocalAddress;
|
||||||
|
@ -226,6 +245,7 @@ namespace client
|
||||||
class I2PUDPClientTunnel
|
class I2PUDPClientTunnel
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
I2PUDPClientTunnel(const std::string & name, const std::string &remoteDest,
|
I2PUDPClientTunnel(const std::string & name, const std::string &remoteDest,
|
||||||
boost::asio::ip::udp::endpoint localEndpoint, std::shared_ptr<i2p::client::ClientDestination> localDestination,
|
boost::asio::ip::udp::endpoint localEndpoint, std::shared_ptr<i2p::client::ClientDestination> localDestination,
|
||||||
uint16_t remotePort, bool gzip);
|
uint16_t remotePort, bool gzip);
|
||||||
|
@ -240,6 +260,7 @@ namespace client
|
||||||
void ExpireStale(const uint64_t delta=I2P_UDP_SESSION_TIMEOUT);
|
void ExpireStale(const uint64_t delta=I2P_UDP_SESSION_TIMEOUT);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
typedef std::pair<boost::asio::ip::udp::endpoint, uint64_t> UDPConvo;
|
typedef std::pair<boost::asio::ip::udp::endpoint, uint64_t> UDPConvo;
|
||||||
void RecvFromLocal();
|
void RecvFromLocal();
|
||||||
void HandleRecvFromLocal(const boost::system::error_code & e, std::size_t transferred);
|
void HandleRecvFromLocal(const boost::system::error_code & e, std::size_t transferred);
|
||||||
|
@ -263,6 +284,7 @@ namespace client
|
||||||
class I2PServerTunnel: public I2PService
|
class I2PServerTunnel: public I2PService
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
I2PServerTunnel (const std::string& name, const std::string& address, int port,
|
I2PServerTunnel (const std::string& name, const std::string& address, int port,
|
||||||
std::shared_ptr<ClientDestination> localDestination, int inport = 0, bool gzip = true);
|
std::shared_ptr<ClientDestination> localDestination, int inport = 0, bool gzip = true);
|
||||||
|
|
||||||
|
@ -282,6 +304,7 @@ namespace client
|
||||||
const char* GetName() { return m_Name.c_str (); }
|
const char* GetName() { return m_Name.c_str (); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void HandleResolve (const boost::system::error_code& ecode, boost::asio::ip::tcp::resolver::iterator it,
|
void HandleResolve (const boost::system::error_code& ecode, boost::asio::ip::tcp::resolver::iterator it,
|
||||||
std::shared_ptr<boost::asio::ip::tcp::resolver> resolver);
|
std::shared_ptr<boost::asio::ip::tcp::resolver> resolver);
|
||||||
|
|
||||||
|
@ -290,6 +313,7 @@ namespace client
|
||||||
virtual std::shared_ptr<I2PTunnelConnection> CreateI2PConnection (std::shared_ptr<i2p::stream::Stream> stream);
|
virtual std::shared_ptr<I2PTunnelConnection> CreateI2PConnection (std::shared_ptr<i2p::stream::Stream> stream);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool m_IsUniqueLocal;
|
bool m_IsUniqueLocal;
|
||||||
std::string m_Name, m_Address;
|
std::string m_Name, m_Address;
|
||||||
int m_Port;
|
int m_Port;
|
||||||
|
@ -302,28 +326,34 @@ namespace client
|
||||||
class I2PServerTunnelHTTP: public I2PServerTunnel
|
class I2PServerTunnelHTTP: public I2PServerTunnel
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
I2PServerTunnelHTTP (const std::string& name, const std::string& address, int port,
|
I2PServerTunnelHTTP (const std::string& name, const std::string& address, int port,
|
||||||
std::shared_ptr<ClientDestination> localDestination, const std::string& host,
|
std::shared_ptr<ClientDestination> localDestination, const std::string& host,
|
||||||
int inport = 0, bool gzip = true);
|
int inport = 0, bool gzip = true);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::shared_ptr<I2PTunnelConnection> CreateI2PConnection (std::shared_ptr<i2p::stream::Stream> stream);
|
std::shared_ptr<I2PTunnelConnection> CreateI2PConnection (std::shared_ptr<i2p::stream::Stream> stream);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::string m_Host;
|
std::string m_Host;
|
||||||
};
|
};
|
||||||
|
|
||||||
class I2PServerTunnelIRC: public I2PServerTunnel
|
class I2PServerTunnelIRC: public I2PServerTunnel
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
I2PServerTunnelIRC (const std::string& name, const std::string& address, int port,
|
I2PServerTunnelIRC (const std::string& name, const std::string& address, int port,
|
||||||
std::shared_ptr<ClientDestination> localDestination, const std::string& webircpass,
|
std::shared_ptr<ClientDestination> localDestination, const std::string& webircpass,
|
||||||
int inport = 0, bool gzip = true);
|
int inport = 0, bool gzip = true);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::shared_ptr<I2PTunnelConnection> CreateI2PConnection (std::shared_ptr<i2p::stream::Stream> stream);
|
std::shared_ptr<I2PTunnelConnection> CreateI2PConnection (std::shared_ptr<i2p::stream::Stream> stream);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::string m_WebircPass;
|
std::string m_WebircPass;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,22 +8,26 @@ namespace i2p
|
||||||
namespace client
|
namespace client
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
client tunnel that uses same OBEP as IBGW of each remote lease for a remote destination
|
* client tunnel that uses same OBEP as IBGW of each remote lease for a remote destination
|
||||||
*/
|
*/
|
||||||
class MatchedTunnelDestination : public RunnableClientDestination, public i2p::tunnel::ITunnelPeerSelector
|
class MatchedTunnelDestination : public RunnableClientDestination, public i2p::tunnel::ITunnelPeerSelector
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MatchedTunnelDestination(const i2p::data::PrivateKeys& keys, const std::string & remoteName, const std::map<std::string, std::string> * params = nullptr);
|
|
||||||
|
MatchedTunnelDestination(const i2p::data::PrivateKeys& keys, const std::string & remoteName,
|
||||||
|
const std::map<std::string, std::string> * params = nullptr);
|
||||||
void Start();
|
void Start();
|
||||||
void Stop();
|
void Stop();
|
||||||
|
|
||||||
bool SelectPeers(i2p::tunnel::Path & peers, int hops, bool inbound);
|
bool SelectPeers(i2p::tunnel::Path & peers, int hops, bool inbound);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void ResolveCurrentLeaseSet();
|
void ResolveCurrentLeaseSet();
|
||||||
void HandleFoundCurrentLeaseSet(std::shared_ptr<const i2p::data::LeaseSet> ls);
|
void HandleFoundCurrentLeaseSet(std::shared_ptr<const i2p::data::LeaseSet> ls);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::string m_RemoteName;
|
std::string m_RemoteName;
|
||||||
i2p::data::IdentHash m_RemoteIdent;
|
i2p::data::IdentHash m_RemoteIdent;
|
||||||
std::shared_ptr<const i2p::data::LeaseSet> m_RemoteLeaseSet;
|
std::shared_ptr<const i2p::data::LeaseSet> m_RemoteLeaseSet;
|
||||||
|
|
|
@ -54,8 +54,7 @@ namespace client
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default: ;
|
||||||
;
|
|
||||||
}
|
}
|
||||||
m_SocketType = eSAMSocketTypeTerminated;
|
m_SocketType = eSAMSocketTypeTerminated;
|
||||||
if (m_Socket.is_open ())
|
if (m_Socket.is_open ())
|
||||||
|
|
|
@ -99,6 +99,7 @@ namespace client
|
||||||
bool IsSession(const std::string & id) const;
|
bool IsSession(const std::string & id) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void TerminateClose() { Terminate(nullptr); }
|
void TerminateClose() { Terminate(nullptr); }
|
||||||
|
|
||||||
void HandleHandshakeReceived (const boost::system::error_code& ecode, std::size_t bytes_transferred);
|
void HandleHandshakeReceived (const boost::system::error_code& ecode, std::size_t bytes_transferred);
|
||||||
|
|
|
@ -41,6 +41,7 @@ namespace proxy
|
||||||
class SOCKSHandler: public i2p::client::I2PServiceHandler, public std::enable_shared_from_this<SOCKSHandler>
|
class SOCKSHandler: public i2p::client::I2PServiceHandler, public std::enable_shared_from_this<SOCKSHandler>
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
enum state
|
enum state
|
||||||
{
|
{
|
||||||
GET_SOCKSV,
|
GET_SOCKSV,
|
||||||
|
@ -165,6 +166,7 @@ namespace proxy
|
||||||
const uint16_t m_UpstreamProxyPort;
|
const uint16_t m_UpstreamProxyPort;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
SOCKSHandler(SOCKSServer * parent, std::shared_ptr<boost::asio::ip::tcp::socket> sock, const std::string & upstreamAddr, const uint16_t upstreamPort, const bool useUpstream) :
|
SOCKSHandler(SOCKSServer * parent, std::shared_ptr<boost::asio::ip::tcp::socket> sock, const std::string & upstreamAddr, const uint16_t upstreamPort, const bool useUpstream) :
|
||||||
I2PServiceHandler(parent),
|
I2PServiceHandler(parent),
|
||||||
m_proxy_resolver(parent->GetService()),
|
m_proxy_resolver(parent->GetService()),
|
||||||
|
@ -652,8 +654,7 @@ namespace proxy
|
||||||
LogPrint(eLogDebug, "SOCKS: async upstream sock read");
|
LogPrint(eLogDebug, "SOCKS: async upstream sock read");
|
||||||
if (m_upstreamSock) {
|
if (m_upstreamSock) {
|
||||||
m_upstreamSock->async_read_some(boost::asio::buffer(m_upstream_response, SOCKS_UPSTREAM_SOCKS4A_REPLY_SIZE),
|
m_upstreamSock->async_read_some(boost::asio::buffer(m_upstream_response, SOCKS_UPSTREAM_SOCKS4A_REPLY_SIZE),
|
||||||
std::bind(&SOCKSHandler::HandleUpstreamSockRecv, shared_from_this(),
|
std::bind(&SOCKSHandler::HandleUpstreamSockRecv, shared_from_this(), std::placeholders::_1, std::placeholders::_2));
|
||||||
std::placeholders::_1, std::placeholders::_2));
|
|
||||||
} else {
|
} else {
|
||||||
LogPrint(eLogError, "SOCKS: no upstream socket for read");
|
LogPrint(eLogError, "SOCKS: no upstream socket for read");
|
||||||
SocksRequestFailed(SOCKS5_GEN_FAIL);
|
SocksRequestFailed(SOCKS5_GEN_FAIL);
|
||||||
|
|
|
@ -14,6 +14,7 @@ namespace proxy
|
||||||
class SOCKSServer: public i2p::client::TCPIPAcceptor
|
class SOCKSServer: public i2p::client::TCPIPAcceptor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
SOCKSServer(const std::string& name, const std::string& address, int port, bool outEnable, const std::string& outAddress, uint16_t outPort,
|
SOCKSServer(const std::string& name, const std::string& address, int port, bool outEnable, const std::string& outAddress, uint16_t outPort,
|
||||||
std::shared_ptr<i2p::client::ClientDestination> localDestination = nullptr);
|
std::shared_ptr<i2p::client::ClientDestination> localDestination = nullptr);
|
||||||
~SOCKSServer() {};
|
~SOCKSServer() {};
|
||||||
|
@ -21,6 +22,7 @@ namespace proxy
|
||||||
void SetUpstreamProxy(const std::string & addr, const uint16_t port);
|
void SetUpstreamProxy(const std::string & addr, const uint16_t port);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
// Implements TCPIPAcceptor
|
// Implements TCPIPAcceptor
|
||||||
std::shared_ptr<i2p::client::I2PServiceHandler> CreateHandler(std::shared_ptr<boost::asio::ip::tcp::socket> socket);
|
std::shared_ptr<i2p::client::I2PServiceHandler> CreateHandler(std::shared_ptr<boost::asio::ip::tcp::socket> socket);
|
||||||
const char* GetName() { return m_Name.c_str (); }
|
const char* GetName() { return m_Name.c_str (); }
|
||||||
|
|
Loading…
Reference in a new issue