ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/modules/m_pong.c
Revision: 69
Committed: Tue Oct 4 16:09:51 2005 UTC (20 years, 10 months ago) by adx
Content type: text/x-csrc
File size: 3593 byte(s)
Log Message:
- splitted ircd/libio, all headers connected with libio sources have been
  moved for internal use only. To use libio interface, include "libio.h"
  (which is already done in "stdinc.h")


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

Properties

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