ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_ping.c
Revision: 885
Committed: Wed Oct 31 18:09:24 2007 UTC (17 years, 9 months ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid-7.2/modules/m_ping.c
File size: 3857 byte(s)
Log Message:
- Removed LazyLinks in 7.2 to stop people from asking why we keep
  broken code for half a decade. LL will be implemented in a smarter
  fashion in due time

File Contents

# User Rev Content
1 adx 30 /*
2     * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3     * m_ping.c: Requests that a PONG message be sent back.
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 "handlers.h"
27     #include "client.h"
28     #include "ircd.h"
29     #include "numeric.h"
30     #include "send.h"
31     #include "irc_string.h"
32     #include "msg.h"
33     #include "parse.h"
34     #include "modules.h"
35     #include "hash.h"
36     #include "s_conf.h"
37     #include "s_serv.h"
38    
39     static void m_ping(struct Client*, struct Client*, int, char**);
40     static void ms_ping(struct Client*, struct Client*, int, char**);
41    
42     struct Message ping_msgtab = {
43     "PING", 0, 0, 1, 0, MFLG_SLOW, 0,
44     {m_unregistered, m_ping, ms_ping, m_ignore, m_ping, m_ping}
45     };
46    
47     #ifndef STATIC_MODULES
48     void
49     _modinit(void)
50     {
51     mod_add_cmd(&ping_msgtab);
52     }
53    
54     void
55     _moddeinit(void)
56     {
57     mod_del_cmd(&ping_msgtab);
58     }
59    
60 knight 31 const char *_version = "$Revision$";
61 adx 30 #endif
62    
63     /*
64     ** m_ping
65     ** parv[0] = sender prefix
66     ** parv[1] = origin
67     ** parv[2] = destination
68     */
69     static void
70     m_ping(struct Client *client_p, struct Client *source_p,
71     int parc, char *parv[])
72     {
73     struct Client *target_p;
74     char *origin, *destination;
75    
76     if (parc < 2 || *parv[1] == '\0')
77     {
78     sendto_one(source_p, form_str(ERR_NOORIGIN), me.name, parv[0]);
79     return;
80     }
81    
82     origin = parv[1];
83     destination = parv[2]; /* Will get NULL or pointer (parc >= 2!!) */
84    
85     if (ConfigFileEntry.disable_remote && !IsOper(source_p))
86     {
87     sendto_one(source_p,":%s PONG %s :%s", me.name,
88     (destination) ? destination : me.name, origin);
89     return;
90     }
91    
92     if (!EmptyString(destination) && irccmp(destination, me.name) != 0)
93     {
94     /* We're sending it across servers.. origin == client_p->name --fl_ */
95     origin = client_p->name;
96    
97     if ((target_p = find_server(destination)) != NULL)
98     {
99     sendto_one(target_p,":%s PING %s :%s", parv[0],
100     origin, destination);
101     }
102     else
103     {
104     sendto_one(source_p, form_str(ERR_NOSUCHSERVER),
105     me.name, parv[0], destination);
106     return;
107     }
108     }
109     else
110     sendto_one(source_p,":%s PONG %s :%s", me.name,
111     (destination) ? destination : me.name, origin);
112     }
113    
114     static void
115     ms_ping(struct Client *client_p, struct Client *source_p,
116     int parc, char *parv[])
117     {
118     struct Client *target_p;
119     const char *origin, *destination;
120    
121     if (parc < 2 || *parv[1] == '\0')
122     {
123     sendto_one(source_p, form_str(ERR_NOORIGIN), me.name, parv[0]);
124     return;
125     }
126    
127     origin = source_p->name;
128     destination = parv[2]; /* Will get NULL or pointer (parc >= 2!!) */
129    
130     if (!EmptyString(destination) && irccmp(destination, me.name) != 0 && irccmp(destination, me.id) != 0)
131     {
132     if ((target_p = find_server(destination)))
133     sendto_one(target_p,":%s PING %s :%s", parv[0],
134     origin, destination);
135     else
136     {
137     sendto_one(source_p, form_str(ERR_NOSUCHSERVER),
138     ID_or_name(&me, client_p), parv[0], destination);
139     return;
140     }
141     }
142     else
143     sendto_one(source_p,":%s PONG %s :%s",
144     ID_or_name(&me, client_p), (destination) ? destination : me.name, origin);
145     }

Properties

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