|
|
@ -494,8 +494,9 @@ namespace http { |
|
|
|
auto ntcpServer = i2p::transport::transports.GetNTCPServer (); |
|
|
|
auto ntcpServer = i2p::transport::transports.GetNTCPServer (); |
|
|
|
if (ntcpServer) |
|
|
|
if (ntcpServer) |
|
|
|
{ |
|
|
|
{ |
|
|
|
s << "<b>NTCP</b><br>\r\n"; |
|
|
|
auto sessions = ntcpServer->GetNTCPSessions (); |
|
|
|
for (const auto& it: ntcpServer->GetNTCPSessions ()) |
|
|
|
s << "<b>NTCP</b> ( " << (int) sessions.size() << " )<br>\r\n"; |
|
|
|
|
|
|
|
for (const auto& it: sessions ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (it.second && it.second->IsEstablished ()) |
|
|
|
if (it.second && it.second->IsEstablished ()) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -512,8 +513,9 @@ namespace http { |
|
|
|
auto ssuServer = i2p::transport::transports.GetSSUServer (); |
|
|
|
auto ssuServer = i2p::transport::transports.GetSSUServer (); |
|
|
|
if (ssuServer) |
|
|
|
if (ssuServer) |
|
|
|
{ |
|
|
|
{ |
|
|
|
s << "<br>\r\n<b>SSU</b><br>\r\n"; |
|
|
|
auto sessions = ssuServer->GetSessions (); |
|
|
|
for (const auto& it: ssuServer->GetSessions ()) |
|
|
|
s << "<br>\r\n<b>SSU</b> ( " << (int) sessions.size() << " )<br>\r\n"; |
|
|
|
|
|
|
|
for (const auto& it: sessions) |
|
|
|
{ |
|
|
|
{ |
|
|
|
auto endpoint = it.second->GetRemoteEndpoint (); |
|
|
|
auto endpoint = it.second->GetRemoteEndpoint (); |
|
|
|
if (it.second->IsOutgoing ()) s << " ⇒ "; |
|
|
|
if (it.second->IsOutgoing ()) s << " ⇒ "; |
|
|
@ -713,20 +715,22 @@ namespace http { |
|
|
|
} |
|
|
|
} |
|
|
|
/* method #2: 'Authorization' header sent */ |
|
|
|
/* method #2: 'Authorization' header sent */ |
|
|
|
if (req.headers.count("Authorization") > 0) { |
|
|
|
if (req.headers.count("Authorization") > 0) { |
|
|
|
|
|
|
|
bool result = false; |
|
|
|
std::string provided = req.headers.find("Authorization")->second; |
|
|
|
std::string provided = req.headers.find("Authorization")->second; |
|
|
|
std::string expected = user + ":" + pass; |
|
|
|
std::string expected = user + ":" + pass; |
|
|
|
char b64_creds[64]; |
|
|
|
size_t b64_sz = i2p::data::Base64EncodingBufferSize(expected.length()) + 1; |
|
|
|
|
|
|
|
char * b64_creds = new char[b64_sz]; |
|
|
|
std::size_t len = 0; |
|
|
|
std::size_t len = 0; |
|
|
|
len = i2p::data::ByteStreamToBase64((unsigned char *)expected.c_str(), expected.length(), b64_creds, sizeof(b64_creds)); |
|
|
|
len = i2p::data::ByteStreamToBase64((unsigned char *)expected.c_str(), expected.length(), b64_creds, b64_sz); |
|
|
|
/* if we decoded properly then check credentials */ |
|
|
|
/* if we decoded properly then check credentials */ |
|
|
|
if(len) { |
|
|
|
if(len) { |
|
|
|
b64_creds[len] = '\0'; |
|
|
|
b64_creds[len] = '\0'; |
|
|
|
expected = "Basic "; |
|
|
|
expected = "Basic "; |
|
|
|
expected += b64_creds; |
|
|
|
expected += b64_creds; |
|
|
|
return expected == provided; |
|
|
|
result = expected == provided; |
|
|
|
} |
|
|
|
} |
|
|
|
/** we decoded wrong so it's not a correct login credential */ |
|
|
|
delete [] b64_creds; |
|
|
|
return false; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
LogPrint(eLogWarning, "HTTPServer: auth failure from ", m_Socket->remote_endpoint().address ()); |
|
|
|
LogPrint(eLogWarning, "HTTPServer: auth failure from ", m_Socket->remote_endpoint().address ()); |
|
|
|