ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/modules/m_pong.c
Revision: 126
Committed: Fri Oct 14 02:41:46 2005 UTC (20 years, 10 months ago) by db
Content type: text/x-csrc
File size: 3613 byte(s)
Log Message:
- attach/conf cleanup take 2
- Each client has now one AccessItem for its connect
  stored in localClient->iline
- The corresponding class is now stored in localClient->class

The ramifications of this move are, there is no conf list to traverse
to find the AccessItem, the class is instantly available from the localClient
struct without having to traverse the confs list and indirectly through the
aconf. This speeds up get_sendq etc. functions. As a bonus, at least
4 fewer bytes are used in the Client struct, since a dlink list is 4 words.
It does mean there is no longer a separate conf oper, which leads to the
kludge of patching the clients iline into an oper conf when
a client opers up. I don't think the oper flags are used after the client
is opered, so the patching operation may not be necessary.

- Server confs are stored in ->serv->sconf as before but attaching
  happens much earlier.
- server hub/leaf masks continues to be a dlink list but linked from
  the ->serv which is only allocated for servers.

- cleaned up some comments, added a comment, notably to check_server()
  which badly needed it.
- Pass ClassItem or AccessItem etc. in when it makes more sense than passing
  in struct ConfItem. This simplified and clarified rebuild_cidr_class()

And lo, there was a great rejoicing.


File Contents

# User Rev Content
1 adx 30 /*
2     * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3     * m_pong.c: The reply to a ping message.
4     *
5     * Copyright (C) 2002 by the past and present ircd coders, and others.
6     *
7     * This program is free software; you can redistribute it and/or modify
8     * it under the terms of the GNU General Public License as published by
9     * the Free Software Foundation; either version 2 of the License, or
10     * (at your option) any later version.
11     *
12     * This program is distributed in the hope that it will be useful,
13     * but WITHOUT ANY WARRANTY; without even the implied warranty of
14     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15     * GNU General Public License for more details.
16     *
17     * You should have received a copy of the GNU General Public License
18     * along with this program; if not, write to the Free Software
19     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20     * USA
21     *
22 knight 31 * $Id$
23 adx 30 */
24    
25     #include "stdinc.h"
26     #include "ircd.h"
27     #include "handlers.h"
28 db 126 #include "s_conf.h"
29 adx 30 #include "s_user.h"
30     #include "client.h"
31     #include "hash.h" /* for find_client() */
32     #include "numeric.h"
33     #include "s_conf.h"
34     #include "send.h"
35     #include "msg.h"
36     #include "parse.h"
37     #include "modules.h"
38    
39     static void mr_pong(struct Client *, struct Client *, int, char **);
40     static void ms_pong(struct Client *, struct Client *, int, char **);
41    
42     struct Message pong_msgtab = {
43     "PONG", 0, 0, 1, 0, MFLG_SLOW | MFLG_UNREG, 0,
44     {mr_pong, m_ignore, ms_pong, m_ignore, m_ignore, m_ignore}
45     };
46    
47     #ifndef STATIC_MODULES
48     void
49     _modinit(void)
50     {
51     mod_add_cmd(&pong_msgtab);
52     }
53    
54     void
55     _moddeinit(void)
56     {
57     mod_del_cmd(&pong_msgtab);
58     }
59    
60 knight 31 const char *_version = "$Revision$";
61 adx 30 #endif
62    
63     static void
64     ms_pong(struct Client *client_p, struct Client *source_p,
65     int parc, char *parv[])
66     {
67     struct Client *target_p;
68     const char *origin, *destination;
69    
70     if (parc < 2 || *parv[1] == '\0')
71     {
72     sendto_one(source_p, form_str(ERR_NOORIGIN),
73     me.name, parv[0]);
74     return;
75     }
76    
77     origin = parv[1];
78     destination = parv[2];
79    
80     /* Now attempt to route the PONG, comstud pointed out routable PING
81     * is used for SPING. routable PING should also probably be left in
82     * -Dianora
83     * That being the case, we will route, but only for registered clients (a
84     * case can be made to allow them only from servers). -Shadowfax
85     */
86     if (!EmptyString(destination) && !match(destination, me.name) &&
87     irccmp(destination, me.id))
88     {
89     if ((target_p = find_client(destination)) ||
90     (target_p = find_server(destination)))
91     sendto_one(target_p,":%s PONG %s %s",
92     parv[0], origin, destination);
93     else
94     {
95     sendto_one(source_p, form_str(ERR_NOSUCHSERVER),
96     me.name, parv[0], destination);
97     return;
98     }
99     }
100     }
101    
102     static void
103     mr_pong(struct Client *client_p, struct Client *source_p,
104     int parc, char *parv[])
105     {
106     if (parc == 2 && *parv[1] != '\0')
107     {
108     if(ConfigFileEntry.ping_cookie && (source_p->flags&FLAGS_GOTUSER) && source_p->name[0])
109     {
110     unsigned long incoming_ping = strtoul(parv[1], NULL, 10);
111     if(incoming_ping)
112     {
113     if(source_p->localClient->random_ping == incoming_ping)
114     {
115     char buf[USERLEN+1];
116     strlcpy(buf, source_p->username, sizeof(buf));
117     SetPingCookie(source_p);
118     register_local_user(client_p, source_p, source_p->name, buf);
119     }
120     else
121     {
122     sendto_one(source_p, form_str(ERR_WRONGPONG), me.name,
123     source_p->name, source_p->localClient->random_ping);
124     return;
125     }
126     }
127     }
128    
129     }
130     else
131     sendto_one(source_p, form_str(ERR_NOORIGIN), me.name, parv[0]);
132     }
133    

Properties

Name Value
svn:eol-style native
svn:keywords Id Revision