mirror of
				https://github.com/PurpleI2P/i2pd.git
				synced 2025-11-04 08:30:46 +00:00 
			
		
		
		
	filter out unspecified addresses. Check floodfill status change
This commit is contained in:
		
							parent
							
								
									0f9e3c5b33
								
							
						
					
					
						commit
						846eac29dc
					
				
					 4 changed files with 44 additions and 44 deletions
				
			
		| 
						 | 
				
			
			@ -207,9 +207,18 @@ namespace data
 | 
			
		|||
		{
 | 
			
		||||
			if (r->IsNewer (buf, len))
 | 
			
		||||
			{
 | 
			
		||||
				bool wasFloodfill = r->IsFloodfill ();
 | 
			
		||||
				r->Update (buf, len);
 | 
			
		||||
				LogPrint (eLogInfo, "NetDb: RouterInfo updated: ", ident.ToBase64());
 | 
			
		||||
				// TODO: check if floodfill has been changed
 | 
			
		||||
				if (wasFloodfill != r->IsFloodfill ()) // if floodfill status updated
 | 
			
		||||
				{
 | 
			
		||||
					LogPrint (eLogDebug, "NetDb: RouterInfo floodfill status updated: ", ident.ToBase64());
 | 
			
		||||
					std::unique_lock<std::mutex> l(m_FloodfillsMutex);
 | 
			
		||||
					if (wasFloodfill)
 | 
			
		||||
						m_Floodfills.remove (r);	
 | 
			
		||||
					else	
 | 
			
		||||
						m_Floodfills.push_back (r);
 | 
			
		||||
				}	
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
| 
						 | 
				
			
			@ -220,7 +229,7 @@ namespace data
 | 
			
		|||
		else
 | 
			
		||||
		{
 | 
			
		||||
			r = std::make_shared<RouterInfo> (buf, len);
 | 
			
		||||
			if (!r->IsUnreachable ())
 | 
			
		||||
			if (!r->IsUnreachable () && r->HasValidAddresses ())
 | 
			
		||||
			{
 | 
			
		||||
				bool inserted = false;
 | 
			
		||||
				{
 | 
			
		||||
| 
						 | 
				
			
			@ -559,11 +568,11 @@ namespace data
 | 
			
		|||
					++it;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			// clean up expired floodfills
 | 
			
		||||
			// clean up expired floodfills or not floodfills anymore
 | 
			
		||||
			{
 | 
			
		||||
				std::unique_lock<std::mutex> l(m_FloodfillsMutex);
 | 
			
		||||
				for (auto it = m_Floodfills.begin (); it != m_Floodfills.end ();)
 | 
			
		||||
					if ((*it)->IsUnreachable ())
 | 
			
		||||
					if ((*it)->IsUnreachable () || !(*it)->IsFloodfill ())
 | 
			
		||||
						it = m_Floodfills.erase (it);
 | 
			
		||||
					else
 | 
			
		||||
						++it;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -210,11 +210,19 @@ namespace data
 | 
			
		|||
					address->host = boost::asio::ip::address::from_string (value, ecode);
 | 
			
		||||
					if (!ecode)
 | 
			
		||||
					{
 | 
			
		||||
						// add supported protocol
 | 
			
		||||
						if (address->host.is_v4 ())
 | 
			
		||||
							supportedTransports |= (address->transportStyle == eTransportNTCP) ? eNTCPV4 : eSSUV4;
 | 
			
		||||
						else
 | 
			
		||||
							supportedTransports |= (address->transportStyle == eTransportNTCP) ? eNTCPV6 : eSSUV6;
 | 
			
		||||
#if BOOST_VERSION >= 104900
 | 
			
		||||
						if (!address->host.is_unspecified ()) // check if address is valid
 | 
			
		||||
#else
 | 
			
		||||
						address->host.to_string (ecode);
 | 
			
		||||
						if (!ecode)
 | 
			
		||||
#endif
 | 
			
		||||
						{	
 | 
			
		||||
							// add supported protocol
 | 
			
		||||
							if (address->host.is_v4 ())
 | 
			
		||||
								supportedTransports |= (address->transportStyle == eTransportNTCP) ? eNTCPV4 : eSSUV4;
 | 
			
		||||
							else
 | 
			
		||||
								supportedTransports |= (address->transportStyle == eTransportNTCP) ? eNTCPV6 : eSSUV6;
 | 
			
		||||
						}	
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
				else if (!strcmp (key, "port"))
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -169,6 +169,7 @@ namespace data
 | 
			
		|||
			void EnableV4 ();
 | 
			
		||||
			void DisableV4 ();
 | 
			
		||||
			bool IsCompatible (const RouterInfo& other) const { return m_SupportedTransports & other.m_SupportedTransports; };
 | 
			
		||||
			bool HasValidAddresses () const { return m_SupportedTransports; };
 | 
			
		||||
			bool UsesIntroducer () const;
 | 
			
		||||
			bool IsIntroducer () const { return m_Caps & eSSUIntroducer; };
 | 
			
		||||
			bool IsPeerTesting () const { return m_Caps & eSSUTesting; };
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -426,37 +426,28 @@ namespace transport
 | 
			
		|||
				auto address = peer.router->GetNTCPAddress (!context.SupportsV6 ());
 | 
			
		||||
				if (address && m_NTCPServer)
 | 
			
		||||
				{
 | 
			
		||||
#if BOOST_VERSION >= 104900
 | 
			
		||||
					if (!address->host.is_unspecified ()) // we have address now
 | 
			
		||||
#else
 | 
			
		||||
					boost::system::error_code ecode;
 | 
			
		||||
				  address->host.to_string (ecode);
 | 
			
		||||
					if (!ecode)
 | 
			
		||||
#endif
 | 
			
		||||
					if (!peer.router->UsesIntroducer () && !peer.router->IsUnreachable ())
 | 
			
		||||
					{
 | 
			
		||||
						if (!peer.router->UsesIntroducer () && !peer.router->IsUnreachable ())
 | 
			
		||||
						if(!m_NTCPServer->ShouldLimit())
 | 
			
		||||
						{
 | 
			
		||||
							if(!m_NTCPServer->ShouldLimit())
 | 
			
		||||
							auto s = std::make_shared<NTCPSession> (*m_NTCPServer, peer.router);
 | 
			
		||||
							if(m_NTCPServer->UsingProxy())
 | 
			
		||||
							{
 | 
			
		||||
								auto s = std::make_shared<NTCPSession> (*m_NTCPServer, peer.router);
 | 
			
		||||
								if(m_NTCPServer->UsingProxy())
 | 
			
		||||
								{
 | 
			
		||||
									NTCPServer::RemoteAddressType remote = NTCPServer::eIP4Address;
 | 
			
		||||
									std::string addr = address->host.to_string();
 | 
			
		||||
								NTCPServer::RemoteAddressType remote = NTCPServer::eIP4Address;
 | 
			
		||||
								std::string addr = address->host.to_string();
 | 
			
		||||
 | 
			
		||||
									if(address->host.is_v6())
 | 
			
		||||
										remote = NTCPServer::eIP6Address;
 | 
			
		||||
								if(address->host.is_v6())
 | 
			
		||||
									remote = NTCPServer::eIP6Address;
 | 
			
		||||
 | 
			
		||||
									m_NTCPServer->ConnectWithProxy(addr, address->port, remote, s);
 | 
			
		||||
								}
 | 
			
		||||
								else
 | 
			
		||||
									m_NTCPServer->Connect (address->host, address->port, s);
 | 
			
		||||
								return true;
 | 
			
		||||
								m_NTCPServer->ConnectWithProxy(addr, address->port, remote, s);
 | 
			
		||||
							}
 | 
			
		||||
							else
 | 
			
		||||
							{
 | 
			
		||||
								LogPrint(eLogWarning, "Transports: NTCP Limit hit falling back to SSU");
 | 
			
		||||
							}
 | 
			
		||||
								m_NTCPServer->Connect (address->host, address->port, s);
 | 
			
		||||
							return true;
 | 
			
		||||
						}
 | 
			
		||||
						else
 | 
			
		||||
						{
 | 
			
		||||
							LogPrint(eLogWarning, "Transports: NTCP Limit hit falling back to SSU");
 | 
			
		||||
						}
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
| 
						 | 
				
			
			@ -469,17 +460,8 @@ namespace transport
 | 
			
		|||
				if (m_SSUServer && peer.router->IsSSU (!context.SupportsV6 ()))
 | 
			
		||||
				{
 | 
			
		||||
					auto address = peer.router->GetSSUAddress (!context.SupportsV6 ());
 | 
			
		||||
#if BOOST_VERSION >= 104900
 | 
			
		||||
					if (!address->host.is_unspecified ()) // we have address now
 | 
			
		||||
#else
 | 
			
		||||
					boost::system::error_code ecode;
 | 
			
		||||
					address->host.to_string (ecode);
 | 
			
		||||
					if (!ecode)
 | 
			
		||||
#endif
 | 
			
		||||
					{
 | 
			
		||||
						m_SSUServer->CreateSession (peer.router, address->host, address->port);
 | 
			
		||||
						return true;
 | 
			
		||||
					}
 | 
			
		||||
					m_SSUServer->CreateSession (peer.router, address->host, address->port);
 | 
			
		||||
					return true;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			LogPrint (eLogInfo, "Transports: No NTCP or SSU addresses available");
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue