ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/branches/ircd-hybrid-newconf/modules/m_testmask.c
Revision: 747
Committed: Mon Jul 24 22:14:17 2006 UTC (19 years, 1 month ago) by adx
Content type: text/x-csrc
Original Path: ircd-hybrid/modules/m_testmask.c
File size: 3572 byte(s)
Log Message:
+ fixed everything except m_gline and m_spoof.
+ still to do: ban storage, limits, iphash, parser, conf_connect_allowed

File Contents

# User Rev Content
1 adx 30 /*
2     * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3     * m_testmask.c: Counts the birdies err local and remote clients.
4     *
5     * Copyright (C) 2005 by Diane Bruce
6     * Coypright (C) 2005 ircd-hybrid team
7     *
8     * Redistribution and use in source and binary forms, with or without
9     * modification, are permitted provided that the following conditions are
10     * met:
11     *
12     * 1.Redistributions of source code must retain the above copyright notice,
13     * this list of conditions and the following disclaimer.
14     * 2.Redistributions in binary form must reproduce the above copyright
15     * notice, this list of conditions and the following disclaimer in the
16     * documentation and/or other materials provided with the distribution.
17     * 3.The name of the author may not be used to endorse or promote products
18     * derived from this software without specific prior written permission.
19     *
20     * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21     * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22     * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23     * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24     * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25     * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26     * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27     * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28     * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29     * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30     * POSSIBILITY OF SUCH DAMAGE.
31     *
32 knight 31 * $Id$
33 adx 30 */
34    
35     #include "stdinc.h"
36     #include "handlers.h"
37     #include "client.h"
38     #include "common.h"
39     #include "ircd_defs.h"
40     #include "ircd.h"
41     #include "restart.h"
42     #include "send.h"
43     #include "msg.h"
44     #include "numeric.h"
45     #include "parse.h"
46 db 470 #include "conf/modules.h"
47 adx 30
48     static void mo_testmask(struct Client *, struct Client *, int, char *[]);
49    
50     struct Message testmask_msgtab = {
51     "TESTMASK", 0, 0, 0, 0, MFLG_SLOW, 0,
52     {m_unregistered, m_not_oper, m_ignore, m_ignore, mo_testmask, m_ignore}
53     };
54    
55 adx 442 INIT_MODULE(m_testmask, "$Revision$")
56 adx 30 {
57     mod_add_cmd(&testmask_msgtab);
58     }
59    
60 adx 442 CLEANUP_MODULE
61 adx 30 {
62     mod_del_cmd(&testmask_msgtab);
63     }
64    
65     /* mo_testmask()
66     *
67     * inputs - pointer to physical connection request is coming from
68     * - pointer to source connection request is coming from
69     * - parc arg count
70     * - parv actual arguments
71     * output - NONE
72     * side effects - count up clients matching mask
73     * i.e. /quote testmask user@host
74     */
75     static void
76     mo_testmask(struct Client *client_p, struct Client *source_p,
77     int parc, char *parv[])
78     {
79     char *given_host;
80     char *given_user = parv[1];
81     int local_count = 0, remote_count = 0;
82     dlink_node *ptr, *next_ptr;
83     struct Client *target_p;
84    
85     if (parc < 2 || ((given_host = strchr(given_user, '@')) == NULL))
86     {
87     sendto_one(source_p, ":%s NOTICE %s :usage: user@host",
88     me.name, source_p->name);
89     return;
90     }
91    
92     *given_host++ = '\0';
93    
94     DLINK_FOREACH_SAFE(ptr, next_ptr, global_client_list.head)
95     {
96     target_p = ptr->data;
97    
98     if (IsDead(target_p) || !IsClient(target_p))
99     continue;
100    
101     if (match(given_user, target_p->username) &&
102 adx 747 match(given_host, target_p->host))
103 adx 30 {
104     if (MyConnect(target_p))
105 adx 747 local_count++;
106 adx 30 else
107 adx 747 remote_count++;
108 adx 30 }
109     }
110    
111     sendto_one(source_p, form_str(RPL_TESTMASK), me.name, source_p->name,
112     given_user, given_host, local_count, remote_count);
113     }

Properties

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