Author: Isomer / ZenShadow
[ircu2.10.12-pk.git] / ircd / s_user.c
index f4456a4e91443d746843ab170f30f013fcc3100f..a7c0c03e7c150ae575ec68eb038b88db8f6f222c 100644 (file)
@@ -272,6 +272,51 @@ int hunt_server(int MustBeOper, struct Client *cptr, struct Client *sptr, char *
   return (HUNTED_PASS);
 }
 
+int hunt_server_cmd(struct Client *from, const char *cmd, const char *tok,
+                   struct Client *one, int MustBeOper, const char *pattern,
+                   int server, int parc, char *parv[])
+{
+  struct Client *acptr;
+  char *to;
+
+  /* Assume it's me, if no server or an unregistered client */
+  if (parc <= server || EmptyString((to = parv[server])) || IsUnknown(from))
+    return (HUNTED_ISME);
+
+  /* Make sure it's a server */
+  if (MyUser(from)) {
+    /* Make sure it's a server */
+    if (!strchr(to, '*')) {
+      if (0 == (acptr = FindClient(to)))
+        return HUNTED_NOSUCH;
+
+      if (acptr->user)
+        acptr = acptr->user->server;
+    } else if (!(acptr = find_match_server(to))) {
+      send_reply(from, ERR_NOSUCHSERVER, to);
+      return (HUNTED_NOSUCH);
+    }
+  } else if (!(acptr = FindNServer(to)))
+    return (HUNTED_NOSUCH);        /* Server broke off in the meantime */
+
+  if (IsMe(acptr))
+    return (HUNTED_ISME);
+
+  if (MustBeOper && !IsPrivileged(from)) {
+    send_reply(from, ERR_NOPRIVILEGES);
+    return HUNTED_NOSUCH;
+  }
+
+  assert(!IsServer(from));
+
+  parv[server] = (char *) acptr; /* HACK! HACK! HACK! ARGH! */
+
+  sendcmdto_one(from, cmd, tok, acptr, pattern, parv[1], parv[2], parv[3],
+               parv[4], parv[5], parv[6], parv[7], parv[8]);
+
+  return (HUNTED_PASS);
+}
+
 /*
  * 'do_nick_name' ensures that the given parameter (nick) is really a proper
  * string for a nickname (note, the 'nick' may be modified in the process...)
@@ -534,15 +579,14 @@ int register_user(struct Client *cptr, struct Client *sptr,
         strcmp(sptr->username, username) != 0))
     {
       ServerStats->is_ref++;
-      /* XXX sendto_one used with ERR_INVALIDUSERNAME--explanations */
-      sendto_one(cptr, ":%s %d %s :Your username is invalid.",
-                 me.name, ERR_INVALIDUSERNAME, cptr->name);
-      sendto_one(cptr,
-                 ":%s %d %s :Connect with your real username, in lowercase.",
-                 me.name, ERR_INVALIDUSERNAME, cptr->name);
-      sendto_one(cptr, ":%s %d %s :If your mail address were foo@bar.com, "
-                 "your username would be foo.",
-                 me.name, ERR_INVALIDUSERNAME, cptr->name);
+
+      send_reply(cptr, SND_EXPLICIT | ERR_INVALIDUSERNAME,
+                ":Your username is invalid.");
+      send_reply(cptr, SND_EXPLICIT | ERR_INVALIDUSERNAME,
+                ":Connect with your real username, in lowercase.");
+      send_reply(cptr, SND_EXPLICIT | ERR_INVALIDUSERNAME,
+                ":If your mail address were foo@bar.com, your username "
+                "would be foo.");
       return exit_client(cptr, sptr, &me, "USER: Bad username");
     }
     Count_unknownbecomesclient(sptr, UserStats);
@@ -583,16 +627,6 @@ int register_user(struct Client *cptr, struct Client *sptr,
     nextping = CurrentTime;
     if (sptr->snomask & SNO_NOISY)
       set_snomask(sptr, sptr->snomask & SNO_NOISY, SNO_ADD);
-#ifdef ALLOW_SNO_CONNEXIT
-#ifdef SNO_CONNEXIT_IP
-    sendto_opmask_butone(0, SNO_CONNEXIT, "Client connecting: %s (%s@%s) "
-                        "[%s] {%d}", nick, user->username, user->host,
-                        cptr->sock_ip, get_client_class(sptr));
-#else /* SNO_CONNEXIT_IP */
-    sendto_opmask_butone(0, SNO_CONEXIT, "Client connecting: %s (%s@%s)",
-                        nick, user->username, user->host);
-#endif /* SNO_CONNEXIT_IP */
-#endif /* ALLOW_SNO_CONNEXIT */
     IPcheck_connect_succeeded(sptr);
   }
   else
@@ -813,8 +847,7 @@ int set_nick_name(struct Client* cptr, struct Client* sptr,
       do {
         sptr->cookie = (ircrandom() & 0x7fffffff);
       } while (!sptr->cookie);
-      /* XXX sendto_one used to send PING--must be very careful! */
-      sendto_one(cptr, "PING :%u", sptr->cookie);
+      sendrawto_one(cptr, MSG_PING " :%u", sptr->cookie);
     }
     else if (*sptr->user->host && sptr->cookie == COOKIE_VERIFIED) {
       /*
@@ -915,7 +948,7 @@ int check_target_limit(struct Client *sptr, void *target, const char *name,
     else {
 #ifdef GODMODE
       /* XXX Let's get rid of GODMODE */
-      sendto_one(sptr, ":%s NOTICE %s :New target: %s; ft " TIME_T_FMT,
+      sendto_one(sptr, ":%s NOTICE %s :New target: %s; ft " TIME_T_FMT, /* XXX Possibly DEAD */
           me.name, sptr->name, name, (CurrentTime - sptr->nexttarget) / TARGET_DELAY);
 #endif
       sptr->nexttarget += TARGET_DELAY;