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. 21
      HTTPProxy.cpp
  2. 2
      HTTPServer.cpp
  3. 54
      Transports.cpp
  4. 10
      docs/family.md

21
HTTPProxy.cpp

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

2
HTTPServer.cpp

@ -534,7 +534,7 @@ namespace util
auto dest = i2p::client::context.FindLocalDestination (ident); auto dest = i2p::client::context.FindLocalDestination (ident);
if (dest) 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 << dest->GetIdentity ()->ToBase64 () << "</textarea><br>\r\n<br>\r\n";
s << "<b>LeaseSets:</b> <i>" << dest->GetNumRemoteLeaseSets () << "</i><br>\r\n"; s << "<b>LeaseSets:</b> <i>" << dest->GetNumRemoteLeaseSets () << "</i><br>\r\n";
auto pool = dest->GetTunnelPool (); auto pool = dest->GetTunnelPool ();

54
Transports.cpp

@ -376,20 +376,25 @@ namespace transport
auto& peer = it1->second; auto& peer = it1->second;
if (!ecode && peer.router) if (!ecode && peer.router)
{ {
auto address = (*it).endpoint ().address (); while (it != boost::asio::ip::tcp::resolver::iterator())
LogPrint (eLogDebug, "Transports: ", (*it).host_name (), " has been resolved to ", address); {
if (address.is_v4 () || context.SupportsV6 ()) auto address = (*it).endpoint ().address ();
{ LogPrint (eLogDebug, "Transports: ", (*it).host_name (), " has been resolved to ", address);
auto addr = peer.router->GetNTCPAddress (); // TODO: take one we requested if (address.is_v4 () || context.SupportsV6 ())
if (addr)
{ {
auto s = std::make_shared<NTCPSession> (*m_NTCPServer, peer.router); auto addr = peer.router->GetNTCPAddress (); // TODO: take one we requested
m_NTCPServer->Connect (address, addr->port, s); if (addr)
return; {
} auto s = std::make_shared<NTCPSession> (*m_NTCPServer, peer.router);
m_NTCPServer->Connect (address, addr->port, s);
return;
}
break;
}
else
LogPrint (eLogInfo, "Transports: NTCP ", address, " is not supported");
it++;
} }
else
LogPrint (eLogInfo, "Can't connect to NTCP ", address, " ipv6 is not supported");
} }
LogPrint (eLogError, "Transports: Unable to resolve NTCP address: ", ecode.message ()); LogPrint (eLogError, "Transports: Unable to resolve NTCP address: ", ecode.message ());
std::unique_lock<std::mutex> l(m_PeersMutex); std::unique_lock<std::mutex> l(m_PeersMutex);
@ -414,19 +419,24 @@ namespace transport
auto& peer = it1->second; auto& peer = it1->second;
if (!ecode && peer.router) if (!ecode && peer.router)
{ {
auto address = (*it).endpoint ().address (); while (it != boost::asio::ip::tcp::resolver::iterator())
LogPrint (eLogDebug, "Transports: ", (*it).host_name (), " has been resolved to ", address); {
if (address.is_v4 () || context.SupportsV6 ()) auto address = (*it).endpoint ().address ();
{ LogPrint (eLogDebug, "Transports: ", (*it).host_name (), " has been resolved to ", address);
auto addr = peer.router->GetSSUAddress (); // TODO: take one we requested if (address.is_v4 () || context.SupportsV6 ())
if (addr)
{ {
m_SSUServer->CreateSession (peer.router, address, addr->port); auto addr = peer.router->GetSSUAddress (); // TODO: take one we requested
return; if (addr)
{
m_SSUServer->CreateSession (peer.router, address, addr->port);
return;
}
break;
} }
else
LogPrint (eLogInfo, "Transports: SSU ", address, " is not supported");
it++;
} }
else
LogPrint (eLogInfo, "Can't connect to SSU ", address, " ipv6 is not supported");
} }
LogPrint (eLogError, "Transports: Unable to resolve SSU address: ", ecode.message ()); LogPrint (eLogError, "Transports: Unable to resolve SSU address: ", ecode.message ());
std::unique_lock<std::mutex> l(m_PeersMutex); std::unique_lock<std::mutex> l(m_PeersMutex);

10
docs/family.md

@ -8,11 +8,11 @@ New family
----------- -----------
You must create family self-signed certificate and key. You must create family self-signed certificate and key.
The only key type supposted is prime256v1. The only key type supposted is prime256v1.
Use the following list of commands: Use the following list of commands:
openssl ecparam -name prime256v1 -genkey -out <your family name>.key openssl ecparam -name prime256v1 -genkey -out <your family name>.key
openssl req -new -key <your family name>.key -out <your family name>.csr openssl req -new -key <your family name>.key -out <your family name>.csr
touch v3.ext touch v3.ext
openssl x509 -req -days 3650 -in <your family name>.csr -signkey <your family name>.key -out <your family name>.crt -extfile v3.ext openssl x509 -req -days 3650 -in <your family name>.csr -signkey <your family name>.key -out <your family name>.crt -extfile v3.ext
specify <your family name>.family.i2p.net for CN. specify <your family name>.family.i2p.net for CN.

Loading…
Cancel
Save