| 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); |
| 136 |
< |
|
| 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; |
| 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 |
|
|
| 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 |
|
|
| 325 |
|
handler = mptr->handlers[client_p->handler]; |
| 326 |
|
|
| 327 |
|
/* check right amount of params is passed... --is */ |
| 328 |
< |
if (i < mptr->parameters) |
| 328 |
> |
if (i < mptr->args_min) |
| 329 |
|
{ |
| 330 |
|
if (!IsServer(client_p)) |
| 331 |
|
{ |
| 337 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 338 |
|
"Dropping server %s due to (invalid) command '%s' " |
| 339 |
|
"with only %d arguments (expecting %d).", |
| 340 |
< |
client_p->name, mptr->cmd, i, mptr->parameters); |
| 341 |
< |
ilog(L_CRIT, "Insufficient parameters (%d) for command '%s' from %s.", |
| 340 |
> |
client_p->name, mptr->cmd, i, mptr->args_min); |
| 341 |
> |
ilog(LOG_TYPE_IRCD, "Insufficient parameters (%d) for command '%s' from %s.", |
| 342 |
|
i, mptr->cmd, client_p->name); |
| 343 |
|
exit_client(client_p, client_p, |
| 344 |
|
"Not enough arguments to server command."); |
| 348 |
|
(*handler)(client_p, from, i, hpara); |
| 349 |
|
} |
| 350 |
|
|
| 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 |
– |
|
| 351 |
|
/* add_msg_element() |
| 352 |
|
* |
| 353 |
|
* inputs - pointer to MessageTree |
| 387 |
|
* Thus 'A' -> 0x1 'B' -> 0x2 'c' -> 0x3 etc. |
| 388 |
|
*/ |
| 389 |
|
|
| 390 |
< |
if ((ntree_p = mtree_p->pointers[*cmd & (MAXPTRLEN-1)]) == NULL) |
| 390 |
> |
if ((ntree_p = mtree_p->pointers[*cmd & (MAXPTRLEN - 1)]) == NULL) |
| 391 |
|
{ |
| 392 |
< |
ntree_p = (struct MessageTree *)MyMalloc(sizeof(struct MessageTree)); |
| 393 |
< |
mtree_p->pointers[*cmd & (MAXPTRLEN-1)] = ntree_p; |
| 392 |
> |
ntree_p = MyMalloc(sizeof(struct MessageTree)); |
| 393 |
> |
mtree_p->pointers[*cmd & (MAXPTRLEN - 1)] = ntree_p; |
| 394 |
|
|
| 395 |
|
mtree_p->links++; /* Have new pointer, so up ref count */ |
| 396 |
|
} |
| 397 |
< |
add_msg_element(ntree_p, msg_p, cmd+1); |
| 397 |
> |
|
| 398 |
> |
add_msg_element(ntree_p, msg_p, cmd + 1); |
| 399 |
|
} |
| 400 |
|
} |
| 401 |
|
|
| 427 |
|
{ |
| 428 |
|
struct MessageTree *ntree_p; |
| 429 |
|
|
| 430 |
< |
/* In case this is called for a nonexistent command |
| 430 |
> |
/* |
| 431 |
> |
* In case this is called for a nonexistent command |
| 432 |
|
* check that there is a msg pointer here, else links-- goes -ve |
| 433 |
|
* -db |
| 434 |
|
*/ |
| 498 |
– |
|
| 435 |
|
if ((*cmd == '\0') && (mtree_p->msg != NULL)) |
| 436 |
|
{ |
| 437 |
|
mtree_p->msg = NULL; |
| 439 |
|
} |
| 440 |
|
else |
| 441 |
|
{ |
| 442 |
< |
if ((ntree_p = mtree_p->pointers[*cmd & (MAXPTRLEN-1)]) != NULL) |
| 442 |
> |
if ((ntree_p = mtree_p->pointers[*cmd & (MAXPTRLEN - 1)]) != NULL) |
| 443 |
|
{ |
| 444 |
< |
del_msg_element(ntree_p, cmd+1); |
| 444 |
> |
del_msg_element(ntree_p, cmd + 1); |
| 445 |
> |
|
| 446 |
|
if (ntree_p->links == 0) |
| 447 |
|
{ |
| 448 |
< |
mtree_p->pointers[*cmd & (MAXPTRLEN-1)] = NULL; |
| 448 |
> |
mtree_p->pointers[*cmd & (MAXPTRLEN - 1)] = NULL; |
| 449 |
|
mtree_p->links--; |
| 450 |
|
MyFree(ntree_p); |
| 451 |
|
} |
| 463 |
|
static struct Message * |
| 464 |
|
msg_tree_parse(const char *cmd, struct MessageTree *root) |
| 465 |
|
{ |
| 466 |
< |
struct MessageTree *mtree; |
| 466 |
> |
struct MessageTree *mtree = root; |
| 467 |
|
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 */ |
| 468 |
|
|
| 469 |
< |
} |
| 469 |
> |
while (IsAlpha(*cmd) && (mtree = mtree->pointers[*cmd & (MAXPTRLEN - 1)])) |
| 470 |
> |
if (*++cmd == '\0') |
| 471 |
> |
return mtree->msg; |
| 472 |
|
|
| 473 |
< |
return(NULL); |
| 473 |
> |
return NULL; |
| 474 |
|
} |
| 475 |
|
|
| 476 |
|
/* mod_add_cmd() |
| 484 |
|
void |
| 485 |
|
mod_add_cmd(struct Message *msg) |
| 486 |
|
{ |
| 487 |
< |
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); |
| 487 |
> |
assert(msg && msg->cmd); |
| 488 |
|
|
| 489 |
|
/* command already added? */ |
| 490 |
< |
if ((found_msg = msg_tree_parse(msg->cmd, &msg_tree)) != NULL) |
| 490 |
> |
if (msg_tree_parse(msg->cmd, &msg_tree)) |
| 491 |
|
return; |
| 492 |
|
|
| 493 |
|
add_msg_element(&msg_tree, msg, msg->cmd); |
| 503 |
|
void |
| 504 |
|
mod_del_cmd(struct Message *msg) |
| 505 |
|
{ |
| 506 |
< |
assert(msg != NULL); |
| 581 |
< |
|
| 582 |
< |
if (msg == NULL) |
| 583 |
< |
return; |
| 506 |
> |
assert(msg && msg->cmd); |
| 507 |
|
|
| 508 |
|
del_msg_element(&msg_tree, msg->cmd); |
| 509 |
|
} |
| 517 |
|
struct Message * |
| 518 |
|
find_command(const char *cmd) |
| 519 |
|
{ |
| 520 |
< |
return(msg_tree_parse(cmd, &msg_tree)); |
| 520 |
> |
return msg_tree_parse(cmd, &msg_tree); |
| 521 |
> |
} |
| 522 |
> |
|
| 523 |
> |
static void |
| 524 |
> |
recurse_report_messages(struct Client *source_p, const struct MessageTree *mtree) |
| 525 |
> |
{ |
| 526 |
> |
unsigned int i; |
| 527 |
> |
|
| 528 |
> |
if (mtree->msg != NULL) |
| 529 |
> |
sendto_one(source_p, form_str(RPL_STATSCOMMANDS), |
| 530 |
> |
me.name, source_p->name, mtree->msg->cmd, |
| 531 |
> |
mtree->msg->count, mtree->msg->bytes, |
| 532 |
> |
mtree->msg->rcount); |
| 533 |
> |
|
| 534 |
> |
for (i = 0; i < MAXPTRLEN; ++i) |
| 535 |
> |
if (mtree->pointers[i] != NULL) |
| 536 |
> |
recurse_report_messages(source_p, mtree->pointers[i]); |
| 537 |
|
} |
| 538 |
|
|
| 539 |
|
/* report_messages() |
| 545 |
|
void |
| 546 |
|
report_messages(struct Client *source_p) |
| 547 |
|
{ |
| 548 |
< |
struct MessageTree *mtree = &msg_tree; |
| 549 |
< |
int i; |
| 548 |
> |
const struct MessageTree *mtree = &msg_tree; |
| 549 |
> |
unsigned int i; |
| 550 |
|
|
| 551 |
< |
for (i = 0; i < MAXPTRLEN; i++) |
| 613 |
< |
{ |
| 551 |
> |
for (i = 0; i < MAXPTRLEN; ++i) |
| 552 |
|
if (mtree->pointers[i] != NULL) |
| 553 |
|
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 |
– |
} |
| 631 |
– |
|
| 632 |
– |
for (i = 0; i < MAXPTRLEN; i++) |
| 633 |
– |
{ |
| 634 |
– |
if (mtree->pointers[i] != NULL) |
| 635 |
– |
recurse_report_messages(source_p, mtree->pointers[i]); |
| 636 |
– |
} |
| 554 |
|
} |
| 555 |
|
|
| 556 |
|
/* cancel_clients() |
| 593 |
|
sendto_realops_flags(UMODE_DEBUG, L_ALL, |
| 594 |
|
"Not dropping server %s (%s) for Fake Direction", |
| 595 |
|
client_p->name, source_p->name); |
| 596 |
< |
return(-1); |
| 596 |
> |
return -1; |
| 597 |
|
/* return exit_client(client_p, client_p, &me, "Fake Direction");*/ |
| 598 |
|
} |
| 599 |
|
|
| 615 |
|
source_p->name, source_p->username, source_p->host, |
| 616 |
|
source_p->from->name, get_client_name(client_p, MASK_IP)); |
| 617 |
|
|
| 618 |
< |
return(0); |
| 618 |
> |
return 0; |
| 619 |
|
} |
| 620 |
|
|
| 621 |
|
/* remove_unknown() |
| 667 |
|
* a ping pong error message... |
| 668 |
|
*/ |
| 669 |
|
static void |
| 670 |
< |
do_numeric(char numeric[], struct Client *client_p, struct Client *source_p, |
| 671 |
< |
int parc, char *parv[]) |
| 670 |
> |
handle_numeric(char numeric[], struct Client *client_p, struct Client *source_p, |
| 671 |
> |
int parc, char *parv[]) |
| 672 |
|
{ |
| 673 |
|
struct Client *target_p; |
| 674 |
|
struct Channel *chptr; |
| 694 |
|
t += tl; |
| 695 |
|
} |
| 696 |
|
|
| 697 |
< |
ircsprintf(t," :%s", parv[parc-1]); |
| 697 |
> |
ircsprintf(t, " :%s", parv[parc-1]); |
| 698 |
|
|
| 699 |
|
if (((target_p = find_person(client_p, parv[1])) != NULL) || |
| 700 |
< |
((target_p = find_server(parv[1])) != NULL)) |
| 700 |
> |
((target_p = hash_find_server(parv[1])) != NULL)) |
| 701 |
|
{ |
| 702 |
|
if (IsMe(target_p)) |
| 703 |
|
{ |
| 747 |
|
|
| 748 |
|
/* Fake it for server hiding, if its our client */ |
| 749 |
|
if (ConfigServerHide.hide_servers && |
| 750 |
< |
MyClient(target_p) && !IsOper(target_p)) |
| 750 |
> |
MyClient(target_p) && !HasUMode(target_p, UMODE_OPER)) |
| 751 |
|
sendto_one(target_p, ":%s %s %s%s", me.name, numeric, target_p->name, buffer); |
| 752 |
< |
else if (!MyClient(target_p) && IsCapable(target_p->from, CAP_TS6) && HasID(source_p)) |
| 753 |
< |
sendto_one(target_p, ":%s %s %s%s", source_p->id, numeric, target_p->id, buffer); |
| 754 |
< |
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); |
| 752 |
> |
else |
| 753 |
> |
sendto_one(target_p, ":%s %s %s%s", ID_or_name(source_p, target_p->from), |
| 754 |
> |
numeric, ID_or_name(target_p, target_p->from), buffer); |
| 755 |
|
return; |
| 756 |
|
} |
| 757 |
|
else if ((chptr = hash_find_channel(parv[1])) != NULL) |
| 758 |
< |
sendto_channel_local(ALL_MEMBERS, NO, chptr, |
| 758 |
> |
sendto_channel_local(ALL_MEMBERS, 0, chptr, |
| 759 |
|
":%s %s %s %s", |
| 760 |
|
source_p->name, |
| 761 |
|
numeric, chptr->chname, buffer); |
| 771 |
|
int parc, char *parv[]) |
| 772 |
|
{ |
| 773 |
|
sendto_one(source_p, form_str(ERR_NOPRIVILEGES), |
| 774 |
< |
me.name, parv[0]); |
| 774 |
> |
me.name, source_p->name); |
| 775 |
|
} |
| 776 |
|
|
| 777 |
|
void |
| 778 |
|
m_unregistered(struct Client *client_p, struct Client *source_p, |
| 779 |
|
int parc, char *parv[]) |
| 780 |
|
{ |
| 781 |
< |
/* bit of a hack. |
| 782 |
< |
* 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 |
< |
} |
| 781 |
> |
sendto_one(source_p, form_str(ERR_NOTREGISTERED), me.name, |
| 782 |
> |
source_p->name[0] ? source_p->name : "*"); |
| 783 |
|
} |
| 784 |
|
|
| 785 |
|
void |
| 786 |
|
m_registered(struct Client *client_p, struct Client *source_p, |
| 787 |
|
int parc, char *parv[]) |
| 788 |
|
{ |
| 789 |
< |
sendto_one(client_p, form_str(ERR_ALREADYREGISTRED), |
| 790 |
< |
me.name, parv[0]); |
| 789 |
> |
sendto_one(source_p, form_str(ERR_ALREADYREGISTRED), |
| 790 |
> |
me.name, source_p->name); |
| 791 |
|
} |
| 792 |
|
|
| 793 |
|
void |
| 797 |
|
return; |
| 798 |
|
} |
| 799 |
|
|
| 800 |
+ |
void |
| 801 |
+ |
rfc1459_command_send_error(struct Client *client_p, struct Client *source_p, |
| 802 |
+ |
int parc, char *parv[]) |
| 803 |
+ |
{ |
| 804 |
+ |
const char *in_para; |
| 805 |
+ |
|
| 806 |
+ |
in_para = (parc > 1 && *parv[1] != '\0') ? parv[1] : "<>"; |
| 807 |
+ |
|
| 808 |
+ |
ilog(LOG_TYPE_IRCD, "Received ERROR message from %s: %s", |
| 809 |
+ |
source_p->name, in_para); |
| 810 |
+ |
|
| 811 |
+ |
if (client_p == source_p) |
| 812 |
+ |
{ |
| 813 |
+ |
sendto_realops_flags(UMODE_ALL, L_ADMIN, "ERROR :from %s -- %s", |
| 814 |
+ |
get_client_name(client_p, HIDE_IP), in_para); |
| 815 |
+ |
sendto_realops_flags(UMODE_ALL, L_OPER, "ERROR :from %s -- %s", |
| 816 |
+ |
get_client_name(client_p, MASK_IP), in_para); |
| 817 |
+ |
} |
| 818 |
+ |
else |
| 819 |
+ |
{ |
| 820 |
+ |
sendto_realops_flags(UMODE_ALL, L_OPER, "ERROR :from %s via %s -- %s", |
| 821 |
+ |
source_p->name, get_client_name(client_p, MASK_IP), in_para); |
| 822 |
+ |
sendto_realops_flags(UMODE_ALL, L_ADMIN, "ERROR :from %s via %s -- %s", |
| 823 |
+ |
source_p->name, get_client_name(client_p, HIDE_IP), in_para); |
| 824 |
+ |
} |
| 825 |
+ |
|
| 826 |
+ |
if (MyClient(source_p)) |
| 827 |
+ |
exit_client(source_p, source_p, "ERROR"); |
| 828 |
+ |
} |