]> jfr.im git - irc/evilnet/x3.git/blobdiff - src/gline.c
Couple of srvx updates.
[irc/evilnet/x3.git] / src / gline.c
index e48bc77b0a3064480e63d6510eaf9e8ff8b4051d..96f02d3f92c8dda3eade5b6dbc630f5070976c4b 100644 (file)
@@ -3,9 +3,9 @@
  *
  * This file is part of x3.
  *
- * srvx is free software; you can redistribute it and/or modify
+ * x3 is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation; either version 3 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
@@ -122,19 +122,13 @@ gline_remove(const char *target, int announce)
             timeq_add(new_first->expires, gline_expire, 0);
         }
     }
-#ifdef WITH_PROTOCOL_BAHAMUT
-    /* Bahamut is sort of lame: It permanently remembers any AKILLs
-     * with durations longer than a day, and will never auto-expire
-     * them.  So when the time comes, we'd better remind it.  */
-    announce = 1;
-#endif
     if (announce)
         irc_ungline(target);
     return res;
 }
 
 struct gline *
-gline_add(const char *issuer, const char *target, unsigned long duration, const char *reason, time_t issued, int announce)
+gline_add(const char *issuer, const char *target, unsigned long duration, const char *reason, time_t issued, int announce, int silent)
 {
     struct gline *ent;
     struct gline *prev_first;
@@ -162,7 +156,7 @@ gline_add(const char *issuer, const char *target, unsigned long duration, const
        timeq_add(ent->expires, gline_expire, 0);
     }
     if (announce)
-        irc_gline(NULL, ent);
+        irc_gline(NULL, ent, silent);
     return ent;
 }
 
@@ -170,8 +164,6 @@ static char *
 gline_alternate_target(const char *target)
 {
     const char *hostname;
-    unsigned long ip;
-    char *res;
 
     /* If no host part, bail. */
     if (!(hostname = strchr(target, '@')))
@@ -179,23 +171,16 @@ gline_alternate_target(const char *target)
     /* If host part contains wildcards, bail. */
     if (hostname[strcspn(hostname, "*?/")])
         return NULL;
-    /* If host part looks like an IP, parse it that way. */
-    if (!hostname[strspn(hostname+1, "0123456789.")+1]) {
-        struct in_addr in;
-        struct hostent *he;
-        if (inet_aton(hostname+1, &in)
-            && (he = gethostbyaddr((char*)&in, sizeof(in), AF_INET))) {
-            res = malloc((hostname - target) + 2 + strlen(he->h_name));
-            sprintf(res, "%.*s@%s", hostname - target, target, he->h_name);
-            return res;
-        } else
-            return NULL;
-    } else if (getipbyname(hostname+1, &ip)) {
-        res = malloc((hostname - target) + 18);
-        sprintf(res, "%.*s@%lu.%lu.%lu.%lu", hostname - target, target, ip & 255, (ip >> 8) & 255, (ip >> 16) & 255, (ip >> 24) & 255);
-        return res;
-    } else
-        return NULL;
+#if 0
+    irc_in_addr_t in; /* move this to the right place */
+    if (irc_pton(&in, NULL, hostname+1)) {
+        if (getnameinfo(/*TODO*/))
+              return NULL;
+    } else if (!getaddrinfo(/*TODO*/)) {
+    } else return NULL;
+#else
+    return NULL;
+#endif
 }
 
 struct gline *
@@ -232,7 +217,7 @@ static int
 gline_refresh_helper(UNUSED_ARG(void *key), void *data, void *extra)
 {
     struct gline *ge = data;
-    irc_gline(extra, ge);
+    irc_gline(extra, ge, 0);
     return 0;
 }
 
@@ -279,7 +264,7 @@ gline_add_record(const char *key, void *data, UNUSED_ARG(void *extra))
         issuer = "<unknown>";
     }
     if (expiration > now)
-        gline_add(issuer, key, expiration - now, reason, issued, 0);
+        gline_add(issuer, key, expiration - now, reason, issued, 0, 0);
     return 0;
 }
 
@@ -312,7 +297,7 @@ gline_saxdb_write(struct saxdb_context *ctx)
 }
 
 static void
-gline_db_cleanup(void)
+gline_db_cleanup(UNUSED_ARG(void *extra))
 {
     heap_delete(gline_heap);
     dict_delete(gline_dict);
@@ -325,7 +310,7 @@ gline_init(void)
     gline_dict = dict_new();
     dict_set_free_data(gline_dict, free_gline_from_dict);
     saxdb_register("gline", gline_saxdb_read, gline_saxdb_write);
-    reg_exit_func(gline_db_cleanup);
+    reg_exit_func(gline_db_cleanup, NULL);
 }
 
 struct gline_discrim *
@@ -439,3 +424,4 @@ gline_discrim_search(struct gline_discrim *discrim, gline_search_func gsf, void
     heap_remove_pred(gline_heap, gline_search_helper, &search);
     return search.hits;
 }
+