Author: Kev <klmitch@mit.edu>
[ircu2.10.12-pk.git] / ircd / ircd_relay.c
index 0953568cccd7dfb76d3de6b5088b1e4fe6940627..49541e4e0d38f0fec482588d5fdde5d6df014faa 100644 (file)
@@ -30,6 +30,7 @@
 #include "hash.h"
 #include "ircd.h"
 #include "ircd_chattr.h"
+#include "ircd_features.h"
 #include "ircd_reply.h"
 #include "ircd_string.h"
 #include "match.h"
@@ -158,14 +159,16 @@ void relay_directed_message(struct Client* sptr, char* name, char* server, const
   assert(0 != text);
   assert(0 != server);
 
-  if (0 == (acptr = FindServer(server + 1))) {
+  if ((acptr = FindServer(server + 1)) == NULL || !IsChannelService(acptr))
+  {
     send_reply(sptr, ERR_NOSUCHNICK, name);
     return;
   }
   /*
    * NICK[%host]@server addressed? See if <server> is me first
    */
-  if (!IsMe(acptr)) {
+  if (!IsMe(acptr))
+  {
     sendcmdto_one(sptr, CMD_PRIVATE, acptr, "%s :%s", name, text);
     return;
   }
@@ -178,8 +181,23 @@ void relay_directed_message(struct Client* sptr, char* name, char* server, const
   if ((host = strchr(name, '%')))
     *host++ = '\0';
 
+  /* As reported by Vampire-, it's possible to brute force finding users
+   * by sending a message to each server and see which one succeeded.
+   * This means we have to remove error reporting.  Sigh.  Better than
+   * removing the ability to send directed messages to client servers 
+   * Thanks for the suggestion Vampire=.  -- Isomer 2001-08-28
+   * Argh, /ping nick@server, disallow messages to non +k clients :/  I hate
+   * this. -- Isomer 2001-09-16
+   */
   if (!(acptr = FindUser(name)) || !MyUser(acptr) ||
-      (!EmptyString(host) && 0 != match(host, cli_user(acptr)->host))) {
+      (!EmptyString(host) && 0 != match(host, cli_user(acptr)->host)) ||
+      !IsChannelService(acptr))
+  {
+    /*
+     * By this stage we might as well not bother because they will
+     * know that this server is currently linked because of the
+     * increased lag.
+     */
     send_reply(sptr, ERR_NOSUCHNICK, name);
     return;
   }
@@ -295,8 +313,9 @@ void server_relay_private_message(struct Client* sptr, const char* name, const c
    * nickname addressed?
    */
   if (0 == (acptr = findNUser(name)) || !IsUser(acptr)) {
-    send_reply(sptr, SND_EXPLICIT | ERR_NOSUCHNICK, "* :Target left UnderNet. "
-              "Failed to deliver: [%.20s]", text);
+    send_reply(sptr, SND_EXPLICIT | ERR_NOSUCHNICK, "* :Target left %s. "
+              "Failed to deliver: [%.20s]", feature_str(FEAT_NETWORK),
+               text);
     return;
   }
   if (is_silenced(sptr, acptr))