Changeset 1487

Show
Ignore:
Timestamp:
12/11/07 02:44:46 (9 months ago)
Author:
common
Message:

nepenthes

  • if replace_local_ips is not set, do not replace 0.0.0.0
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • nepenthes/trunk/nepenthes-core/src/DownloadManager.cpp

    r1463 r1487  
    303303        g_Nepenthes->getEventMgr()->handleEvent(&se); 
    304304 
    305         if (down->getDownloadUrl()->getPort() <= 0 || down->getDownloadUrl()->getPort() > 65536
     305        if ( down->getDownloadUrl()->getPort() <= 0 || down->getDownloadUrl()->getPort() > 65536
    306306        { 
    307307                logWarn("malformed url 0<port<65536  , %s \n",down->getUrl().c_str()); 
     
    317317                logSpam("Host %s is valid ip \n",down->getDownloadUrl()->getHost().c_str()); 
    318318                bool bReplaceHost = false; 
    319                 if (isLocalAddress(ulAddress) == true
     319                if ( isLocalAddress(ulAddress) == true
    320320                { // local ip 
    321                         if (m_ReplaceLocalIps
     321                        if ( m_ReplaceLocalIps
    322322                        { 
    323323                                bReplaceHost = true; 
    324324                                logInfo("Link %s  has local address, replacing with real ip \n",down->getUrl().c_str()); 
    325325 
    326                         }else 
     326                        } 
     327                        else 
    327328                        { 
    328329                                logDebug(" Address %s is local, we will not download \n",inet_ntoa( *(in_addr *)&ulAddress)); 
     
    330331                                return false; 
    331332                        } 
    332              
    333                          
    334                 }else 
     333 
     334 
     335                } 
     336                else 
    335337                { 
    336                         if (ulAddress == 0) // replace 0.0.0.0 
     338                        if ( ulAddress == 0 && m_ReplaceLocalIps ) // replace 0.0.0.0 
    337339                        { 
    338340                                bReplaceHost = true; 
     
    340342                } 
    341343 
    342                 if (bReplaceHost
     344                if ( bReplaceHost
    343345                { 
    344 /*                      pDown->m_sUri  = pDown->m_pUri->m_protocol; 
    345                         pDown->m_sUri += "://"; 
    346                         pDown->m_sUri += inet_ntoa( *(in_addr *)&pDown->m_ulAddress); 
    347                         pDown->m_sUri += "/"; 
    348                         pDown->m_sUri += pDown->m_pUri->m_file;                  // fixme port 
    349                         pDown->m_pUri->m_host = inet_ntoa( *(in_addr *)&pDown->m_ulAddress); 
    350 */       
    351                         string sUrl =   down->getDownloadUrl()->getProtocol(); 
     346                        string sUrl =   down->getDownloadUrl()->getProtocol(); 
    352347                        sUrl += "://"; 
     348 
    353349                        uint32_t newaddr = down->getRemoteHost(); 
    354350                        sUrl += inet_ntoa(*(in_addr *)&newaddr); 
    355351                        down->getDownloadUrl()->setHost(newaddr); 
    356  
    357 #ifdef WIN32 
    358                         char *port = (char *)malloc(7); 
    359                         memset(port,0,7); 
    360                         _snprintf(port,7,":%i/",down->getDownloadUrl()->getPort()); 
    361             sUrl += port; 
    362                         free(port); 
    363 #else 
     352                        logInfo("Replaced Address, new URL is %s \n",sUrl.c_str()); 
     353 
    364354                        char *port; 
    365355                        asprintf(&port,":%i/",down->getDownloadUrl()->getPort()); 
    366             sUrl += port; 
     356                       sUrl += port; 
    367357                        free(port); 
    368 #endif 
     358 
    369359                        sUrl += down->getDownloadUrl()->getPath(); 
    370360                        down->setUrl(&sUrl); 
    371                         logInfo("Replaced Address, new URL is %s \n",sUrl.c_str()); 
    372361                } 
    373362        } 
     
    375364 
    376365        list <DownloadHandlerTuple>::iterator handler; 
    377         for(handler = m_DownloadHandlers.begin(); handler != m_DownloadHandlers.end(); handler++
    378         { 
    379                 if(handler->m_Protocol == down->getDownloadUrl()->getProtocol()
     366        for ( handler = m_DownloadHandlers.begin(); handler != m_DownloadHandlers.end(); handler++
     367        { 
     368                if ( handler->m_Protocol == down->getDownloadUrl()->getProtocol()
    380369                { 
    381370                        logInfo("Handler %s will download %s \n",handler->m_Handler->getDownloadHandlerName().c_str(),down->getUrl().c_str());