]> jfr.im git - irc/quakenet/snircd-patchqueue.git/blob - badchan
Refresh patch
[irc/quakenet/snircd-patchqueue.git] / badchan
1 # HG changeset patch
2 # Parent f49987f27c65a72ee0611e57c25a0c5309e5cec1
3
4 diff -r f49987f27c65 include/gline.h
5 --- a/include/gline.h Sun Jul 14 18:24:36 2013 +0100
6 +++ b/include/gline.h Sun Jul 14 18:25:15 2013 +0100
7 @@ -136,6 +136,7 @@
8 struct Gline *gline);
9 extern struct Gline *gline_find(char *userhost, unsigned int flags);
10 extern struct Gline *gline_lookup(struct Client *cptr, unsigned int flags);
11 +extern struct Gline *gline_lookup_badchan(char *userhost, unsigned int flags);
12 extern void gline_free(struct Gline *gline);
13 extern void gline_burst(struct Client *cptr);
14 extern int gline_resend(struct Client *cptr, struct Gline *gline);
15 diff -r f49987f27c65 ircd/gline.c
16 --- a/ircd/gline.c Sun Jul 14 18:24:36 2013 +0100
17 +++ b/ircd/gline.c Sun Jul 14 18:25:15 2013 +0100
18 @@ -24,7 +24,9 @@
19 #include "config.h"
20
21 #include "gline.h"
22 +#include "channel.h"
23 #include "client.h"
24 +#include "hash.h"
25 #include "ircd.h"
26 #include "ircd_alloc.h"
27 #include "ircd_features.h"
28 @@ -184,8 +186,8 @@
29 }
30
31 /** Check local clients against a new G-line.
32 - * If the G-line is inactive or a badchan, return immediately.
33 - * Otherwise, if any users match it, disconnect them.
34 + * If the G-line is inactive, return immediately.
35 + * Otherwise, if any users match it, disconnect them or kick them if the G-line is a BADCHAN.
36 * @param[in] cptr Peer connect that sent the G-line.
37 * @param[in] sptr Client that originated the G-line.
38 * @param[in] gline New G-line to check.
39 @@ -200,53 +202,72 @@
40 if (feature_bool(FEAT_DISABLE_GLINES))
41 return 0; /* G-lines are disabled */
42
43 - if (GlineIsBadChan(gline)) /* no action taken on badchan glines */
44 - return 0;
45 if (!GlineIsActive(gline)) /* no action taken on inactive glines */
46 return 0;
47
48 - for (fd = HighestFd; fd >= 0; --fd) {
49 - /*
50 - * get the users!
51 - */
52 - if ((acptr = LocalClientArray[fd])) {
53 - if (!cli_user(acptr))
54 - continue;
55 + if (GlineIsBadChan(gline)) {
56 + /* Handle BADCHAN gline */
57 + struct Channel *chptr,*nchptr;
58 + struct Membership *member,*nmember;
59
60 - if (GlineIsRealName(gline)) { /* Realname Gline */
61 - Debug((DEBUG_DEBUG,"Realname Gline: %s %s",(cli_info(acptr)),
62 - gline->gl_user+2));
63 - if (match(gline->gl_user+2, cli_info(acptr)) != 0)
64 - continue;
65 - Debug((DEBUG_DEBUG,"Matched!"));
66 - } else { /* Host/IP gline */
67 - if (cli_user(acptr)->username &&
68 - match(gline->gl_user, (cli_user(acptr))->realusername) != 0)
69 + for(chptr=GlobalChannelList;chptr;chptr=nchptr) {
70 + nchptr=chptr->next;
71 + if (match(gline->gl_user, chptr->chname))
72 + continue;
73 + for (member=chptr->members;member;member=nmember) {
74 + nmember=member->next_member;
75 + if (!MyUser(member->user) || IsZombie(member) || IsAnOper(member->user))
76 + continue;
77 + sendcmdto_serv_butone(&me, CMD_KICK, NULL, "%H %C :Badchanneled (%s)", chptr, member->user, gline->gl_reason);
78 + sendcmdto_channel_butserv_butone(&his, CMD_KICK, chptr, NULL, 0, "%H %C :Badchanneled (%s)", chptr, member->user, gline->gl_reason);
79 + make_zombie(member, member->user, &me, &me, chptr);
80 + retval=1;
81 + }
82 + }
83 + } else {
84 + for (fd = HighestFd; fd >= 0; --fd) {
85 + /*
86 + * get the users!
87 + */
88 + if ((acptr = LocalClientArray[fd])) {
89 + if (!cli_user(acptr))
90 continue;
91
92 - if (GlineIsIpMask(gline)) {
93 - if (!ipmask_check(&cli_ip(acptr), &gline->gl_addr, gline->gl_bits))
94 + if (GlineIsRealName(gline)) { /* Realname Gline */
95 + Debug((DEBUG_DEBUG,"Realname Gline: %s %s",(cli_info(acptr)),
96 + gline->gl_user+2));
97 + if (match(gline->gl_user+2, cli_info(acptr)) != 0)
98 + continue;
99 + Debug((DEBUG_DEBUG,"Matched!"));
100 + } else { /* Host/IP gline */
101 + if (cli_user(acptr)->username &&
102 + match(gline->gl_user, (cli_user(acptr))->realusername) != 0)
103 continue;
104 +
105 + if (GlineIsIpMask(gline)) {
106 + if (!ipmask_check(&cli_ip(acptr), &gline->gl_addr, gline->gl_bits))
107 + continue;
108 + }
109 + else {
110 + if (match(gline->gl_host, cli_sockhost(acptr)) != 0)
111 + continue;
112 + }
113 }
114 - else {
115 - if (match(gline->gl_host, cli_sockhost(acptr)) != 0)
116 - continue;
117 - }
118 +
119 + /* ok, here's one that got G-lined */
120 + send_reply(acptr, SND_EXPLICIT | ERR_YOUREBANNEDCREEP, ":%s",
121 + gline->gl_reason);
122 +
123 + /* let the ops know about it */
124 + sendto_opmask_butone(0, SNO_GLINE, "G-line active for %s",
125 + get_client_name(acptr, SHOW_IP));
126 +
127 + /* and get rid of him */
128 + /* Asuka - Reimplement HEAD_IN_SAND_GLINE from Lain */
129 + if ((tval = exit_client_msg(cptr, acptr, &me,
130 + feature_bool(FEAT_HIS_GLINE) ? "G-lined" : "G-lined (%s)", gline->gl_reason)))
131 + retval = tval; /* retain killed status */
132 }
133 -
134 - /* ok, here's one that got G-lined */
135 - send_reply(acptr, SND_EXPLICIT | ERR_YOUREBANNEDCREEP, ":%s",
136 - gline->gl_reason);
137 -
138 - /* let the ops know about it */
139 - sendto_opmask_butone(0, SNO_GLINE, "G-line active for %s",
140 - get_client_name(acptr, SHOW_IP));
141 -
142 - /* and get rid of him */
143 - /* Asuka - Reimplement HEAD_IN_SAND_GLINE from Lain */
144 - if ((tval = exit_client_msg(cptr, acptr, &me,
145 - feature_bool(FEAT_HIS_GLINE) ? "G-lined" : "G-lined (%s)", gline->gl_reason)))
146 - retval = tval; /* retain killed status */
147 }
148 }
149 return retval;
150 @@ -972,6 +993,29 @@
151 return gline;
152 }
153
154 +struct Gline *
155 +gline_lookup_badchan(char *userhost, unsigned int flags)
156 +{
157 + struct Gline *gline;
158 + struct Gline *sgline;
159 +
160 + if (flags & (GLINE_BADCHAN | GLINE_ANY)) {
161 + gliter(BadChanGlineList, gline, sgline) {
162 + if ((flags & GLINE_GLOBAL && gline->gl_flags & GLINE_LOCAL) ||
163 + (flags & GLINE_LASTMOD && !gline->gl_lastmod))
164 + continue;
165 +
166 + if ((flags & GLINE_EXACT ? ircd_strcmp(gline->gl_user, userhost) :
167 + match(gline->gl_user, userhost)) == 0) {
168 + if (GlineIsActive(gline))
169 + return gline;
170 + }
171 + }
172 + }
173 +
174 + return 0;
175 +}
176 +
177 /** Find a matching G-line for a user.
178 * @param[in] cptr Client to compare against.
179 * @param[in] flags Bitwise combination of GLINE_GLOBAL and/or
180 @@ -1162,6 +1206,16 @@
181 GlineIsRemActive(gline) ? '+' : '-',
182 gline->gl_reason);
183 }
184 +
185 + gliter(BadChanGlineList, gline, sgline) {
186 + send_reply(sptr, RPL_STATSGLINE, 'G', gline->gl_user, "", "", "", "",
187 + gline->gl_expire + TSoffset, gline->gl_lastmod,
188 + gline->gl_lifetime + TSoffset,
189 + gline->gl_state == GLOCAL_ACTIVATED ? ">" :
190 + (gline->gl_state == GLOCAL_DEACTIVATED ? "<" : ""),
191 + GlineIsRemActive(gline) ? '+' : '-', gline->gl_reason);
192 + }
193 +
194 }
195
196 /** Calculate memory used by G-lines.
197 diff -r f49987f27c65 ircd/m_join.c
198 --- a/ircd/m_join.c Sun Jul 14 18:24:36 2013 +0100
199 +++ b/ircd/m_join.c Sun Jul 14 18:25:15 2013 +0100
200 @@ -150,9 +150,9 @@
201 }
202
203 /* BADCHANed channel */
204 - if ((gline = gline_find(name, GLINE_BADCHAN | GLINE_EXACT)) &&
205 - GlineIsActive(gline) && !IsAnOper(sptr)) {
206 - send_reply(sptr, ERR_BANNEDFROMCHAN, name);
207 + if (!IsAnOper(sptr)
208 + && (gline = gline_lookup_badchan(name, GLINE_BADCHAN))) {
209 + send_reply(sptr, ERR_BADCHANNAME, name, gline->gl_reason);
210 continue;
211 }
212
213 diff -r f49987f27c65 ircd/s_err.c
214 --- a/ircd/s_err.c Sun Jul 14 18:24:36 2013 +0100
215 +++ b/ircd/s_err.c Sun Jul 14 18:25:15 2013 +0100
216 @@ -990,7 +990,7 @@
217 /* 478 */
218 { ERR_BANLISTFULL, "%s %s :Channel ban/ignore list is full", "478" },
219 /* 479 */
220 - { ERR_BADCHANNAME, "%s :Cannot join channel (access denied on this server)", "479" },
221 + { ERR_BADCHANNAME, "%s :Cannot join channel (G-lined: %s)", "479" },
222 /* 480 */
223 { 0 },
224 /* 481 */