Browse Source

* HTTPProxy.cpp : don't reuse part of httppserver, addresshelpers handling will be moved to proxy in future

pull/551/head
hagen 8 years ago
parent
commit
6f77c6f3f4
  1. 25
      HTTPProxy.cpp
  2. 2
      HTTPServer.h

25
HTTPProxy.cpp

@ -20,7 +20,6 @@ @@ -20,7 +20,6 @@
#include "I2PTunnel.h"
#include "Config.h"
#include "HTTP.h"
#include "HTTPServer.h"
namespace i2p {
namespace proxy {
@ -52,7 +51,7 @@ namespace proxy { @@ -52,7 +51,7 @@ namespace proxy {
void Terminate();
void AsyncSockRead();
void HTTPRequestFailed(const char *message);
void RedirectToJumpService();
void RedirectToJumpService(std::string & host);
void ExtractRequest();
bool ValidateHTTPRequest();
void HandleJumpServices();
@ -119,11 +118,23 @@ namespace proxy { @@ -119,11 +118,23 @@ namespace proxy {
std::bind(&HTTPReqHandler::SentHTTPFailed, shared_from_this(), std::placeholders::_1));
}
void HTTPReqHandler::RedirectToJumpService(/*HTTPReqHandler::errTypes error*/)
void HTTPReqHandler::RedirectToJumpService(std::string & host)
{
std::stringstream ss;
i2p::http::ShowJumpServices (ss, m_address);
boost::asio::async_write(*m_sock, boost::asio::buffer(ss.str ()),
i2p::http::HTTPRes res;
i2p::http::URL url;
/* TODO: don't redirect to webconsole, it's not always work, handle jumpservices here */
i2p::config::GetOption("http.address", url.host);
i2p::config::GetOption("http.port", url.port);
url.path = "/";
url.query = "page=jumpservices&address=";
url.query += host;
res.code = 302; /* redirect */
res.add_header("Location", url.to_string().c_str());
std::string response = res.to_string();
boost::asio::async_write(*m_sock, boost::asio::buffer(response),
std::bind(&HTTPReqHandler::SentHTTPFailed, shared_from_this(), std::placeholders::_1));
}
@ -198,7 +209,7 @@ namespace proxy { @@ -198,7 +209,7 @@ namespace proxy {
if (str_rmatch(m_address, ".i2p"))
{
if (!i2p::client::context.GetAddressBook ().GetIdentHash (m_address, identHash)){
RedirectToJumpService();
RedirectToJumpService(m_address);
return false;
}
}

2
HTTPServer.h

@ -61,8 +61,6 @@ namespace http { @@ -61,8 +61,6 @@ namespace http {
boost::asio::io_service::work m_Work;
boost::asio::ip::tcp::acceptor m_Acceptor;
};
void ShowJumpServices (std::stringstream& s, const std::string& address);
} // http
} // i2p

Loading…
Cancel
Save