23 |
|
*/ |
24 |
|
|
25 |
|
#include "stdinc.h" |
26 |
– |
#include "parse.h" |
26 |
|
#include "client.h" |
27 |
+ |
#include "parse.h" |
28 |
|
#include "channel.h" |
29 |
– |
#include "handlers.h" |
30 |
– |
#include "common.h" |
29 |
|
#include "hash.h" |
30 |
|
#include "irc_string.h" |
31 |
|
#include "sprintf_irc.h" |
32 |
|
#include "ircd.h" |
33 |
|
#include "numeric.h" |
34 |
< |
#include "s_log.h" |
37 |
< |
#include "s_stats.h" |
34 |
> |
#include "log.h" |
35 |
|
#include "send.h" |
36 |
< |
#include "ircd_handler.h" |
40 |
< |
#include "msg.h" |
41 |
< |
#include "s_conf.h" |
36 |
> |
#include "conf.h" |
37 |
|
#include "memory.h" |
38 |
|
#include "s_user.h" |
39 |
|
#include "s_serv.h" |
102 |
|
* NOTE: parse() should not be called recursively by other functions! |
103 |
|
*/ |
104 |
|
static char *sender; |
105 |
< |
static char *para[MAXPARA + 1]; |
105 |
> |
static char *para[MAXPARA + 2]; /* <prefix> + <params> + NULL */ |
106 |
|
static char buffer[1024]; |
107 |
|
|
108 |
|
static int cancel_clients(struct Client *, struct Client *, char *); |
109 |
|
static void remove_unknown(struct Client *, char *, char *); |
110 |
< |
static void do_numeric(char[], struct Client *, struct Client *, int, char **); |
111 |
< |
static void handle_command(struct Message *, struct Client *, struct Client *, unsigned int, char **); |
117 |
< |
static void recurse_report_messages(struct Client *source_p, struct MessageTree *mtree); |
118 |
< |
static void add_msg_element(struct MessageTree *mtree_p, struct Message *msg_p, const char *cmd); |
119 |
< |
static void del_msg_element(struct MessageTree *mtree_p, const char *cmd); |
120 |
< |
|
121 |
< |
/* turn a string into a parc/parv pair */ |
122 |
< |
static inline int |
123 |
< |
string_to_array(char *string, char *parv[MAXPARA]) |
124 |
< |
{ |
125 |
< |
char *p; |
126 |
< |
char *buf = string; |
127 |
< |
int x = 1; |
128 |
< |
|
129 |
< |
parv[x] = NULL; |
130 |
< |
|
131 |
< |
while (*buf == ' ') /* skip leading spaces */ |
132 |
< |
buf++; |
133 |
< |
|
134 |
< |
if (*buf == '\0') /* ignore all-space args */ |
135 |
< |
return(x); |
110 |
> |
static void handle_numeric(char[], struct Client *, struct Client *, int, char *[]); |
111 |
> |
static void handle_command(struct Message *, struct Client *, struct Client *, unsigned int, char *[]); |
112 |
|
|
137 |
– |
do |
138 |
– |
{ |
139 |
– |
if (*buf == ':') /* Last parameter */ |
140 |
– |
{ |
141 |
– |
buf++; |
142 |
– |
parv[x++] = buf; |
143 |
– |
parv[x] = NULL; |
144 |
– |
return(x); |
145 |
– |
} |
146 |
– |
else |
147 |
– |
{ |
148 |
– |
parv[x++] = buf; |
149 |
– |
parv[x] = NULL; |
150 |
– |
|
151 |
– |
if ((p = strchr(buf, ' ')) != NULL) |
152 |
– |
{ |
153 |
– |
*p++ = '\0'; |
154 |
– |
buf = p; |
155 |
– |
} |
156 |
– |
else |
157 |
– |
return(x); |
158 |
– |
} |
159 |
– |
|
160 |
– |
while (*buf == ' ') |
161 |
– |
buf++; |
162 |
– |
|
163 |
– |
if (*buf == '\0') |
164 |
– |
return(x); |
165 |
– |
} while (x < MAXPARA - 1); |
166 |
– |
|
167 |
– |
if (*p == ':') |
168 |
– |
p++; |
169 |
– |
|
170 |
– |
parv[x++] = p; |
171 |
– |
parv[x] = NULL; |
172 |
– |
return(x); |
173 |
– |
} |
113 |
|
|
114 |
|
/* |
115 |
|
* parse a buffer. |
120 |
|
parse(struct Client *client_p, char *pbuffer, char *bufend) |
121 |
|
{ |
122 |
|
struct Client *from = client_p; |
123 |
< |
char *ch; |
124 |
< |
char *s; |
125 |
< |
char *numeric = 0; |
126 |
< |
unsigned int i = 0; |
127 |
< |
int paramcount; |
128 |
< |
int mpara = 0; |
190 |
< |
struct Message *mptr = NULL; |
123 |
> |
struct Message *msg_ptr = NULL; |
124 |
> |
char *ch = NULL; |
125 |
> |
char *s = NULL; |
126 |
> |
char *numeric = NULL; |
127 |
> |
unsigned int parc = 0; |
128 |
> |
unsigned int paramcount; |
129 |
|
|
130 |
|
if (IsDefunct(client_p)) |
131 |
|
return; |
133 |
|
assert(client_p->localClient->fd.flags.open); |
134 |
|
assert((bufend - pbuffer) < 512); |
135 |
|
|
136 |
< |
for (ch = pbuffer; *ch == ' '; ch++) /* skip spaces */ |
136 |
> |
for (ch = pbuffer; *ch == ' '; ++ch) /* skip spaces */ |
137 |
|
/* null statement */ ; |
138 |
|
|
201 |
– |
para[0] = from->name; |
202 |
– |
|
139 |
|
if (*ch == ':') |
140 |
|
{ |
141 |
< |
ch++; |
142 |
< |
|
207 |
< |
/* Copy the prefix to 'sender' assuming it terminates |
141 |
> |
/* |
142 |
> |
* Copy the prefix to 'sender' assuming it terminates |
143 |
|
* with SPACE (or NULL, which is an error, though). |
144 |
|
*/ |
145 |
< |
sender = ch; |
145 |
> |
sender = ++ch; |
146 |
|
|
147 |
|
if ((s = strchr(ch, ' ')) != NULL) |
148 |
|
{ |
149 |
|
*s = '\0'; |
150 |
< |
s++; |
216 |
< |
ch = s; |
150 |
> |
ch = ++s; |
151 |
|
} |
152 |
|
|
153 |
|
if (*sender && IsServer(client_p)) |
154 |
|
{ |
221 |
– |
/* |
222 |
– |
* XXX it could be useful to know which of these occurs most frequently. |
223 |
– |
* the ID check should always come first, though, since it is so easy. |
224 |
– |
*/ |
155 |
|
if ((from = find_person(client_p, sender)) == NULL) |
156 |
< |
{ |
227 |
< |
from = find_server(sender); |
156 |
> |
from = hash_find_server(sender); |
157 |
|
|
229 |
– |
if (from == NULL && IsCapable(client_p, CAP_TS6) && |
230 |
– |
client_p->name[0] == '*' && IsDigit(*sender) && strlen(sender) == 3) |
231 |
– |
{ |
232 |
– |
/* Dirty hack to allow messages from masked SIDs (i.e. the ones |
233 |
– |
* hidden by fakename="..."). It shouldn't break anything, since |
234 |
– |
* unknown SIDs don't happen during normal ircd work --adx |
235 |
– |
*/ |
236 |
– |
from = client_p; |
237 |
– |
} |
238 |
– |
} |
239 |
– |
|
158 |
|
/* Hmm! If the client corresponding to the |
159 |
|
* prefix is not found--what is the correct |
160 |
|
* action??? Now, I will ignore the message |
163 |
|
*/ |
164 |
|
if (from == NULL) |
165 |
|
{ |
166 |
< |
ServerStats->is_unpf++; |
166 |
> |
++ServerStats.is_unpf; |
167 |
|
remove_unknown(client_p, sender, pbuffer); |
168 |
|
return; |
169 |
|
} |
170 |
|
|
253 |
– |
para[0] = from->name; |
254 |
– |
|
171 |
|
if (from->from != client_p) |
172 |
|
{ |
173 |
< |
ServerStats->is_wrdi++; |
173 |
> |
++ServerStats.is_wrdi; |
174 |
|
cancel_clients(client_p, from, pbuffer); |
175 |
|
return; |
176 |
|
} |
177 |
|
} |
178 |
|
|
179 |
|
while (*ch == ' ') |
180 |
< |
ch++; |
180 |
> |
++ch; |
181 |
|
} |
182 |
|
|
183 |
|
if (*ch == '\0') |
184 |
|
{ |
185 |
< |
ServerStats->is_empt++; |
185 |
> |
++ServerStats.is_empt; |
186 |
|
return; |
187 |
|
} |
188 |
|
|
197 |
|
if (*(ch + 3) == ' ' && /* ok, lets see if its a possible numeric.. */ |
198 |
|
IsDigit(*ch) && IsDigit(*(ch + 1)) && IsDigit(*(ch + 2))) |
199 |
|
{ |
284 |
– |
mptr = NULL; |
200 |
|
numeric = ch; |
201 |
|
paramcount = MAXPARA; |
202 |
< |
ServerStats->is_num++; |
202 |
> |
++ServerStats.is_num; |
203 |
|
s = ch + 3; /* I know this is ' ' from above if */ |
204 |
|
*s++ = '\0'; /* blow away the ' ', and point s to next part */ |
205 |
|
} |
206 |
|
else |
207 |
|
{ |
208 |
< |
int ii = 0; |
208 |
> |
unsigned int ii = 0; |
209 |
|
|
210 |
|
if ((s = strchr(ch, ' ')) != NULL) |
211 |
|
*s++ = '\0'; |
212 |
|
|
213 |
< |
if ((mptr = find_command(ch)) == NULL) |
213 |
> |
if ((msg_ptr = find_command(ch)) == NULL) |
214 |
|
{ |
215 |
|
/* Note: Give error message *only* to recognized |
216 |
|
* persons. It's a nightmare situation to have |
222 |
|
* Hm, when is the buffer empty -- if a command |
223 |
|
* code has been found ?? -Armin |
224 |
|
*/ |
225 |
< |
if (pbuffer[0] != '\0') |
225 |
> |
if (*pbuffer != '\0') |
226 |
|
{ |
227 |
|
if (IsClient(from)) |
228 |
|
sendto_one(from, form_str(ERR_UNKNOWNCOMMAND), |
229 |
|
me.name, from->name, ch); |
230 |
|
} |
231 |
|
|
232 |
< |
ServerStats->is_unco++; |
232 |
> |
++ServerStats.is_unco; |
233 |
|
return; |
234 |
|
} |
235 |
|
|
236 |
< |
assert(mptr->cmd != NULL); |
322 |
< |
|
323 |
< |
paramcount = mptr->parameters; |
324 |
< |
mpara = mptr->maxpara; |
236 |
> |
assert(msg_ptr->cmd != NULL); |
237 |
|
|
238 |
+ |
paramcount = msg_ptr->args_max; |
239 |
|
ii = bufend - ((s) ? s : ch); |
240 |
< |
mptr->bytes += ii; |
240 |
> |
msg_ptr->bytes += ii; |
241 |
|
} |
242 |
|
|
243 |
< |
if (s != NULL) |
244 |
< |
i = string_to_array(s, para); |
245 |
< |
else |
243 |
> |
/* |
244 |
> |
* Must the following loop really be so devious? On surface it |
245 |
> |
* splits the message to parameters from blank spaces. But, if |
246 |
> |
* paramcount has been reached, the rest of the message goes into |
247 |
> |
* this last parameter (about same effect as ":" has...) --msa |
248 |
> |
*/ |
249 |
> |
|
250 |
> |
/* Note initially true: s==NULL || *(s-1) == '\0' !! */ |
251 |
> |
|
252 |
> |
para[parc] = from->name; |
253 |
> |
|
254 |
> |
if (s) |
255 |
|
{ |
256 |
< |
i = 0; |
257 |
< |
para[1] = NULL; |
256 |
> |
if (paramcount > MAXPARA) |
257 |
> |
paramcount = MAXPARA; |
258 |
> |
|
259 |
> |
while (1) |
260 |
> |
{ |
261 |
> |
while (*s == ' ') |
262 |
> |
*s++ = '\0'; |
263 |
> |
|
264 |
> |
if (*s == '\0') |
265 |
> |
break; |
266 |
> |
|
267 |
> |
if (*s == ':') |
268 |
> |
{ |
269 |
> |
/* The rest is a single parameter */ |
270 |
> |
para[++parc] = s + 1; |
271 |
> |
break; |
272 |
> |
} |
273 |
> |
|
274 |
> |
para[++parc] = s; |
275 |
> |
|
276 |
> |
if (parc >= paramcount) |
277 |
> |
break; |
278 |
> |
|
279 |
> |
while (*s && *s != ' ') |
280 |
> |
++s; |
281 |
> |
} |
282 |
|
} |
283 |
|
|
284 |
< |
if (mptr == NULL) |
285 |
< |
do_numeric(numeric, client_p, from, i, para); |
284 |
> |
para[++parc] = NULL; |
285 |
> |
|
286 |
> |
if (msg_ptr != NULL) |
287 |
> |
handle_command(msg_ptr, client_p, from, parc, para); |
288 |
|
else |
289 |
< |
handle_command(mptr, client_p, from, i, para); |
289 |
> |
handle_numeric(numeric, client_p, from, parc, para); |
290 |
|
} |
291 |
|
|
292 |
|
/* handle_command() |
301 |
|
*/ |
302 |
|
static void |
303 |
|
handle_command(struct Message *mptr, struct Client *client_p, |
304 |
< |
struct Client *from, unsigned int i, char *hpara[MAXPARA]) |
304 |
> |
struct Client *from, unsigned int i, char *hpara[]) |
305 |
|
{ |
306 |
|
MessageHandler handler = 0; |
307 |
|
|
310 |
|
|
311 |
|
mptr->count++; |
312 |
|
|
365 |
– |
/* New patch to avoid server flooding from unregistered connects |
366 |
– |
* - Pie-Man 07/27/2000 */ |
367 |
– |
if (!IsRegistered(client_p)) |
368 |
– |
{ |
369 |
– |
/* if its from a possible server connection |
370 |
– |
* ignore it.. more than likely its a header thats sneaked through |
371 |
– |
*/ |
372 |
– |
if ((IsHandshake(client_p) || IsConnecting(client_p) || |
373 |
– |
IsServer(client_p)) && !(mptr->flags & MFLG_UNREG)) |
374 |
– |
return; |
375 |
– |
} |
376 |
– |
|
313 |
|
handler = mptr->handlers[client_p->handler]; |
314 |
|
|
315 |
|
/* check right amount of params is passed... --is */ |
316 |
< |
if (i < mptr->parameters) |
316 |
> |
if (i < mptr->args_min) |
317 |
|
{ |
318 |
|
if (!IsServer(client_p)) |
319 |
|
{ |
325 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, |
326 |
|
"Dropping server %s due to (invalid) command '%s' " |
327 |
|
"with only %d arguments (expecting %d).", |
328 |
< |
client_p->name, mptr->cmd, i, mptr->parameters); |
329 |
< |
ilog(L_CRIT, "Insufficient parameters (%d) for command '%s' from %s.", |
328 |
> |
client_p->name, mptr->cmd, i, mptr->args_min); |
329 |
> |
ilog(LOG_TYPE_IRCD, "Insufficient parameters (%d) for command '%s' from %s.", |
330 |
|
i, mptr->cmd, client_p->name); |
331 |
|
exit_client(client_p, client_p, |
332 |
|
"Not enough arguments to server command."); |
336 |
|
(*handler)(client_p, from, i, hpara); |
337 |
|
} |
338 |
|
|
403 |
– |
/* clear_tree_parse() |
404 |
– |
* |
405 |
– |
* inputs - NONE |
406 |
– |
* output - NONE |
407 |
– |
* side effects - MUST MUST be called at startup ONCE before |
408 |
– |
* any other keyword routine is used. |
409 |
– |
*/ |
410 |
– |
void |
411 |
– |
clear_tree_parse(void) |
412 |
– |
{ |
413 |
– |
memset(&msg_tree, 0, sizeof(msg_tree)); |
414 |
– |
} |
415 |
– |
|
339 |
|
/* add_msg_element() |
340 |
|
* |
341 |
|
* inputs - pointer to MessageTree |
375 |
|
* Thus 'A' -> 0x1 'B' -> 0x2 'c' -> 0x3 etc. |
376 |
|
*/ |
377 |
|
|
378 |
< |
if ((ntree_p = mtree_p->pointers[*cmd & (MAXPTRLEN-1)]) == NULL) |
378 |
> |
if ((ntree_p = mtree_p->pointers[*cmd & (MAXPTRLEN - 1)]) == NULL) |
379 |
|
{ |
380 |
< |
ntree_p = (struct MessageTree *)MyMalloc(sizeof(struct MessageTree)); |
381 |
< |
mtree_p->pointers[*cmd & (MAXPTRLEN-1)] = ntree_p; |
380 |
> |
ntree_p = MyMalloc(sizeof(struct MessageTree)); |
381 |
> |
mtree_p->pointers[*cmd & (MAXPTRLEN - 1)] = ntree_p; |
382 |
|
|
383 |
|
mtree_p->links++; /* Have new pointer, so up ref count */ |
384 |
|
} |
385 |
< |
add_msg_element(ntree_p, msg_p, cmd+1); |
385 |
> |
|
386 |
> |
add_msg_element(ntree_p, msg_p, cmd + 1); |
387 |
|
} |
388 |
|
} |
389 |
|
|
415 |
|
{ |
416 |
|
struct MessageTree *ntree_p; |
417 |
|
|
418 |
< |
/* In case this is called for a nonexistent command |
418 |
> |
/* |
419 |
> |
* In case this is called for a nonexistent command |
420 |
|
* check that there is a msg pointer here, else links-- goes -ve |
421 |
|
* -db |
422 |
|
*/ |
498 |
– |
|
423 |
|
if ((*cmd == '\0') && (mtree_p->msg != NULL)) |
424 |
|
{ |
425 |
|
mtree_p->msg = NULL; |
427 |
|
} |
428 |
|
else |
429 |
|
{ |
430 |
< |
if ((ntree_p = mtree_p->pointers[*cmd & (MAXPTRLEN-1)]) != NULL) |
430 |
> |
if ((ntree_p = mtree_p->pointers[*cmd & (MAXPTRLEN - 1)]) != NULL) |
431 |
|
{ |
432 |
< |
del_msg_element(ntree_p, cmd+1); |
432 |
> |
del_msg_element(ntree_p, cmd + 1); |
433 |
> |
|
434 |
|
if (ntree_p->links == 0) |
435 |
|
{ |
436 |
< |
mtree_p->pointers[*cmd & (MAXPTRLEN-1)] = NULL; |
436 |
> |
mtree_p->pointers[*cmd & (MAXPTRLEN - 1)] = NULL; |
437 |
|
mtree_p->links--; |
438 |
|
MyFree(ntree_p); |
439 |
|
} |
449 |
|
* side effects - none |
450 |
|
*/ |
451 |
|
static struct Message * |
452 |
< |
msg_tree_parse(const char *cmd, struct MessageTree *root) |
452 |
> |
msg_tree_parse(const char *cmd) |
453 |
|
{ |
454 |
< |
struct MessageTree *mtree; |
454 |
> |
struct MessageTree *mtree = &msg_tree; |
455 |
|
assert(cmd && *cmd); |
531 |
– |
for (mtree = root->pointers[(*cmd) & (MAXPTRLEN-1)]; mtree != NULL; |
532 |
– |
mtree = mtree->pointers[(*++cmd) & (MAXPTRLEN-1)]) |
533 |
– |
{ |
534 |
– |
if (!IsAlpha(*cmd)) |
535 |
– |
return(NULL); |
536 |
– |
if (*(cmd + 1) == '\0') |
537 |
– |
return(mtree->msg); /* NULL if parsed invalid/unknown command */ |
456 |
|
|
457 |
< |
} |
457 |
> |
while (IsAlpha(*cmd) && (mtree = mtree->pointers[*cmd & (MAXPTRLEN - 1)])) |
458 |
> |
if (*++cmd == '\0') |
459 |
> |
return mtree->msg; |
460 |
|
|
461 |
< |
return(NULL); |
461 |
> |
return NULL; |
462 |
|
} |
463 |
|
|
464 |
|
/* mod_add_cmd() |
472 |
|
void |
473 |
|
mod_add_cmd(struct Message *msg) |
474 |
|
{ |
475 |
< |
struct Message *found_msg; |
556 |
< |
|
557 |
< |
if (msg == NULL) |
558 |
< |
return; |
559 |
< |
|
560 |
< |
/* someone loaded a module with a bad messagetab */ |
561 |
< |
assert(msg->cmd != NULL); |
475 |
> |
assert(msg && msg->cmd); |
476 |
|
|
477 |
|
/* command already added? */ |
478 |
< |
if ((found_msg = msg_tree_parse(msg->cmd, &msg_tree)) != NULL) |
478 |
> |
if (msg_tree_parse(msg->cmd)) |
479 |
|
return; |
480 |
|
|
481 |
|
add_msg_element(&msg_tree, msg, msg->cmd); |
491 |
|
void |
492 |
|
mod_del_cmd(struct Message *msg) |
493 |
|
{ |
494 |
< |
assert(msg != NULL); |
581 |
< |
|
582 |
< |
if (msg == NULL) |
583 |
< |
return; |
494 |
> |
assert(msg && msg->cmd); |
495 |
|
|
496 |
|
del_msg_element(&msg_tree, msg->cmd); |
497 |
|
} |
505 |
|
struct Message * |
506 |
|
find_command(const char *cmd) |
507 |
|
{ |
508 |
< |
return(msg_tree_parse(cmd, &msg_tree)); |
508 |
> |
return msg_tree_parse(cmd); |
509 |
> |
} |
510 |
> |
|
511 |
> |
static void |
512 |
> |
recurse_report_messages(struct Client *source_p, const struct MessageTree *mtree) |
513 |
> |
{ |
514 |
> |
unsigned int i; |
515 |
> |
|
516 |
> |
if (mtree->msg != NULL) |
517 |
> |
sendto_one(source_p, form_str(RPL_STATSCOMMANDS), |
518 |
> |
me.name, source_p->name, mtree->msg->cmd, |
519 |
> |
mtree->msg->count, mtree->msg->bytes, |
520 |
> |
mtree->msg->rcount); |
521 |
> |
|
522 |
> |
for (i = 0; i < MAXPTRLEN; ++i) |
523 |
> |
if (mtree->pointers[i] != NULL) |
524 |
> |
recurse_report_messages(source_p, mtree->pointers[i]); |
525 |
|
} |
526 |
|
|
527 |
|
/* report_messages() |
533 |
|
void |
534 |
|
report_messages(struct Client *source_p) |
535 |
|
{ |
536 |
< |
struct MessageTree *mtree = &msg_tree; |
537 |
< |
int i; |
611 |
< |
|
612 |
< |
for (i = 0; i < MAXPTRLEN; i++) |
613 |
< |
{ |
614 |
< |
if (mtree->pointers[i] != NULL) |
615 |
< |
recurse_report_messages(source_p, mtree->pointers[i]); |
616 |
< |
} |
617 |
< |
} |
618 |
< |
|
619 |
< |
static void |
620 |
< |
recurse_report_messages(struct Client *source_p, struct MessageTree *mtree) |
621 |
< |
{ |
622 |
< |
int i; |
623 |
< |
|
624 |
< |
if (mtree->msg != NULL) |
625 |
< |
{ |
626 |
< |
sendto_one(source_p, form_str(RPL_STATSCOMMANDS), |
627 |
< |
me.name, source_p->name, mtree->msg->cmd, |
628 |
< |
mtree->msg->count, mtree->msg->bytes, |
629 |
< |
mtree->msg->rcount); |
630 |
< |
} |
536 |
> |
const struct MessageTree *mtree = &msg_tree; |
537 |
> |
unsigned int i; |
538 |
|
|
539 |
< |
for (i = 0; i < MAXPTRLEN; i++) |
633 |
< |
{ |
539 |
> |
for (i = 0; i < MAXPTRLEN; ++i) |
540 |
|
if (mtree->pointers[i] != NULL) |
541 |
|
recurse_report_messages(source_p, mtree->pointers[i]); |
636 |
– |
} |
542 |
|
} |
543 |
|
|
544 |
|
/* cancel_clients() |
581 |
|
sendto_realops_flags(UMODE_DEBUG, L_ALL, |
582 |
|
"Not dropping server %s (%s) for Fake Direction", |
583 |
|
client_p->name, source_p->name); |
584 |
< |
return(-1); |
584 |
> |
return -1; |
585 |
|
/* return exit_client(client_p, client_p, &me, "Fake Direction");*/ |
586 |
|
} |
587 |
|
|
603 |
|
source_p->name, source_p->username, source_p->host, |
604 |
|
source_p->from->name, get_client_name(client_p, MASK_IP)); |
605 |
|
|
606 |
< |
return(0); |
606 |
> |
return 0; |
607 |
|
} |
608 |
|
|
609 |
|
/* remove_unknown() |
655 |
|
* a ping pong error message... |
656 |
|
*/ |
657 |
|
static void |
658 |
< |
do_numeric(char numeric[], struct Client *client_p, struct Client *source_p, |
659 |
< |
int parc, char *parv[]) |
658 |
> |
handle_numeric(char numeric[], struct Client *client_p, struct Client *source_p, |
659 |
> |
int parc, char *parv[]) |
660 |
|
{ |
661 |
|
struct Client *target_p; |
662 |
|
struct Channel *chptr; |
682 |
|
t += tl; |
683 |
|
} |
684 |
|
|
685 |
< |
ircsprintf(t," :%s", parv[parc-1]); |
685 |
> |
ircsprintf(t, " :%s", parv[parc-1]); |
686 |
|
|
687 |
|
if (((target_p = find_person(client_p, parv[1])) != NULL) || |
688 |
< |
((target_p = find_server(parv[1])) != NULL)) |
688 |
> |
((target_p = hash_find_server(parv[1])) != NULL)) |
689 |
|
{ |
690 |
|
if (IsMe(target_p)) |
691 |
|
{ |
735 |
|
|
736 |
|
/* Fake it for server hiding, if its our client */ |
737 |
|
if (ConfigServerHide.hide_servers && |
738 |
< |
MyClient(target_p) && !IsOper(target_p)) |
738 |
> |
MyClient(target_p) && !HasUMode(target_p, UMODE_OPER)) |
739 |
|
sendto_one(target_p, ":%s %s %s%s", me.name, numeric, target_p->name, buffer); |
740 |
< |
else if (!MyClient(target_p) && IsCapable(target_p->from, CAP_TS6) && HasID(source_p)) |
741 |
< |
sendto_one(target_p, ":%s %s %s%s", source_p->id, numeric, target_p->id, buffer); |
742 |
< |
else /* either it is our client, or a client linked throuh a non-ts6 server. must use names! */ |
838 |
< |
sendto_one(target_p, ":%s %s %s%s", source_p->name, numeric, target_p->name, buffer); |
740 |
> |
else |
741 |
> |
sendto_one(target_p, ":%s %s %s%s", ID_or_name(source_p, target_p->from), |
742 |
> |
numeric, ID_or_name(target_p, target_p->from), buffer); |
743 |
|
return; |
744 |
|
} |
745 |
|
else if ((chptr = hash_find_channel(parv[1])) != NULL) |
746 |
< |
sendto_channel_local(ALL_MEMBERS, NO, chptr, |
746 |
> |
sendto_channel_local(ALL_MEMBERS, 0, chptr, |
747 |
|
":%s %s %s %s", |
748 |
|
source_p->name, |
749 |
|
numeric, chptr->chname, buffer); |
759 |
|
int parc, char *parv[]) |
760 |
|
{ |
761 |
|
sendto_one(source_p, form_str(ERR_NOPRIVILEGES), |
762 |
< |
me.name, parv[0]); |
762 |
> |
me.name, source_p->name); |
763 |
|
} |
764 |
|
|
765 |
|
void |
766 |
|
m_unregistered(struct Client *client_p, struct Client *source_p, |
767 |
|
int parc, char *parv[]) |
768 |
|
{ |
769 |
< |
/* bit of a hack. |
770 |
< |
* I don't =really= want to waste a bit in a flag |
867 |
< |
* number_of_nick_changes is only really valid after the client |
868 |
< |
* is fully registered.. |
869 |
< |
*/ |
870 |
< |
if (client_p->localClient->number_of_nick_changes == 0) |
871 |
< |
{ |
872 |
< |
sendto_one(client_p, ":%s %d * %s :Register first.", |
873 |
< |
me.name, ERR_NOTREGISTERED, parv[0]); |
874 |
< |
client_p->localClient->number_of_nick_changes++; |
875 |
< |
} |
769 |
> |
sendto_one(source_p, form_str(ERR_NOTREGISTERED), me.name, |
770 |
> |
source_p->name[0] ? source_p->name : "*"); |
771 |
|
} |
772 |
|
|
773 |
|
void |
774 |
|
m_registered(struct Client *client_p, struct Client *source_p, |
775 |
|
int parc, char *parv[]) |
776 |
|
{ |
777 |
< |
sendto_one(client_p, form_str(ERR_ALREADYREGISTRED), |
778 |
< |
me.name, parv[0]); |
777 |
> |
sendto_one(source_p, form_str(ERR_ALREADYREGISTRED), |
778 |
> |
me.name, source_p->name); |
779 |
|
} |
780 |
|
|
781 |
|
void |
785 |
|
return; |
786 |
|
} |
787 |
|
|
788 |
+ |
void |
789 |
+ |
rfc1459_command_send_error(struct Client *client_p, struct Client *source_p, |
790 |
+ |
int parc, char *parv[]) |
791 |
+ |
{ |
792 |
+ |
const char *in_para; |
793 |
+ |
|
794 |
+ |
in_para = (parc > 1 && *parv[1] != '\0') ? parv[1] : "<>"; |
795 |
+ |
|
796 |
+ |
ilog(LOG_TYPE_IRCD, "Received ERROR message from %s: %s", |
797 |
+ |
source_p->name, in_para); |
798 |
+ |
|
799 |
+ |
if (client_p == source_p) |
800 |
+ |
{ |
801 |
+ |
sendto_realops_flags(UMODE_ALL, L_ADMIN, "ERROR :from %s -- %s", |
802 |
+ |
get_client_name(client_p, HIDE_IP), in_para); |
803 |
+ |
sendto_realops_flags(UMODE_ALL, L_OPER, "ERROR :from %s -- %s", |
804 |
+ |
get_client_name(client_p, MASK_IP), in_para); |
805 |
+ |
} |
806 |
+ |
else |
807 |
+ |
{ |
808 |
+ |
sendto_realops_flags(UMODE_ALL, L_OPER, "ERROR :from %s via %s -- %s", |
809 |
+ |
source_p->name, get_client_name(client_p, MASK_IP), in_para); |
810 |
+ |
sendto_realops_flags(UMODE_ALL, L_ADMIN, "ERROR :from %s via %s -- %s", |
811 |
+ |
source_p->name, get_client_name(client_p, HIDE_IP), in_para); |
812 |
+ |
} |
813 |
+ |
|
814 |
+ |
if (MyClient(source_p)) |
815 |
+ |
exit_client(source_p, source_p, "ERROR"); |
816 |
+ |
} |