mirror of
				https://github.com/PurpleI2P/i2pd.git
				synced 2025-11-04 08:30:46 +00:00 
			
		
		
		
	Merge branch 'upstream-openssl'
This commit is contained in:
		
						commit
						03927b0a68
					
				
					 23 changed files with 85 additions and 76 deletions
				
			
		| 
						 | 
				
			
			@ -173,7 +173,7 @@ namespace client
 | 
			
		|||
			return 0;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		for (auto it: addresses) {
 | 
			
		||||
		for (const auto& it: addresses) {
 | 
			
		||||
			f << it.first << "," << it.second.ToBase32 () << std::endl;
 | 
			
		||||
			num++;
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			@ -252,7 +252,7 @@ namespace client
 | 
			
		|||
			}	
 | 
			
		||||
			LogPrint (eLogError, "Addressbook: subscription download timeout");
 | 
			
		||||
			m_IsDownloading = false;
 | 
			
		||||
		}	
 | 
			
		||||
		}
 | 
			
		||||
		if (m_Storage)
 | 
			
		||||
		{
 | 
			
		||||
			m_Storage->Save (m_Addresses);
 | 
			
		||||
| 
						 | 
				
			
			@ -260,7 +260,7 @@ namespace client
 | 
			
		|||
			m_Storage = nullptr;
 | 
			
		||||
		}
 | 
			
		||||
		m_DefaultSubscription = nullptr;	
 | 
			
		||||
		for (auto it: m_Subscriptions)
 | 
			
		||||
		for (auto& it: m_Subscriptions)
 | 
			
		||||
			delete it;
 | 
			
		||||
		m_Subscriptions.clear ();	
 | 
			
		||||
	}	
 | 
			
		||||
| 
						 | 
				
			
			@ -418,7 +418,7 @@ namespace client
 | 
			
		|||
	{
 | 
			
		||||
		std::map<std::string, i2p::data::IdentHash> localAddresses;
 | 
			
		||||
		m_Storage->LoadLocal (localAddresses);
 | 
			
		||||
		for (auto it: localAddresses)
 | 
			
		||||
		for (const auto& it: localAddresses)
 | 
			
		||||
		{
 | 
			
		||||
			auto dot = it.first.find ('.');
 | 
			
		||||
			if (dot != std::string::npos)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										8
									
								
								BOB.cpp
									
										
									
									
									
								
							
							
						
						
									
										8
									
								
								BOB.cpp
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -536,8 +536,8 @@ namespace client
 | 
			
		|||
	void BOBCommandSession::ListCommandHandler (const char * operand, size_t len)
 | 
			
		||||
	{
 | 
			
		||||
		LogPrint (eLogDebug, "BOB: list");
 | 
			
		||||
		auto& destinations = m_Owner.GetDestinations ();
 | 
			
		||||
		for (auto it: destinations)
 | 
			
		||||
		const auto& destinations = m_Owner.GetDestinations ();
 | 
			
		||||
		for (const auto& it: destinations)
 | 
			
		||||
			SendData (it.first.c_str ());
 | 
			
		||||
		SendReplyOK ("Listing done");
 | 
			
		||||
	}	
 | 
			
		||||
| 
						 | 
				
			
			@ -619,7 +619,7 @@ namespace client
 | 
			
		|||
	BOBCommandChannel::~BOBCommandChannel ()
 | 
			
		||||
	{
 | 
			
		||||
		Stop ();
 | 
			
		||||
		for (auto it: m_Destinations)
 | 
			
		||||
		for (const auto& it: m_Destinations)
 | 
			
		||||
			delete it.second;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -633,7 +633,7 @@ namespace client
 | 
			
		|||
	void BOBCommandChannel::Stop ()
 | 
			
		||||
	{
 | 
			
		||||
		m_IsRunning = false;
 | 
			
		||||
		for (auto it: m_Destinations)
 | 
			
		||||
		for (auto& it: m_Destinations)
 | 
			
		||||
			it.second->Stop ();
 | 
			
		||||
		m_Acceptor.cancel ();	
 | 
			
		||||
		m_Service.stop ();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -196,7 +196,7 @@ namespace client
 | 
			
		|||
 | 
			
		||||
		LogPrint(eLogInfo, "Clients: stopping AddressBook");
 | 
			
		||||
		m_AddressBook.Stop ();		
 | 
			
		||||
		for (auto it: m_Destinations)
 | 
			
		||||
		for (auto& it: m_Destinations)
 | 
			
		||||
			it.second->Stop ();
 | 
			
		||||
		m_Destinations.clear ();
 | 
			
		||||
		m_SharedLocalDestination = nullptr; 
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -103,7 +103,7 @@ namespace client
 | 
			
		|||
	{
 | 
			
		||||
		if (m_IsRunning)	
 | 
			
		||||
			Stop ();
 | 
			
		||||
		for (auto it: m_LeaseSetRequests)
 | 
			
		||||
		for (auto& it: m_LeaseSetRequests)
 | 
			
		||||
			if (it.second->requestComplete) it.second->requestComplete (nullptr);
 | 
			
		||||
		m_LeaseSetRequests.clear ();
 | 
			
		||||
		if (m_Pool)
 | 
			
		||||
| 
						 | 
				
			
			@ -658,7 +658,7 @@ namespace client
 | 
			
		|||
				it = m_RemoteLeaseSets.erase (it);
 | 
			
		||||
			}	
 | 
			
		||||
			else 
 | 
			
		||||
				it++;
 | 
			
		||||
				++it;
 | 
			
		||||
		}
 | 
			
		||||
	}	
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -686,7 +686,7 @@ namespace client
 | 
			
		|||
		{	
 | 
			
		||||
			m_StreamingDestination = std::make_shared<i2p::stream::StreamingDestination> (GetSharedFromThis ()); // TODO:
 | 
			
		||||
			m_StreamingDestination->Start ();	
 | 
			
		||||
			for (auto it: m_StreamingDestinationsByPorts)
 | 
			
		||||
			for (auto& it: m_StreamingDestinationsByPorts)
 | 
			
		||||
				it.second->Start ();
 | 
			
		||||
			return true;
 | 
			
		||||
		}	
 | 
			
		||||
| 
						 | 
				
			
			@ -700,7 +700,7 @@ namespace client
 | 
			
		|||
		{
 | 
			
		||||
			m_StreamingDestination->Stop ();
 | 
			
		||||
			m_StreamingDestination = nullptr;
 | 
			
		||||
			for (auto it: m_StreamingDestinationsByPorts)
 | 
			
		||||
			for (auto& it: m_StreamingDestinationsByPorts)
 | 
			
		||||
				it.second->Stop ();
 | 
			
		||||
			if (m_DatagramDestination)
 | 
			
		||||
			{
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										20
									
								
								Garlic.cpp
									
										
									
									
									
								
							
							
						
						
									
										20
									
								
								Garlic.cpp
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -111,7 +111,7 @@ namespace garlic
 | 
			
		|||
				it = m_UnconfirmedTagsMsgs.erase (it);
 | 
			
		||||
			}	
 | 
			
		||||
			else 
 | 
			
		||||
				it++;
 | 
			
		||||
				++it;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -123,7 +123,7 @@ namespace garlic
 | 
			
		|||
			if (ts >= it->creationTime + OUTGOING_TAGS_EXPIRATION_TIMEOUT)
 | 
			
		||||
				it = m_SessionTags.erase (it);
 | 
			
		||||
			else 
 | 
			
		||||
				it++;
 | 
			
		||||
				++it;
 | 
			
		||||
		}
 | 
			
		||||
		CleanupUnconfirmedTags ();
 | 
			
		||||
		return !m_SessionTags.empty () || !m_UnconfirmedTagsMsgs.empty ();
 | 
			
		||||
| 
						 | 
				
			
			@ -144,7 +144,7 @@ namespace garlic
 | 
			
		|||
				ret = true;
 | 
			
		||||
			}	
 | 
			
		||||
			else
 | 
			
		||||
				it++;
 | 
			
		||||
				++it;
 | 
			
		||||
		}	
 | 
			
		||||
		return ret;
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -615,7 +615,7 @@ namespace garlic
 | 
			
		|||
				it = m_Tags.erase (it);
 | 
			
		||||
			}	
 | 
			
		||||
			else
 | 
			
		||||
				it++;
 | 
			
		||||
				++it;
 | 
			
		||||
		}
 | 
			
		||||
		if (numExpiredTags > 0)
 | 
			
		||||
			LogPrint (eLogDebug, "Garlic: ", numExpiredTags, " tags expired for ", GetIdentHash().ToBase64 ());
 | 
			
		||||
