]> jfr.im git - solanum.git/blobdiff - authd/reslib.c
authd: Fix DNSBL messages
[solanum.git] / authd / reslib.c
index 59ea43f3e452cd773664536616a95569837da3a6..7771da6c5da812d43a83127267237e414cb9cc14 100644 (file)
 #include <rb_lib.h>
 
 #ifndef _WIN32
+
 #include <netdb.h>
+
+typedef struct addrinfo rb_addrinfo;
+
 #else
 #include "getaddrinfo.h"
 #include "getnameinfo.h"
 #define freeaddrinfo rb_freeaddrinfo
 
 extern const char * get_windows_nameservers(void);
+typedef struct rb_addrinfo rb_addrinfo;
 #endif
 
 #include "stdinc.h"
 #include "ircd_defs.h"
-#include "common.h"
 #include "ircd.h"
 #include "res.h"
 #include "reslib.h"
@@ -126,7 +130,12 @@ static const char digitvalue[256] = {
   -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /*256*/
 };
 
+#ifndef _WIN32
 static int parse_resvconf(void);
+#else
+static void parse_windows_resolvers(void);
+#endif
+
 static void add_nameserver(const char *);
 
 static const char digits[] = "0123456789";
@@ -153,12 +162,31 @@ int
 irc_res_init(void)
 {
   irc_nscount = 0;
+#ifndef _WIN32
   parse_resvconf();
+#else
+  parse_windows_resolvers();
+#endif
   if (irc_nscount == 0)
     add_nameserver("127.0.0.1");
   return 0;
 }
 
+#ifdef _WIN32
+static void
+parse_windows_resolvers(void)
+{
+        const char *ns = get_windows_nameservers();
+        char *server;
+        char *p;
+        char *buf = rb_strdup(ns);
+        for(server = rb_strtok_r(buf, " ", &p); server != NULL;server = rb_strtok_r(NULL, " ", &p))
+        {
+                add_nameserver(server);
+        }
+        rb_free(buf);
+}
+#else
 /* parse_resvconf()
  *
  * inputs - NONE
@@ -215,15 +243,16 @@ parse_resvconf(void)
     if ((p = strpbrk(arg, " \t")) != NULL)
       *p = '\0';  /* take the first word */
 
-    if (strcasecmp(opt, "domain") == 0)
+    if (rb_strcasecmp(opt, "domain") == 0)
       rb_strlcpy(irc_domain, arg, sizeof(irc_domain));
-    else if (strcasecmp(opt, "nameserver") == 0)
+    else if (rb_strcasecmp(opt, "nameserver") == 0)
       add_nameserver(arg);
   }
 
   fclose(file);
   return 0;
 }
+#endif
 
 /* add_nameserver()
  *
@@ -235,7 +264,7 @@ parse_resvconf(void)
 static void
 add_nameserver(const char *arg)
 {
-  struct addrinfo hints, *res;
+  rb_addrinfo hints, *res;
 
   /* Done max number of nameservers? */
   if (irc_nscount >= IRCD_MAXNS)