git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@753 77e5149b-7576-45b1-b177-96237e5ba77b
Tomasz Kojm authored on 2004/08/15 09:32:04... | ... |
@@ -93,6 +93,7 @@ Philippe Gay <ph.gay*free.fr> |
93 | 93 |
Luca 'NERvOus' Gibelli <nervous*clamav.net> |
94 | 94 |
Scott Gifford <sgifford*suspectclass.com> |
95 | 95 |
Stephen Gran <steve*lobefin.net> |
96 |
+Marek Gutkowski <hobbit*core.segfault.pl> |
|
96 | 97 |
Nigel Horne <njh*smsltd.demon.co.uk> |
97 | 98 |
Hrvoje Habjanic <hrvoje.habjanic*zg.hinet.hr> |
98 | 99 |
Robert Hogan <robert*roberthogan.net> |
... | ... |
@@ -1,3 +1,9 @@ |
1 |
+Sun Aug 15 02:19:54 CEST 2004 (tk) |
|
2 |
+---------------------------------- |
|
3 |
+ * freshclam: try all IP addresses provided by gethostbyname() in single |
|
4 |
+ attempt, if needed (patch by Marek Gutkowski |
|
5 |
+ <hobbit*core.segfault.pl>) |
|
6 |
+ |
|
1 | 7 |
Sat Aug 14 14:44:39 CEST 2004 (tk) |
2 | 8 |
---------------------------------- |
3 | 9 |
* configure: fix detection of inet_ntop on Solaris (patch by David Champion |
... | ... |
@@ -356,7 +356,7 @@ int download(const struct cfgstruct *copt, const struct optstruct *opt) |
356 | 356 |
ret = downloadmanager(copt, opt, cpt->strarg); |
357 | 357 |
alarm(0); |
358 | 358 |
|
359 |
- if(ret == 52 || ret == 54) { |
|
359 |
+ if(ret == 54) { |
|
360 | 360 |
if(try < maxattempts - 1) { |
361 | 361 |
mprintf("Trying again...\n"); |
362 | 362 |
logg("Trying again...\n"); |
... | ... |
@@ -155,7 +155,7 @@ int downloaddb(const char *localname, const char *remotename, const char *hostna |
155 | 155 |
hostfd = wwwconnect(hostname, proxy, port, ipaddr); |
156 | 156 |
|
157 | 157 |
if(hostfd < 0) { |
158 |
- mprintf("@Connection with %s (IP: %s) failed.\n", hostname, ipaddr); |
|
158 |
+ mprintf("@Connection with %s failed.\n", hostname); |
|
159 | 159 |
return 52; |
160 | 160 |
} else |
161 | 161 |
mprintf("*Connected to %s (%s).\n", hostname, ipaddr); |
... | ... |
@@ -278,7 +278,7 @@ int downloaddb(const char *localname, const char *remotename, const char *hostna |
278 | 278 |
/* proxy support finshed by njh@bandsman.co.uk */ |
279 | 279 |
int wwwconnect(const char *server, const char *proxy, int pport, char *ip) |
280 | 280 |
{ |
281 |
- int socketfd, port; |
|
281 |
+ int socketfd, port, i; |
|
282 | 282 |
struct sockaddr_in name; |
283 | 283 |
struct hostent *host; |
284 | 284 |
char ipaddr[16]; |
... | ... |
@@ -326,23 +326,31 @@ int wwwconnect(const char *server, const char *proxy, int pport, char *ip) |
326 | 326 |
return -1; |
327 | 327 |
} |
328 | 328 |
|
329 |
- /* this dirty hack comes from pink - Nosuid TCP/IP ping 1.6 */ |
|
330 |
- ia = (unsigned char *) host->h_addr; |
|
331 |
- sprintf(ipaddr, "%u.%u.%u.%u", ia[0], ia[1], ia[2], ia[3]); |
|
329 |
+ for(i = 0; host->h_addr_list[i] != 0; i++) { |
|
330 |
+ /* this dirty hack comes from pink - Nosuid TCP/IP ping 1.6 */ |
|
331 |
+ ia = (unsigned char *) host->h_addr_list[i]; |
|
332 |
+ sprintf(ipaddr, "%u.%u.%u.%u", ia[0], ia[1], ia[2], ia[3]); |
|
332 | 333 |
|
333 |
- if(ip) |
|
334 |
- strcpy(ip, ipaddr); |
|
334 |
+ if(ip) |
|
335 |
+ strcpy(ip, ipaddr); |
|
336 |
+ |
|
337 |
+ if(i > 0) |
|
338 |
+ mprintf("Trying host %s (%s)...\n", hostpt, ipaddr); |
|
335 | 339 |
|
336 |
- name.sin_addr = *((struct in_addr *) host->h_addr); |
|
337 |
- name.sin_port = htons(port); |
|
340 |
+ name.sin_addr = *((struct in_addr *) host->h_addr_list[i]); |
|
341 |
+ name.sin_port = htons(port); |
|
342 |
+ |
|
343 |
+ if(connect(socketfd, (struct sockaddr *) &name, sizeof(struct sockaddr_in)) == -1) { |
|
344 |
+ mprintf("@Can't connect to port %d of host %s (%s)\n", port, hostpt, ipaddr); |
|
345 |
+ continue; |
|
346 |
+ } |
|
338 | 347 |
|
339 |
- if(connect(socketfd, (struct sockaddr *) &name, sizeof(struct sockaddr_in)) == -1) { |
|
340 |
- mprintf("@Can't connect to port %d of host %s (%s)\n", port, hostpt, ipaddr); |
|
341 |
- close(socketfd); |
|
342 |
- return -2; |
|
348 |
+ return socketfd; |
|
343 | 349 |
} |
344 | 350 |
|
345 |
- return socketfd; |
|
351 |
+ close(socketfd); |
|
352 |
+ mprintf("@No servers could be reached. Giving up\n"); |
|
353 |
+ return -2; |
|
346 | 354 |
} |
347 | 355 |
|
348 | 356 |
/* njh@bandsman.co.uk: added proxy support */ |