ПРОЕКТЫ 


  АРХИВ 


Apache-Talk @lexa.ru 

Inet-Admins @info.east.ru 

Filmscanners @halftone.co.uk 

Security-alerts @yandex-team.ru 

nginx-ru @sysoev.ru 

  СТАТЬИ 


  ПЕРСОНАЛЬНОЕ 


  ПРОГРАММЫ 



ПИШИТЕ
ПИСЬМА












     АРХИВ :: Inet-Admins
Inet-Admins mailing list archive (inet-admins@info.east.ru)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[inet-admins] squid patch (dns_nameservers)



Привет.

Патчик, позволяющий указать squid'у (1.1.x) какой ns использовать
в качестве resolver'а вместо тех, что указаны в /etc/resolv.conf. За
основу был взят код squid 1.2.x, поправлена пара ошибок и сделано
портабельнее.

*** src/cache_cf.c.orig	Thu Jan  1 00:36:58 1998
--- src/cache_cf.c	Sun Apr 12 17:42:31 1998
***************
*** 1310,1315 ****
--- 1310,1318 ----
  	else if (!strcmp(token, "dns_testnames"))
  	    parseWordlist(&Config.dns_testname_list);
  
+ 	else if (!strcmp(token, "dns_nameservers"))
+ 	    parseWordlist(&Config.dns_nameservers);
+ 
  	else if (!strcmp(token, "single_parent_bypass"))
  	    parseOnOff(&Config.singleParentBypass);
  
***************
*** 1502,1507 ****
--- 1505,1511 ----
      wordlistDestroy(&Config.mcast_group_list);
      wordlistDestroy(&Config.inside_firewall_list);
      wordlistDestroy(&Config.dns_testname_list);
+     wordlistDestroy(&Config.dns_nameservers);
      wordlistDestroy(&Config.cache_stoplist);
      ip_acl_destroy(&Config.local_ip_list);
      ip_acl_destroy(&Config.firewall_ip_list);
*** src/cache_cf.h.orig	Mon Dec  1 10:07:57 1997
--- src/cache_cf.h	Sun Apr 12 17:42:31 1998
***************
*** 241,246 ****
--- 241,247 ----
      wordlist *mcast_group_list;
      wordlist *inside_firewall_list;
      wordlist *dns_testname_list;
+     wordlist *dns_nameservers;
      relist *cache_stop_relist;
      ip_acl *local_ip_list;
      ip_acl *firewall_ip_list;
*** src/dns.c.orig	Tue Jun  3 20:25:44 1997
--- src/dns.c	Sun Apr 12 18:00:07 1998
***************
*** 106,111 ****
--- 106,118 ----
  
  #include "squid.h"
  
+ #if HAVE_ARPA_NAMESER_H
+ #include <arpa/nameser.h>
+ #endif
+ #if HAVE_RESOLV_H
+ #include <resolv.h>
+ #endif
+ 
  struct dnsQueueData {
      struct dnsQueueData *next;
      void *data;
***************
*** 130,135 ****
--- 137,145 ----
      int fd;
      int len;
      LOCAL_ARRAY(char, buf, 128);
+     char *args[MAXNS * 2 + 3];
+     int nargs = 0, nscount = 0;
+     wordlist *w;
  
      cfd = comm_open(SOCK_STREAM,
  	0,
***************
*** 201,210 ****
      fclose(debug_log);
      close(fd);
      close(cfd);
      if (Config.Options.res_defnames)
! 	execlp(command, "(dnsserver)", "-D", NULL);
!     else
! 	execlp(command, "(dnsserver)", NULL);
      debug(50, 0, "dnsOpenServer: %s: %s\n", command, xstrerror());
      _exit(1);
      return 0;
--- 211,231 ----
      fclose(debug_log);
      close(fd);
      close(cfd);
+ 
+     args[nargs++] = (char *)command;
      if (Config.Options.res_defnames)
! 	args[nargs++] = "-D";
!     if (Config.dns_nameservers != NULL) {
! 	for (w = Config.dns_nameservers; w != NULL; w = w->next) {
! 	    if (++nscount > MAXNS)
! 		 break;
! 	    args[nargs++] = "-s";
! 	    args[nargs++] = w->key;
! 	}
!     }
!     args[nargs++] = NULL;
!     execvp(command, args);
! 
      debug(50, 0, "dnsOpenServer: %s: %s\n", command, xstrerror());
      _exit(1);
      return 0;
*** src/dnsserver.c.orig	Thu Aug 21 23:15:27 1997
--- src/dnsserver.c	Sun Apr 12 18:11:42 1998
***************
*** 264,269 ****
--- 264,271 ----
      int alias_count = 0;
      int i;
      int c;
+     int opt_s = 0;
+     extern char *optarg;
  
      safe_inet_addr("255.255.255.255", &no_addr);
  
***************
*** 280,287 ****
  #endif
  #endif
  
!     while ((c = getopt(argc, argv, "vhdD")) != -1) {
  	switch (c) {
  	case 'v':
  	    printf("dnsserver version %s\n", SQUID_VERSION);
  	    exit(0);
--- 282,298 ----
  #endif
  #endif
  
!     while ((c = getopt(argc, argv, "s:vhdD")) != -1) {
  	switch (c) {
+ 	case 's':
+ 	    if (opt_s == 0) {
+ 		_res.nscount = 0;
+ 		_res.options |= RES_INIT;
+ 		opt_s = 1;
+ 	    }
+ 	    if (_res.nscount < MAXNS)
+ 		safe_inet_addr(optarg, &_res.nsaddr_list[_res.nscount++].sin_addr);
+ 	    break;
  	case 'v':
  	    printf("dnsserver version %s\n", SQUID_VERSION);
  	    exit(0);
*** src/squid.conf.pre.in.orig	Thu Jan  1 00:36:59 1998
--- src/squid.conf.pre.in	Sun Apr 12 18:28:43 1998
***************
*** 564,569 ****
--- 564,577 ----
  #
  #dns_defnames off
  
+ #  TAG: dns_nameservers
+ #	This tag specifies a list of nameservers to be used as
+ #	resolvers instead of those given in /etc/resolv.conf file.
+ #	See also resolv.conf(5) for maximum number of nameservers
+ #	may be listed.  There are no defaults.
+ #
+ #dns_nameservers 10.0.0.1 192.172.0.4
+ 
  #  TAG: unlinkd_program
  #	Specify the location of the executable for file deletion process.
  #


-- 
Игорь Винокуров
Российская Торговая Система, ТЦ Пауфор
=============================================================================
"inet-admins" Internet access mailing list. Maintained by East Connection ISP.
Mail "unsubscribe inet-admins" to Majordomo@info.east.ru if you want to quit.



 




Copyright © Lexa Software, 1996-2009.