]> jfr.im git - solanum.git/blobdiff - ircd/authd.c
authd: allow querying the list of DNS servers.
[solanum.git] / ircd / authd.c
index 663e34861406f11e514693646e1ce469f4e86dad..491d02379f048a4b329ed6467678818b3a7a7141 100644 (file)
@@ -23,8 +23,8 @@
  */
 
 #include <stdinc.h>
-#include <ratbox_lib.h>
-#include <struct.h>
+#include <rb_lib.h>
+#include <client.h>
 #include <ircd_defs.h>
 #include <parse.h>
 #include <authd.h>
@@ -67,7 +67,7 @@ start_authd(void)
                                     "Unable to execute authd in %s or %s/libexec/charybdis",
                                     PKGLIBEXECDIR, ConfigFileEntry.dpath);
                                sendto_realops_snomask(SNO_GENERAL, L_ALL,
-                                                      "Unable to execute resolver in %s or %s/libexec/charybdis",
+                                                      "Unable to execute authd in %s or %s/libexec/charybdis",
                                                       PKGLIBEXECDIR, ConfigFileEntry.dpath);
                                return 1;
                        }
@@ -97,14 +97,15 @@ parse_authd_reply(rb_helper * helper)
        ssize_t len;
        int parc;
        char dnsBuf[READBUF_SIZE];
-
        char *parv[MAXPARA + 1];
+
        while((len = rb_helper_read(helper, dnsBuf, sizeof(dnsBuf))) > 0)
        {
-               parc = rb_string_to_array(dnsBuf, parv, MAXPARA+1); 
+               parc = rb_string_to_array(dnsBuf, parv, MAXPARA+1);
 
-               if(*parv[0] == 'R')
+               switch (*parv[0])
                {
+               case 'E':
                        if(parc != 5)
                        {
                                ilog(L_MAIN, "authd sent a result with wrong number of arguments: got %d", parc);
@@ -112,9 +113,37 @@ parse_authd_reply(rb_helper * helper)
                                return;
                        }
                        dns_results_callback(parv[1], parv[2], parv[3], parv[4]);
+                       break;
+               case 'X':
+               case 'Y':
+               case 'Z':
+                       if(parc < 3)
+                       {
+                               ilog(L_MAIN, "authd sent a result with wrong number of arguments: got %d", parc);
+                               restart_authd();
+                               return;
+                       }
+
+                       /* Select by type */
+                       switch(*parv[2])
+                       {
+                       case 'D':
+                               /* parv[0] conveys status */
+                               if(parc < 4)
+                               {
+                                       ilog(L_MAIN, "authd sent a result with wrong number of arguments: got %d", parc);
+                                       restart_authd();
+                                       return;
+                               }
+                               dns_stats_results_callback(parv[1], parv[0], parc - 3, (const char **)&parv[3]);
+                               break;
+                       default:
+                               break;
+                       }
+                       break;
+               default:
+                       break;
                }
-               else
-                       return;
        }
 }
 
@@ -132,7 +161,7 @@ static void
 restart_authd_cb(rb_helper * helper)
 {
        ilog(L_MAIN, "authd: restart_authd_cb called, authd died?");
-       sendto_realops_snomask(SNO_GENERAL, L_ALL, "authd - restart_authd_cb called, authd died?");
+       sendto_realops_snomask(SNO_GENERAL, L_ALL, "authd: restart_authd_cb called, authd died?");
        if(helper != NULL)
        {
                rb_helper_close(helper);