| 28 |
|
#include "channel.h" |
| 29 |
|
#include "hash.h" |
| 30 |
|
#include "irc_string.h" |
| 31 |
– |
#include "sprintf_irc.h" |
| 31 |
|
#include "ircd.h" |
| 32 |
|
#include "numeric.h" |
| 33 |
|
#include "log.h" |
| 102 |
|
*/ |
| 103 |
|
static char *sender; |
| 104 |
|
static char *para[MAXPARA + 2]; /* <prefix> + <params> + NULL */ |
| 106 |
– |
static char buffer[1024]; |
| 105 |
|
|
| 106 |
|
static int cancel_clients(struct Client *, struct Client *, char *); |
| 107 |
|
static void remove_unknown(struct Client *, char *, char *); |
| 196 |
|
IsDigit(*ch) && IsDigit(*(ch + 1)) && IsDigit(*(ch + 2))) |
| 197 |
|
{ |
| 198 |
|
numeric = ch; |
| 199 |
< |
paramcount = MAXPARA; |
| 199 |
> |
paramcount = 2; /* destination, and the rest of it */ |
| 200 |
|
++ServerStats.is_num; |
| 201 |
|
s = ch + 3; /* I know this is ' ' from above if */ |
| 202 |
|
*s++ = '\0'; /* blow away the ' ', and point s to next part */ |
| 265 |
|
if (*s == ':') |
| 266 |
|
{ |
| 267 |
|
/* The rest is a single parameter */ |
| 268 |
< |
para[++parc] = s + 1; |
| 268 |
> |
para[++parc] = s + (!numeric); /* keep the colon if it's a numeric */ |
| 269 |
|
break; |
| 270 |
|
} |
| 271 |
|
|
| 320 |
|
} |
| 321 |
|
else |
| 322 |
|
{ |
| 323 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 323 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
| 324 |
|
"Dropping server %s due to (invalid) command '%s' " |
| 325 |
|
"with only %d arguments (expecting %d).", |
| 326 |
|
client_p->name, mptr->cmd, i, mptr->args_min); |
| 570 |
|
*/ |
| 571 |
|
if (IsServer(source_p) || IsMe(source_p)) |
| 572 |
|
{ |
| 573 |
< |
sendto_realops_flags(UMODE_DEBUG, L_ADMIN, "Message for %s[%s] from %s", |
| 573 |
> |
sendto_realops_flags(UMODE_DEBUG, L_ADMIN, SEND_NOTICE, |
| 574 |
> |
"Message for %s[%s] from %s", |
| 575 |
|
source_p->name, source_p->from->name, |
| 576 |
|
get_client_name(client_p, SHOW_IP)); |
| 577 |
< |
sendto_realops_flags(UMODE_DEBUG, L_OPER, "Message for %s[%s] from %s", |
| 577 |
> |
sendto_realops_flags(UMODE_DEBUG, L_OPER, SEND_NOTICE, |
| 578 |
> |
"Message for %s[%s] from %s", |
| 579 |
|
source_p->name, source_p->from->name, |
| 580 |
|
get_client_name(client_p, MASK_IP)); |
| 581 |
< |
sendto_realops_flags(UMODE_DEBUG, L_ALL, |
| 581 |
> |
sendto_realops_flags(UMODE_DEBUG, L_ALL, SEND_NOTICE, |
| 582 |
|
"Not dropping server %s (%s) for Fake Direction", |
| 583 |
|
client_p->name, source_p->name); |
| 584 |
|
return -1; |
| 594 |
|
* |
| 595 |
|
* all servers must be TS these days --is |
| 596 |
|
*/ |
| 597 |
< |
sendto_realops_flags(UMODE_DEBUG, L_ADMIN, |
| 597 |
> |
sendto_realops_flags(UMODE_DEBUG, L_ADMIN, SEND_NOTICE, |
| 598 |
|
"Message for %s[%s@%s!%s] from %s (TS, ignored)", |
| 599 |
|
source_p->name, source_p->username, source_p->host, |
| 600 |
|
source_p->from->name, get_client_name(client_p, SHOW_IP)); |
| 601 |
< |
sendto_realops_flags(UMODE_DEBUG, L_OPER, |
| 601 |
> |
sendto_realops_flags(UMODE_DEBUG, L_OPER, SEND_NOTICE, |
| 602 |
|
"Message for %s[%s@%s!%s] from %s (TS, ignored)", |
| 603 |
|
source_p->name, source_p->username, source_p->host, |
| 604 |
|
source_p->from->name, get_client_name(client_p, MASK_IP)); |
| 626 |
|
if ((IsDigit(*lsender) && strlen(lsender) <= IRC_MAXSID) || |
| 627 |
|
strchr(lsender, '.') != NULL) |
| 628 |
|
{ |
| 629 |
< |
sendto_realops_flags(UMODE_DEBUG, L_ADMIN, |
| 629 |
> |
sendto_realops_flags(UMODE_DEBUG, L_ADMIN, SEND_NOTICE, |
| 630 |
|
"Unknown prefix (%s) from %s, Squitting %s", |
| 631 |
|
lbuffer, get_client_name(client_p, SHOW_IP), lsender); |
| 632 |
< |
sendto_realops_flags(UMODE_DEBUG, L_OPER, |
| 632 |
> |
sendto_realops_flags(UMODE_DEBUG, L_OPER, SEND_NOTICE, |
| 633 |
|
"Unknown prefix (%s) from %s, Squitting %s", |
| 634 |
|
lbuffer, client_p->name, lsender); |
| 635 |
|
sendto_one(client_p, ":%s SQUIT %s :(Unknown prefix (%s) from %s)", |
| 653 |
|
* wrong with the message, just *DROP* it! Don't even think of |
| 654 |
|
* sending back a neat error message -- big danger of creating |
| 655 |
|
* a ping pong error message... |
| 656 |
+ |
* |
| 657 |
+ |
* Rewritten by Nemesi, Jan 1999, to support numeric nicks in parv[1] |
| 658 |
+ |
* |
| 659 |
+ |
* Called when we get a numeric message from a remote _server_ and we are |
| 660 |
+ |
* supposed to forward it somewhere. Note that we always ignore numerics sent |
| 661 |
+ |
* to 'me' and simply drop the message if we can't handle with this properly: |
| 662 |
+ |
* the savvy approach is NEVER generate an error in response to an... error :) |
| 663 |
|
*/ |
| 664 |
|
static void |
| 665 |
|
handle_numeric(char numeric[], struct Client *client_p, struct Client *source_p, |
| 666 |
|
int parc, char *parv[]) |
| 667 |
|
{ |
| 668 |
< |
struct Client *target_p; |
| 669 |
< |
struct Channel *chptr; |
| 663 |
< |
char *t; /* current position within the buffer */ |
| 664 |
< |
int i, tl; /* current length of presently being built string in t */ |
| 668 |
> |
struct Client *target_p = NULL; |
| 669 |
> |
struct Channel *chptr = NULL; |
| 670 |
|
|
| 671 |
+ |
/* Avoid trash, we need it to come from a server and have a target */ |
| 672 |
|
if (parc < 2 || !IsServer(source_p)) |
| 673 |
|
return; |
| 674 |
|
|
| 675 |
< |
/* Remap low number numerics. */ |
| 676 |
< |
if (numeric[0] == '0') |
| 677 |
< |
numeric[0] = '1'; |
| 678 |
< |
|
| 679 |
< |
/* Prepare the parameter portion of the message into 'buffer'. |
| 680 |
< |
* (Because the buffer is twice as large as the message buffer |
| 675 |
< |
* for the socket, no overflow can occur here... ...on current |
| 676 |
< |
* assumptions--bets are off, if these are changed --msa) |
| 675 |
> |
/* |
| 676 |
> |
* Who should receive this message ? Will we do something with it ? |
| 677 |
> |
* Note that we use findUser functions, so the target can't be neither |
| 678 |
> |
* a server, nor a channel (?) nor a list of targets (?) .. u2.10 |
| 679 |
> |
* should never generate numeric replies to non-users anyway |
| 680 |
> |
* Ahem... it can be a channel actually, csc bots use it :\ --Nem |
| 681 |
|
*/ |
| 682 |
< |
t = buffer; |
| 683 |
< |
for (i = 2; i < (parc - 1); i++) |
| 684 |
< |
{ |
| 685 |
< |
tl = ircsprintf(t, " %s", parv[i]); |
| 682 |
< |
t += tl; |
| 683 |
< |
} |
| 684 |
< |
|
| 685 |
< |
ircsprintf(t, " :%s", parv[parc-1]); |
| 686 |
< |
|
| 687 |
< |
if (((target_p = find_person(client_p, parv[1])) != NULL) || |
| 688 |
< |
((target_p = hash_find_server(parv[1])) != NULL)) |
| 689 |
< |
{ |
| 690 |
< |
if (IsMe(target_p)) |
| 691 |
< |
{ |
| 692 |
< |
int num; |
| 693 |
< |
|
| 694 |
< |
/* |
| 695 |
< |
* We shouldn't get numerics sent to us, |
| 696 |
< |
* any numerics we do get indicate a bug somewhere.. |
| 697 |
< |
*/ |
| 698 |
< |
/* ugh. this is here because of nick collisions. when two servers |
| 699 |
< |
* relink, they burst each other their nicks, then perform collides. |
| 700 |
< |
* if there is a nick collision, BOTH servers will kill their own |
| 701 |
< |
* nicks, and BOTH will kill the other servers nick, which wont exist, |
| 702 |
< |
* because it will have been already killed by the local server. |
| 703 |
< |
* |
| 704 |
< |
* unfortunately, as we cant guarantee other servers will do the |
| 705 |
< |
* "right thing" on a nick collision, we have to keep both kills. |
| 706 |
< |
* ergo we need to ignore ERR_NOSUCHNICK. --fl_ |
| 707 |
< |
*/ |
| 708 |
< |
/* quick comment. This _was_ tried. i.e. assume the other servers |
| 709 |
< |
* will do the "right thing" and kill a nick that is colliding. |
| 710 |
< |
* unfortunately, it did not work. --Dianora |
| 711 |
< |
*/ |
| 682 |
> |
if (IsChanPrefix(*parv[1])) |
| 683 |
> |
chptr = hash_find_channel(parv[1]); |
| 684 |
> |
else |
| 685 |
> |
target_p = find_person(client_p, parv[1]); |
| 686 |
|
|
| 687 |
< |
/* Yes, a good compiler would have optimised this, but |
| 688 |
< |
* this is probably easier to read. -db |
| 715 |
< |
*/ |
| 716 |
< |
num = atoi(numeric); |
| 687 |
> |
if (((!target_p) || (target_p->from == client_p)) && !chptr) |
| 688 |
> |
return; |
| 689 |
|
|
| 690 |
< |
if ((num != ERR_NOSUCHNICK)) |
| 691 |
< |
sendto_realops_flags(UMODE_ALL, L_ADMIN, |
| 692 |
< |
"*** %s(via %s) sent a %s numeric to me: %s", |
| 693 |
< |
source_p->name, client_p->name, numeric, buffer); |
| 694 |
< |
return; |
| 695 |
< |
} |
| 696 |
< |
else if (target_p->from == client_p) |
| 697 |
< |
{ |
| 698 |
< |
/* This message changed direction (nick collision?) |
| 699 |
< |
* ignore it. |
| 700 |
< |
*/ |
| 729 |
< |
return; |
| 730 |
< |
} |
| 690 |
> |
/* |
| 691 |
> |
* Remap low number numerics, not that I understand WHY.. --Nemesi |
| 692 |
> |
*/ |
| 693 |
> |
/* |
| 694 |
> |
* numerics below 100 talk about the current 'connection', you're not |
| 695 |
> |
* connected to a remote server so it doesn't make sense to send them |
| 696 |
> |
* remotely - but the information they contain may be useful, so we |
| 697 |
> |
* remap them up. Weird, but true. -- Isomer |
| 698 |
> |
*/ |
| 699 |
> |
if (numeric[0] == '0') |
| 700 |
> |
numeric[0] = '1'; |
| 701 |
|
|
| 702 |
< |
/* csircd will send out unknown umode flag for +a (admin), drop it here. */ |
| 703 |
< |
if ((atoi(numeric) == ERR_UMODEUNKNOWNFLAG) && MyClient(target_p)) |
| 734 |
< |
return; |
| 735 |
< |
|
| 702 |
> |
if (target_p) |
| 703 |
> |
{ |
| 704 |
|
/* Fake it for server hiding, if its our client */ |
| 705 |
< |
if (ConfigServerHide.hide_servers && |
| 706 |
< |
MyClient(target_p) && !HasUMode(target_p, UMODE_OPER)) |
| 707 |
< |
sendto_one(target_p, ":%s %s %s%s", me.name, numeric, target_p->name, buffer); |
| 705 |
> |
if (ConfigServerHide.hide_servers && MyClient(target_p) && |
| 706 |
> |
!HasUMode(target_p, UMODE_OPER)) |
| 707 |
> |
sendto_one(target_p, ":%s %s %s %s", me.name, numeric, target_p->name, parv[2]); |
| 708 |
|
else |
| 709 |
< |
sendto_one(target_p, ":%s %s %s%s", ID_or_name(source_p, target_p->from), |
| 710 |
< |
numeric, ID_or_name(target_p, target_p->from), buffer); |
| 743 |
< |
return; |
| 709 |
> |
sendto_one(target_p, ":%s %s %s %s", ID_or_name(source_p, target_p->from), |
| 710 |
> |
numeric, ID_or_name(target_p, target_p->from), parv[2]); |
| 711 |
|
} |
| 712 |
< |
else if ((chptr = hash_find_channel(parv[1])) != NULL) |
| 712 |
> |
else |
| 713 |
|
sendto_channel_local(ALL_MEMBERS, 0, chptr, ":%s %s %s %s", |
| 714 |
< |
source_p->name, |
| 748 |
< |
numeric, chptr->chname, buffer); |
| 714 |
> |
source_p->name, numeric, chptr->chname, parv[2]); |
| 715 |
|
} |
| 716 |
|
|
| 717 |
|
/* m_not_oper() |
| 763 |
|
|
| 764 |
|
if (client_p == source_p) |
| 765 |
|
{ |
| 766 |
< |
sendto_realops_flags(UMODE_ALL, L_ADMIN, "ERROR :from %s -- %s", |
| 766 |
> |
sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, |
| 767 |
> |
"ERROR :from %s -- %s", |
| 768 |
|
get_client_name(client_p, HIDE_IP), in_para); |
| 769 |
< |
sendto_realops_flags(UMODE_ALL, L_OPER, "ERROR :from %s -- %s", |
| 769 |
> |
sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE, |
| 770 |
> |
"ERROR :from %s -- %s", |
| 771 |
|
get_client_name(client_p, MASK_IP), in_para); |
| 772 |
|
} |
| 773 |
|
else |
| 774 |
|
{ |
| 775 |
< |
sendto_realops_flags(UMODE_ALL, L_OPER, "ERROR :from %s via %s -- %s", |
| 776 |
< |
source_p->name, get_client_name(client_p, MASK_IP), in_para); |
| 809 |
< |
sendto_realops_flags(UMODE_ALL, L_ADMIN, "ERROR :from %s via %s -- %s", |
| 775 |
> |
sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, |
| 776 |
> |
"ERROR :from %s via %s -- %s", |
| 777 |
|
source_p->name, get_client_name(client_p, HIDE_IP), in_para); |
| 778 |
+ |
sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE, |
| 779 |
+ |
"ERROR :from %s via %s -- %s", |
| 780 |
+ |
source_p->name, get_client_name(client_p, MASK_IP), in_para); |
| 781 |
|
} |
| 782 |
|
|
| 783 |
|
if (MyClient(source_p)) |