added possibility for FAKEIDENTS (srvx initialized)
authorpk910 <philipp@zoelle1.de>
Sun, 17 Jul 2011 01:58:21 +0000 (03:58 +0200)
committerpk910 <philipp@zoelle1.de>
Sun, 17 Jul 2011 01:58:21 +0000 (03:58 +0200)
include/handlers.h
include/msg.h
include/numeric.h
ircd/m_fakehost.c
ircd/parse.c
ircd/s_err.c
ircd/s_user.c

index 8d522155f81199205a41c637a0d860daca0e6611..1fed4090b0c87142f727ccc80c781e29ef82a52e 100644 (file)
@@ -194,6 +194,7 @@ extern int ms_end_of_burst(struct Client*, struct Client*, int, char*[]);
 extern int ms_end_of_burst_ack(struct Client*, struct Client*, int, char*[]);
 extern int ms_error(struct Client*, struct Client*, int, char*[]);
 extern int ms_fakehost(struct Client*, struct Client*, int, char*[]);
+extern int ms_fakehost2(struct Client*, struct Client*, int, char*[]);
 extern int ms_fakehost_old(struct Client*, struct Client*, int, char*[]);
 extern int ms_gline(struct Client*, struct Client*, int, char*[]);
 extern int ms_hidehost(struct Client*, struct Client*, int, char*[]);
index a7448d6294ef04d2e6ecd0394bb80b8665023a1f..eae47662d6ceb9fba9b370d4b969985521fdc99e 100644 (file)
@@ -364,6 +364,10 @@ struct Client;
 #define TOK_FAKEHOST        "FH"
 #define CMD_FAKEHOST        MSG_FAKEHOST, TOK_FAKEHOST
 
+#define MSG_FAKEHOST2        "FAKEHOST2"
+#define TOK_FAKEHOST2        "FH2"
+#define CMD_FAKEHOST2        MSG_FAKEHOST2, TOK_FAKEHOST2
+
 #define MSG_FAKEHOST_OLD    "FAKE"
 #define TOK_FAKEHOST_OLD    "FA"
 #define CMD_FAKEHOST_OLD    MSG_FAKEHOST_OLD, TOK_FAKEHOST_OLD
index ba7affed7a296e409be4537eb01a92e1072bfc5c..ebabc1c6427ee440ff4551b30e47953233ac1102 100644 (file)
@@ -319,6 +319,7 @@ extern const struct Numeric* get_error_numeric(int err);
 /*      RPL_END_USERS        394        Dalnet/EFnet/IRCnet */
 /*      RPL_NOUSERS          395        Dalnet/EFnet/IRCnet */
 #define RPL_HOSTHIDDEN       396       /* UMODE +x completed succesfuly */
+#define RPL_HOSTIDENTHIDDEN  397       /* UMODE +x completed succesfuly (with USERNAME change) */
 
 /*
  * Errors are in the range from 400-599 currently and are grouped by what
index 7dd31fd0035b64e4d43811929b8f77035acc39a0..fa8ff3bef736c8e24ce6aa45af5eb127f0bfffb0 100644 (file)
@@ -267,6 +267,48 @@ int ms_fakehost(struct Client *cptr, struct Client *sptr, int parc, char *parv[]
     return 0;
 }
 
+/* ms_fakehost2 - new fakehost server message handler (SRVX initialized)
+ *
+ * parv[0] = sender prefix
+ * parv[1] = target user numeric
+ * parv[2] = target user's new ident
+ * parv[3] = target user's new fake host
+ * parv[4] = FORCE (optional)
+ */
+/** Remote fakehost
+ * Allows servers to force a fakehost on remote users.
+ *
+ * The FAKEHOST request can be generated by EVERY server. It is forwarded to the server
+ * of the user which then sets the fakehost and broadcasts the new fakehost.
+ */
+int ms_fakehost2(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) {
+    struct Client *target, *acptr;
+    int i;
+
+    if(parc < 4) {
+        return need_more_params(sptr, "FAKEHOST");
+    }
+
+    if(!(target = findNUser(parv[1]))) {
+        /* Silently ignore FAKEHOSTs for disconnected users. */
+        return 0;
+    }
+
+    /* Ignore the assignment if it changes nothing. */
+    if(IsFakeHost(target) && strcmp(cli_user(target)->fakehost, parv[3]) == 0 && strcmp(cli_user(target)->username, parv[2]) == 0) {
+        return 0;
+    }
+
+    /* Set fakehost and propagate the changed host. */
+    ircd_strncpy(cli_user(target)->username, parv[2], USERLEN);
+    ircd_strncpy(cli_user(target)->fakehost, parv[3], HOSTLEN);
+    hide_hostmask(target, FLAG_FAKEHOST);
+
+    sendcmdto_serv_butone(sptr, CMD_FAKEHOST2, cptr, "%C %s %s", target, parv[2], parv[3]);
+
+    return 0;
+}
+
 /*
  * ms_fakehost_old - old fakehost server message handler
  *
index 8a58d5bbaee199c4604924308848567c59fb62f2..49e656421a1a2b4a16b035fb5bf744adf27af3af 100644 (file)
@@ -633,6 +633,13 @@ struct Message msgtab[] = {
     /* UNREG, CLIENT, SERVER, OPER, SERVICE */
     { m_ignore, m_not_oper, ms_fakehost, m_fakehost, m_ignore }
   },
