]> jfr.im git - irc/rqf/shadowircd.git/blobdiff - src/client.c
Remove silly a2client_p, entirely pointless since User.server removal.
[irc/rqf/shadowircd.git] / src / client.c
index 29e2fedcba50dbc130321c3524689dda0aaadf22..4be29abf6cd5b6c53cf109e68c64d4642a09d509 100644 (file)
@@ -1,10 +1,11 @@
 /*
- *  ircd-ratbox: A slightly useful ircd.
+ *  charybdis: an advanced ircd.
  *  client.c: Controls clients.
  *
  *  Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
  *  Copyright (C) 1996-2002 Hybrid Development Team
  *  Copyright (C) 2002-2005 ircd-ratbox development team
+ *  Copyright (C) 2007 William Pitcock
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -21,7 +22,7 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
  *  USA
  *
- *  $Id: client.c 3319 2007-03-29 20:03:06Z jilles $
+ *  $Id: client.c 3514 2007-06-06 16:25:21Z nenolod $
  */
 #include "stdinc.h"
 #include "config.h"
@@ -58,6 +59,9 @@
 #include "msg.h"
 #include "monitor.h"
 #include "blacklist.h"
+#include "reject.h"
+#include "scache.h"
+#include "irc_dictionary.h"
 
 #define DEBUG_EXITED_CLIENTS
 
@@ -81,6 +85,8 @@ extern BlockHeap *pclient_heap;
 
 extern char current_uid[IDLEN];
 
+struct Dictionary *nd_dict = NULL;
+
 enum
 {
        D_LINED,
@@ -123,6 +129,8 @@ init_client(void)
        eventAddIsh("check_pings", check_pings, NULL, 30);
        eventAddIsh("free_exited_clients", &free_exited_clients, NULL, 4);
        eventAddIsh("exit_aborted_clients", exit_aborted_clients, NULL, 1);
+
+       nd_dict = irc_dictionary_create(irccmp);
 }
 
 
@@ -154,7 +162,7 @@ make_client(struct Client *from)
 
                client_p->localClient->lasttime = client_p->localClient->firsttime = CurrentTime;
 
-               client_p->localClient->fd = -1;
+               client_p->localClient->F = NULL;
                client_p->localClient->ctrlfd = -1;
 
                client_p->preClient = (struct PreClient *) BlockHeapAlloc(pclient_heap);
@@ -214,8 +222,8 @@ free_local_client(struct Client *client_p)
                client_p->localClient->listener = 0;
        }
 
