mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 12:24:19 +00:00
start/stop accepting transit tunnels
This commit is contained in:
parent
ba96288438
commit
6fd5db250b
@ -6,9 +6,10 @@
|
|||||||
#include "TransitTunnel.h"
|
#include "TransitTunnel.h"
|
||||||
#include "Transports.h"
|
#include "Transports.h"
|
||||||
#include "NetDb.h"
|
#include "NetDb.h"
|
||||||
#include "HTTPServer.h"
|
|
||||||
#include "I2PEndian.h"
|
#include "I2PEndian.h"
|
||||||
#include "Streaming.h"
|
#include "Streaming.h"
|
||||||
|
#include "RouterContext.h"
|
||||||
|
#include "HTTPServer.h"
|
||||||
|
|
||||||
// For image and info
|
// For image and info
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
@ -461,6 +462,8 @@ namespace util
|
|||||||
const char HTTP_COMMAND_TUNNELS[] = "tunnels";
|
const char HTTP_COMMAND_TUNNELS[] = "tunnels";
|
||||||
const char HTTP_COMMAND_TRANSIT_TUNNELS[] = "transit_tunnels";
|
const char HTTP_COMMAND_TRANSIT_TUNNELS[] = "transit_tunnels";
|
||||||
const char HTTP_COMMAND_TRANSPORTS[] = "transports";
|
const char HTTP_COMMAND_TRANSPORTS[] = "transports";
|
||||||
|
const char HTTP_COMMAND_START_ACCEPTING_TUNNELS[] = "start_accepting_tunnels";
|
||||||
|
const char HTTP_COMMAND_STOP_ACCEPTING_TUNNELS[] = "stop_accepting_tunnels";
|
||||||
const char HTTP_COMMAND_LOCAL_DESTINATIONS[] = "local_destinations";
|
const char HTTP_COMMAND_LOCAL_DESTINATIONS[] = "local_destinations";
|
||||||
const char HTTP_COMMAND_LOCAL_DESTINATION[] = "local_destination";
|
const char HTTP_COMMAND_LOCAL_DESTINATION[] = "local_destination";
|
||||||
const char HTTP_PARAM_BASE32_ADDRESS[] = "b32";
|
const char HTTP_PARAM_BASE32_ADDRESS[] = "b32";
|
||||||
@ -654,6 +657,11 @@ namespace util
|
|||||||
s << "<br><b><a href=/?" << HTTP_COMMAND_TRANSIT_TUNNELS << ">Transit tunnels</a></b>";
|
s << "<br><b><a href=/?" << HTTP_COMMAND_TRANSIT_TUNNELS << ">Transit tunnels</a></b>";
|
||||||
s << "<br><b><a href=/?" << HTTP_COMMAND_TRANSPORTS << ">Transports</a></b><br>";
|
s << "<br><b><a href=/?" << HTTP_COMMAND_TRANSPORTS << ">Transports</a></b><br>";
|
||||||
|
|
||||||
|
if (i2p::context.AcceptsTunnels ())
|
||||||
|
s << "<br><b><a href=/?" << HTTP_COMMAND_STOP_ACCEPTING_TUNNELS << ">Stop accepting tunnels</a></b><br>";
|
||||||
|
else
|
||||||
|
s << "<br><b><a href=/?" << HTTP_COMMAND_START_ACCEPTING_TUNNELS << ">Start accepting tunnels</a></b><br>";
|
||||||
|
|
||||||
s << "<p><a href=\"zmw2cyw2vj7f6obx3msmdvdepdhnw2ctc4okza2zjxlukkdfckhq.b32.i2p\">Flibusta</a></p>";
|
s << "<p><a href=\"zmw2cyw2vj7f6obx3msmdvdepdhnw2ctc4okza2zjxlukkdfckhq.b32.i2p\">Flibusta</a></p>";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -667,6 +675,10 @@ namespace util
|
|||||||
ShowTunnels (s);
|
ShowTunnels (s);
|
||||||
else if (cmd == HTTP_COMMAND_TRANSIT_TUNNELS)
|
else if (cmd == HTTP_COMMAND_TRANSIT_TUNNELS)
|
||||||
ShowTransitTunnels (s);
|
ShowTransitTunnels (s);
|
||||||
|
else if (cmd == HTTP_COMMAND_START_ACCEPTING_TUNNELS)
|
||||||
|
StartAcceptingTunnels (s);
|
||||||
|
else if (cmd == HTTP_COMMAND_STOP_ACCEPTING_TUNNELS)
|
||||||
|
StopAcceptingTunnels (s);
|
||||||
else if (cmd == HTTP_COMMAND_LOCAL_DESTINATIONS)
|
else if (cmd == HTTP_COMMAND_LOCAL_DESTINATIONS)
|
||||||
ShowLocalDestinations (s);
|
ShowLocalDestinations (s);
|
||||||
else if (cmd == HTTP_COMMAND_LOCAL_DESTINATION)
|
else if (cmd == HTTP_COMMAND_LOCAL_DESTINATION)
|
||||||
@ -795,6 +807,18 @@ namespace util
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HTTPConnection::StartAcceptingTunnels (std::stringstream& s)
|
||||||
|
{
|
||||||
|
i2p::context.SetAcceptsTunnels (true);
|
||||||
|
s << "Accepting tunnels started" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HTTPConnection::StopAcceptingTunnels (std::stringstream& s)
|
||||||
|
{
|
||||||
|
i2p::context.SetAcceptsTunnels (false);
|
||||||
|
s << "Accepting tunnels stopped" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
void HTTPConnection::HandleDestinationRequest (const std::string& address, const std::string& uri)
|
void HTTPConnection::HandleDestinationRequest (const std::string& address, const std::string& uri)
|
||||||
{
|
{
|
||||||
std::string request = "GET " + uri + " HTTP/1.1\r\nHost:" + address + "\r\n";
|
std::string request = "GET " + uri + " HTTP/1.1\r\nHost:" + address + "\r\n";
|
||||||
|
@ -64,6 +64,8 @@ namespace util
|
|||||||
void ShowTransitTunnels (std::stringstream& s);
|
void ShowTransitTunnels (std::stringstream& s);
|
||||||
void ShowLocalDestinations (std::stringstream& s);
|
void ShowLocalDestinations (std::stringstream& s);
|
||||||
void ShowLocalDestination (const std::string& b32, std::stringstream& s);
|
void ShowLocalDestination (const std::string& b32, std::stringstream& s);
|
||||||
|
void StartAcceptingTunnels (std::stringstream& s);
|
||||||
|
void StopAcceptingTunnels (std::stringstream& s);
|
||||||
void FillContent (std::stringstream& s);
|
void FillContent (std::stringstream& s);
|
||||||
std::string ExtractAddress ();
|
std::string ExtractAddress ();
|
||||||
void ExtractParams (const std::string& str, std::map<std::string, std::string>& params);
|
void ExtractParams (const std::string& str, std::map<std::string, std::string>& params);
|
||||||
|
@ -297,7 +297,7 @@ namespace i2p
|
|||||||
i2p::tunnel::tunnels.AddTransitTunnel (transitTunnel);
|
i2p::tunnel::tunnels.AddTransitTunnel (transitTunnel);
|
||||||
// replace record to reply
|
// replace record to reply
|
||||||
I2NPBuildResponseRecord * reply = (I2NPBuildResponseRecord *)(records + i);
|
I2NPBuildResponseRecord * reply = (I2NPBuildResponseRecord *)(records + i);
|
||||||
reply->ret = 0;
|
reply->ret = i2p::context.AcceptsTunnels () ? 0 : 30; // always reject with bandwidth reason (30)
|
||||||
//TODO: fill filler
|
//TODO: fill filler
|
||||||
CryptoPP::SHA256().CalculateDigest(reply->hash, reply->padding, sizeof (reply->padding) + 1); // + 1 byte of ret
|
CryptoPP::SHA256().CalculateDigest(reply->hash, reply->padding, sizeof (reply->padding) + 1); // + 1 byte of ret
|
||||||
// encrypt reply
|
// encrypt reply
|
||||||
|
@ -12,7 +12,7 @@ namespace i2p
|
|||||||
RouterContext context;
|
RouterContext context;
|
||||||
|
|
||||||
RouterContext::RouterContext ():
|
RouterContext::RouterContext ():
|
||||||
m_LastUpdateTime (0), m_IsUnreachable (false)
|
m_LastUpdateTime (0), m_IsUnreachable (false), m_AcceptsTunnels (true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,6 +32,8 @@ namespace i2p
|
|||||||
void RemoveIntroducer (const boost::asio::ip::udp::endpoint& e);
|
void RemoveIntroducer (const boost::asio::ip::udp::endpoint& e);
|
||||||
bool IsUnreachable () const { return m_IsUnreachable; };
|
bool IsUnreachable () const { return m_IsUnreachable; };
|
||||||
void SetUnreachable ();
|
void SetUnreachable ();
|
||||||
|
bool AcceptsTunnels () const { return m_AcceptsTunnels; };
|
||||||
|
void SetAcceptsTunnels (bool acceptsTunnels) { m_AcceptsTunnels = acceptsTunnels; };
|
||||||
|
|
||||||
// implements LocalDestination
|
// implements LocalDestination
|
||||||
const i2p::data::PrivateKeys& GetPrivateKeys () const { return m_Keys; };
|
const i2p::data::PrivateKeys& GetPrivateKeys () const { return m_Keys; };
|
||||||
@ -53,7 +55,7 @@ namespace i2p
|
|||||||
i2p::data::PrivateKeys m_Keys;
|
i2p::data::PrivateKeys m_Keys;
|
||||||
CryptoPP::AutoSeededRandomPool m_Rnd;
|
CryptoPP::AutoSeededRandomPool m_Rnd;
|
||||||
uint64_t m_LastUpdateTime;
|
uint64_t m_LastUpdateTime;
|
||||||
bool m_IsUnreachable;
|
bool m_IsUnreachable, m_AcceptsTunnels;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern RouterContext context;
|
extern RouterContext context;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user