diff -rubB larbin-orig/larbin.conf.ini larbin/larbin.conf.ini --- larbin-orig/larbin.conf.ini Tue Dec 30 10:10:01 2003 +++ larbin/larbin.conf.ini Thu Jan 1 12:06:05 2004 @@ -29,6 +29,8 @@ #noExternalLinks # time between 2 calls on the same server (in sec) : NEVER less than 30 waitDuration 60 +# use this address as source IP address for fetching pages +#fetchSrcAddr 0.0.0.0 # Make requests through a proxy (use with care) #proxy www 8080 --- larbin-orig/src/fetch/site.cc Tue Dec 30 10:10:01 2003 +++ larbin/src/fetch/site.cc Thu Jan 1 11:58:02 2004 @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -46,6 +47,11 @@ else global::verifMax(fd); conn->socket = fd; + if (global::fetchSrcAddr != NULL) { + if (bind(fd, (struct sockaddr *) global::fetchSrcAddr, sizeof(struct sockaddr_in)) != 0) + cerr << "Unable to bind socket for fetching pages - check fetchSrcAddr in config file" << endl; + exit(1); + } for (;;) { fcntl(fd, F_SETFL, O_NONBLOCK); struct sockaddr_in *theaddr; --- larbin-orig/src/global.cc Tue Dec 30 10:10:01 2003 +++ larbin/src/global.cc Thu Jan 1 11:48:28 2004 @@ -64,6 +64,7 @@ char *global::sender; char *global::headers; char *global::headersRobots; +sockaddr_in *global::fetchSrcAddr; sockaddr_in *global::proxyAddr; Vector *global::domains; Vector global::forbExt; @@ -121,6 +122,7 @@ dnsConn = 3; httpPort = 0; inputPort = 0; // by default, no input available + fetchSrcAddr = NULL; proxyAddr = NULL; domains = NULL; // FIFOs @@ -246,6 +248,22 @@ } else if (!strcasecmp(tok, "waitduration")) { tok = nextToken(&posParse); waitDuration = atoi(tok); + } else if (!strcasecmp(tok, "fetchSrcAddr")) { + // host name and dns call + tok = nextToken(&posParse); + struct hostent* hp; + fetchSrcAddr = new sockaddr_in; + memset((char *) fetchSrcAddr, 0, sizeof (struct sockaddr_in)); + if ((hp = gethostbyname(tok)) == NULL) { + endhostent(); + cerr << "Unable to find fetchSrcAddr ip address (" << tok << ")\n"; + exit(1); + } else { + fetchSrcAddr->sin_family = hp->h_addrtype; + memcpy ((char*) &fetchSrcAddr->sin_addr, hp->h_addr, hp->h_length); + } + endhostent(); + fetchSrcAddr->sin_port = 0; } else if (!strcasecmp(tok, "proxy")) { // host name and dns call tok = nextToken(&posParse); diff -rubB larbin-orig/src/global.h larbin/src/global.h --- larbin-orig/src/global.h Tue Dec 30 10:10:01 2003 +++ larbin/src/global.h Thu Jan 1 11:45:28 2004 @@ -117,6 +117,10 @@ */ static char *headers; static char *headersRobots; // used when asking a robots.txt + + /* use this address as source address when fetching pages */ + static sockaddr_in *fetchSrcAddr; + /* internet address of the proxy (if any) */ static sockaddr_in *proxyAddr; /** connect to this server through a proxy using connection conn