From 241fa041ccfa00c2f9f255c4c2a572d877b975e3 Mon Sep 17 00:00:00 2001 From: Perry Lorier Date: Sun, 15 Apr 2001 06:58:57 +0000 Subject: [PATCH] Author: Isomer Log message: Lots of little changes I've been sitting on, mostly minor cleanups to m_*.c git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@404 c9e4aea6-c8fd-4c43-8297-357d70d61c8c --- RELEASE.NOTES | 2 + doc/rfc1459.unet | 3 +- include/ircd_reply.h | 1 - include/s_user.h | 1 - ircd/ircd_reply.c | 11 ----- ircd/m_admin.c | 18 +++++++- ircd/m_away.c | 50 +++++++++++++++++++++ ircd/m_connect.c | 1 + ircd/m_desynch.c | 30 ------------- ircd/m_endburst.c | 48 -------------------- ircd/m_help.c | 17 -------- ircd/m_info.c | 102 +++++++++++++------------------------------ ircd/s_user.c | 44 ------------------- 13 files changed, 102 insertions(+), 226 deletions(-) diff --git a/RELEASE.NOTES b/RELEASE.NOTES index 9113235..4e17c49 100644 --- a/RELEASE.NOTES +++ b/RELEASE.NOTES @@ -139,3 +139,5 @@ The kernel has a kernel destination cache size of 4096. If the kernel sees more than 4096 IP's in 60s it warns 'dst cache overflow'. This limit can be changed by modifying /proc/sys/net/ipv4/route/max_size. +A patch to select is also recommended if you have regular poll/select +errors. \ No newline at end of file diff --git a/doc/rfc1459.unet b/doc/rfc1459.unet index 84d106a..6a3f36b 100644 --- a/doc/rfc1459.unet +++ b/doc/rfc1459.unet @@ -1718,7 +1718,8 @@ RFC 1459 Internet Relay Chat Protocol May 1993 The admin message is used to find the name of the administrator of the given server, or current server if parameter is omitted. Each server must have the ability to forward ADMIN messages to other - servers. + servers. The given server may be a nick, where the server that the + nick is on will be queried. Numeric Replies: diff --git a/include/ircd_reply.h b/include/ircd_reply.h index 4ea9e5a..9df7d96 100644 --- a/include/ircd_reply.h +++ b/include/ircd_reply.h @@ -28,7 +28,6 @@ extern int protocol_violation(struct Client* cptr, const char* pattern, ...); extern int need_more_params(struct Client* cptr, const char* cmd); extern int send_error_to_client(struct Client* cptr, int error, ...); extern int send_reply(struct Client* to, int reply, ...); -extern int send_admin_info(struct Client* to); #define SND_EXPLICIT 0x40000000 /* first arg is a pattern to use */ diff --git a/include/s_user.h b/include/s_user.h index c8457ad..fec38e2 100644 --- a/include/s_user.h +++ b/include/s_user.h @@ -63,7 +63,6 @@ extern int register_user(struct Client* cptr, struct Client* sptr, extern void user_count_memory(size_t* count_out, size_t* bytes_out); -extern int user_set_away(struct User* user, char* message); extern int do_nick_name(char* nick); extern int set_nick_name(struct Client* cptr, struct Client* sptr, const char* nick, int parc, char* parv[]); diff --git a/ircd/ircd_reply.c b/ircd/ircd_reply.c index 3a222a3..39d6514 100644 --- a/ircd/ircd_reply.c +++ b/ircd/ircd_reply.c @@ -106,16 +106,5 @@ int send_reply(struct Client *to, int reply, ...) return 0; /* convenience return */ } -int send_admin_info(struct Client* sptr) -{ - const struct LocalConf* admin = conf_get_local(); - assert(0 != sptr); - - send_reply(sptr, RPL_ADMINME, cli_name(&me)); - send_reply(sptr, RPL_ADMINLOC1, admin->location1); - send_reply(sptr, RPL_ADMINLOC2, admin->location2); - send_reply(sptr, RPL_ADMINEMAIL, admin->contact); - return 0; -} diff --git a/ircd/m_admin.c b/ircd/m_admin.c index 839d714..a6bbcce 100644 --- a/ircd/m_admin.c +++ b/ircd/m_admin.c @@ -97,6 +97,19 @@ #include +static int send_admin_info(struct Client* sptr) +{ + const struct LocalConf* admin = conf_get_local(); + assert(0 != sptr); + + send_reply(sptr, RPL_ADMINME, cli_name(&me)); + send_reply(sptr, RPL_ADMINLOC1, admin->location1); + send_reply(sptr, RPL_ADMINLOC2, admin->location2); + send_reply(sptr, RPL_ADMINEMAIL, admin->contact); + return 0; +} + + /* * m_admin - generic message handler * @@ -110,7 +123,10 @@ int m_admin(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) if (parc > 1) { struct Client *acptr; - if (!(acptr = find_match_server(parv[1]))) + acptr = FindUser(parv[1]); + if (acptr) + parv[1] = cli_name(cli_user(acptr)->server); + else if (!(acptr = find_match_server(parv[1]))) return send_reply(sptr, ERR_NOSUCHSERVER, parv[1]); parv[1] = cli_name(acptr); diff --git a/ircd/m_away.c b/ircd/m_away.c index 787e570..79127a3 100644 --- a/ircd/m_away.c +++ b/ircd/m_away.c @@ -89,6 +89,7 @@ #endif /* 0 */ #include "client.h" #include "ircd.h" +#include "ircd_alloc.h" #include "ircd_reply.h" #include "ircd_string.h" #include "msg.h" @@ -99,12 +100,61 @@ #include +/* + * user_set_away - set user away state + * returns 1 if client is away or changed away message, 0 if + * client is removing away status. + * NOTE: this function may modify user and message, so they + * must be mutable. + */ +static int user_set_away(struct User* user, char* message) +{ + char* away; + assert(0 != user); + + away = user->away; + + if (EmptyString(message)) { + /* + * Marking as not away + */ + if (away) { + MyFree(away); + user->away = 0; + } + } + else { + /* + * Marking as away + */ + unsigned int len = strlen(message); + + if (len > TOPICLEN) { + message[TOPICLEN] = '\0'; + len = TOPICLEN; + } + if (away) + away = (char*) MyRealloc(away, len + 1); + else + away = (char*) MyMalloc(len + 1); + assert(0 != away); + + user->away = away; + strcpy(away, message); + } + return (user->away != 0); +} + + /* * m_away - generic message handler template * - Added 14 Dec 1988 by jto. * * parv[0] = sender prefix * parv[1] = away message + * + * TODO: Throttle aways - many people have a script which resets the away + * message every 10 seconds which really chews the bandwidth. */ int m_away(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) { diff --git a/ircd/m_connect.c b/ircd/m_connect.c index cbc75bb..43d704a 100644 --- a/ircd/m_connect.c +++ b/ircd/m_connect.c @@ -138,6 +138,7 @@ int ms_connect(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) * checked it's args, if we don't have parc == 4, something * isn't right. */ + protocol_violation(sptr, "Too few parameters to connect"); return need_more_params(sptr, "CONNECT"); } diff --git a/ircd/m_desynch.c b/ircd/m_desynch.c index eee568f..dcb7e22 100644 --- a/ircd/m_desynch.c +++ b/ircd/m_desynch.c @@ -119,33 +119,3 @@ int ms_desynch(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) return 0; } - -#if 0 -/* - * m_desynch - * - * Writes to all +g users; for sending wall type debugging/anti-hack info. - * Added 23 Apr 1998 --Run - * - * parv[0] - sender prefix - * parv[parc-1] - message text - */ -int m_desynch(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) -{ - if (IsServer(sptr) && parc >= 2) - { - int i; - struct Client *acptr; - /* Send message to local +g clients as if it were a wallops */ - sprintf_irc(sendbuf, ":%s WALLOPS :%s", parv[0], parv[parc - 1]); /* XXX DEAD */ - for (i = 0; i <= HighestFd; i++) - if ((acptr = LocalClientArray[i]) && !IsServer(acptr) && !IsMe(acptr) && - SendDebug(acptr)) - sendbufto_one(acptr); /* XXX DEAD */ - /* Send message to remote +g clients */ - sendto_g_serv_butone(cptr, "%s DESYNCH :%s", NumServ(sptr), parv[parc - 1]); /* XXX DEAD */ - } - return 0; -} -#endif /* 0 */ - diff --git a/ircd/m_endburst.c b/ircd/m_endburst.c index c987428..9243d30 100644 --- a/ircd/m_endburst.c +++ b/ircd/m_endburst.c @@ -166,51 +166,3 @@ int ms_end_of_burst_ack(struct Client *cptr, struct Client *sptr, int parc, char return 0; } - - -#if 0 -/* - * m_end_of_burst - Added Xorath 6-14-96, rewritten by Run 24-7-96 - * - and fixed by record and Kev 8/1/96 - * - and really fixed by Run 15/8/96 :p - * This the last message in a net.burst. - * It clears a flag for the server sending the burst. - * - * parv[0] - sender prefix - */ -int m_end_of_burst(struct Client *cptr, struct Client *sptr, int parc, char **parv) -{ - if (!IsServer(sptr)) - return 0; - - sendto_op_mask(SNO_NETWORK, "Completed net.burst from %s.", sptr->name); /* XXX DEAD */ - sendto_serv_butone(cptr, "%s EB", NumServ(sptr)); /* XXX DEAD */ - ClearBurst(sptr); - SetBurstAck(sptr); - if (MyConnect(sptr)) - sendto_one(sptr, "%s EA", NumServ(&me)); /* XXX DEAD */ - - return 0; -} -/* - * m_end_of_burst_ack - * - * This the acknowledge message of the `END_OF_BURST' message. - * It clears a flag for the server receiving the burst. - * - * parv[0] - sender prefix - */ -int m_end_of_burst_ack(struct Client *cptr, struct Client *sptr, int parc, char **parv) -{ - if (!IsServer(sptr)) - return 0; - - sendto_op_mask(SNO_NETWORK, "%s acknowledged end of net.burst.", sptr->name); /* XXX DEAD */ - sendto_serv_butone(cptr, "%s EA", NumServ(sptr)); /* XXX DEAD */ - ClearBurstAck(sptr); - - return 0; -} - -#endif /* 0 */ - diff --git a/ircd/m_help.c b/ircd/m_help.c index 36d53eb..a56341f 100644 --- a/ircd/m_help.c +++ b/ircd/m_help.c @@ -111,20 +111,3 @@ int m_help(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) return 0; } - -#if 0 -/* - * m_help - * - * parv[0] = sender prefix - */ -int m_help(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) -{ - int i; - - for (i = 0; msgtab[i].cmd; i++) - sendto_one(sptr, ":%s NOTICE %s :%s", me.name, parv[0], msgtab[i].cmd); /* XXX DEAD */ - return 0; -} -#endif /* 0 */ - diff --git a/ircd/m_info.c b/ircd/m_info.c index ea3db75..6c08e84 100644 --- a/ircd/m_info.c +++ b/ircd/m_info.c @@ -96,6 +96,7 @@ #include "numnicks.h" #include "s_misc.h" #include "s_user.h" +#include "s_conf.h" #include "send.h" #include "version.h" @@ -111,27 +112,21 @@ int m_info(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) { const char **text = infotext; - if (hunt_server_cmd(sptr, CMD_INFO, cptr, 1, ":%C", 1, parc, parv) == + if (hunt_server_cmd(sptr, CMD_INFO, cptr, 1, ":%C", 1, parc, parv) != HUNTED_ISME) + return 0; + + while (text[2]) { - while (text[2]) - { - if (!IsOper(sptr)) - send_reply(sptr, RPL_INFO, *text); - text++; - } - if (IsOper(sptr)) - { - while (*text) - send_reply(sptr, RPL_INFO, *text++); - send_reply(sptr, RPL_INFO, ""); - } - send_reply(sptr, SND_EXPLICIT | RPL_INFO, ":Birth Date: %s, compile # %s", - creation, generation); - send_reply(sptr, SND_EXPLICIT | RPL_INFO, ":On-line since %s", - myctime(cli_firsttime(&me))); - send_reply(sptr, RPL_ENDOFINFO); + send_reply(sptr, RPL_INFO, *text); + text++; } + send_reply(sptr, SND_EXPLICIT | RPL_INFO, ":Birth Date: %s, compile # %s", + creation, generation); + send_reply(sptr, SND_EXPLICIT | RPL_INFO, ":On-line since %s", + myctime(cli_firsttime(&me))); + send_reply(sptr, RPL_ENDOFINFO); + return 0; } @@ -148,27 +143,26 @@ int ms_info(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) if (IsServer(sptr)) return 0; - if (hunt_server_cmd(sptr, CMD_INFO, cptr, 1, ":%C", 1, parc, parv) == + if (hunt_server_cmd(sptr, CMD_INFO, cptr, 1, ":%C", 1, parc, parv) != HUNTED_ISME) + return 0; + while (text[2]) { - while (text[2]) - { - if (!IsOper(sptr)) - send_reply(sptr, RPL_INFO, *text); - text++; - } - if (IsOper(sptr)) - { - while (*text) - send_reply(sptr, RPL_INFO, *text++); - send_reply(sptr, RPL_INFO, ""); - } - send_reply(sptr, SND_EXPLICIT | RPL_INFO, ":Birth Date: %s, compile # %s", - creation, generation); - send_reply(sptr, SND_EXPLICIT | RPL_INFO, ":On-line since %s", - myctime(cli_firsttime(&me))); - send_reply(sptr, RPL_ENDOFINFO); + if (!IsOper(sptr)) + send_reply(sptr, RPL_INFO, *text); + text++; + } + if (IsOper(sptr)) + { + while (*text) + send_reply(sptr, RPL_INFO, *text++); + send_reply(sptr, RPL_INFO, ""); } + send_reply(sptr, SND_EXPLICIT | RPL_INFO, ":Birth Date: %s, compile # %s", + creation, generation); + send_reply(sptr, SND_EXPLICIT | RPL_INFO, ":On-line since %s", + myctime(cli_firsttime(&me))); + send_reply(sptr, RPL_ENDOFINFO); return 0; } @@ -206,39 +200,3 @@ int mo_info(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) return 0; } - -#if 0 -/* - * m_info - * - * parv[0] = sender prefix - * parv[1] = servername - */ -int m_info(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) -{ - const char **text = infotext; - - if (hunt_server(1, cptr, sptr, "%s%s " TOK_INFO " :%s", 1, parc, parv) == HUNTED_ISME) /* XXX DEAD */ - { - while (text[2]) - { - if (!IsOper(sptr)) - sendto_one(sptr, rpl_str(RPL_INFO), me.name, parv[0], *text); /* XXX DEAD */ - text++; - } - if (IsOper(sptr)) - { - while (*text) - sendto_one(sptr, rpl_str(RPL_INFO), me.name, parv[0], *text++); /* XXX DEAD */ - sendto_one(sptr, rpl_str(RPL_INFO), me.name, parv[0], ""); /* XXX DEAD */ - } - sendto_one(sptr, ":%s %d %s :Birth Date: %s, compile # %s", /* XXX DEAD */ - me.name, RPL_INFO, parv[0], creation, generation); - sendto_one(sptr, ":%s %d %s :On-line since %s", /* XXX DEAD */ - me.name, RPL_INFO, parv[0], myctime(me.firsttime)); - sendto_one(sptr, rpl_str(RPL_ENDOFINFO), me.name, parv[0]); /* XXX DEAD */ - } - return 0; -} -#endif /* 0 */ - diff --git a/ircd/s_user.c b/ircd/s_user.c index b4695ed..c607f1b 100644 --- a/ircd/s_user.c +++ b/ircd/s_user.c @@ -130,50 +130,6 @@ void user_count_memory(size_t* count_out, size_t* bytes_out) *bytes_out = userCount * sizeof(struct User); } -/* - * user_set_away - set user away state - * returns 1 if client is away or changed away message, 0 if - * client is removing away status. - * NOTE: this function may modify user and message, so they - * must be mutable. - */ -int user_set_away(struct User* user, char* message) -{ - char* away; - assert(0 != user); - - away = user->away; - - if (EmptyString(message)) { - /* - * Marking as not away - */ - if (away) { - MyFree(away); - user->away = 0; - } - } - else { - /* - * Marking as away - */ - unsigned int len = strlen(message); - - if (len > TOPICLEN) { - message[TOPICLEN] = '\0'; - len = TOPICLEN; - } - if (away) - away = (char*) MyRealloc(away, len + 1); - else - away = (char*) MyMalloc(len + 1); - assert(0 != away); - - user->away = away; - strcpy(away, message); - } - return (user->away != 0); -} /* * next_client -- 2.20.1