-       if(client_p->localClient->fd >= 0)
-               comm_close(client_p->localClient->fd);
+       if(client_p->localClient->F)
+               comm_close(client_p->localClient->F->fd);
 
        if(client_p->localClient->passwd)
        {
@@ -296,45 +304,10 @@ check_pings_list(dlink_list * list)
        {
                client_p = ptr->data;
 
-               /*
-                ** Note: No need to notify opers here. It's
-                ** already done when "FLAGS_DEADSOCKET" is set.
-                */
                if(!MyConnect(client_p) || IsDead(client_p))
                        continue;
 
-               if(IsPerson(client_p))
-               {
-                       if(!IsExemptKline(client_p) &&
-                          GlobalSetOptions.idletime &&
-                          !IsOper(client_p) &&
-                          !IsIdlelined(client_p) &&
-                          ((CurrentTime - client_p->localClient->last) > GlobalSetOptions.idletime))
-                       {
-                               struct ConfItem *aconf;
-
-                               aconf = make_conf();
-                               aconf->status = CONF_KILL;
-
-                               DupString(aconf->host, client_p->host);
-                               DupString(aconf->passwd, "idle exceeder");
-                               DupString(aconf->user, client_p->username);
-                               aconf->port = 0;
-                               aconf->hold = CurrentTime + 60;
-                               add_temp_kline(aconf);
-                               sendto_realops_snomask(SNO_GENERAL, L_ALL,
-                                                    "Idle time limit exceeded for %s - temp k-lining",
-                                                    get_client_name(client_p, HIDE_IP));
-
-                               exit_client(client_p, client_p, &me, aconf->passwd);
-                               continue;
-                       }
-               }
-
-               if(!IsRegistered(client_p))
-                       ping = ConfigFileEntry.connect_timeout;
-               else
-                       ping = get_client_ping(client_p);
+               ping = get_client_ping(client_p);
 
                if(ping < (CurrentTime - client_p->localClient->lasttime))
                {
@@ -345,9 +318,9 @@ check_pings_list(dlink_list * list)
                        if(((CurrentTime - client_p->localClient->lasttime) >= (2 * ping)
                            && (client_p->flags & FLAGS_PINGSENT)))
                        {
-                               if(IsAnyServer(client_p))
+                               if(IsServer(client_p))
                                {
-                                       sendto_realops_snomask(SNO_GENERAL, is_remote_connect(client_p) && !IsServer(client_p) ? L_NETWIDE : L_ALL,
+                                       sendto_realops_snomask(SNO_GENERAL, L_ALL,
                                                             "No response from %s, closing link",
                                                             get_server_name(client_p, HIDE_IP));
                                        ilog(L_SERVER,
@@ -391,6 +364,7 @@ check_unknowns_list(dlink_list * list)
 {
        dlink_node *ptr, *next_ptr;
        struct Client *client_p;
+       int timeout;
 
        DLINK_FOREACH_SAFE(ptr, next_ptr, list->head)
        {
@@ -404,8 +378,20 @@ check_unknowns_list(dlink_list * list)
                 * for > 30s, close them.
                 */
 
-               if((CurrentTime - client_p->localClient->firsttime) > 30)
+               timeout = IsAnyServer(client_p) ? ConfigFileEntry.connect_timeout : 30;
+               if((CurrentTime - client_p->localClient->firsttime) > timeout)
+               {
+                       if(IsAnyServer(client_p))
+                       {
+                               sendto_realops_snomask(SNO_GENERAL, is_remote_connect(client_p) ? L_NETWIDE : L_ALL,
+                                                    "No response from %s, closing link",
+                                                    get_server_name(client_p, HIDE_IP));
+                               ilog(L_SERVER,
+                                    "No response from %s, closing link",
+                                    log_client_name(client_p, HIDE_IP));
+                       }
                        exit_client(client_p, client_p, &me, "Connection timed out");
+               }
        }
 }
 
@@ -1099,7 +1085,7 @@ free_exited_clients(void *unused)
                                                target_p->name, (unsigned int) target_p->status,
                                                target_p->flags, target_p->flags2, target_p->handler);
                                        sendto_realops_snomask(SNO_GENERAL, L_ALL,
-                                               "Please report this to the ratbox developers!");
+                                               "Please report this to the charybdis developers!");
                                        found++;
                                }
                        }
@@ -1284,7 +1270,7 @@ exit_aborted_clients(void *unused)
                                        abt->client->name, (unsigned int) abt->client->status,
                                        abt->client->flags, abt->client->flags2, abt->client->handler);
                                sendto_realops_snomask(SNO_GENERAL, L_ALL,
-                                       "Please report this to the ratbox developers!");
+                                       "Please report this to the charybdis developers!");
                                continue;
                        }
                }
