diff --git a/HTTPProxy.cpp b/HTTPProxy.cpp index 6e835d21..c252614b 100644 --- a/HTTPProxy.cpp +++ b/HTTPProxy.cpp @@ -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 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 HandleJumpServices(); i2p::data::IdentHash identHash; - if (!i2p::client::context.GetAddressBook ().GetIdentHash (m_address, identHash)){ - RedirectToJumpService(); - return false; + if (IsI2PAddress ()) + { + if (!i2p::client::context.GetAddressBook ().GetIdentHash (m_address, identHash)){ + RedirectToJumpService(); + return false; + } } + m_request = m_method; m_request.push_back(' '); diff --git a/HTTPServer.cpp b/HTTPServer.cpp index 9ffa0599..67ddf362 100644 --- a/HTTPServer.cpp +++ b/HTTPServer.cpp @@ -534,7 +534,7 @@ namespace util auto dest = i2p::client::context.FindLocalDestination (ident); if (dest) { - s << "Base64:
\r\n
\r\n
\r\n"; s << "LeaseSets: " << dest->GetNumRemoteLeaseSets () << "
\r\n"; auto pool = dest->GetTunnelPool (); diff --git a/Transports.cpp b/Transports.cpp index 2127b646..275c6f90 100644 --- a/Transports.cpp +++ b/Transports.cpp @@ -376,20 +376,25 @@ namespace transport auto& peer = it1->second; if (!ecode && peer.router) { - auto address = (*it).endpoint ().address (); - LogPrint (eLogDebug, "Transports: ", (*it).host_name (), " has been resolved to ", address); - if (address.is_v4 () || context.SupportsV6 ()) - { - auto addr = peer.router->GetNTCPAddress (); // TODO: take one we requested - if (addr) + while (it != boost::asio::ip::tcp::resolver::iterator()) + { + auto address = (*it).endpoint ().address (); + LogPrint (eLogDebug, "Transports: ", (*it).host_name (), " has been resolved to ", address); + if (address.is_v4 () || context.SupportsV6 ()) { - auto s = std::make_shared (*m_NTCPServer, peer.router); - m_NTCPServer->Connect (address, addr->port, s); - return; - } + auto addr = peer.router->GetNTCPAddress (); // TODO: take one we requested + if (addr) + { + auto s = std::make_shared (*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 ()); std::unique_lock l(m_PeersMutex); @@ -414,19 +419,24 @@ namespace transport auto& peer = it1->second; if (!ecode && peer.router) { - auto address = (*it).endpoint ().address (); - LogPrint (eLogDebug, "Transports: ", (*it).host_name (), " has been resolved to ", address); - if (address.is_v4 () || context.SupportsV6 ()) - { - auto addr = peer.router->GetSSUAddress (); // TODO: take one we requested - if (addr) + while (it != boost::asio::ip::tcp::resolver::iterator()) + { + auto address = (*it).endpoint ().address (); + LogPrint (eLogDebug, "Transports: ", (*it).host_name (), " has been resolved to ", address); + if (address.is_v4 () || context.SupportsV6 ()) { - m_SSUServer->CreateSession (peer.router, address, addr->port); - return; + auto addr = peer.router->GetSSUAddress (); // TODO: take one we requested + 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 ()); std::unique_lock l(m_PeersMutex); diff --git a/docs/family.md b/docs/family.md index 0f307143..8ef76b7a 100644 --- a/docs/family.md +++ b/docs/family.md @@ -8,11 +8,11 @@ New family ----------- You must create family self-signed certificate and key. The only key type supposted is prime256v1. -Use the following list of commands: -openssl ecparam -name prime256v1 -genkey -out .key -openssl req -new -key .key -out .csr -touch v3.ext -openssl x509 -req -days 3650 -in .csr -signkey .key -out .crt -extfile v3.ext +Use the following list of commands: +openssl ecparam -name prime256v1 -genkey -out .key +openssl req -new -key .key -out .csr +touch v3.ext +openssl x509 -req -days 3650 -in .csr -signkey .key -out .crt -extfile v3.ext specify .family.i2p.net for CN.