ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid-7.2/modules/m_lljoin.c
Revision: 632
Committed: Thu Jun 1 10:53:00 2006 UTC (17 years, 10 months ago) by michael
Content type: text/x-csrc
File size: 5289 byte(s)
Log Message:
- Added channel::disable_fake_channels which disallows creation of channels
  that have ascii 2, 3, 31 and 160 in their names.
- Minor improvements and cleanups to channel name validation routines
  backported from 7.3

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 * m_lljoin.c: Joins a user on a lazy-link to a channel.
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 * $Id$
23 */
24
25 #include "stdinc.h"
26 #include "tools.h"
27 #include "channel.h"
28 #include "channel_mode.h"
29 #include "client.h"
30 #include "hash.h"
31 #include "common.h"
32 #include "irc_string.h"
33 #include "ircd.h"
34 #include "list.h"
35 #include "numeric.h"
36 #include "s_serv.h"
37 #include "s_conf.h"
38 #include "send.h"
39 #include "handlers.h"
40 #include "msg.h"
41 #include "parse.h"
42 #include "modules.h"
43
44
45 static void ms_lljoin(struct Client *,struct Client *,int,char **);
46
47 struct Message lljoin_msgtab = {
48 "LLJOIN", 0, 0, 3, 0, MFLG_SLOW | MFLG_UNREG, 0L,
49 {m_unregistered, m_ignore, ms_lljoin, m_ignore, m_ignore, m_ignore}
50 };
51 #ifndef STATIC_MODULES
52
53 void
54 _modinit(void)
55 {
56 mod_add_cmd(&lljoin_msgtab);
57 }
58
59 void
60 _moddeinit(void)
61 {
62 mod_del_cmd(&lljoin_msgtab);
63 }
64
65 const char *_version = "$Revision$";
66 #endif
67 /*
68 * m_lljoin
69 * parv[0] = sender prefix
70 * parv[1] = channel
71 * parv[2] = nick ("!nick" == cjoin)
72 * parv[3] = key (optional)
73 *
74 * If a lljoin is received, from our uplink, join
75 * the requested client to the given channel, or ignore it
76 * if there is an error.
77 *
78 * Ok, the way this works. Leaf client tries to join a channel,
79 * it doesn't exist so the join does a cburst request on behalf of the
80 * client, and aborts that join. The cburst sjoin's the channel if it
81 * exists on the hub, and sends back an LLJOIN to the leaf. Thats where
82 * this is now..
83 *
84 */
85 static void
86 ms_lljoin(struct Client *client_p, struct Client *source_p,
87 int parc, char *parv[])
88 {
89 char *chname = NULL;
90 char *nick = NULL;
91 char *key = NULL;
92 int flags;
93 int i;
94 struct Client *target_p;
95 struct Channel *chptr;
96
97 if (uplink && !IsCapable(uplink,CAP_LL))
98 {
99 sendto_realops_flags(UMODE_ALL, L_ALL,
100 "*** LLJOIN requested from non LL server %s",
101 client_p->name);
102 return;
103 }
104
105 chname = parv[1];
106 if(chname == NULL)
107 return;
108
109 nick = parv[2];
110 if(nick == NULL)
111 return;
112
113 if (parc >3)
114 key = parv[3];
115
116 flags = 0;
117
118 target_p = find_person(client_p, nick);
119
120 if (!target_p)
121 return;
122
123 if (!MyClient(target_p))
124 return;
125
126 if (!check_channel_name(chname, 0))
127 {
128 sendto_realops_flags(UMODE_DEBUG, L_ALL,
129 "*** Too long or invalid channel name from %s: %s",
130 target_p->name, chname);
131 return;
132 }
133
134 chptr = make_channel(chname);
135 flags = CHFL_CHANOP;
136
137 if(!chptr)
138 return;
139
140 if (dlink_list_length(&chptr->members) == 0)
141 flags = CHFL_CHANOP;
142 else
143 flags = 0;
144
145 /* XXX in m_join.c :( */
146 /* check_spambot_warning(target_p, chname); */
147
148 /* They _could_ join a channel twice due to lag */
149 if(chptr)
150 {
151 if (IsMember(target_p, chptr)) /* already a member, ignore this */
152 return;
153 }
154 else
155 {
156 sendto_one(target_p, form_str(ERR_UNAVAILRESOURCE),
157 me.name, nick, chptr->chname);
158 return;
159 }
160
161 if ((i = can_join(target_p, chptr, key)))
162 {
163 sendto_one(target_p, form_str(i),
164 me.name, nick, chptr->chname);
165 return;
166 }
167
168 if ((dlink_list_length(&target_p->channel) >= ConfigChannel.max_chans_per_user) &&
169 (!IsOper(target_p) || (dlink_list_length(&target_p->channel) >=
170 ConfigChannel.max_chans_per_user*3)))
171 {
172 sendto_one(target_p, form_str(ERR_TOOMANYCHANNELS),
173 me.name, nick, chptr->chname );
174 return;
175 }
176
177 if (flags == CHFL_CHANOP)
178 {
179 chptr->channelts = CurrentTime;
180
181 sendto_one(uplink,
182 ":%s SJOIN %lu %s + :@%s",
183 me.name,
184 (unsigned long) chptr->channelts,
185 chptr->chname,
186 nick);
187 }
188
189 sendto_one(uplink,
190 ":%s SJOIN %lu %s + :%s",
191 me.name,
192 (unsigned long) chptr->channelts,
193 chptr->chname,
194 nick);
195
196 add_user_to_channel(chptr, target_p, flags, YES);
197
198 sendto_channel_local(ALL_MEMBERS, NO, chptr,
199 ":%s!%s@%s JOIN :%s",
200 target_p->name,
201 target_p->username,
202 target_p->host,
203 chptr->chname);
204
205 if (flags & CHFL_CHANOP)
206 {
207 chptr->mode.mode |= MODE_TOPICLIMIT;
208 chptr->mode.mode |= MODE_NOPRIVMSGS;
209
210 sendto_channel_local(ALL_MEMBERS, NO, chptr,
211 ":%s MODE %s +nt",
212 me.name, chptr->chname);
213 sendto_one(uplink,
214 ":%s MODE %s +nt",
215 me.name, chptr->chname);
216 }
217
218 channel_member_names(target_p, chptr, 1);
219 }

Properties

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