diff -p -N -U 4 -r firedns/changes_cm.txt firedns-0.1.30cm1/changes_cm.txt --- firedns/changes_cm.txt 1970-01-01 01:00:00.000000000 +0100 +++ firedns-0.1.30cm1/changes_cm.txt 2002-11-12 22:15:11.000000000 +0100 @@ -0,0 +1,5 @@ +added local binding for ip4 + +firedns will bind to the ip given in: /etc/firedns_bind.conf + +Collin R. Mulliner diff -p -N -U 4 -r firedns/firedns.c firedns-0.1.30cm1/firedns.c --- firedns/firedns.c 2002-10-30 19:01:12.000000000 +0100 +++ firedns-0.1.30cm1/firedns.c 2002-11-12 21:57:10.000000000 +0100 @@ -36,11 +36,13 @@ static const char tagstring[] = "$Id: fi #define min(a,b) (a < b ? a : b) static struct in_addr servers4[FDNS_MAX]; /* up to FDNS_MAX nameservers; populated by firedns_init() */ static int i4; /* actual count of nameservers; set by firedns_init() */ +static struct in_addr local_bind_i4; /* address to bind to for outgoing dns querys */ #ifdef FIREDNS_USE_IPV6 static int i6; static struct in6_addr servers6[FDNS_MAX]; +static struct in6_addr local_bind_i6; /* address to bind to for outgoing dns querys */ #endif static int initdone = 0; /* to ensure firedns_init() only runs once (on the first call) */ static int wantclose = 0; @@ -161,8 +163,37 @@ void firedns_init() { /* on first call o } } fclose(f); + /* read /etc/firedns_bind.conf */ + f = fopen(FDNS_CONFIG_LOCAL_BIND, "r"); + if (f == NULL) { + /* fall back to 0.0.0.0 (any) */ + memset(&local_bind_i4, 0, sizeof(struct in_addr)); + +#ifdef FIREDNS_USE_IPV6 + /* ? local_bind_i6 ? */ +#endif + + } + else { + while (fgets(buf,1024,f) != NULL) { + + if (firedns_aton4_s(buf,&addr4) != NULL) { + memcpy(&local_bind_i4,&addr4,sizeof(struct in_addr)); + break; + } + +#ifdef FIREDNS_USE_IPV6 + if (firedns_aton6_s(buf,&addr6) != NULL) { + memcpy(&local_bind_i6,&addr6,sizeof(struct in6_addr)); + break; + } +#endif + + } + fclose(f); + } } static int firedns_send_requests(struct s_header *h, struct s_connection *s, int l) { /* send DNS query */ int i; @@ -241,8 +272,12 @@ static struct s_connection *firedns_add_ if (s->fd != -1) { struct sockaddr_in6 addr6; memset(&addr6,0,sizeof(addr6)); addr6.sin6_family = AF_INET6; + + /* ? */ + /* memcpy(addr6.sin6_addr.s6_addr,local_bind_i6,12); */ + if (bind(s->fd,(struct sockaddr *)&addr6,sizeof(addr6)) == 0) s->v6 = 1; else close(s->fd); @@ -261,9 +296,9 @@ static struct s_connection *firedns_add_ struct sockaddr_in addr; memset(&addr,0,sizeof(addr)); addr.sin_family = AF_INET; addr.sin_port = 0; - addr.sin_addr.s_addr = INADDR_ANY; + memcpy(&addr.sin_addr.s_addr, &local_bind_i4, sizeof(struct in_addr)); if (bind(s->fd,(struct sockaddr *)&addr,sizeof(addr)) != 0) { close(s->fd); s->fd = -1; } diff -p -N -U 4 -r firedns/firedns.h firedns-0.1.30cm1/firedns.h --- firedns/firedns.h 2002-08-31 23:15:24.000000000 +0200 +++ firedns-0.1.30cm1/firedns.h 2002-11-12 21:53:22.000000000 +0100 @@ -36,8 +36,9 @@ struct in6_addr { #endif #define FDNS_MAX 8 /* max number of nameservers used */ #define FDNS_CONFIG_PREF "/etc/firedns.conf" /* preferred firedns config file */ +#define FDNS_CONFIG_LOCAL_BIND "/etc/firedns_bind.conf" /* contains ip to bind to */ #define FDNS_CONFIG_FBCK "/etc/resolv.conf" /* fallback config file */ #define FDNS_PORT 53 /* DNS well known port */ #define FDNS_QRY_A 1 /* name to IP address */ #define FDNS_QRY_AAAA 28 /* name to IP6 address */ diff -p -N -U 4 -r firedns/man/libfiredns.3 firedns-0.1.30cm1/man/libfiredns.3 --- firedns/man/libfiredns.3 2002-06-18 17:00:34.000000000 +0200 +++ firedns-0.1.30cm1/man/libfiredns.3 2002-11-12 22:08:54.000000000 +0100 @@ -70,8 +70,10 @@ Blocking functions: /usr/local/lib/libfiredns.a .br /etc/firedns.conf .br +/etc/firedns_bind.conf +.br /etc/resolv.conf .SH BUGS FireDNS is very network unfriendly. It sends queries to all nameservers in /etc/firedns.conf or (fallback) /etc/resolv.conf