]> jfr.im git - irc/freenode/syn.git/commitdiff
gateways.c: rip out unused reverse lookup code
authorJanik Kleinhoff <redacted>
Wed, 13 Feb 2019 04:33:59 +0000 (04:33 +0000)
committerJanik Kleinhoff <redacted>
Wed, 13 Feb 2019 04:33:59 +0000 (04:33 +0000)
gateways.c

index e0ba9f349db4a23f33a0bca12a220e0928f29e29..7747fc2c25935a5ea3959403c3c383cf28741180 100644 (file)
@@ -6,20 +6,6 @@
 static void check_user(hook_user_nick_t *data, bool isnewuser);
 static bool maybe_kline_user_host(user_t *u, const char *hostname);
 
-typedef struct
-{
-    user_t *u;
-    sockaddr_any_t sa;
-    dns_query_t dns_query;
-} reverse_lookup_client;
-
-mowgli_heap_t *rlc_heap;
-
-static void start_reverse_lookup(user_t *u, const char *ip);
-static void reverse_lookup_callback(void *vptr, dns_reply_t *reply);
-static void free_rlc_info(user_t *u);
-static void abort_rlc(user_t *u);
-
 static void check_all_users(void *v)
 {
     user_t *u;
@@ -49,10 +35,6 @@ static void mod_init(module_t *m)
     hook_add_hook("syn_kline_added", check_all_users);
     hook_add_event("syn_kline_check");
 
-    hook_add_event("user_delete");
-    hook_add_user_delete(abort_rlc);
-    rlc_heap = mowgli_heap_create(sizeof(rlc_heap), 512, BH_NOW);
-
     check_all_users(NULL);
 }
 
@@ -60,9 +42,6 @@ static void mod_deinit(module_unload_intent_t intent)
 {
     hook_del_user_add(gateway_newuser);
     hook_del_hook("syn_kline_added", check_all_users);
-
-    mowgli_heap_destroy(rlc_heap);
-    hook_del_user_delete(abort_rlc);
 }
 
 static bool maybe_kline_user_host(user_t *u, const char *hostname)
@@ -159,17 +138,6 @@ static void check_user(hook_user_nick_t *data, bool isnewuser)
         return;
     }
 
-#if 0
-    if (!p)
-    {
-        syn_debug(3, "no hostname found for %s!%s@%s[%s]; doing reverse lookup", u->nick, u->user, u->host, u->gecos);
-
-        // There was no hostname, only an IP. This can happen when the hostname is too long to fit in a gecos field.
-        // Do a reverse lookup and see whether the hostname is also klined.
-        start_reverse_lookup(u, identhost);
-    }
-#endif
-
     // As above, but for gecos hostnames
     syn_kline_check_data_t d = { gecos, u };
     hook_call_event("syn_kline_check", &d);
@@ -177,78 +145,6 @@ static void check_user(hook_user_nick_t *data, bool isnewuser)
     hook_call_event("syn_kline_check", &d);
 }
 
-// Reverse DNS lookup stuff below here
-
-static void start_reverse_lookup(user_t *u, const char *ip)
-{
-    reverse_lookup_client *rlc = mowgli_heap_alloc(rlc_heap);
-
-    rlc->u = u;
-    rlc->dns_query.ptr = rlc;
-    rlc->dns_query.callback = reverse_lookup_callback;
-
-    if (0 == inet_aton(ip, &rlc->sa.sin.sin_addr))
-    {
-        syn_debug(3, "failed to convert ip address [%s] for user [%s]", ip, u->nick);
-        mowgli_heap_free(rlc_heap, rlc);
-        return;
-    }
-
-    rlc->sa.sa.sa_family = AF_INET;
-
-    syn_debug(3, "starting reverse lookup on [%s] for user [%s]", ip, u->nick);
-
-    gethost_byaddr(&rlc->sa, &rlc->dns_query);
-
-    free_rlc_info(u);
-    privatedata_set(u, "syn:gateway:rlcinfo", rlc);
-}
-
-static void free_rlc_info(user_t *u)
-{
-    reverse_lookup_client *rlc = privatedata_get(u, "syn:gateway:rlcinfo");
-    if (!rlc)
-        return;
-
-    mowgli_heap_free(rlc_heap, rlc);
-    privatedata_set(u, "syn:gateway:rlcinfo", 0);
-}
-
-static void abort_rlc(user_t *u)
-{
-    // User quit. If a reverse lookup is pending, blank out the user pointer to avoid crashing when it completes
-    reverse_lookup_client *rlc = privatedata_get(u, "syn:gateway:rlcinfo");
-    if (!rlc)
-        return;
-
-    rlc->u = NULL;
-}
-
-static void reverse_lookup_callback(void *vptr, dns_reply_t *reply)
-{
-    reverse_lookup_client *rlc = vptr;
-    user_t *u = rlc->u;
-
-    if (!u)
-    {
-        // User quit, and abort_rlc() blanked out the u pointer for us
-        return;
-    }
-
-    // Whether there's a kline or not, we're done with this info.
-    free_rlc_info(u);
-
-    if (!reply)
-    {
-        syn_debug(3, "got lookup callback with no reply for user [%s]", u->nick);
-        return;
-    }
-
-    syn_debug(3, "got reverse lookup info [%s] for user [%s]", reply->h_name, u->nick);
-
-    maybe_kline_user_host(u, reply->h_name);
-}
-
 DECLARE_MODULE_V1
 (
         "syn/gateways", false, mod_init, mod_deinit,