Use HIS_SERVERNAME instead of cli_name(&me) for a variety of
authorMichael Poole <mdpoole@troilus.org>
Fri, 15 Jul 2005 03:02:50 +0000 (03:02 +0000)
committerMichael Poole <mdpoole@troilus.org>
Fri, 15 Jul 2005 03:02:50 +0000 (03:02 +0000)
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
include/ircd_features.h
ircd/channel.c
ircd/ircd_features.c
ircd/m_burst.c
ircd/m_whois.c
ircd/s_misc.c

index 34f80d685aa0403a07fb5a0a7bb6346a757b9e13..13c6520c116ec10671e29ddab138ebe3b43c954b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2005-07-14  Michael Poole <mdpoole@troilus.org>
+
+       * 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 <mdpoole@troilus.org>
 
        * doc/example.conf (General): Update comment about vhost to match
index fae743ceba5c33dbf32d3540881e33ba8359252b..e452f62da39ea44a1031a2fb5889f89e363c3878 100644 (file)
@@ -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.
  */
index 81be0d993346796f09e823b4b51ce458a5b1c4bc..09e3a4484dc848d79087cbe15a0835b4297b6fc4 100644 (file)
@@ -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;
 
index 26a028977290fdfdc3b90a7daa8e5a91d85eb2d1..8f5b1cea10dd9373493a18b2c1e72fa071560fe7 100644 (file)
@@ -50,6 +50,8 @@
 #include <stdlib.h>
 #include <string.h>
 
+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 */
index 01be1a6a6c9dc6cf3c524ccb77b2e916e43ad1f5..79cce5a6cb3abd5673690eaa53b7c9fd95e736f1 100644 (file)
@@ -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);
         }
       }
index 43d7833998c3216c56c9683d41e280bc65118652..8a28793d3c966f8687a00d3123c441c57d233b57 100644 (file)
@@ -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)
   {
index e0be99b7d04b70cc9f691ef45ff28fcf74258ac7..34638546a759dcbb08dfee40031d46023575ef85 100644 (file)
@@ -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)) &&