From 2cc57cb6020fcf2d6cbfa8f1ca2472bacf9817e3 Mon Sep 17 00:00:00 2001 From: Michael Poole Date: Tue, 14 Dec 2004 03:00:57 +0000 Subject: [PATCH] Allow the resolver source address to be specified in the configuration. git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@1273 c9e4aea6-c8fd-4c43-8297-357d70d61c8c --- ChangeLog | 13 +++++++++++++ doc/example.conf | 17 ++++++++++------- ircd/ircd_lexer.l | 1 + ircd/ircd_parser.y | 9 ++++++++- ircd/ircd_res.c | 6 +++++- 5 files changed, 37 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index d80d8bb..aa11bc9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2004-12-13 Michael Poole + + * 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 * doc/example.conf: Update configuration to move Client block diff --git a/doc/example.conf b/doc/example.conf index 3f38924..b0b10f8 100644 --- a/doc/example.conf +++ b/doc/example.conf @@ -53,17 +53,20 @@ # General { # name = "servername"; # vhost = "virtualhost"; +# resolver = "ipaddress"; # description = "description"; # numeric = numericnumber; # }; # -# 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, 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 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. diff --git a/ircd/ircd_lexer.l b/ircd/ircd_lexer.l index 8aa1925..7b847d6 100644 --- a/ircd/ircd_lexer.l +++ b/ircd/ircd_lexer.l @@ -76,6 +76,7 @@ static struct lexer_token { TOKEN(OPER), TOKEN(LOCAL), TOKEN(VHOST), + TOKEN(RESOLVER), TOKEN(MASK), TOKEN(HIDDEN), TOKEN(MOTD), diff --git a/ircd/ircd_parser.y b/ircd/ircd_parser.y index 68c90d8..920cf47 100644 --- a/ircd/ircd_parser.y +++ b/ircd/ircd_parser.y @@ -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) diff --git a/ircd/ircd_res.c b/ircd/ircd_res.c index feb1d82..a376549 100644 --- a/ircd/ircd_res.c +++ b/ircd/ircd_res.c @@ -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; -- 2.20.1