Browse code

fix support for LocalIPAddress

git-svn: trunk@1864

Tomasz Kojm authored on 2006/03/20 05:54:48
Showing 3 changed files
... ...
@@ -1,3 +1,8 @@
1
+Sun Mar 19 21:49:19 CET 2006 (tk)
2
+---------------------------------
3
+  * freshclam: fix support for LocalIPAddress (patch by Anton Yuzhaninov
4
+	       <citrin*citrin.ru>)
5
+
1 6
 Tue Mar 14 11:40:49 GMT 2006 (njh)
2 7
 ----------------------------------
3 8
   * libclamav/tnef.c:	Check fseeks will work before calling fseek
... ...
@@ -136,8 +136,8 @@ int downloadmanager(const struct cfgstruct *copt, const struct optstruct *opt, c
136 136
     }
137 137
 #endif /* HAVE_RESOLV_H */
138 138
 
139
-    if(optl(opt, "localip")) {
140
-        localip = getargl(opt, "localip");
139
+    if(optl(opt, "local-address")) {
140
+        localip = getargl(opt, "local-address");
141 141
     } else if((cpt = cfgopt(copt, "LocalIPAddress"))->enabled) {
142 142
 	localip = cpt->strarg;
143 143
     }
... ...
@@ -468,6 +468,17 @@ int wwwconnect(const char *server, const char *proxy, int pport, char *ip, char
468 468
 
469 469
     name.sin_family = AF_INET;
470 470
 
471
+#ifdef PF_INET
472
+    socketfd = socket(PF_INET, SOCK_STREAM, 0);
473
+#else
474
+    socketfd = socket(AF_INET, SOCK_STREAM, 0);
475
+#endif
476
+
477
+    if(socketfd < 0) {
478
+	logg("!Can't create new socket\n");
479
+	return -1;
480
+    }
481
+
471 482
     if (localip) {
472 483
 	if ((he = gethostbyname(localip)) == NULL) {
473 484
 	    char *herr;
... ...
@@ -556,6 +567,7 @@ int wwwconnect(const char *server, const char *proxy, int pport, char *ip, char
556 556
 		break;
557 557
 	}
558 558
         logg("^Can't get information about %s: %s\n", hostpt, herr);
559
+	close(socketfd);
559 560
 	return -1;
560 561
     }
561 562
 
... ...
@@ -573,12 +585,6 @@ int wwwconnect(const char *server, const char *proxy, int pport, char *ip, char
573 573
 	name.sin_addr = *((struct in_addr *) host->h_addr_list[i]);
574 574
 	name.sin_port = htons(port);
575 575
 
576
-#ifdef PF_INET
577
-	socketfd = socket(PF_INET, SOCK_STREAM, 0);
578
-#else
579
-	socketfd = socket(AF_INET, SOCK_STREAM, 0);
580
-#endif
581
-
582 576
 	if(connect(socketfd, (struct sockaddr *) &name, sizeof(struct sockaddr_in)) == -1) {
583 577
 	    logg("Can't connect to port %d of host %s (IP: %s)\n", port, hostpt, ipaddr);
584 578
 	    close(socketfd);
... ...
@@ -60,7 +60,7 @@ int main(int argc, char **argv)
60 60
 	    {"no-dns", 0, 0, 0},
61 61
 	    {"checks", 1, 0, 'c'},
62 62
 	    {"http-proxy", 1, 0, 0},
63
-	    {"client-address", 1, 0, 'a'},
63
+	    {"local-address", 1, 0, 'a'},
64 64
 	    {"proxy-user", 1, 0, 0},
65 65
 	    {"daemon-notify", 2, 0, 0},
66 66
 	    {"on-update-execute", 1, 0, 0},