ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/contrib/m_jupe.c
Revision: 76
Committed: Tue Oct 4 19:38:49 2005 UTC (20 years, 10 months ago) by adx
Content type: text/x-csrc
File size: 4938 byte(s)
Log Message:
- fixed contrib #includes

File Contents

# User Rev Content
1 adx 30 /*
2     * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3     * m_jupe.c: Jupes a server.
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 "channel.h"
28     #include "client.h"
29     #include "ircd.h"
30     #include "numeric.h"
31     #include "s_serv.h"
32     #include "send.h"
33     #include "whowas.h"
34     #include "hash.h"
35     #include "msg.h"
36     #include "parse.h"
37     #include "modules.h"
38     #include "common.h"
39     #include "s_conf.h"
40    
41     static void mo_jupe(struct Client *, struct Client *, int, char *[]);
42     static int bogus_host(char *);
43    
44     struct Message jupe_msgtab = {
45     "JUPE", 0, 0, 3, 0, MFLG_SLOW, 0,
46     {m_unregistered, m_not_oper, mo_jupe, m_ignore, mo_jupe, m_ignore}
47     };
48    
49     #ifndef STATIC_MODULES
50     void
51     _modinit(void)
52     {
53     mod_add_cmd(&jupe_msgtab);
54     }
55    
56     void
57     _moddeinit(void)
58     {
59     mod_del_cmd(&jupe_msgtab);
60     }
61    
62 knight 31 const char *_version = "$Revision$";
63 adx 30 #endif
64    
65     /*
66     * mo_jupe()
67     * parv[0] = sender prefix
68     * parv[1] = server we're juping
69     * parv[2] = reason for jupe
70     */
71     static void
72     mo_jupe(struct Client *client_p, struct Client *source_p,
73     int parc, char *parv[])
74     {
75     struct Client *target_p = NULL;
76     struct Client *ajupe = NULL;
77     dlink_node *m = NULL;
78     char reason[REALLEN + 1];
79    
80     if (!IsAdmin(source_p))
81     {
82     sendto_one(source_p, form_str(ERR_NOPRIVILEGES),
83     me.name, source_p->name);
84     return;
85     }
86    
87     if (*parv[2] == '\0')
88     {
89     sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
90     me.name, source_p->name, "JUPE");
91     return;
92     }
93    
94     if (!ServerInfo.hub)
95     {
96     sendto_one(source_p, ":%s NOTICE %s :Must be used from a hub server",
97     me.name, source_p->name);
98     return;
99     }
100    
101     if (bogus_host(parv[1]))
102     {
103     sendto_one(source_p, ":%s NOTICE %s :Invalid servername: %s",
104     me.name, source_p->name, parv[1]);
105     return;
106     }
107    
108     if (match(parv[1], me.name))
109     {
110     sendto_one(source_p, ":%s NOTICE %s :I can't jupe myself!",
111     me.name, source_p->name);
112     return;
113     }
114    
115     /* we need to give 7 chars to prepend "JUPED: " */
116     if (strlen(parv[2]) > (REALLEN - 7))
117     parv[2][REALLEN - 7] = '\0';
118    
119     sendto_wallops_flags(UMODE_WALLOP, &me,
120     "JUPE for %s requested by %s: %s",
121     parv[1], get_oper_name(source_p), parv[2]);
122    
123     sendto_server(NULL, source_p, NULL, NOCAPS, NOCAPS, LL_ICLIENT,
124     ":%s WALLOPS :JUPE for %s requested by %s!%s@%s: %s",
125     me.name, parv[1], source_p->name,
126     source_p->username, source_p->host, parv[2]);
127     ilog(L_NOTICE, "JUPE for %s requested by %s: %s",
128     parv[1], get_oper_name(source_p), parv[2]);
129    
130     if ((target_p = find_server(parv[1])) != NULL)
131     exit_client(target_p, &me, parv[2]);
132    
133     sendto_server(NULL, NULL, NULL, NOCAPS, NOCAPS, NOFLAGS,
134     ":%s SERVER %s 1 :JUPED: %s",
135     me.name, parv[1], parv[2]);
136    
137     sendto_realops_flags(UMODE_ALL, L_ALL,
138     "Link with %s established: (JUPED) link",
139     parv[1]);
140    
141     ajupe = make_client(NULL);
142    
143     /* make_client() adds client to unknown_list */
144     if ((m = dlinkFindDelete(&unknown_list, ajupe)) != NULL)
145     free_dlink_node(m);
146    
147     make_server(ajupe);
148    
149     strlcpy(ajupe->name, parv[1], sizeof(ajupe->name));
150     ircsprintf(reason, "JUPED: %s", parv[2]);
151     strlcpy(ajupe->info, reason, sizeof(ajupe->info));
152    
153     ajupe->servptr = &me;
154     ajupe->hopcount = 1;
155    
156     SetServer(ajupe);
157     SetDead(ajupe);
158    
159     Count.myserver++;
160    
161     hash_add_client(ajupe);
162     dlinkAdd(ajupe, &ajupe->lnode, &ajupe->servptr->serv->servers);
163     dlinkAdd(ajupe, make_dlink_node(), &global_serv_list);
164    
165     /* XXX is this really necessary?
166     * for now, 'cause of the way squit works
167     */
168     dlinkAdd(ajupe, &ajupe->node, &global_client_list);
169     }
170    
171     /* bogus_host()
172     *
173     * inputs - hostname
174     * output - 1 if a bogus hostname input,
175     * - 0 if its valid
176     * side effects - none
177     */
178     static int
179     bogus_host(char *host)
180     {
181     unsigned int length = 0;
182     unsigned int dots = 0;
183     char *s = host;
184    
185     for (; *s; s++)
186     {
187     if (!IsServChar(*s))
188     return 1;
189    
190     ++length;
191    
192     if ('.' == *s)
193     ++dots;
194     }
195    
196     return !dots || length > HOSTLEN;
197     }

Properties

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