]> jfr.im git - irc/rqf/shadowircd.git/blobdiff - src/client.c
Remove various obsolete ConfItem statuses (types) and flags.
[irc/rqf/shadowircd.git] / src / client.c
index 045f857853a523b4fbd7ed51f80668e7d9e037b9..012076be8ebfa5e1fcc1243847b161249e7f28e0 100644 (file)
@@ -85,6 +85,8 @@ extern BlockHeap *pclient_heap;
 
 extern char current_uid[IDLEN];
 
+struct Dictionary *nd_dict = NULL;
+
 enum
 {
        D_LINED,
@@ -127,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);
 }
 
 
@@ -158,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);
@@ -218,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->fd >= 0)
+               comm_close(client_p->localClient->F->fd);
 
        if(client_p->localClient->passwd)
        {
@@ -300,10 +304,6 @@ 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;
 
@@ -335,10 +335,7 @@ check_pings_list(dlink_list * list)
                        }
                }
 
-               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))
                {
@@ -349,9 +346,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,
@@ -395,6 +392,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)
        {
@@ -408,8 +406,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");
+               }
        }
 }
 
@@ -2087,14 +2097,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)
@@ -2130,14 +2140,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,
@@ -2155,13 +2163,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)