Browse Source

Merge remote-tracking branch 'purple/openssl'

pull/440/head
Jeff Becker 9 years ago
parent
commit
630072b574
No known key found for this signature in database
GPG Key ID: AB950234D6EA286B
  1. 15
      HTTPProxy.cpp
  2. 2
      HTTPServer.cpp
  3. 14
      Transports.cpp

15
HTTPProxy.cpp

@ -39,6 +39,7 @@ namespace proxy @@ -39,6 +39,7 @@ namespace proxy
void HTTPRequestFailed(/*std::string message*/);
void RedirectToJumpService();
void ExtractRequest();
bool IsI2PAddress();
bool ValidateHTTPRequest();
void HandleJumpServices();
bool CreateHTTPRequest(uint8_t *http_buff, std::size_t len);
@ -176,6 +177,16 @@ namespace proxy @@ -176,6 +177,16 @@ namespace proxy
m_path.erase(addressHelperPos);
}
bool HTTPProxyHandler::IsI2PAddress()
{
auto pos = m_address.rfind (".i2p");
if (pos != std::string::npos && (pos+4) == m_address.length ())
{
return true;
}
return false;
}
bool HTTPProxyHandler::CreateHTTPRequest(uint8_t *http_buff, std::size_t len)
{
ExtractRequest(); //TODO: parse earlier
@ -183,10 +194,14 @@ namespace proxy @@ -183,10 +194,14 @@ namespace proxy
HandleJumpServices();
i2p::data::IdentHash identHash;
if (IsI2PAddress ())
{
if (!i2p::client::context.GetAddressBook ().GetIdentHash (m_address, identHash)){
RedirectToJumpService();
return false;
}
}
m_request = m_method;
m_request.push_back(' ');

2
HTTPServer.cpp

@ -534,7 +534,7 @@ namespace util @@ -534,7 +534,7 @@ namespace util
auto dest = i2p::client::context.FindLocalDestination (ident);
if (dest)
{
s << "<b>Base64:</b><br>\r\n<textarea readonly=\"readonly\" cols=\"64\" rows=\"1\" wrap=\"off\">";
s << "<b>Base64:</b><br>\r\n<textarea readonly=\"readonly\" cols=\"64\" rows=\"11\" wrap=\"on\">";
s << dest->GetIdentity ()->ToBase64 () << "</textarea><br>\r\n<br>\r\n";
s << "<b>LeaseSets:</b> <i>" << dest->GetNumRemoteLeaseSets () << "</i><br>\r\n";
auto pool = dest->GetTunnelPool ();

14
Transports.cpp

@ -375,6 +375,8 @@ namespace transport @@ -375,6 +375,8 @@ namespace transport
{
auto& peer = it1->second;
if (!ecode && peer.router)
{
while (it != boost::asio::ip::tcp::resolver::iterator())
{
auto address = (*it).endpoint ().address ();
LogPrint (eLogDebug, "Transports: ", (*it).host_name (), " has been resolved to ", address);
@ -387,9 +389,12 @@ namespace transport @@ -387,9 +389,12 @@ namespace transport
m_NTCPServer->Connect (address, addr->port, s);
return;
}
break;
}
else
LogPrint (eLogInfo, "Can't connect to NTCP ", address, " ipv6 is not supported");
LogPrint (eLogInfo, "Transports: NTCP ", address, " is not supported");
it++;
}
}
LogPrint (eLogError, "Transports: Unable to resolve NTCP address: ", ecode.message ());
std::unique_lock<std::mutex> l(m_PeersMutex);
@ -413,6 +418,8 @@ namespace transport @@ -413,6 +418,8 @@ namespace transport
{
auto& peer = it1->second;
if (!ecode && peer.router)
{
while (it != boost::asio::ip::tcp::resolver::iterator())
{
auto address = (*it).endpoint ().address ();
LogPrint (eLogDebug, "Transports: ", (*it).host_name (), " has been resolved to ", address);
@ -424,9 +431,12 @@ namespace transport @@ -424,9 +431,12 @@ namespace transport
m_SSUServer->CreateSession (peer.router, address, addr->port);
return;
}
break;
}
else
LogPrint (eLogInfo, "Can't connect to SSU ", address, " ipv6 is not supported");
LogPrint (eLogInfo, "Transports: SSU ", address, " is not supported");
it++;
}
}
LogPrint (eLogError, "Transports: Unable to resolve SSU address: ", ecode.message ());
std::unique_lock<std::mutex> l(m_PeersMutex);

Loading…
Cancel
Save