| 
						 | 
				
			
			@ -631,7 +631,7 @@ namespace garlic
 | 
			
		|||
				it = m_Sessions.erase (it);
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
				it++;
 | 
			
		||||
				++it;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -643,26 +643,26 @@ namespace garlic
 | 
			
		|||
	void GarlicDestination::DeliveryStatusSent (GarlicRoutingSessionPtr session, uint32_t msgID)
 | 
			
		||||
	{
 | 
			
		||||
		m_DeliveryStatusSessions[msgID] = session;
 | 
			
		||||
	}		
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	void GarlicDestination::HandleDeliveryStatusMessage (std::shared_ptr<I2NPMessage> msg)
 | 
			
		||||
	{
 | 
			
		||||
		uint32_t msgID = bufbe32toh (msg->GetPayload ());
 | 
			
		||||
		{
 | 
			
		||||
			auto it = m_DeliveryStatusSessions.find (msgID);
 | 
			
		||||
			if (it != m_DeliveryStatusSessions.end ())			
 | 
			
		||||
			if (it != m_DeliveryStatusSessions.end ())
 | 
			
		||||
			{
 | 
			
		||||
				it->second->MessageConfirmed (msgID);
 | 
			
		||||
				m_DeliveryStatusSessions.erase (it);
 | 
			
		||||
				LogPrint (eLogDebug, "Garlic: message ", msgID, " acknowledged");
 | 
			
		||||
			}	
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	void GarlicDestination::SetLeaseSetUpdated ()
 | 
			
		||||
	{
 | 
			
		||||
		std::unique_lock<std::mutex> l(m_SessionsMutex);	
 | 
			
		||||
		for (auto it: m_Sessions)
 | 
			
		||||
		std::unique_lock<std::mutex> l(m_SessionsMutex);
 | 
			
		||||
		for (auto& it: m_Sessions)
 | 
			
		||||
			it.second->SetLeaseSetUpdated ();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										2
									
								
								HTTP.cpp
									
										
									
									
									
								
							
							
						
						
									
										2
									
								
								HTTP.cpp
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -160,7 +160,7 @@ namespace http {
 | 
			
		|||
    strsplit(query, tokens, '&');
 | 
			
		||||
 | 
			
		||||
    params.clear();
 | 
			
		||||
    for (auto it : tokens) {
 | 
			
		||||
    for (const auto& it : tokens) {
 | 
			
		||||
      std::size_t eq = it.find ('=');
 | 
			
		||||
      if (eq != std::string::npos) {
 | 
			
		||||
        auto e = std::pair<std::string, std::string>(it.substr(0, eq), it.substr(eq + 1));
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -105,7 +105,7 @@ namespace proxy {
 | 
			
		|||
		ss << "<p>" << description << "</p>\r\n";
 | 
			
		||||
		std::string content = ss.str();
 | 
			
		||||
		SendProxyError(content);
 | 
			
		||||
  }
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	void HTTPReqHandler::HostNotFound(std::string & host) {
 | 
			
		||||
		std::stringstream ss;
 | 
			
		||||
| 
						 | 
				
			
			@ -113,13 +113,13 @@ namespace proxy {
 | 
			
		|||
		   << "<p>Remote host not found in router's addressbook</p>\r\n"
 | 
			
		||||
		   << "<p>You may try to find this host on jumpservices below:</p>\r\n"
 | 
			
		||||
		   << "<ul>\r\n";
 | 
			
		||||
		for (auto & js : jumpservices) {
 | 
			
		||||
		for (const auto& js : jumpservices) {
 | 
			
		||||
			ss << "  <li><a href=\"" << js.second << host << "\">" << js.first << "</a></li>\r\n";
 | 
			
		||||
		}
 | 
			
		||||
		ss << "</ul>\r\n";
 | 
			
		||||
		std::string content = ss.str();
 | 
			
		||||
		SendProxyError(content);
 | 
			
		||||
  }
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	void HTTPReqHandler::SendProxyError(std::string & content)
 | 
			
		||||
	{
 | 
			
		||||
| 
						 | 
				
			
			@ -164,7 +164,7 @@ namespace proxy {
 | 
			
		|||
		req.del_header("Forwarded");
 | 
			
		||||
		/* drop proxy-disclosing headers */
 | 
			
		||||
		std::vector<std::string> toErase;
 | 
			
		||||
		for (auto it : req.headers) {
 | 
			
		||||
		for (const auto& it : req.headers) {
 | 
			
		||||
			if (it.first.compare(0, 12, "X-Forwarded-") == 0) {
 | 
			
		||||
				toErase.push_back(it.first);
 | 
			
		||||
			} else if (it.first.compare(0, 6, "Proxy-") == 0) {
 | 
			
		||||
| 
						 | 
				
			
			@ -173,7 +173,7 @@ namespace proxy {
 | 
			
		|||
				/* allow */
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		for (auto header : toErase) {
 | 
			
		||||
		for (const auto& header : toErase) {
 | 
			
		||||
			req.headers.erase(header);
 | 
			
		||||
		}
 | 
			
		||||
		/* replace headers */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -210,7 +210,7 @@ namespace http {
 | 
			
		|||
		s << "<b>Router Family:</b> " << i2p::context.GetRouterInfo().GetProperty("family") << "<br>\r\n";
 | 
			
		||||
		s << "<b>Router Caps:</b> " << i2p::context.GetRouterInfo().GetProperty("caps") << "<br>\r\n";
 | 
			
		||||
		s << "<b>Our external address:</b>" << "<br>\r\n" ;
 | 
			
		||||
		for (auto address : i2p::context.GetRouterInfo().GetAddresses())
 | 
			
		||||
		for (const auto& address : i2p::context.GetRouterInfo().GetAddresses())
 | 
			
		||||
		{
 | 
			
		||||
			switch (address->transportStyle)
 | 
			
		||||
			{
 | 
			
		||||
| 
						 | 
				
			
			@ -283,7 +283,7 @@ namespace http {
 | 
			
		|||
			}	
 | 
			
		||||
			s << "<br>\r\n";
 | 
			
		||||
			s << "<b>Tags</b><br>Incoming: " << dest->GetNumIncomingTags () << "<br>Outgoing:<br>" << std::endl;
 | 
			
		||||
			for (auto it: dest->GetSessions ())
 | 
			
		||||
			for (const auto& it: dest->GetSessions ())
 | 
			
		||||
			{
 | 
			
		||||
				s << i2p::client::context.GetAddressBook ().ToAddress(it.first) << " ";
 | 
			
		||||
				s << it.second->GetNumOutgoingTags () << "<br>" << std::endl;
 | 
			
		||||
| 
						 | 
				
			
			@ -314,7 +314,7 @@ namespace http {
 | 
			
		|||
			s << "<th>Status</th>";
 | 
			
		||||
			s << "</tr>";
 | 
			
		||||
 | 
			
		||||
			for (auto it: dest->GetAllStreams ())
 | 
			
		||||
			for (const auto& it: dest->GetAllStreams ())
 | 
			
		||||
			{	
 | 
			
		||||
				s << "<tr>";
 | 
			
		||||
				s << "<td>" << it->GetSendStreamID () << "</td>";
 | 
			
		||||
| 
						 | 
				
			
			@ -432,7 +432,7 @@ namespace http {
 | 
			
		|||
	void ShowTransitTunnels (std::stringstream& s)
 | 
			
		||||
	{
 | 
			
		||||
		s << "<b>Transit tunnels:</b><br>\r\n<br>\r\n";
 | 
			
		||||
		for (auto it: i2p::tunnel::tunnels.GetTransitTunnels ())
 | 
			
		||||
		for (const auto& it: i2p::tunnel::tunnels.GetTransitTunnels ())
 | 
			
		||||
		{
 | 
			
		||||
			if (std::dynamic_pointer_cast<i2p::tunnel::TransitTunnelGateway>(it))
 | 
			
		||||
				s << it->GetTunnelID () << " ⇒ ";
 | 
			
		||||
| 
						 | 
				
			
			@ -451,7 +451,7 @@ namespace http {
 | 
			
		|||
		if (ntcpServer)
 | 
			
		||||
		{	
 | 
			
		||||
			s << "<b>NTCP</b><br>\r\n";
 | 
			
		||||
			for (auto it: ntcpServer->GetNTCPSessions ())
 | 
			
		||||
			for (const auto& it: ntcpServer->GetNTCPSessions ())
 | 
			
		||||
			{
 | 
			
		||||
				if (it.second && it.second->IsEstablished ())
 | 
			
		||||
				{
 | 
			
		||||
| 
						 | 
				
			
			@ -469,7 +469,7 @@ namespace http {
 | 
			
		|||
		if (ssuServer)
 | 
			
		||||
		{
 | 
			
		||||
			s << "<br>\r\n<b>SSU</b><br>\r\n";
 | 
			
		||||
			for (auto it: ssuServer->GetSessions ())
 | 
			
		||||
			for (const auto& it: ssuServer->GetSessions ())
 | 
			
		||||
			{
 | 
			
		||||
				auto endpoint = it.second->GetRemoteEndpoint ();
 | 
			
		||||
				if (it.second->IsOutgoing ()) s << " ⇒ ";
 | 
			
		||||
| 
						 | 
				
			
			@ -481,7 +481,7 @@ namespace http {
 | 
			
		|||
				s << "<br>\r\n" << std::endl;
 | 
			
		||||
			}
 | 
			
		||||
			s << "<br>\r\n<b>SSU6</b><br>\r\n";
 | 
			
		||||
			for (auto it: ssuServer->GetSessionsV6 ())
 | 
			
		||||
			for (const auto& it: ssuServer->GetSessionsV6 ())
 | 
			
		||||
			{
 | 
			
		||||
				auto endpoint = it.second->GetRemoteEndpoint ();
 | 
			
		||||
				if (it.second->IsOutgoing ()) s << " ⇒ ";
 | 
			
		||||
| 
						 | 
				
			
			@ -526,7 +526,7 @@ namespace http {
 | 
			
		|||
		s << i2p::client::context.GetAddressBook ().ToAddress(ident) << "</a><br>\r\n";
 | 
			
		||||
		s << "<br>\r\n";
 | 
			
		||||
		s << "<b>Streams:</b><br>\r\n";
 | 
			
		||||
		for (auto it: session->ListSockets())
 | 
			
		||||
		for (const auto& it: session->ListSockets())
 | 
			
		||||
		{
 | 
			
		||||
			switch (it->GetSocketType ())
 | 
			
		||||
			{
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										2
									
								
								I2CP.cpp
									
										
									
									
									
								
							
							
						
						
									
										2
									
								
								I2CP.cpp
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -659,7 +659,7 @@ namespace client
 | 
			
		|||
	{
 | 
			
		||||
		m_IsRunning = false;
 | 
			
		||||
		m_Acceptor.cancel ();
 | 
			
		||||
		for (auto it: m_Sessions)
 | 
			
		||||
		for (auto& it: m_Sessions)
 | 
			
		||||
			it.second->Stop ();
 | 
			
		||||
		m_Sessions.clear ();
 | 
			
		||||
		m_Service.stop ();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -202,7 +202,7 @@ namespace i2p
 | 
			
		|||
		len += 32;
 | 
			
		||||
		buf[len] = routers.size (); 
 | 
			
		||||
		len++;
 | 
			
		||||
		for (auto it: routers)
 | 
			
		||||
		for (const auto& it: routers)
 | 
			
		||||
		{
 | 
			
		||||
			memcpy (buf + len, it, 32);
 | 
			
		||||
			len += 32;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -358,7 +358,7 @@ namespace client
 | 
			
		|||
 | 
			
		||||
	void I2PControlService::RouterInfoHandler (const boost::property_tree::ptree& params, std::ostringstream& results)
 | 
			
		||||
	{
 | 
			
		||||
		for (auto it = params.begin (); it != params.end (); it++)
 | 
			
		||||
		for (auto it = params.begin (); it != params.end (); ++it)
 | 
			
		||||
		{
 | 
			
		||||
			LogPrint (eLogDebug, "I2PControl: RouterInfo request: ", it->first);
 | 
			
		||||
			auto it1 = m_RouterInfoHandlers.find (it->first);
 | 
			
		||||
| 
						 | 
				
			
			@ -434,7 +434,7 @@ namespace client
 | 
			
		|||
 | 
			
		||||
	void I2PControlService::RouterManagerHandler (const boost::property_tree::ptree& params, std::ostringstream& results)
 | 
			
		||||
	{
 | 
			
		||||
		for (auto it = params.begin (); it != params.end (); it++)
 | 
			
		||||
		for (auto it = params.begin (); it != params.end (); ++it)
 | 
			
		||||
		{
 | 
			
		||||
			if (it != params.begin ()) results << ",";	
 | 
			
		||||
			LogPrint (eLogDebug, "I2PControl: RouterManager request: ", it->first);
 | 
			
		||||
| 
						 | 
				
			
			@ -483,7 +483,7 @@ namespace client
 | 
			
		|||
// network setting
 | 
			
		||||
	void I2PControlService::NetworkSettingHandler (const boost::property_tree::ptree& params, std::ostringstream& results)
 | 
			
		||||
	{
 | 
			
		||||
		for (auto it = params.begin (); it != params.end (); it++)
 | 
			
		||||
		for (auto it = params.begin (); it != params.end (); ++it)
 | 
			
		||||
		{
 | 
			
		||||
			if (it != params.begin ()) results << ",";	
 | 
			
		||||
			LogPrint (eLogDebug, "I2PControl: NetworkSetting request: ", it->first);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										12
									
								
								LeaseSet.cpp
									
										
									
									
									
								
							
							
						
						
									
										12
									
								
								LeaseSet.cpp
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -64,10 +64,10 @@ namespace data
 | 
			
		|||
			return;
 | 
			
		||||
		}	
 | 
			
		||||
 | 
			
		||||
		// reset existing leases	
 | 
			
		||||
		// reset existing leases
 | 
			
		||||
		if (m_StoreLeases)
 | 
			
		||||
			for (auto it: m_Leases)
 | 
			
		||||
				it->isUpdated = false;		
 | 
			
		||||
			for (auto& it: m_Leases)
 | 
			
		||||
				it->isUpdated = false;
 | 
			
		||||
		else	
 | 
			
		||||
			m_Leases.clear ();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -123,7 +123,7 @@ namespace data
 | 
			
		|||
					m_Leases.erase (it++);
 | 
			
		||||
				}	
 | 
			
		||||
				else
 | 
			
		||||
					it++;
 | 
			
		||||
					++it;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -174,7 +174,7 @@ namespace data
 | 
			
		|||
	{
 | 
			
		||||
		auto ts = i2p::util::GetMillisecondsSinceEpoch ();
 | 
			
		||||
		std::vector<std::shared_ptr<const Lease> > leases;
 | 
			
		||||
		for (auto it: m_Leases)
 | 
			
		||||
		for (const auto& it: m_Leases)
 | 
			
		||||
		{
 | 
			
		||||
			auto endDate = it->endDate;
 | 
			
		||||
			if (withThreshold)
 | 
			
		||||
| 
						 | 
				
			
			@ -190,7 +190,7 @@ namespace data
 | 
			
		|||
	bool LeaseSet::HasExpiredLeases () const
 | 
			
		||||
 	{
 | 
			
		||||
		auto ts = i2p::util::GetMillisecondsSinceEpoch ();
 | 
			
		||||
		for (auto it: m_Leases)
 | 
			
		||||
		for (const auto& it: m_Leases)
 | 
			
		||||
			if (ts >= it->endDate) return true;
 | 
			
		||||
		return false;
 | 
			
		||||
 	}	
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -19,7 +19,8 @@ namespace i2p
 | 
			
		|||
namespace transport
 | 
			
		||||
{
 | 
			
		||||
	NTCPSession::NTCPSession (NTCPServer& server, std::shared_ptr<const i2p::data::RouterInfo> in_RemoteRouter): 
 | 
			
		||||
		TransportSession (in_RemoteRouter),	m_Server (server), m_Socket (m_Server.GetService ()), 
 | 
			
		||||
		TransportSession (in_RemoteRouter, NTCP_TERMINATION_TIMEOUT),	
 | 
			
		||||
		m_Server (server), m_Socket (m_Server.GetService ()), 
 | 
			
		||||
		m_TerminationTimer (m_Server.GetService ()), m_IsEstablished (false), m_IsTerminated (false),
 | 
			
		||||
		m_ReceiveBufferOffset (0), m_NextMessage (nullptr), m_IsSending (false)
 | 
			
		||||
	{		
 | 
			
		||||
| 
						 | 
				
			
			@ -731,7 +732,7 @@ namespace transport
 | 
			
		|||
	void NTCPSession::ScheduleTermination ()
 | 
			
		||||
	{
 | 
			
		||||
		m_TerminationTimer.cancel ();
 | 
			
		||||
		m_TerminationTimer.expires_from_now (boost::posix_time::seconds(NTCP_TERMINATION_TIMEOUT));
 | 
			
		||||
		m_TerminationTimer.expires_from_now (boost::posix_time::seconds(GetTerminationTimeout ()));
 | 
			
		||||
		m_TerminationTimer.async_wait (std::bind (&NTCPSession::HandleTerminationTimer,
 | 
			
		||||
			shared_from_this (), std::placeholders::_1));
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -740,7 +741,7 @@ namespace transport
 | 
			
		|||
	{
 | 
			
		||||
		if (ecode != boost::asio::error::operation_aborted)
 | 
			
		||||
		{	
 | 
			
		||||
			LogPrint (eLogDebug, "NTCP: No activity for ", NTCP_TERMINATION_TIMEOUT, " seconds");
 | 
			
		||||
			LogPrint (eLogDebug, "NTCP: No activity for ", GetTerminationTimeout (), " seconds");
 | 
			
		||||
			//Terminate ();
 | 
			
		||||
			m_Socket.close ();// invoke Terminate () from HandleReceive 
 | 
			
		||||
		}	
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										26
									
								
								NetDb.cpp
									
										
									
									
									
								
							
							
						
						
									
										26
									
								
								NetDb.cpp
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -51,7 +51,7 @@ namespace data
 | 
			
		|||
	{
 | 
			
		||||
		if (m_IsRunning)
 | 
			
		||||
		{	
 | 
			
		||||
			for (auto it: m_RouterInfos)
 | 
			
		||||
			for (auto& it: m_RouterInfos)
 | 
			
		||||
				it.second->SaveProfile ();
 | 
			
		||||
			DeleteObsoleteProfiles ();
 | 
			
		||||
			m_RouterInfos.clear ();
 | 
			
		||||
| 
						 | 
				
			
			@ -339,7 +339,7 @@ namespace data
 | 
			
		|||
		m_LastLoad = i2p::util::GetSecondsSinceEpoch();
 | 
			
		||||
		std::vector<std::string> files;
 | 
			
		||||
		m_Storage.Traverse(files);
 | 
			
		||||
		for (auto path : files)
 | 
			
		||||
		for (const auto& path : files)
 | 
			
		||||
			LoadRouterInfo(path);
 | 
			
		||||
 | 
			
		||||
		LogPrint (eLogInfo, "NetDb: ", m_RouterInfos.size(), " routers loaded (", m_Floodfills.size (), " floodfils)");
 | 
			
		||||
| 
						 | 
				
			
			@ -357,7 +357,7 @@ namespace data
 | 
			
		|||
			expirationTimeout = i2p::context.IsFloodfill () ? NETDB_FLOODFILL_EXPIRATION_TIMEOUT*1000LL :
 | 
			
		||||
					NETDB_MIN_EXPIRATION_TIMEOUT*1000LL + (NETDB_MAX_EXPIRATION_TIMEOUT - NETDB_MIN_EXPIRATION_TIMEOUT)*1000LL*NETDB_MIN_ROUTERS/total;	
 | 
			
		||||
 | 
			
		||||
		for (auto it: m_RouterInfos)
 | 
			
		||||
		for (auto& it: m_RouterInfos)
 | 
			
		||||
		{	
 | 
			
		||||
			std::string ident = it.second->GetIdentHashBase64();
 | 
			
		||||
			std::string path  = m_Storage.Path(ident);
 | 
			
		||||
| 
						 | 
				
			
			@ -405,7 +405,7 @@ namespace data
 | 
			
		|||
						it = m_RouterInfos.erase (it);
 | 
			
		||||
						continue;
 | 
			
		||||
					}	
 | 
			
		||||
					it++;
 | 
			
		||||
					++it;
 | 
			
		||||
				}
 | 
			
		||||
			}	
 | 
			
		||||
			// clean up expired floodfiils
 | 
			
		||||
| 
						 | 
				
			
			@ -415,7 +415,7 @@ namespace data
 | 
			
		|||
					if ((*it)->IsUnreachable ())
 | 
			
		||||
						it = m_Floodfills.erase (it);
 | 
			
		||||
					else
 | 
			
		||||
						it++;
 | 
			
		||||
						++it;
 | 
			
		||||
			}	
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -901,7 +901,7 @@ namespace data
 | 
			
		|||
		{	
 | 
			
		||||
			uint32_t i = 0;
 | 
			
		||||
			std::unique_lock<std::mutex> l(m_RouterInfosMutex);
 | 
			
		||||
			for (auto it: m_RouterInfos)
 | 
			
		||||
			for (const auto& it: m_RouterInfos)
 | 
			
		||||
			{	
 | 
			
		||||
				if (i >= ind)
 | 
			
		||||
				{	
 | 
			
		||||
| 
						 | 
				
			
			@ -933,7 +933,7 @@ namespace data
 | 
			
		|||
		else	
 | 
			
		||||
			minMetric.SetMax ();
 | 
			
		||||
		std::unique_lock<std::mutex> l(m_FloodfillsMutex);
 | 
			
		||||
		for (auto it: m_Floodfills)
 | 
			
		||||
		for (const auto& it: m_Floodfills)
 | 
			
		||||
		{	
 | 
			
		||||
			if (!it->IsUnreachable ())
 | 
			
		||||
			{	
 | 
			
		||||
| 
						 | 
				
			
			@ -964,7 +964,7 @@ namespace data
 | 
			
		|||
		if (closeThanUsOnly) ourMetric = destKey ^ i2p::context.GetIdentHash ();
 | 
			
		||||
		{
 | 
			
		||||
			std::unique_lock<std::mutex> l(m_FloodfillsMutex);
 | 
			
		||||
			for (auto it: m_Floodfills)
 | 
			
		||||
			for (const auto& it: m_Floodfills)
 | 
			
		||||
			{
 | 
			
		||||
				if (!it->IsUnreachable ())
 | 
			
		||||
				{	
 | 
			
		||||
| 
						 | 
				
			
			@ -983,11 +983,11 @@ namespace data
 | 
			
		|||
 | 
			
		||||
		std::vector<IdentHash> res;	
 | 
			
		||||
		size_t i = 0;			
 | 
			
		||||
		for (auto it: sorted)
 | 
			
		||||
		for (const auto& it: sorted)
 | 
			
		||||
		{
 | 
			
		||||
			if (i < num)
 | 
			
		||||
			{
 | 
			
		||||
				auto& ident = it.r->GetIdentHash ();
 | 
			
		||||
				const auto& ident = it.r->GetIdentHash ();
 | 
			
		||||
				if (!excluded.count (ident))
 | 
			
		||||
				{	
 | 
			
		||||
					res.push_back (ident);
 | 
			
		||||
| 
						 | 
				
			
			@ -1016,7 +1016,7 @@ namespace data
 | 
			
		|||
		IdentHash destKey = CreateRoutingKey (destination);
 | 
			
		||||
		minMetric.SetMax ();
 | 
			
		||||
		// must be called from NetDb thread only
 | 
			
		||||
		for (auto it: m_RouterInfos)
 | 
			
		||||
		for (const auto& it: m_RouterInfos)
 | 
			
		||||
		{	
 | 
			
		||||
			if (!it.second->IsFloodfill ())
 | 
			
		||||
			{	
 | 
			
		||||
| 
						 | 
				
			
			@ -1042,7 +1042,7 @@ namespace data
 | 
			
		|||
				it = m_LeaseSets.erase (it);
 | 
			
		||||
			}	
 | 
			
		||||
			else 
 | 
			
		||||
				it++;
 | 
			
		||||
				++it;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1054,7 +1054,7 @@ namespace data
 | 
			
		|||
			if (ts > it->second.second + 180) // 3 minutes
 | 
			
		||||
				it = m_LookupResponses.erase (it);
 | 
			
		||||
			else
 | 
			
		||||
				it++;
 | 
			
		||||
				++it;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -141,7 +141,7 @@ namespace data
 | 
			
		|||
			if (done)
 | 
			
		||||
				it = m_RequestedDestinations.erase (it);
 | 
			
		||||
			else
 | 
			
		||||
				it++;
 | 
			
		||||
				++it;
 | 
			
		||||
		}	
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -167,7 +167,7 @@ namespace data
 | 
			
		|||
 | 
			
		||||
		std::vector<std::string> files;
 | 
			
		||||
		m_ProfilesStorage.Traverse(files);
 | 
			
		||||
		for (auto path: files) {
 | 
			
		||||
		for (const auto& path: files) {
 | 
			
		||||
			if (stat(path.c_str(), &st) != 0) {
 | 
			
		||||
				LogPrint(eLogWarning, "Profiling: Can't stat(): ", path);
 | 
			
		||||
				continue;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										5
									
								
								Queue.h
									
										
									
									
									
								
							
							
						
						
									
										5
									
								
								Queue.h
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -7,6 +7,7 @@
 | 
			
		|||
#include <thread>
 | 
			
		||||
#include <condition_variable>
 | 
			
		||||
#include <functional>
 | 
			
		||||
#include <utility>
 | 
			
		||||
 | 
			
		||||
namespace i2p
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -20,7 +21,7 @@ namespace util
 | 
			
		|||
			void Put (Element e)
 | 
			
		||||
			{
 | 
			
		||||
				std::unique_lock<std::mutex>  l(m_QueueMutex);
 | 
			
		||||
				m_Queue.push (e);	
 | 
			
		||||
				m_Queue.push (std::move(e));
 | 
			
		||||
				m_NonEmpty.notify_one ();
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -29,7 +30,7 @@ namespace util
 | 
			
		|||
				if (!vec.empty ())
 | 
			
		||||
				{	
 | 
			
		||||
					std::unique_lock<std::mutex>  l(m_QueueMutex);
 | 
			
		||||
					for (auto it: vec)
 | 
			
		||||
					for (const auto& it: vec)
 | 
			
		||||
						m_Queue.push (it);	
 | 
			
		||||
					m_NonEmpty.notify_one ();
 | 
			
		||||
				}	
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -26,7 +26,7 @@ namespace proxy
 | 
			
		|||
	{
 | 
			
		||||
		uint8_t size;
 | 
			
		||||
		char value[max_socks_hostname_size];
 | 
			
		||||
		void FromString (std::string str) 
 | 
			
		||||
		void FromString (const std::string& str)
 | 
			
		||||
		{
 | 
			
		||||
			size = str.length();
 | 
			
		||||
			if (str.length() > max_socks_hostname_size) size = max_socks_hostname_size;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -12,7 +12,8 @@ namespace i2p
 | 
			
		|||
namespace transport
 | 
			
		||||
{
 | 
			
		||||
	SSUSession::SSUSession (SSUServer& server, boost::asio::ip::udp::endpoint& remoteEndpoint,
 | 
			
		||||
		std::shared_ptr<const i2p::data::RouterInfo> router, bool peerTest ): TransportSession (router), 
 | 
			
		||||
		std::shared_ptr<const i2p::data::RouterInfo> router, bool peerTest ): 
 | 
			
		||||
		TransportSession (router, SSU_TERMINATION_TIMEOUT), 
 | 
			
		||||
		m_Server (server), m_RemoteEndpoint (remoteEndpoint), m_Timer (GetService ()), 
 | 
			
		||||
		m_IsPeerTest (peerTest),m_State (eSessionStateUnknown), m_IsSessionKey (false), 
 | 
			
		||||
		m_RelayTag (0),m_Data (*this), m_IsDataReceived (false)
 | 
			
		||||
| 
						 | 
				
			
			@ -882,7 +883,7 @@ namespace transport
 | 
			
		|||
	void SSUSession::ScheduleTermination ()
 | 
			
		||||
	{
 | 
			
		||||
		m_Timer.cancel ();
 | 
			
		||||
		m_Timer.expires_from_now (boost::posix_time::seconds(SSU_TERMINATION_TIMEOUT));
 | 
			
		||||
		m_Timer.expires_from_now (boost::posix_time::seconds(GetTerminationTimeout ()));
 | 
			
		||||
		m_Timer.async_wait (std::bind (&SSUSession::HandleTerminationTimer,
 | 
			
		||||
			shared_from_this (), std::placeholders::_1));
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -891,7 +892,7 @@ namespace transport
 | 
			
		|||
	{
 | 
			
		||||
		if (ecode != boost::asio::error::operation_aborted)
 | 
			
		||||
		{	
 | 
			
		||||
			LogPrint (eLogWarning, "SSU: no activity with ", m_RemoteEndpoint, " for ", SSU_TERMINATION_TIMEOUT, " seconds");
 | 
			
		||||
			LogPrint (eLogWarning, "SSU: no activity with ", m_RemoteEndpoint, " for ", GetTerminationTimeout (), " seconds");
 | 
			
		||||
			Failed ();
 | 
			
		||||
		}	
 | 
			
		||||
	}	
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -53,8 +53,8 @@ namespace transport
 | 
			
		|||
	{
 | 
			
		||||
		public:
 | 
			
		||||
 | 
			
		||||
			TransportSession (std::shared_ptr<const i2p::data::RouterInfo> router): 
 | 
			
		||||
				m_DHKeysPair (nullptr), m_NumSentBytes (0), m_NumReceivedBytes (0), m_IsOutgoing (router)
 | 
			
		||||
			TransportSession (std::shared_ptr<const i2p::data::RouterInfo> router, int terminationTimeout): 
 | 
			
		||||
				m_DHKeysPair (nullptr), m_NumSentBytes (0), m_NumReceivedBytes (0), m_IsOutgoing (router), m_TerminationTimeout (terminationTimeout)
 | 
			
		||||
			{
 | 
			
		||||
				if (router)
 | 
			
		||||
					m_RemoteIdentity = router->GetRouterIdentity ();
 | 
			
		||||
| 
						 | 
				
			
			@ -70,6 +70,9 @@ namespace transport
 | 
			
		|||
			size_t GetNumReceivedBytes () const { return m_NumReceivedBytes; };
 | 
			
		||||
			bool IsOutgoing () const { return m_IsOutgoing; };
 | 
			
		||||
			
 | 
			
		||||
			int GetTerminationTimeout () const { return m_TerminationTimeout; };
 | 
			
		||||
			void SetTerminationTimeout (int terminationTimeout) { m_TerminationTimeout = terminationTimeout; };	
 | 
			
		||||
 | 
			
		||||
			virtual void SendI2NPMessages (const std::vector<std::shared_ptr<I2NPMessage> >& msgs) = 0;
 | 
			
		||||
			
 | 
			
		||||
		protected:
 | 
			
		||||
| 
						 | 
				
			
			@ -78,6 +81,7 @@ namespace transport
 | 
			
		|||
			std::shared_ptr<i2p::crypto::DHKeys> m_DHKeysPair; // X - for client and Y - for server
 | 
			
		||||
			size_t m_NumSentBytes, m_NumReceivedBytes;
 | 
			
		||||
			bool m_IsOutgoing;
 | 
			
		||||
			int m_TerminationTimeout;
 | 
			
		||||
	};	
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -570,6 +570,8 @@ namespace transport
 | 
			
		|||
				}	
 | 
			
		||||
				if (sendDatabaseStore)
 | 
			
		||||
					session->SendI2NPMessages ({ CreateDatabaseStoreMsg () });
 | 
			
		||||
				else
 | 
			
		||||
					session->SetTerminationTimeout (10); // most likely it's publishing, no follow-up messages expected, set timeout to 10 seconds
 | 
			
		||||
				it->second.sessions.push_back (session);
 | 
			
		||||
				session->SendI2NPMessages (it->second.delayedMessages);
 | 
			
		||||
				it->second.delayedMessages.clear ();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										2
									
								
								Tunnel.h
									
										
									
									
									
								
							
							
						
						
									
										2
									
								
								Tunnel.h
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -224,7 +224,7 @@ namespace tunnel
 | 
			
		|||
			std::list<std::shared_ptr<TunnelPool>> m_Pools;
 | 
			
		||||
			std::shared_ptr<TunnelPool> m_ExploratoryPool;
 | 
			
		||||
			i2p::util::Queue<std::shared_ptr<I2NPMessage> > m_Queue;
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
			// some stats
 | 
			
		||||
			int m_NumSuccesiveTunnelCreations, m_NumFailedTunnelCreations;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -23,7 +23,7 @@ After successfull build i2pd could be installed with:
 | 
			
		|||
```bash
 | 
			
		||||
make install
 | 
			
		||||
```
 | 
			
		||||
or you can just use 'make' once you have all dependacies (boost and openssl) installed 
 | 
			
		||||
or you can just use 'make' once you have all dependencies (boost and openssl) installed 
 | 
			
		||||
 | 
			
		||||
```bash
 | 
			
		||||
git clone https://github.com/PurpleI2P/i2pd.git
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue