Allow the resolver source address to be specified in the configuration.
authorMichael Poole <mdpoole@troilus.org>
Tue, 14 Dec 2004 03:00:57 +0000 (03:00 +0000)
committerMichael Poole <mdpoole@troilus.org>
Tue, 14 Dec 2004 03:00:57 +0000 (03:00 +0000)
git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@1273 c9e4aea6-c8fd-4c43-8297-357d70d61c8c

ChangeLog
doc/example.conf
ircd/ircd_lexer.l
ircd/ircd_parser.y
ircd/ircd_res.c

index d80d8bb1408bad7254a4997fe0619b08a7491482..aa11bc9353206ab1f4588172715e2859659c4de8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2004-12-13  Michael Poole <mdpoole@troilus.org>
+
+       * doc/example.conf: Update General block comment to mention
+       new RESOLVER option and to explain IPv6 support.
+
+       * ircd/ircd_lexer.l: Recognize RESOLVER token.
+
+       * ircd/ircd_parser.y: Declare RESOLVER token and use it in an
+       alternative for generalitem.
+
+       * ircd/ircd_res.c: Define global ResolverAddr variable.  If it is
+       valid, use it instead of VirtualHost in restart_resolver().
+
 2004-12-13  Michael Poole <mdpoole@troilus.org>
 
        * doc/example.conf: Update configuration to move Client block
index 3f389240006207c92a37d492ab53433eb4362bf2..b0b10f8d7d38e9586ed2251f4e353660111b3031 100644 (file)
 # General {
 #         name = "servername";
 #         vhost = "virtualhost";
+#         resolver = "ipaddress";
 #         description = "description";
 #         numeric = numericnumber;
 # };
 #
-# <virtual host> must contain either a * or a valid IPv4 address in
-# dotted quad notation. (127.0.0.1) The address MUST be the address
-# of a physical interface on the host. This address is used for outgoing
-# connections only, see Port{} for listener virtual hosting.
-# If in doubt put a * or the IP of your primary interface here.
-# The server must be compiled with virtual hosting turned on to get this
-# to work correctly.
+# If present, <virtual host> must contain a valid address in dotted
+# quad or IPv6 numeric notation (127.0.0.1 or ::1).  The address MUST
+# be the address of a physical interface on the host.  This address is
+# used for outgoing connections if the Connect{} block does not
+# override it.  See Port{} for listener virtual hosting.  If in doubt,
+# leave it out.
+#
+# You may need to specify the resolver address if your compile
+# defaults to using IPv6 but your resolvers are all IPv4 hosts.
 #
 # Note that <server numeric> has to be unique on the network your server
 # is running on, must be between 0 and 4095, and is not updated on a rehash.
index 8aa1925b9e74b753140be9a51d3e61d860b10bce..7b847d69673e33f34c5cce21d90cd13336020b93 100644 (file)
@@ -76,6 +76,7 @@ static struct lexer_token {
   TOKEN(OPER),
   TOKEN(LOCAL),
   TOKEN(VHOST),
+  TOKEN(RESOLVER),
   TOKEN(MASK),
   TOKEN(HIDDEN),
   TOKEN(MOTD),
index 68c90d8e31e37db70d71df2783324f81fcff64d5..920cf473db9f94b0ba6c889a90e9c7eb91527198 100644 (file)
@@ -65,6 +65,7 @@
   extern struct ServerConf* serverConfList;
   extern struct s_map*      GlobalServiceMapList;
   extern struct qline*      GlobalQuarantineList;
+  extern struct irc_sockaddr ResolverAddr;
 
   int yylex(void);
   /* Now all the globals we need :/... */
@@ -135,6 +136,7 @@ static void parse_error(char *pattern,...) {
 %token NO
 %token OPER
 %token VHOST
+%token RESOLVER
 %token HIDDEN
 %token MOTD
 %token JUPE
@@ -271,7 +273,7 @@ generalblock: GENERAL '{' generalitems '}'
     parse_error("Your General block must contain a numeric (between 1 and 4095).");
 } ';' ;
 generalitems: generalitem generalitems | generalitem;
-generalitem: generalnumeric | generalname | generalvhost | generaldesc | error;
+generalitem: generalnumeric | generalname | generalvhost | generalresolver | generaldesc | error;
 generalnumeric: NUMERIC '=' NUMBER ';'
 {
   if (localConf.numeric == 0)
@@ -302,6 +304,11 @@ generalvhost: VHOST '=' QSTRING ';'
   ircd_aton(&VirtualHost.addr, $3);
 };
 
+generalresolver: RESOLVER '=' QSTRING ';'
+{
+  ircd_aton(&ResolverAddr.addr, $3);
+};
+
 adminblock: ADMIN '{' adminitems '}'
 {
   if (localConf.location1 == NULL)
index feb1d82b8c04f512ed1e105141b84ae616b1d350..a37654931a9c59499b9c60f890d0eb66b4055a48 100644 (file)
@@ -140,6 +140,8 @@ extern struct irc_sockaddr irc_nsaddr_list[IRCD_MAXNS];
 extern int irc_nscount;
 extern char irc_domain[HOSTLEN];
 
+struct irc_sockaddr ResolverAddr;
+
 /** Check whether \a inp is a nameserver we use.
  * @param[in] inp Nameserver address.
  * @return Non-zero if we trust \a inp; zero if not.
@@ -171,8 +173,10 @@ restart_resolver(void)
 
   if (!s_active(&res_socket))
   {
+    struct irc_sockaddr *local;
     int fd;
-    fd = os_socket(&VirtualHost, SOCK_DGRAM, "Resolver UDP socket");
+    local = irc_in_addr_valid(&ResolverAddr) ? &ResolverAddr : &VirtualHost;
+    fd = os_socket(local, SOCK_DGRAM, "Resolver UDP socket");
     if (fd < 0) return;
     if (!socket_add(&res_socket, res_readreply, NULL, SS_DATAGRAM,
                     SOCK_EVENT_READABLE, fd)) return;