/[svn]/ircd-hybrid/modules/m_pong.c
ViewVC logotype

Annotation of /ircd-hybrid/modules/m_pong.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 502 - (hide annotations)
Fri Mar 3 19:49:25 2006 UTC (15 years, 3 months ago) by michael
File MIME type: text/x-chdr
File size: 3623 byte(s)
- Implemented CAP command handler based uppon ircu's m_cap()
- Added somewhat outdated draft-mitchell-irc-capabilities-01.txt until
  I get the latest version from kev.
- Added "multi-prefix" cap so clients supporting "multi-prefix"
  may recieve multi prefixed NAMES replies, e.g. @%+nick1 @+nick2 ..
- Fixed "make clean" for src/conf/

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 db 470 #include "conf/modules.h"
38 adx 30
39 michael 458 static void mr_pong(struct Client *, struct Client *, int, char *[]);
40     static void ms_pong(struct Client *, struct Client *, int, char *[]);
41 adx 30
42     struct Message pong_msgtab = {
43     "PONG", 0, 0, 1, 0, MFLG_SLOW | MFLG_UNREG, 0,
44 michael 458 { mr_pong, m_ignore, ms_pong, m_ignore, m_ignore, m_ignore }
45 adx 30 };
46    
47 adx 442 INIT_MODULE(m_pong, "$Revision$")
48 adx 30 {
49     mod_add_cmd(&pong_msgtab);
50     }
51    
52 adx 442 CLEANUP_MODULE
53 adx 30 {
54     mod_del_cmd(&pong_msgtab);
55     }
56    
57     static void
58     ms_pong(struct Client *client_p, struct Client *source_p,
59     int parc, char *parv[])
60     {
61 michael 502 const char *origin = NULL, *destination = NULL;
62 adx 30
63 michael 458 if (*parv[1] == '\0')
64 adx 30 {
65     sendto_one(source_p, form_str(ERR_NOORIGIN),
66     me.name, parv[0]);
67     return;
68     }
69    
70     origin = parv[1];
71     destination = parv[2];
72    
73 michael 502 /*
74     * Now attempt to route the PONG, comstud pointed out routable PING
75 adx 30 * is used for SPING. routable PING should also probably be left in
76     * -Dianora
77     * That being the case, we will route, but only for registered clients (a
78     * case can be made to allow them only from servers). -Shadowfax
79     */
80     if (!EmptyString(destination) && !match(destination, me.name) &&
81     irccmp(destination, me.id))
82     {
83 michael 502 struct Client *target_p = NULL;
84    
85     if ((target_p = find_client(destination)) ||
86     (target_p = find_server(destination)))
87     sendto_one(target_p, ":%s PONG %s %s",
88     parv[0], origin, destination);
89     else
90     sendto_one(source_p, form_str(ERR_NOSUCHSERVER),
91     me.name, parv[0], destination);
92 adx 30 }
93     }
94    
95     static void
96     mr_pong(struct Client *client_p, struct Client *source_p,
97     int parc, char *parv[])
98     {
99 michael 458 assert(source_p == client_p);
100    
101 adx 30 if (parc == 2 && *parv[1] != '\0')
102     {
103 michael 502 if (ConfigFileEntry.ping_cookie && !source_p->localClient->registration)
104 adx 30 {
105 michael 458 unsigned long incoming_ping = strtoul(parv[1], NULL, 10);
106 michael 502
107 michael 458 if (incoming_ping)
108     {
109 michael 502 if (source_p->localClient->random_ping == incoming_ping)
110     {
111     char buf[USERLEN + 1];
112    
113     strlcpy(buf, source_p->username, sizeof(buf));
114     SetPingCookie(source_p);
115     register_local_user(source_p, buf);
116 michael 458 }
117 michael 502 else
118     {
119     sendto_one(source_p, form_str(ERR_WRONGPONG), me.name,
120     source_p->name, source_p->localClient->random_ping);
121     return;
122     }
123 adx 30 }
124     }
125 michael 458 }
126 adx 30 else
127     sendto_one(source_p, form_str(ERR_NOORIGIN), me.name, parv[0]);
128     }

Properties

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

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.28