mirror of
				https://github.com/PurpleI2P/i2pd.git
				synced 2025-11-04 08:30:46 +00:00 
			
		
		
		
	fixed #1387
This commit is contained in:
		
							parent
							
								
									2900bc26a5
								
							
						
					
					
						commit
						f7a084969a
					
				
					 3 changed files with 13 additions and 7 deletions
				
			
		| 
						 | 
				
			
			@ -110,9 +110,10 @@ namespace transport
 | 
			
		|||
		}
 | 
			
		||||
 | 
			
		||||
		err = UPNP_GetValidIGD (m_Devlist, &m_upnpUrls, &m_upnpData, m_NetworkAddr, sizeof (m_NetworkAddr));
 | 
			
		||||
        m_upnpUrlsInitialized=err!=0;
 | 
			
		||||
		if (err == UPNP_IGD_VALID_CONNECTED)
 | 
			
		||||
		{
 | 
			
		||||
			err = UPNP_GetExternalIPAddress (m_upnpUrls.controlURL, m_upnpData.first.servicetype, m_externalIPAddress);
 | 
			
		||||
            err = UPNP_GetExternalIPAddress (m_upnpUrls.controlURL, m_upnpData.first.servicetype, m_externalIPAddress);
 | 
			
		||||
			if(err != UPNPCOMMAND_SUCCESS)
 | 
			
		||||
			{
 | 
			
		||||
				LogPrint (eLogError, "UPnP: unable to get external address: error ", err);
 | 
			
		||||
| 
						 | 
				
			
			@ -218,11 +219,14 @@ namespace transport
 | 
			
		|||
 | 
			
		||||
	void UPnP::CloseMapping (std::shared_ptr<i2p::data::RouterInfo::Address> address)
 | 
			
		||||
	{
 | 
			
		||||
        if(!m_upnpUrlsInitialized) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
		std::string strType (GetProto (address)), strPort (std::to_string (address->port));
 | 
			
		||||
		int err = UPNPCOMMAND_SUCCESS;
 | 
			
		||||
		
 | 
			
		||||
		err = CheckMapping (strPort.c_str (), strType.c_str ());
 | 
			
		||||
		if (err == UPNPCOMMAND_SUCCESS)
 | 
			
		||||
        if (err == UPNPCOMMAND_SUCCESS)
 | 
			
		||||
		{
 | 
			
		||||
			err = UPNP_DeletePortMapping (m_upnpUrls.controlURL, m_upnpData.first.servicetype, strPort.c_str (), strType.c_str (), NULL);
 | 
			
		||||
			LogPrint (eLogError, "UPnP: DeletePortMapping() returned : ", err);
 | 
			
		||||
| 
						 | 
				
			
			@ -233,8 +237,11 @@ namespace transport
 | 
			
		|||
	{
 | 
			
		||||
		freeUPNPDevlist (m_Devlist);
 | 
			
		||||
		m_Devlist = 0;
 | 
			
		||||
		FreeUPNPUrls (&m_upnpUrls);
 | 
			
		||||
	}
 | 
			
		||||
        if(m_upnpUrlsInitialized){
 | 
			
		||||
            FreeUPNPUrls (&m_upnpUrls);
 | 
			
		||||
            m_upnpUrlsInitialized=false;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
	std::string UPnP::GetProto (std::shared_ptr<i2p::data::RouterInfo::Address> address)
 | 
			
		||||
	{
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -60,6 +60,7 @@ namespace transport
 | 
			
		|||
		std::mutex m_StartedMutex;
 | 
			
		||||
		boost::asio::io_service m_Service;
 | 
			
		||||
		boost::asio::deadline_timer m_Timer;
 | 
			
		||||
        bool m_upnpUrlsInitialized=false;
 | 
			
		||||
		struct UPNPUrls m_upnpUrls;
 | 
			
		||||
		struct IGDdatas m_upnpData;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue