Changeset 1487
- Timestamp:
- 12/11/07 02:44:46 (9 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
nepenthes/trunk/nepenthes-core/src/DownloadManager.cpp
r1463 r1487 303 303 g_Nepenthes->getEventMgr()->handleEvent(&se); 304 304 305 if ( down->getDownloadUrl()->getPort() <= 0 || down->getDownloadUrl()->getPort() > 65536)305 if ( down->getDownloadUrl()->getPort() <= 0 || down->getDownloadUrl()->getPort() > 65536 ) 306 306 { 307 307 logWarn("malformed url 0<port<65536 , %s \n",down->getUrl().c_str()); … … 317 317 logSpam("Host %s is valid ip \n",down->getDownloadUrl()->getHost().c_str()); 318 318 bool bReplaceHost = false; 319 if ( isLocalAddress(ulAddress) == true)319 if ( isLocalAddress(ulAddress) == true ) 320 320 { // local ip 321 if ( m_ReplaceLocalIps)321 if ( m_ReplaceLocalIps ) 322 322 { 323 323 bReplaceHost = true; 324 324 logInfo("Link %s has local address, replacing with real ip \n",down->getUrl().c_str()); 325 325 326 }else 326 } 327 else 327 328 { 328 329 logDebug(" Address %s is local, we will not download \n",inet_ntoa( *(in_addr *)&ulAddress)); … … 330 331 return false; 331 332 } 332 333 334 }else 333 334 335 } 336 else 335 337 { 336 if ( ulAddress == 0) // replace 0.0.0.0338 if ( ulAddress == 0 && m_ReplaceLocalIps ) // replace 0.0.0.0 337 339 { 338 340 bReplaceHost = true; … … 340 342 } 341 343 342 if ( bReplaceHost)344 if ( bReplaceHost ) 343 345 { 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(); 352 347 sUrl += "://"; 348 353 349 uint32_t newaddr = down->getRemoteHost(); 354 350 sUrl += inet_ntoa(*(in_addr *)&newaddr); 355 351 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 364 354 char *port; 365 355 asprintf(&port,":%i/",down->getDownloadUrl()->getPort()); 366 sUrl += port;356 sUrl += port; 367 357 free(port); 368 #endif 358 369 359 sUrl += down->getDownloadUrl()->getPath(); 370 360 down->setUrl(&sUrl); 371 logInfo("Replaced Address, new URL is %s \n",sUrl.c_str());372 361 } 373 362 } … … 375 364 376 365 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() ) 380 369 { 381 370 logInfo("Handler %s will download %s \n",handler->m_Handler->getDownloadHandlerName().c_str(),down->getUrl().c_str());
