mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 21:37:17 +01:00
* tune logging
This commit is contained in:
parent
576801cd32
commit
8949ebf041
|
@ -159,7 +159,7 @@ namespace garlic
|
||||||
// create message
|
// create message
|
||||||
if (!tagFound) // new session
|
if (!tagFound) // new session
|
||||||
{
|
{
|
||||||
LogPrint (eLogWarning, "Garlic: No tags available. Use ElGamal");
|
LogPrint (eLogWarning, "Garlic: No tags available, will use ElGamal");
|
||||||
if (!m_Destination)
|
if (!m_Destination)
|
||||||
{
|
{
|
||||||
LogPrint (eLogError, "Garlic: Can't use ElGamal for unknown destination");
|
LogPrint (eLogError, "Garlic: Can't use ElGamal for unknown destination");
|
||||||
|
|
|
@ -65,13 +65,13 @@ namespace proxy
|
||||||
|
|
||||||
void HTTPProxyHandler::AsyncSockRead()
|
void HTTPProxyHandler::AsyncSockRead()
|
||||||
{
|
{
|
||||||
LogPrint(eLogDebug,"--- HTTP Proxy async sock read");
|
LogPrint(eLogDebug, "HTTPProxy: async sock read");
|
||||||
if(m_sock) {
|
if(m_sock) {
|
||||||
m_sock->async_receive(boost::asio::buffer(m_http_buff, http_buffer_size),
|
m_sock->async_receive(boost::asio::buffer(m_http_buff, http_buffer_size),
|
||||||
std::bind(&HTTPProxyHandler::HandleSockRecv, shared_from_this(),
|
std::bind(&HTTPProxyHandler::HandleSockRecv, shared_from_this(),
|
||||||
std::placeholders::_1, std::placeholders::_2));
|
std::placeholders::_1, std::placeholders::_2));
|
||||||
} else {
|
} else {
|
||||||
LogPrint(eLogError,"--- HTTP Proxy no socket for read");
|
LogPrint(eLogError, "HTTPProxy: no socket for read");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ namespace proxy
|
||||||
if (Kill()) return;
|
if (Kill()) return;
|
||||||
if (m_sock)
|
if (m_sock)
|
||||||
{
|
{
|
||||||
LogPrint(eLogDebug,"--- HTTP Proxy close sock");
|
LogPrint(eLogDebug, "HTTPProxy: close sock");
|
||||||
m_sock->close();
|
m_sock->close();
|
||||||
m_sock = nullptr;
|
m_sock = nullptr;
|
||||||
}
|
}
|
||||||
|
@ -102,7 +102,7 @@ namespace proxy
|
||||||
|
|
||||||
void HTTPProxyHandler::ExtractRequest()
|
void HTTPProxyHandler::ExtractRequest()
|
||||||
{
|
{
|
||||||
LogPrint(eLogDebug,"--- HTTP Proxy method is: ", m_method, "\nRequest is: ", m_url);
|
LogPrint(eLogDebug, "HTTPProxy: request: ", m_method, " ", m_url);
|
||||||
std::string server="";
|
std::string server="";
|
||||||
std::string port="80";
|
std::string port="80";
|
||||||
boost::regex rHTTP("http://(.*?)(:(\\d+))?(/.*)");
|
boost::regex rHTTP("http://(.*?)(:(\\d+))?(/.*)");
|
||||||
|
@ -114,7 +114,7 @@ namespace proxy
|
||||||
if (m[2].str() != "") port=m[3].str();
|
if (m[2].str() != "") port=m[3].str();
|
||||||
path=m[4].str();
|
path=m[4].str();
|
||||||
}
|
}
|
||||||
LogPrint(eLogDebug,"--- HTTP Proxy server is: ",server, " port is: ", port, "\n path is: ",path);
|
LogPrint(eLogDebug, "HTTPProxy: server: ", server, ", port: ", port, ", path: ", path);
|
||||||
m_address = server;
|
m_address = server;
|
||||||
m_port = boost::lexical_cast<int>(port);
|
m_port = boost::lexical_cast<int>(port);
|
||||||
m_path = path;
|
m_path = path;
|
||||||
|
@ -124,7 +124,7 @@ namespace proxy
|
||||||
{
|
{
|
||||||
if ( m_version != "HTTP/1.0" && m_version != "HTTP/1.1" )
|
if ( m_version != "HTTP/1.0" && m_version != "HTTP/1.1" )
|
||||||
{
|
{
|
||||||
LogPrint(eLogError,"--- HTTP Proxy unsupported version: ", m_version);
|
LogPrint(eLogError, "HTTPProxy: unsupported version: ", m_version);
|
||||||
HTTPRequestFailed(); //TODO: send right stuff
|
HTTPRequestFailed(); //TODO: send right stuff
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -156,7 +156,7 @@ namespace proxy
|
||||||
}
|
}
|
||||||
auto base64 = m_path.substr (addressHelperPos + strlen(helpermark1));
|
auto base64 = m_path.substr (addressHelperPos + strlen(helpermark1));
|
||||||
base64 = i2p::util::http::urlDecode(base64); //Some of the symbols may be urlencoded
|
base64 = i2p::util::http::urlDecode(base64); //Some of the symbols may be urlencoded
|
||||||
LogPrint (eLogDebug,"Jump service for ", m_address, " found at ", base64, ". Inserting to address book");
|
LogPrint (eLogInfo, "HTTPProxy: jump service for ", m_address, ", inserting to address book");
|
||||||
//TODO: this is very dangerous and broken. We should ask the user before doing anything see http://pastethis.i2p/raw/pn5fL4YNJL7OSWj3Sc6N/
|
//TODO: this is very dangerous and broken. We should ask the user before doing anything see http://pastethis.i2p/raw/pn5fL4YNJL7OSWj3Sc6N/
|
||||||
//TODO: we could redirect the user again to avoid dirtiness in the browser
|
//TODO: we could redirect the user again to avoid dirtiness in the browser
|
||||||
i2p::client::context.GetAddressBook ().InsertAddress (m_address, base64);
|
i2p::client::context.GetAddressBook ().InsertAddress (m_address, base64);
|
||||||
|
@ -229,13 +229,13 @@ namespace proxy
|
||||||
{
|
{
|
||||||
case '\n': EnterState(DONE); break;
|
case '\n': EnterState(DONE); break;
|
||||||
default:
|
default:
|
||||||
LogPrint(eLogError,"--- HTTP Proxy rejected invalid request ending with: ", ((int)*http_buff));
|
LogPrint(eLogError, "HTTPProxy: rejected invalid request ending with: ", ((int)*http_buff));
|
||||||
HTTPRequestFailed(); //TODO: add correct code
|
HTTPRequestFailed(); //TODO: add correct code
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
LogPrint(eLogError,"--- HTTP Proxy invalid state: ", m_state);
|
LogPrint(eLogError, "HTTPProxy: invalid state: ", m_state);
|
||||||
HTTPRequestFailed(); //TODO: add correct code 500
|
HTTPRequestFailed(); //TODO: add correct code 500
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -249,11 +249,11 @@ namespace proxy
|
||||||
|
|
||||||
void HTTPProxyHandler::HandleSockRecv(const boost::system::error_code & ecode, std::size_t len)
|
void HTTPProxyHandler::HandleSockRecv(const boost::system::error_code & ecode, std::size_t len)
|
||||||
{
|
{
|
||||||
LogPrint(eLogDebug,"--- HTTP Proxy sock recv: ", len);
|
LogPrint(eLogDebug, "HTTPProxy: sock recv: ", len, " bytes");
|
||||||
if(ecode)
|
if(ecode)
|
||||||
{
|
{
|
||||||
LogPrint(eLogWarning," --- HTTP Proxy sock recv got error: ", ecode);
|
LogPrint(eLogWarning, "HTTPProxy: sock recv got error: ", ecode);
|
||||||
Terminate();
|
Terminate();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,7 +261,7 @@ namespace proxy
|
||||||
{
|
{
|
||||||
if (m_state == DONE)
|
if (m_state == DONE)
|
||||||
{
|
{
|
||||||
LogPrint(eLogInfo,"--- HTTP Proxy requested: ", m_url);
|
LogPrint(eLogDebug, "HTTPProxy: requested: ", m_url);
|
||||||
GetOwner()->CreateStream (std::bind (&HTTPProxyHandler::HandleStreamRequestComplete,
|
GetOwner()->CreateStream (std::bind (&HTTPProxyHandler::HandleStreamRequestComplete,
|
||||||
shared_from_this(), std::placeholders::_1), m_address, m_port);
|
shared_from_this(), std::placeholders::_1), m_address, m_port);
|
||||||
}
|
}
|
||||||
|
@ -273,13 +273,9 @@ namespace proxy
|
||||||
|
|
||||||
void HTTPProxyHandler::SentHTTPFailed(const boost::system::error_code & ecode)
|
void HTTPProxyHandler::SentHTTPFailed(const boost::system::error_code & ecode)
|
||||||
{
|
{
|
||||||
if (!ecode)
|
if (ecode)
|
||||||
Terminate();
|
LogPrint (eLogError, "HTTPProxy: Closing socket after sending failure because: ", ecode.message ());
|
||||||
else
|
Terminate();
|
||||||
{
|
|
||||||
LogPrint (eLogError,"--- HTTP Proxy Closing socket after sending failure because: ", ecode.message ());
|
|
||||||
Terminate();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void HTTPProxyHandler::HandleStreamRequestComplete (std::shared_ptr<i2p::stream::Stream> stream)
|
void HTTPProxyHandler::HandleStreamRequestComplete (std::shared_ptr<i2p::stream::Stream> stream)
|
||||||
|
@ -287,7 +283,7 @@ namespace proxy
|
||||||
if (stream)
|
if (stream)
|
||||||
{
|
{
|
||||||
if (Kill()) return;
|
if (Kill()) return;
|
||||||
LogPrint (eLogInfo,"--- HTTP Proxy New I2PTunnel connection");
|
LogPrint (eLogInfo, "HTTPProxy: New I2PTunnel connection");
|
||||||
auto connection = std::make_shared<i2p::client::I2PTunnelConnection>(GetOwner(), m_sock, stream);
|
auto connection = std::make_shared<i2p::client::I2PTunnelConnection>(GetOwner(), m_sock, stream);
|
||||||
GetOwner()->AddHandler (connection);
|
GetOwner()->AddHandler (connection);
|
||||||
connection->I2PConnect (reinterpret_cast<const uint8_t*>(m_request.data()), m_request.size());
|
connection->I2PConnect (reinterpret_cast<const uint8_t*>(m_request.data()), m_request.size());
|
||||||
|
@ -295,7 +291,7 @@ namespace proxy
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogPrint (eLogError,"--- HTTP Proxy Issue when creating the stream, check the previous warnings for more info.");
|
LogPrint (eLogError, "HTTPProxy: error when creating the stream, check the previous warnings for more info");
|
||||||
HTTPRequestFailed(); // TODO: Send correct error message host unreachable
|
HTTPRequestFailed(); // TODO: Send correct error message host unreachable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -205,7 +205,7 @@ namespace client
|
||||||
}
|
}
|
||||||
if (ss.eof ())
|
if (ss.eof ())
|
||||||
{
|
{
|
||||||
LogPrint (eLogError, "Malformed I2PControl request. HTTP header expected");
|
LogPrint (eLogError, "I2PControl: malformed request, HTTP header expected");
|
||||||
return; // TODO:
|
return; // TODO:
|
||||||
}
|
}
|
||||||
std::streamoff rem = contentLength + ss.tellg () - bytes_transferred; // more bytes to read
|
std::streamoff rem = contentLength + ss.tellg () - bytes_transferred; // more bytes to read
|
||||||
|
@ -216,7 +216,7 @@ namespace client
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if GCC47_BOOST149
|
#if GCC47_BOOST149
|
||||||
LogPrint (eLogError, "json_read is not supported due bug in boost 1.49 with gcc 4.7");
|
LogPrint (eLogError, "I2PControl: json_read is not supported due bug in boost 1.49 with gcc 4.7");
|
||||||
#else
|
#else
|
||||||
boost::property_tree::ptree pt;
|
boost::property_tree::ptree pt;
|
||||||
boost::property_tree::read_json (ss, pt);
|
boost::property_tree::read_json (ss, pt);
|
||||||
|
@ -233,16 +233,16 @@ namespace client
|
||||||
SendResponse (socket, buf, response, isHtml);
|
SendResponse (socket, buf, response, isHtml);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
LogPrint (eLogWarning, "Unknown I2PControl method ", method);
|
LogPrint (eLogWarning, "I2PControl: unknown method ", method);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
catch (std::exception& ex)
|
catch (std::exception& ex)
|
||||||
{
|
{
|
||||||
LogPrint (eLogError, "I2PControl handle request: ", ex.what ());
|
LogPrint (eLogError, "I2PControl: exception when handle request: ", ex.what ());
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
LogPrint (eLogError, "I2PControl handle request unknown exception");
|
LogPrint (eLogError, "I2PControl: handle request unknown exception");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -527,7 +527,7 @@ namespace client
|
||||||
|
|
||||||
// save key
|
// save key
|
||||||
if ((f = fopen (key_path, "wb")) != NULL) {
|
if ((f = fopen (key_path, "wb")) != NULL) {
|
||||||
LogPrint (eLogInfo, "I2PControl: saving cert key to : ", key_path);
|
LogPrint (eLogInfo, "I2PControl: saving cert key to ", key_path);
|
||||||
PEM_write_PrivateKey (f, pkey, NULL, NULL, 0, NULL, NULL);
|
PEM_write_PrivateKey (f, pkey, NULL, NULL, 0, NULL, NULL);
|
||||||
fclose (f);
|
fclose (f);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -28,7 +28,7 @@ namespace client
|
||||||
m_LocalDestination->CreateStream (streamRequestComplete, identHash, port);
|
m_LocalDestination->CreateStream (streamRequestComplete, identHash, port);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogPrint (eLogWarning, "Remote destination ", dest, " not found");
|
LogPrint (eLogWarning, "I2PService: Remote destination ", dest, " not found");
|
||||||
streamRequestComplete (nullptr);
|
streamRequestComplete (nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ namespace client
|
||||||
{
|
{
|
||||||
if (!ecode)
|
if (!ecode)
|
||||||
{
|
{
|
||||||
LogPrint(eLogDebug,"--- ",GetName()," accepted");
|
LogPrint(eLogDebug, "I2PService: ", GetName(), " accepted");
|
||||||
auto handler = CreateHandler(socket);
|
auto handler = CreateHandler(socket);
|
||||||
if (handler)
|
if (handler)
|
||||||
{
|
{
|
||||||
|
@ -71,7 +71,7 @@ namespace client
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (ecode != boost::asio::error::operation_aborted)
|
if (ecode != boost::asio::error::operation_aborted)
|
||||||
LogPrint (eLogError,"--- ",GetName()," Closing socket on accept because: ", ecode.message ());
|
LogPrint (eLogError, "I2PService: ", GetName(), " closing socket on accept because: ", ecode.message ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -503,12 +503,13 @@ namespace transport
|
||||||
|
|
||||||
void NTCPSession::HandleReceived (const boost::system::error_code& ecode, std::size_t bytes_transferred)
|
void NTCPSession::HandleReceived (const boost::system::error_code& ecode, std::size_t bytes_transferred)
|
||||||
{
|
{
|
||||||
if (ecode)
|
if (ecode) {
|
||||||
{
|
if (ecode != boost::asio::error::operation_aborted)
|
||||||
LogPrint (eLogInfo, "NTCP: Read error: ", ecode.message ());
|
LogPrint (eLogDebug, "NTCP: Read error: ", ecode.message ());
|
||||||
if (!m_NumReceivedBytes) m_Server.Ban (m_ConnectedFrom);
|
if (!m_NumReceivedBytes)
|
||||||
|
m_Server.Ban (m_ConnectedFrom);
|
||||||
//if (ecode != boost::asio::error::operation_aborted)
|
//if (ecode != boost::asio::error::operation_aborted)
|
||||||
Terminate ();
|
Terminate ();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -736,7 +737,7 @@ namespace transport
|
||||||
{
|
{
|
||||||
if (ecode != boost::asio::error::operation_aborted)
|
if (ecode != boost::asio::error::operation_aborted)
|
||||||
{
|
{
|
||||||
LogPrint (eLogWarning, "NTCP: No activity for ", NTCP_TERMINATION_TIMEOUT, " seconds");
|
LogPrint (eLogDebug, "NTCP: No activity for ", NTCP_TERMINATION_TIMEOUT, " seconds");
|
||||||
//Terminate ();
|
//Terminate ();
|
||||||
m_Socket.close ();// invoke Terminate () from HandleReceive
|
m_Socket.close ();// invoke Terminate () from HandleReceive
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue