From 7e7b05cccb573a5982baaf145e5b3e4e578f0272 Mon Sep 17 00:00:00 2001 From: Michael Poole Date: Fri, 15 Jul 2005 03:02:50 +0000 Subject: [PATCH] Use HIS_SERVERNAME instead of cli_name(&me) for a variety of user-visible messages where the real source is hidden. git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@1447 c9e4aea6-c8fd-4c43-8297-357d70d61c8c --- ChangeLog | 18 ++++++++++++++++++ include/ircd_features.h | 2 ++ ircd/channel.c | 4 ++-- ircd/ircd_features.c | 23 +++++++++++++++++++++-- ircd/m_burst.c | 2 +- ircd/m_whois.c | 12 ++++-------- ircd/s_misc.c | 5 +++-- 7 files changed, 51 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 34f80d6..13c6520 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +2005-07-14 Michael Poole + + * include/ircd_features.h: Declare new "his" pseudo-server to hold + FEAT_HIS_SERVERNAME and FEAT_HIS_SERVERINFO in a convenient place. + + * ircd/ircd_features.c: Initialize and update it. + + * ircd/channel.c (modebuf_flush_int): Use it as the apparent + source for opmodes and server mode changes (also when the source + is me). + + * ircd/m_burst.c (ms_burst): Use it as the apparent source for net + rider kicks. + + * ircd/m_whois.c (do_whois): Use it to simplify code here. + + * ircd/s_misc.c (exit_client): Use it as the apparent killer. + 2005-07-14 Michael Poole * doc/example.conf (General): Update comment about vhost to match diff --git a/include/ircd_features.h b/include/ircd_features.h index fae743c..e452f62 100644 --- a/include/ircd_features.h +++ b/include/ircd_features.h @@ -26,6 +26,8 @@ struct Client; struct StatDesc; +extern struct Client his; + /** Contains all feature settings for ircu. * For documentation of each, see doc/readme.features. */ diff --git a/ircd/channel.c b/ircd/channel.c index 81be0d9..09e3a44 100644 --- a/ircd/channel.c +++ b/ircd/channel.c @@ -1630,8 +1630,8 @@ modebuf_flush_int(struct ModeBuf *mbuf, int all) /* Ok, if we were given the OPMODE flag, or its a server, hide the source. */ - if (mbuf->mb_dest & MODEBUF_DEST_OPMODE || IsServer(mbuf->mb_source)) - app_source = &me; + if (mbuf->mb_dest & MODEBUF_DEST_OPMODE || IsServer(mbuf->mb_source) || IsMe(mbuf->mb_source)) + app_source = &his; else app_source = mbuf->mb_source; diff --git a/ircd/ircd_features.c b/ircd/ircd_features.c index 26a0289..8f5b1ce 100644 --- a/ircd/ircd_features.c +++ b/ircd/ircd_features.c @@ -50,6 +50,8 @@ #include #include +struct Client his; + /** List of log output types that can be set */ static struct LogTypes { char *type; /**< Settable name. */ @@ -160,6 +162,20 @@ feature_log_reset(struct Client* from, const char* const* fields, int count) return 0; } +/** Handle an update to FEAT_HIS_SERVERNAME. */ +static void +feature_notify_servername(void) +{ + ircd_strncpy(cli_name(&his), feature_str(FEAT_HIS_SERVERNAME), HOSTLEN); +} + +/** Handle an update to FEAT_HIS_SERVERINFO. */ +static void +feature_notify_serverinfo(void) +{ + ircd_strncpy(cli_info(&his), feature_str(FEAT_HIS_SERVERINFO), REALLEN); +} + /** Report the value of a log setting. * @param[in] from &Client asking for details. * @param[in] fields Array of parameters to get. @@ -381,8 +397,8 @@ static struct FeatureDesc { F_B(HIS_REWRITE, 0, 1, 0), F_I(HIS_REMOTE, 0, 1, 0), F_B(HIS_NETSPLIT, 0, 1, 0), - F_S(HIS_SERVERNAME, 0, "*.undernet.org", 0), - F_S(HIS_SERVERINFO, 0, "The Undernet Underworld", 0), + F_S(HIS_SERVERNAME, 0, "*.undernet.org", feature_notify_servername), + F_S(HIS_SERVERINFO, 0, "The Undernet Underworld", feature_notify_serverinfo), F_S(HIS_URLSERVERS, 0, "http://www.undernet.org/servers.php", 0), /* Misc. random stuff */ @@ -750,6 +766,9 @@ feature_init(void) { int i; + cli_magic(&his) = CLIENT_MAGIC; + cli_status(&his) = STAT_SERVER; + for (i = 0; features[i].type; i++) { switch (features[i].flags & FEAT_MASK) { case FEAT_NONE: /* you're on your own */ diff --git a/ircd/m_burst.c b/ircd/m_burst.c index 01be1a6..79cce5a 100644 --- a/ircd/m_burst.c +++ b/ircd/m_burst.c @@ -249,7 +249,7 @@ int ms_burst(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) && (!(check_modes & MODE_REGONLY) || IsAccount(member->user))) continue; sendcmdto_serv_butone(&me, CMD_KICK, NULL, "%H %C :Net Rider", chptr, member->user); - sendcmdto_channel_butserv_butone(&me, CMD_KICK, chptr, NULL, 0, "%H %C :Net Rider", chptr, member->user); + sendcmdto_channel_butserv_butone(&his, CMD_KICK, chptr, NULL, 0, "%H %C :Net Rider", chptr, member->user); make_zombie(member, member->user, &me, &me, chptr); } } diff --git a/ircd/m_whois.c b/ircd/m_whois.c index 43d7833..8a28793 100644 --- a/ircd/m_whois.c +++ b/ircd/m_whois.c @@ -137,7 +137,8 @@ static void do_whois(struct Client* sptr, struct Client *acptr, int parc) const struct User* user = cli_user(acptr); const char* name = (!*(cli_name(acptr))) ? "?" : cli_name(acptr); - a2cptr = user->server; + a2cptr = feature_bool(FEAT_HIS_WHOIS_SERVERNAME) && !IsAnOper(sptr) + && sptr != acptr ? user->server : &his; assert(user); send_reply(sptr, RPL_WHOISUSER, name, user->username, user->host, cli_info(acptr)); @@ -196,13 +197,8 @@ static void do_whois(struct Client* sptr, struct Client *acptr, int parc) send_reply(sptr, RPL_WHOISCHANNELS, name, buf); } - if (feature_bool(FEAT_HIS_WHOIS_SERVERNAME) && !IsAnOper(sptr) && - sptr != acptr) - send_reply(sptr, RPL_WHOISSERVER, name, feature_str(FEAT_HIS_SERVERNAME), - feature_str(FEAT_HIS_SERVERINFO)); - else - send_reply(sptr, RPL_WHOISSERVER, name, cli_name(a2cptr), - cli_info(a2cptr)); + send_reply(sptr, RPL_WHOISSERVER, name, cli_name(a2cptr), + cli_info(a2cptr)); if (user) { diff --git a/ircd/s_misc.c b/ircd/s_misc.c index e0be99b..3463854 100644 --- a/ircd/s_misc.c +++ b/ircd/s_misc.c @@ -401,8 +401,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)) && -- 2.20.1