]> jfr.im git - irc/rqf/shadowircd.git/blobdiff - src/reslib.c
Clarify connection setup.
[irc/rqf/shadowircd.git] / src / reslib.c
index dcc74504e4cfe7fbb854dc73ecb66c87bc16c22a..38c09ebdf6e5d874766507e70df74578e07fdc85 100644 (file)
 #include "ircd_defs.h"
 #include "common.h"
 #include "ircd.h"
-#include "commio.h"
 #include "res.h"
 #include "reslib.h"
-#include "tools.h"
-#include "event.h"
-#include "irc_string.h"
-#include "sprintf_irc.h"
+#include "match.h"
 
 #define NS_TYPE_ELT             0x40 /* EDNS0 extended label type */
 #define DNS_LABELTYPE_BITSTRING 0x41
-#define MAXLINE 128
+#define DNS_MAXLINE 128
 
 /* $Id: reslib.c 1695 2006-06-27 15:11:23Z jilles $ */
 /* from Hybrid Id: reslib.c 177 2005-10-22 09:05:05Z michael $ */
 
-struct irc_sockaddr_storage irc_nsaddr_list[IRCD_MAXNS];
+struct rb_sockaddr_storage irc_nsaddr_list[IRCD_MAXNS];
 int irc_nscount = 0;
-char irc_domain[HOSTLEN + 1];
+char irc_domain[IRCD_RES_HOSTLEN + 1];
 
 static const char digitvalue[256] = {
   -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /*16*/
@@ -149,7 +145,10 @@ int
 irc_res_init(void)
 {
   irc_nscount = 0;
-  return parse_resvconf();
+  parse_resvconf();
+  if (irc_nscount == 0)
+    add_nameserver("127.0.0.1");
+  return 0;
 }
 
 /* parse_resvconf()
@@ -164,7 +163,7 @@ parse_resvconf(void)
   char *p;
   char *opt;
   char *arg;
-  char input[MAXLINE];
+  char input[DNS_MAXLINE];
   FILE *file;
 
   /* XXX "/etc/resolv.conf" should be from a define in setup.h perhaps
@@ -209,7 +208,7 @@ parse_resvconf(void)
       *p = '\0';  /* take the first word */
 
     if (irccmp(opt, "domain") == 0)
-      strlcpy(irc_domain, arg, sizeof(irc_domain));
+      rb_strlcpy(irc_domain, arg, sizeof(irc_domain));
     else if (irccmp(opt, "nameserver") == 0)
       add_nameserver(arg);
   }
@@ -249,7 +248,7 @@ add_nameserver(const char *arg)
     return;
 
   memcpy(&irc_nsaddr_list[irc_nscount], res->ai_addr, res->ai_addrlen);
-  SET_SS_LEN(irc_nsaddr_list[irc_nscount], res->ai_addrlen);
+  SET_SS_LEN(&irc_nsaddr_list[irc_nscount], res->ai_addrlen);
   irc_nscount++;
   freeaddrinfo(res);
 }
@@ -409,7 +408,7 @@ irc_ns_name_ntop(const char *src, char *dst, size_t dstsiz)
                        }
                        *dn++ = '.';
                }
-               if ((l = labellen((unsigned char*)(cp - 1))) < 0) {
+               if ((l = labellen((const unsigned char*)(cp - 1))) < 0) {
                        errno = EMSGSIZE; /* XXX */
                        return(-1);
                }