+  {
+    MSG_FAKEHOST2,
+    TOK_FAKEHOST2,
+    0, MAXPARA, MFLG_SLOW, 0, NULL,
+    /* UNREG, CLIENT, SERVER, OPER, SERVICE */
+    { m_ignore, m_ignore, ms_fakehost2, m_ignore, m_ignore }
+  },
   {
     MSG_FAKEHOST_OLD,
     TOK_FAKEHOST_OLD,
index 99501c6e024729d3b506480ad3cb04896cc11024..e08877159db2a738458e4c3025a300e2f0566192 100644 (file)
@@ -826,7 +826,7 @@ static Numeric replyTable[] = {
 /* 396 */
   { RPL_HOSTHIDDEN, "%s :is now your hidden host", "396" },
 /* 397 */
-  { 0 },
+  { RPL_HOSTIDENTHIDDEN, "%s@%s :is now your hidden username@host", "397" },
 /* 398 */
   { 0 },
 /* 399 */
index f8d5b94e15ed72ae3ca6b8b4552735106acf83c2..3855fbcd5d03b12eee93a0eea09c675c40a08f12 100644 (file)
@@ -972,8 +972,14 @@ void send_user_info(struct Client* sptr, char* names, int rpl, InfoFormatter fmt
  * @param[in] flag Some flag that affects host-hiding (FLAG_HIDDENHOST, FLAG_ACCOUNT, FLAG_FAKEHOST).
  * @return Zero.
  */
+
 int
-hide_hostmask(struct Client *cptr, unsigned int flag)
+hide_hostmask(struct Client *cptr, unsigned int flag) {
+  return hide_hostmask(chptr, flag, NULL);
+}
+
+int
+hide_hostmask(struct Client *cptr, unsigned int flag, char *username)
 {
   struct Membership *chan;
   char buf[HOSTLEN];
@@ -1018,9 +1024,17 @@ hide_hostmask(struct Client *cptr, unsigned int flag)
   sendcmdto_common_channels_butone(cptr, CMD_QUIT, cptr, ":Registered");
   ircd_strncpy(cli_user(cptr)->host, buf, HOSTLEN);
 
-  /* ok, the client is now fully hidden, so let them know -- hikari */
-  if (MyConnect(cptr))
-   send_reply(cptr, RPL_HOSTHIDDEN, cli_user(cptr)->host);
+  /* spoof also the username if username is passed */
+  if(username) {
+    ircd_strncpy(cli_user(cptr)->username, username, USERLEN);
+     /* ok, the client is now fully hidden, so let them know -- hikari */
+    if (MyConnect(cptr))
+      send_reply(cptr, RPL_HOSTUSERHIDDEN, cli_user(cptr)->username, cli_user(cptr)->host);
+  } else {
+    /* ok, the client is now fully hidden, so let them know -- hikari */
+    if (MyConnect(cptr))
+      send_reply(cptr, RPL_HOSTHIDDEN, cli_user(cptr)->host);
+  }
 
   /*
    * Go through all channels the client was on, rejoin him