X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=ircd%2Fs_misc.c;h=111e9c7dc56508c11028a717367c1fd604c31dc9;hb=refs%2Fheads%2Fupstream-ssl;hp=1c6a2c408ab4105df5b4891e3fffdb22372f8bd5;hpb=19570001d07baa87f2165b8826c8ae1237ac9ddf;p=ircu2.10.12-pk.git diff --git a/ircd/s_misc.c b/ircd/s_misc.c index 1c6a2c4..111e9c7 100644 --- a/ircd/s_misc.c +++ b/ircd/s_misc.c @@ -19,8 +19,10 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * $Id$ + */ +/** @file + * @brief Miscellaneous support functions. + * @version $Id$ */ #include "config.h" @@ -31,7 +33,6 @@ #include "hash.h" #include "ircd.h" #include "ircd_alloc.h" -#include "ircd_auth.h" #include "ircd_features.h" #include "ircd_log.h" #include "ircd_reply.h" @@ -45,6 +46,7 @@ #include "parse.h" #include "querycmds.h" #include "res.h" +#include "s_auth.h" #include "s_bsd.h" #include "s_conf.h" #include "s_debug.h" @@ -52,12 +54,11 @@ #include "s_user.h" #include "send.h" #include "struct.h" -#include "support.h" #include "sys.h" #include "uping.h" #include "userload.h" -#include +/* #include -- Now using assert in ircd_log.h */ #include #include #include @@ -163,37 +164,17 @@ const char* get_client_name(const struct Client* sptr, int showip) { static char nbuf[HOSTLEN * 2 + USERLEN + 5]; - if (MyConnect(sptr)) { - if (showip) - ircd_snprintf(0, nbuf, sizeof(nbuf), "%s[%s@%s]", cli_name(sptr), - IsIdented(sptr) ? cli_username(sptr) : "unknown", - cli_sock_ip(sptr)); - else - return cli_name(sptr); - return nbuf; - } - return cli_name(sptr); -} - -/** Set cli_sockhost(cptr) from \a host. - * If \a host contains an '@', copy starting after that byte. - * Otherwise copy all of \a host. - * @param cptr Client to operate on. - * @param host hostname or user\@hostname string. - */ -void get_sockhost(struct Client *cptr, char *host) -{ - char *s; - if ((s = strchr(host, '@'))) - s++; - else - s = host; - ircd_strncpy(cli_sockhost(cptr), s, HOSTLEN); + if (!MyConnect(sptr) || !showip) + return cli_name(sptr); + ircd_snprintf(0, nbuf, sizeof(nbuf), "%s[%s@%s]", cli_name(sptr), + IsIdented(sptr) ? cli_username(sptr) : "", + cli_sock_ip(sptr)); + return nbuf; } /** * Exit one client, local or remote. Assuming for local client that - * all dependants already have been removed, and socket is closed. + * all dependents already have been removed, and socket is closed. * @param bcptr Client being (s)quitted. * @param comment The QUIT comment to send. */ @@ -201,6 +182,7 @@ void get_sockhost(struct Client *cptr, char *host) static void exit_one_client(struct Client* bcptr, const char* comment) { struct SLink *lp; + struct Ban *bp; if (cli_serv(bcptr) && cli_serv(bcptr)->client_list) /* Was SetServerYXX called ? */ ClearServerYXX(bcptr); /* Removes server from server_list[] */ @@ -214,7 +196,6 @@ static void exit_one_client(struct Client* bcptr, const char* comment) * Stop a running /LIST clean */ if (MyUser(bcptr) && cli_listing(bcptr)) { - cli_listing(bcptr)->chptr->mode.mode &= ~MODE_LISTED; MyFree(cli_listing(bcptr)); cli_listing(bcptr) = NULL; } @@ -233,22 +214,27 @@ static void exit_one_client(struct Client* bcptr, const char* comment) del_invite(bcptr, lp->value.chptr); /* Clean up silencefield */ - while ((lp = cli_user(bcptr)->silence)) - del_silence(bcptr, lp->value.cp); + while ((bp = cli_user(bcptr)->silence)) { + cli_user(bcptr)->silence = bp->next; + free_ban(bp); + } /* Clean up snotice lists */ if (MyUser(bcptr)) set_snomask(bcptr, ~0, SNO_DEL); - if (IsInvisible(bcptr)) + if (IsInvisible(bcptr)) { + assert(UserStats.inv_clients > 0); --UserStats.inv_clients; - if (IsOper(bcptr)) + } + if (IsOper(bcptr)) { + assert(UserStats.opers > 0); --UserStats.opers; + } if (MyConnect(bcptr)) Count_clientdisconnects(bcptr, UserStats); - else { + else Count_remoteclientquits(UserStats, bcptr); - } } else if (IsServer(bcptr)) { @@ -284,8 +270,6 @@ static void exit_one_client(struct Client* bcptr, const char* comment) assert(!IsServer(bcptr)); /* bcptr->user->server->serv->client_list[IndexYXX(bcptr)] = NULL; */ RemoveYXXClient(cli_user(bcptr)->server, cli_yxx(bcptr)); - if (IsIAuthed(bcptr) || cli_iauth(bcptr)) - iauth_exit_client(bcptr); } /* Remove bcptr from the client list */ @@ -337,7 +321,7 @@ static void exit_downlinks(struct Client *cptr, struct Client *sptr, char *comme /* exit_client, rewritten 25-9-94 by Run */ /** - * Eexits a client of *any* type (user, server, etc) + * Exits a client of *any* type (user, server, etc) * from this server. Also, this generates all necessary prototol * messages that this exit may cause. * @@ -345,13 +329,13 @@ static void exit_downlinks(struct Client *cptr, struct Client *sptr, char *comme * this connection. * * For convenience, this function returns a suitable value for - * m_funtion return value: + * m_function return value: * * CPTR_KILLED if (cptr == bcptr) * 0 if (cptr != bcptr) * * This function can be called in two ways: - * 1) From before or in parse(), exitting the 'cptr', in which case it was + * 1) From before or in parse(), exiting the 'cptr', in which case it was * invoked as exit_client(cptr, cptr, &me,...), causing it to always * return CPTR_KILLED. * 2) Via parse from a m_function call, in which case it was invoked as @@ -397,12 +381,15 @@ int exit_client(struct Client *cptr, on_for = CurrentTime - cli_firsttime(victim); + if (IsUser(victim) || IsUserPort(victim)) + auth_send_exit(victim); + if (IsUser(victim)) log_write(LS_USER, L_TRACE, 0, "%Tu %i %s@%s %s %s %s%s %s :%s", cli_firsttime(victim), on_for, cli_user(victim)->username, cli_sockhost(victim), ircd_ntoa(&cli_ip(victim)), - IsAccount(victim) ? cli_username(victim) : "0", + cli_account(victim), NumNick(victim), /* two %s's */ cli_name(victim), cli_info(victim)); @@ -419,8 +406,9 @@ int exit_client(struct Client *cptr, cli_name(killer), comment); else sendrawto_one(victim, MSG_ERROR " :Closing Link: %s by %s (%s)", - cli_name(victim), IsServer(killer) ? cli_name(&me) : - cli_name(killer), comment); + cli_name(victim), + cli_name(IsServer(killer) ? &his : killer), + comment); } } if ((IsServer(victim) || IsHandshake(victim) || IsConnecting(victim)) && @@ -436,7 +424,7 @@ int exit_client(struct Client *cptr, (acptr = findNUser(cli_serv(victim)->by))) { if (cli_user(acptr) == cli_serv(victim)->user) { sendcmdto_one(&me, CMD_NOTICE, acptr, - "%C :Link with %s cancelled: %s", acptr, + "%C :Link with %s canceled: %s", acptr, cli_name(victim), comment); } else { @@ -448,7 +436,7 @@ int exit_client(struct Client *cptr, } } if (killer == &me) - sendto_opmask_butone(acptr, SNO_OLDSNO, "Link with %s cancelled: %s", + sendto_opmask_butone(acptr, SNO_OLDSNO, "Link with %s canceled: %s", cli_name(victim), comment); } } @@ -505,7 +493,7 @@ int exit_client(struct Client *cptr, /* * cptr can only have been killed if it was cptr itself that got killed here, - * because cptr can never have been a dependant of victim --Run + * because cptr can never have been a dependent of victim --Run */ return (cptr == victim) ? CPTR_KILLED : 0; } @@ -580,39 +568,15 @@ void tstats(struct Client *cptr, const struct StatDesc *sd, char *param) { sp->is_sbs += cli_sendB(acptr); sp->is_sbr += cli_receiveB(acptr); - sp->is_sks += cli_sendK(acptr); - sp->is_skr += cli_receiveK(acptr); sp->is_sti += CurrentTime - cli_firsttime(acptr); sp->is_sv++; - if (sp->is_sbs > 1023) - { - sp->is_sks += (sp->is_sbs >> 10); - sp->is_sbs &= 0x3ff; - } - if (sp->is_sbr > 1023) - { - sp->is_skr += (sp->is_sbr >> 10); - sp->is_sbr &= 0x3ff; - } } else if (IsUser(acptr)) { sp->is_cbs += cli_sendB(acptr); sp->is_cbr += cli_receiveB(acptr); - sp->is_cks += cli_sendK(acptr); - sp->is_ckr += cli_receiveK(acptr); sp->is_cti += CurrentTime - cli_firsttime(acptr); sp->is_cl++; - if (sp->is_cbs > 1023) - { - sp->is_cks += (sp->is_cbs >> 10); - sp->is_cbs &= 0x3ff; - } - if (sp->is_cbr > 1023) - { - sp->is_ckr += (sp->is_cbr >> 10); - sp->is_cbr &= 0x3ff; - } } else if (IsUnknown(acptr)) sp->is_ni++; @@ -635,10 +599,10 @@ void tstats(struct Client *cptr, const struct StatDesc *sd, char *param) send_reply(cptr, SND_EXPLICIT | RPL_STATSDEBUG, ":Client server"); send_reply(cptr, SND_EXPLICIT | RPL_STATSDEBUG, ":connected %u %u", sp->is_cl, sp->is_sv); - send_reply(cptr, SND_EXPLICIT | RPL_STATSDEBUG, ":bytes sent %u.%uK %u.%uK", - sp->is_cks, sp->is_cbs, sp->is_sks, sp->is_sbs); - send_reply(cptr, SND_EXPLICIT | RPL_STATSDEBUG, ":bytes recv %u.%uK %u.%uK", - sp->is_ckr, sp->is_cbr, sp->is_skr, sp->is_sbr); - send_reply(cptr, SND_EXPLICIT | RPL_STATSDEBUG, ":time connected %Tu %Tu", + send_reply(cptr, SND_EXPLICIT | RPL_STATSDEBUG, ":bytes sent %Lu %Lu", + sp->is_cbs, sp->is_sbs); + send_reply(cptr, SND_EXPLICIT | RPL_STATSDEBUG, ":bytes recv %Lu %Lu", + sp->is_cbr, sp->is_sbr); + send_reply(cptr, SND_EXPLICIT | RPL_STATSDEBUG, ":time connected %Lu %Lu", sp->is_cti, sp->is_sti); }