diff --git a/HTTPServer.cpp b/HTTPServer.cpp
index e77b5cdf..0f30cc47 100644
--- a/HTTPServer.cpp
+++ b/HTTPServer.cpp
@@ -6,9 +6,10 @@
#include "TransitTunnel.h"
#include "Transports.h"
#include "NetDb.h"
-#include "HTTPServer.h"
#include "I2PEndian.h"
#include "Streaming.h"
+#include "RouterContext.h"
+#include "HTTPServer.h"
// For image and info
#include "version.h"
@@ -460,7 +461,9 @@ namespace util
const char HTTP_COMMAND_TUNNELS[] = "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_DESTINATION[] = "local_destination";
const char HTTP_PARAM_BASE32_ADDRESS[] = "b32";
@@ -654,6 +657,11 @@ namespace util
s << "
Transit tunnels";
s << "
Transports
";
+ if (i2p::context.AcceptsTunnels ())
+ s << "
Stop accepting tunnels
";
+ else
+ s << "
Start accepting tunnels
";
+
s << "
Flibusta
";
}
@@ -667,6 +675,10 @@ namespace util
ShowTunnels (s);
else if (cmd == HTTP_COMMAND_TRANSIT_TUNNELS)
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)
ShowLocalDestinations (s);
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)
{
std::string request = "GET " + uri + " HTTP/1.1\r\nHost:" + address + "\r\n";
diff --git a/HTTPServer.h b/HTTPServer.h
index 12bb4739..7559b975 100644
--- a/HTTPServer.h
+++ b/HTTPServer.h
@@ -64,6 +64,8 @@ namespace util
void ShowTransitTunnels (std::stringstream& s);
void ShowLocalDestinations (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);
std::string ExtractAddress ();
void ExtractParams (const std::string& str, std::map& params);
diff --git a/I2NPProtocol.cpp b/I2NPProtocol.cpp
index 5a6fc678..d0c2e50c 100644
--- a/I2NPProtocol.cpp
+++ b/I2NPProtocol.cpp
@@ -297,7 +297,7 @@ namespace i2p
i2p::tunnel::tunnels.AddTransitTunnel (transitTunnel);
// replace record to reply
I2NPBuildResponseRecord * reply = (I2NPBuildResponseRecord *)(records + i);
- reply->ret = 0;
+ reply->ret = i2p::context.AcceptsTunnels () ? 0 : 30; // always reject with bandwidth reason (30)
//TODO: fill filler
CryptoPP::SHA256().CalculateDigest(reply->hash, reply->padding, sizeof (reply->padding) + 1); // + 1 byte of ret
// encrypt reply
diff --git a/RouterContext.cpp b/RouterContext.cpp
index 27e21544..b5402a75 100644
--- a/RouterContext.cpp
+++ b/RouterContext.cpp
@@ -12,7 +12,7 @@ namespace i2p
RouterContext context;
RouterContext::RouterContext ():
- m_LastUpdateTime (0), m_IsUnreachable (false)
+ m_LastUpdateTime (0), m_IsUnreachable (false), m_AcceptsTunnels (true)
{
}
diff --git a/RouterContext.h b/RouterContext.h
index 2a97982c..188c0c93 100644
--- a/RouterContext.h
+++ b/RouterContext.h
@@ -32,6 +32,8 @@ namespace i2p
void RemoveIntroducer (const boost::asio::ip::udp::endpoint& e);
bool IsUnreachable () const { return m_IsUnreachable; };
void SetUnreachable ();
+ bool AcceptsTunnels () const { return m_AcceptsTunnels; };
+ void SetAcceptsTunnels (bool acceptsTunnels) { m_AcceptsTunnels = acceptsTunnels; };
// implements LocalDestination
const i2p::data::PrivateKeys& GetPrivateKeys () const { return m_Keys; };
@@ -53,7 +55,7 @@ namespace i2p
i2p::data::PrivateKeys m_Keys;
CryptoPP::AutoSeededRandomPool m_Rnd;
uint64_t m_LastUpdateTime;
- bool m_IsUnreachable;
+ bool m_IsUnreachable, m_AcceptsTunnels;
};
extern RouterContext context;