@@ -1419,6 +1405,7 @@ exit_unknown_client(struct Client *client_p, struct Client *source_p, struct Cli
 {
        delete_auth_queries(source_p);
        client_flush_input(source_p);
+       del_unknown_ip(source_p);
        dlinkDelete(&source_p->localClient->tnode, &unknown_list);
 
        if(!IsIOError(source_p))
@@ -1434,7 +1421,6 @@ exit_unknown_client(struct Client *client_p, struct Client *source_p, struct Cli
        del_from_hostname_hash(source_p->host, source_p);
        del_from_client_hash(source_p->name, source_p);
        remove_client_from_list(source_p);
-       free_pre_client(source_p);
        SetDead(source_p);
        dlinkAddAlloc(source_p, &dead_list);
 
@@ -1454,11 +1440,7 @@ exit_remote_server(struct Client *client_p, struct Client *source_p, struct Clie
                strcpy(comment1, "*.net *.split");
        else
        {
-               if((source_p->serv) && (source_p->serv->up))
-                       strcpy(comment1, source_p->serv->up);
-               else
-                       strcpy(comment1, "<Unknown>");
-               
+               strcpy(comment1, source_p->servptr->name);
                strcat(comment1, " ");
                strcat(comment1, source_p->name);
        }
@@ -1490,6 +1472,7 @@ exit_remote_server(struct Client *client_p, struct Client *source_p, struct Clie
 
        del_from_client_hash(source_p->name, source_p);
        remove_client_from_list(source_p);  
+       scache_split(source_p->serv->nameinfo);
        
        SetDead(source_p);
 #ifdef DEBUG_EXITED_CLIENTS
@@ -1566,11 +1549,7 @@ exit_local_server(struct Client *client_p, struct Client *source_p, struct Clien
                strcpy(comment1, "*.net *.split");
        else
        {
-               if((source_p->serv) && (source_p->serv->up))
-                       strcpy(comment1, source_p->serv->up);
-               else
-                       strcpy(comment1, "<Unknown>");
-               
+               strcpy(comment1, source_p->servptr->name);
                strcat(comment1, " ");
                strcat(comment1, source_p->name);
        }
@@ -1590,6 +1569,7 @@ exit_local_server(struct Client *client_p, struct Client *source_p, struct Clien
 
        del_from_client_hash(source_p->name, source_p);
        remove_client_from_list(source_p);
+       scache_split(source_p->serv->nameinfo);
        
        SetDead(source_p);
        dlinkAddAlloc(source_p, &dead_list);
@@ -2089,14 +2069,14 @@ close_connection(struct Client *client_p)
        else
                ServerStats->is_ni++;
 
-       if(-1 < client_p->localClient->fd)
+       if(client_p->localClient->F)
        {
                /* attempt to flush any pending dbufs. Evil, but .. -- adrian */
                if(!IsIOError(client_p))
-                       send_queued_write(client_p->localClient->fd, client_p);
+                       send_queued_write(client_p->localClient->F->fd, client_p);
 
-               comm_close(client_p->localClient->fd);
-               client_p->localClient->fd = -1;
+               comm_close(client_p->localClient->F->fd);
+               client_p->localClient->F = NULL;
        }
 
        if(-1 < client_p->localClient->ctrlfd)
@@ -2132,14 +2112,12 @@ error_exit_client(struct Client *client_p, int error)
         * for reading even though it ends up being an EOF. -avalon
         */
        char errmsg[255];
-       int current_error = comm_get_sockerr(client_p->localClient->fd);
+       int current_error = comm_get_sockerr(client_p->localClient->F->fd);
 
        SetIOError(client_p);
 
        if(IsServer(client_p) || IsHandshake(client_p))
        {
-               int connected = CurrentTime - client_p->localClient->firsttime;
-
                if(error == 0)
                {
                        sendto_realops_snomask(SNO_GENERAL, is_remote_connect(client_p) && !IsServer(client_p) ? L_NETWIDE : L_ALL,
@@ -2157,13 +2135,6 @@ error_exit_client(struct Client *client_p, int error)
                        ilog(L_SERVER, "Lost connection to %s: %s",
                                log_client_name(client_p, SHOW_IP), strerror(current_error));
                }
-
-               sendto_realops_snomask(SNO_GENERAL, L_ALL,
-                                    "%s had been connected for %d day%s, %2d:%02d:%02d",
-                                    client_p->name, connected / 86400,
-                                    (connected / 86400 == 1) ? "" : "s",
-                                    (connected % 86400) / 3600,
-                                    (connected % 3600) / 60, connected % 60);
        }
 
        if(error == 0)