summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/core/m_nick.c895
-rw-r--r--modules/core/m_server.c48
-rw-r--r--modules/m_help.c125
-rw-r--r--modules/m_set.c165
-rw-r--r--modules/m_version.c29
-rw-r--r--modules/m_wallops.c2
-rw-r--r--modules/m_whois.c219
7 files changed, 719 insertions, 764 deletions
diff --git a/modules/core/m_nick.c b/modules/core/m_nick.c
index bd86fd7..2e1c9b5 100644
--- a/modules/core/m_nick.c
+++ b/modules/core/m_nick.c
@@ -46,21 +46,124 @@
#include "s_misc.h"
-static void nick_from_server(struct Client *, struct Client *, int, char **,
- time_t, const char *, char *, char *);
-static void uid_from_server(struct Client *, struct Client *, int, char **,
- time_t, const char *, char *, char *);
-static int check_clean_nick(struct Client *client_p, struct Client *source_p,
- char *nick, struct Client *server_p);
-static int check_clean_user(struct Client *client_p, char *nick, char *user,
- struct Client *server_p);
-static int check_clean_host(struct Client *client_p, char *nick, char *host,
- struct Client *server_p);
-
-static int clean_user_name(const char *);
-static void perform_nick_collides(struct Client *, struct Client *, struct Client *,
- int, char **, time_t, const char *, char *, char *, char *);
+/* clean_user_name()
+ *
+ * input - username
+ * output - none
+ * side effects - walks through the username, returning 0 if erroneous
+ */
+static int
+clean_user_name(const char *user)
+{
+ const char *p = user;
+
+ assert(user && *user);
+
+ for (; *p; ++p)
+ if (!IsUserChar(*p))
+ return 0;
+
+ return p - user <= USERLEN;
+}
+
+/* check_clean_nick()
+ *
+ * input - pointer to source
+ * -
+ * - nickname
+ * - truncated nickname
+ * - origin of client
+ * - pointer to server nick is coming from
+ * output - none
+ * side effects - if nickname is erroneous, or a different length to
+ * truncated nickname, return 1
+ */
+static int
+check_clean_nick(struct Client *client_p, struct Client *source_p,
+ char *nick, struct Client *server_p)
+{
+ /* the old code did some wacky stuff here, if the nick is invalid, kill it
+ * and dont bother messing at all
+ */
+ if (!valid_nickname(nick, 0))
+ {
+ ++ServerStats.is_kill;
+ sendto_realops_flags(UMODE_DEBUG, L_ALL, SEND_NOTICE,
+ "Bad/long Nick: %s From: %s(via %s)",
+ nick, server_p->name, client_p->name);
+
+ sendto_one(client_p, ":%s KILL %s :%s (Bad Nickname)",
+ me.name, nick, me.name);
+
+ /* bad nick change */
+ if (source_p != client_p)
+ {
+ kill_client_ll_serv_butone(client_p, source_p,
+ "%s (Bad Nickname)",
+ me.name);
+ AddFlag(source_p, FLAGS_KILLED);
+ exit_client(source_p, &me, "Bad Nickname");
+ }
+
+ return 1;
+ }
+ return 0;
+}
+
+/* check_clean_user()
+ *
+ * input - pointer to client sending data
+ * - nickname
+ * - username to check
+ * - origin of NICK
+ * output - none
+ * side effects - if username is erroneous, return 1
+ */
+static int
+check_clean_user(struct Client *client_p, char *nick,
+ char *user, struct Client *server_p)
+{
+ if (!clean_user_name(user))
+ {
+ ++ServerStats.is_kill;
+ sendto_realops_flags(UMODE_DEBUG, L_ALL, SEND_NOTICE,
+ "Bad/Long Username: %s Nickname: %s From: %s(via %s)",
+ user, nick, server_p->name, client_p->name);
+ sendto_one(client_p, ":%s KILL %s :%s (Bad Username)",
+ me.name, nick, me.name);
+ return 1;
+ }
+
+ return 0;
+}
+
+/* check_clean_host()
+ *
+ * input - pointer to client sending us data
+ * - nickname
+ * - hostname to check
+ * - source name
+ * output - none
+ * side effects - if hostname is erroneous, return 1
+ */
+static int
+check_clean_host(struct Client *client_p, char *nick,
+ char *host, struct Client *server_p)
+{
+ if (!valid_hostname(host))
+ {
+ ++ServerStats.is_kill;
+ sendto_realops_flags(UMODE_DEBUG, L_ALL, SEND_NOTICE,
+ "Bad/Long Hostname: %s Nickname: %s From: %s(via %s)",
+ host, nick, server_p->name, client_p->name);
+ sendto_one(client_p, ":%s KILL %s :%s (Bad Hostname)",
+ me.name, nick, me.name);
+ return 1;
+ }
+
+ return 0;
+}
/* set_initial_nick()
*
@@ -176,6 +279,317 @@ change_local_nick(struct Client *source_p, const char *nick)
nick, ConfigFileEntry.max_nick_time);
}
+/*
+ * nick_from_server()
+ */
+static void
+nick_from_server(struct Client *client_p, struct Client *source_p, int parc,
+ char *parv[], time_t newts, const char *svsid, char *nick, char *ngecos)
+{
+ int samenick = 0;
+
+ if (IsServer(source_p))
+ {
+ /* A server introducing a new client, change source */
+ source_p = make_client(client_p);
+ dlinkAdd(source_p, &source_p->node, &global_client_list);
+
+ if (parc > 2)
+ source_p->hopcount = atoi(parv[2]);
+ if (newts)
+ source_p->tsinfo = newts;
+ else
+ {
+ newts = source_p->tsinfo = CurrentTime;
+ ts_warn("Remote nick %s (%s) introduced without a TS", nick, parv[0]);
+ }
+
+ strlcpy(source_p->svid, svsid, sizeof(source_p->svid));
+ strlcpy(source_p->info, ngecos, sizeof(source_p->info));
+ /* copy the nick in place */
+ strlcpy(source_p->name, nick, sizeof(source_p->name));
+ hash_add_client(source_p);
+
+ if (parc > 8)
+ {
+ const char *m;
+
+ /* parse usermodes */
+ for (m = &parv[4][1]; *m; ++m)
+ {
+ unsigned int flag = user_modes[(unsigned char)*m];
+
+ if ((flag & UMODE_INVISIBLE) && !HasUMode(source_p, UMODE_INVISIBLE))
+ ++Count.invisi;
+ if ((flag & UMODE_OPER) && !HasUMode(source_p, UMODE_OPER))
+ ++Count.oper;
+
+ source_p->umodes |= flag & SEND_UMODES;
+ }
+
+ register_remote_user(source_p, parv[5], parv[6],
+ parv[7], ngecos);
+ return;
+ }
+ }
+ else if (source_p->name[0])
+ {
+ samenick = !irccmp(source_p->name, nick);
+
+ /* client changing their nick */
+ if (!samenick)
+ {
+ DelUMode(source_p, UMODE_REGISTERED);
+ watch_check_hash(source_p, RPL_LOGOFF);
+ source_p->tsinfo = newts ? newts : CurrentTime;
+ }
+
+ sendto_common_channels_local(source_p, 1, 0, ":%s!%s@%s NICK :%s",
+ source_p->name,source_p->username,
+ source_p->host, nick);
+
+ add_history(source_p, 1);
+ sendto_server(client_p, CAP_TS6, NOCAPS,
+ ":%s NICK %s :%lu",
+ ID(source_p), nick, (unsigned long)source_p->tsinfo);
+ sendto_server(client_p, NOCAPS, CAP_TS6,
+ ":%s NICK %s :%lu",
+ source_p->name, nick, (unsigned long)source_p->tsinfo);
+ }
+
+ /* set the new nick name */
+ if (source_p->name[0])
+ hash_del_client(source_p);
+
+ strlcpy(source_p->name, nick, sizeof(source_p->name));
+ hash_add_client(source_p);
+
+ if (!samenick)
+ watch_check_hash(source_p, RPL_LOGON);
+}
+
+/*
+ * client_from_server()
+ */
+static void
+uid_from_server(struct Client *client_p, struct Client *source_p, int parc,
+ char *parv[], time_t newts, const char *svsid, char *nick, char *ugecos)
+{
+ const char *m = NULL;
+ const char *servername = source_p->name;
+
+ source_p = make_client(client_p);
+ dlinkAdd(source_p, &source_p->node, &global_client_list);
+
+ source_p->hopcount = atoi(parv[2]);
+ source_p->tsinfo = newts;
+ strlcpy(source_p->svid, svsid, sizeof(source_p->svid));
+
+ /* copy the nick in place */
+ strcpy(source_p->name, nick);
+ strlcpy(source_p->id, parv[8], sizeof(source_p->id));
+ strlcpy(source_p->sockhost, parv[7], sizeof(source_p->sockhost));
+ strlcpy(source_p->info, ugecos, sizeof(source_p->info));
+
+ hash_add_client(source_p);
+ hash_add_id(source_p);
+
+ /* parse usermodes */
+ for (m = &parv[4][1]; *m; ++m)
+ {
+ unsigned int flag = user_modes[(unsigned char)*m];
+
+ if ((flag & UMODE_INVISIBLE) && !HasUMode(source_p, UMODE_INVISIBLE))
+ ++Count.invisi;
+ if ((flag & UMODE_OPER) && !HasUMode(source_p, UMODE_OPER))
+ ++Count.oper;
+
+ source_p->umodes |= flag & SEND_UMODES;
+ }
+
+ register_remote_user(source_p, parv[5], parv[6],
+ servername, ugecos);
+}
+
+static void
+perform_nick_collides(struct Client *source_p, struct Client *client_p,
+ struct Client *target_p, int parc, char *parv[],
+ time_t newts, const char *svsid, char *nick, char *gecos, char *uid)
+{
+ int sameuser;
+
+ /* server introducing new nick */
+ if (IsServer(source_p))
+ {
+ /* if we dont have a ts, or their TS's are the same, kill both */
+ if (!newts || !target_p->tsinfo || (newts == target_p->tsinfo))
+ {
+ sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
+ "Nick collision on %s(%s <- %s)(both killed)",
+ target_p->name, target_p->from->name,
+ client_p->name);
+
+ /* if we have a UID, issue a kill for it */
+ if (uid)
+ sendto_one(client_p, ":%s KILL %s :%s (Nick collision (new))",
+ me.id, uid, me.name);
+
+ kill_client_ll_serv_butone(NULL, target_p,
+ "%s (Nick collision (new))",
+ me.name);
+ ++ServerStats.is_kill;
+ sendto_one(target_p, form_str(ERR_NICKCOLLISION),
+ me.name, target_p->name, target_p->name);
+
+ AddFlag(target_p, FLAGS_KILLED);
+ exit_client(target_p, &me, "Nick collision (new)");
+ return;
+ }
+ /* the timestamps are different */
+ else
+ {
+ sameuser = !irccmp(target_p->username, parv[5]) &&
+ !irccmp(target_p->host, parv[6]);
+
+ /* if the users are the same (loaded a client on a different server)
+ * and the new users ts is older, or the users are different and the
+ * new users ts is newer, ignore the new client and let it do the kill
+ */
+ if ((sameuser && newts < target_p->tsinfo) ||
+ (!sameuser && newts > target_p->tsinfo))
+ {
+ if (uid)
+ sendto_one(client_p, ":%s KILL %s :%s (Nick collision (new))",
+ me.id, uid, me.name);
+ return;
+ }
+ else
+ {
+ if (sameuser)
+ sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
+ "Nick collision on %s(%s <- %s)(older killed)",
+ target_p->name, target_p->from->name,
+ client_p->name);
+ else
+ sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
+ "Nick collision on %s(%s <- %s)(newer killed)",
+ target_p->name, target_p->from->name,
+ client_p->name);
+
+ ++ServerStats.is_kill;
+ sendto_one(target_p, form_str(ERR_NICKCOLLISION),
+ me.name, target_p->name, target_p->name);
+
+ /* if it came from a LL server, itd have been source_p,
+ * so we dont need to mark target_p as known
+ */
+ kill_client_ll_serv_butone(source_p, target_p,
+ "%s (Nick collision (new))",
+ me.name);
+
+ AddFlag(target_p, FLAGS_KILLED);
+ exit_client(target_p, &me, "Nick collision");
+
+ if (!uid && (parc == 9 || parc == 10))
+ nick_from_server(client_p, source_p, parc, parv, newts, svsid, nick, gecos);
+ else if (uid && (parc == 10 || parc == 11))
+ uid_from_server(client_p, source_p, parc, parv, newts, svsid, nick, gecos);
+
+ return;
+ }
+ }
+ }
+
+ /* its a client changing nick and causing a collide */
+ if (!newts || !target_p->tsinfo || (newts == target_p->tsinfo))
+ {
+ sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
+ "Nick change collision from %s to %s(%s <- %s)(both killed)",
+ source_p->name, target_p->name, target_p->from->name,
+ client_p->name);
+
+ sendto_one(target_p, form_str(ERR_NICKCOLLISION), me.name,
+ target_p->name, target_p->name);
+
+ ++ServerStats.is_kill;
+ kill_client_ll_serv_butone(NULL, source_p, "%s (Nick change collision)",
+ me.name);
+
+ ++ServerStats.is_kill;
+ kill_client_ll_serv_butone(NULL, target_p, "%s (Nick change collision)",
+ me.name);
+
+ AddFlag(target_p, FLAGS_KILLED);
+ exit_client(target_p, &me, "Nick collision (new)");
+
+ AddFlag(source_p, FLAGS_KILLED);
+ exit_client(source_p, &me, "Nick collision (old)");
+ return;
+ }
+ else
+ {
+ sameuser = !irccmp(target_p->username, source_p->username) &&
+ !irccmp(target_p->host, source_p->host);
+
+ if ((sameuser && newts < target_p->tsinfo) ||
+ (!sameuser && newts > target_p->tsinfo))
+ {
+ if (sameuser)
+ sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
+ "Nick change collision from %s to %s(%s <- %s)(older killed)",
+ source_p->name, target_p->name, target_p->from->name,
+ client_p->name);
+ else
+ sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
+ "Nick change collision from %s to %s(%s <- %s)(newer killed)",
+ source_p->name, target_p->name, target_p->from->name,
+ client_p->name);
+
+ ++ServerStats.is_kill;
+ kill_client_ll_serv_butone(client_p, source_p,
+ "%s (Nick change collision)",
+ me.name);
+
+ AddFlag(source_p, FLAGS_KILLED);
+
+ if (sameuser)
+ exit_client(source_p, &me, "Nick collision (old)");
+ else
+ exit_client(source_p, &me, "Nick collision (new)");
+ return;
+ }
+ else
+ {
+ if (sameuser)
+ sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
+ "Nick collision on %s(%s <- %s)(older killed)",
+ target_p->name, target_p->from->name,
+ client_p->name);
+ else
+ sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
+ "Nick collision on %s(%s <- %s)(newer killed)",
+ target_p->name, target_p->from->name,
+ client_p->name);
+
+ kill_client_ll_serv_butone(source_p, target_p,
+ "%s (Nick collision)",
+ me.name);
+
+ ++ServerStats.is_kill;
+ sendto_one(target_p, form_str(ERR_NICKCOLLISION),
+ me.name, target_p->name, target_p->name);
+
+ AddFlag(target_p, FLAGS_KILLED);
+ exit_client(target_p, &me, "Nick collision");
+ }
+ }
+
+ /* we should only ever call nick_from_server() here, as
+ * this is a client changing nick, not a new client
+ */
+ nick_from_server(client_p, source_p, parc, parv, newts, svsid, nick, gecos);
+}
+
/*! \brief NICK command handler (called by unregistered,
* locally connected clients)
*
@@ -242,7 +656,6 @@ mr_nick(struct Client *client_p, struct Client *source_p,
sendto_one(source_p, form_str(ERR_NICKNAMEINUSE), me.name, "*", nick);
}
-
/*! \brief NICK command handler (called by already registered,
* locally connected clients)
*
@@ -330,7 +743,6 @@ m_nick(struct Client *client_p, struct Client *source_p,
source_p->name, nick);
}
-
/*! \brief NICK command handler (called by servers and remotely
* connected clients)
*
@@ -389,8 +801,8 @@ ms_nick(struct Client *client_p, struct Client *source_p,
if (server_p == NULL)
{
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
- "Invalid server %s from %s for NICK %s",
- parv[7], source_p->name, parv[1]);
+ "Invalid server %s from %s for NICK %s",
+ parv[7], source_p->name, parv[1]);
sendto_one(client_p, ":%s KILL %s :%s (Server doesn't exist!)",
me.name, parv[1], me.name);
return;
@@ -398,7 +810,7 @@ ms_nick(struct Client *client_p, struct Client *source_p,
if (check_clean_nick(client_p, source_p, parv[1], server_p) ||
check_clean_user(client_p, parv[1], parv[5], server_p) ||
- check_clean_host(client_p, parv[1], parv[6], server_p))
+ check_clean_host(client_p, parv[1], parv[6], server_p))
return;
if (IsServer(source_p))
@@ -413,10 +825,10 @@ ms_nick(struct Client *client_p, struct Client *source_p,
return;
if (check_clean_nick(client_p, source_p, parv[1],
- source_p->servptr))
+ source_p->servptr))
return;
- newts = atol(parv[2]);
+ newts = atol(parv[2]);
}
/* if the nick doesnt exist, allow it and process like normal */
@@ -438,7 +850,6 @@ ms_nick(struct Client *client_p, struct Client *source_p,
newts, svsid, parv[1], parv[parc-1], NULL);
}
-
/*! \brief UID command handler (called by servers)
*
* \param client_p Pointer to allocated Client struct with physical connection
@@ -502,18 +913,18 @@ ms_uid(struct Client *client_p, struct Client *source_p,
if ((target_p = hash_find_id(parv[8])) != NULL)
{
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
- "ID collision on %s(%s <- %s)(both killed)",
- target_p->name, target_p->from->name,
- client_p->name);
+ "ID collision on %s(%s <- %s)(both killed)",
+ target_p->name, target_p->from->name,
+ client_p->name);
kill_client_ll_serv_butone(NULL, target_p, "%s (ID collision)",
- me.name);
+ me.name);
++ServerStats.is_kill;
AddFlag(target_p, FLAGS_KILLED);
exit_client(target_p, &me, "ID Collision");
return;
}
-
+
if ((target_p = hash_find_client(parv[1])) == NULL)
uid_from_server(client_p, source_p, parc, parv, newts, svsid, parv[1], parv[parc-1]);
else if (IsUnknown(target_p))
@@ -524,436 +935,6 @@ ms_uid(struct Client *client_p, struct Client *source_p,
else
perform_nick_collides(source_p, client_p, target_p, parc, parv, newts, svsid, parv[1],
parv[parc-1], parv[8]);
-}
-
-/* check_clean_nick()
- *
- * input - pointer to source
- * -
- * - nickname
- * - truncated nickname
- * - origin of client
- * - pointer to server nick is coming from
- * output - none
- * side effects - if nickname is erroneous, or a different length to
- * truncated nickname, return 1
- */
-static int
-check_clean_nick(struct Client *client_p, struct Client *source_p,
- char *nick, struct Client *server_p)
-{
- /* the old code did some wacky stuff here, if the nick is invalid, kill it
- * and dont bother messing at all
- */
- if (!valid_nickname(nick, 0))
- {
- ++ServerStats.is_kill;
- sendto_realops_flags(UMODE_DEBUG, L_ALL, SEND_NOTICE,
- "Bad/long Nick: %s From: %s(via %s)",
- nick, server_p->name, client_p->name);
-
- sendto_one(client_p, ":%s KILL %s :%s (Bad Nickname)",
- me.name, nick, me.name);
-
- /* bad nick change */
- if (source_p != client_p)
- {
- kill_client_ll_serv_butone(client_p, source_p,
- "%s (Bad Nickname)",
- me.name);
- AddFlag(source_p, FLAGS_KILLED);
- exit_client(source_p, &me, "Bad Nickname");
- }
-
- return 1;
- }
-
- return 0;
-}
-
-/* check_clean_user()
- *
- * input - pointer to client sending data
- * - nickname
- * - username to check
- * - origin of NICK
- * output - none
- * side effects - if username is erroneous, return 1
- */
-static int
-check_clean_user(struct Client *client_p, char *nick,
- char *user, struct Client *server_p)
-{
- if (!clean_user_name(user))
- {
- ++ServerStats.is_kill;
- sendto_realops_flags(UMODE_DEBUG, L_ALL, SEND_NOTICE,
- "Bad/Long Username: %s Nickname: %s From: %s(via %s)",
- user, nick, server_p->name, client_p->name);
- sendto_one(client_p, ":%s KILL %s :%s (Bad Username)",
- me.name, nick, me.name);
- return 1;
- }
-
- return 0;
-}
-
-/* check_clean_host()
- *
- * input - pointer to client sending us data
- * - nickname
- * - hostname to check
- * - source name
- * output - none
- * side effects - if hostname is erroneous, return 1
- */
-static int
-check_clean_host(struct Client *client_p, char *nick,
- char *host, struct Client *server_p)
-{
- if (!valid_hostname(host))
- {
- ++ServerStats.is_kill;
- sendto_realops_flags(UMODE_DEBUG, L_ALL, SEND_NOTICE,
- "Bad/Long Hostname: %s Nickname: %s From: %s(via %s)",
- host, nick, server_p->name, client_p->name);
- sendto_one(client_p, ":%s KILL %s :%s (Bad Hostname)",
- me.name, nick, me.name);
- return 1;
- }
-
- return 0;
-}
-
-/* clean_user_name()
- *
- * input - username
- * output - none
- * side effects - walks through the username, returning 0 if erroneous
- */
-static int
-clean_user_name(const char *user)
-{
- const char *p = user;
-
- assert(user && *user);
-
- for (; *p; ++p)
- if (!IsUserChar(*p))
- return 0;
-
- return p - user <= USERLEN;
-}
-
-/*
- * nick_from_server()
- */
-static void
-nick_from_server(struct Client *client_p, struct Client *source_p, int parc,
- char *parv[], time_t newts, const char *svsid, char *nick, char *ngecos)
-{
- int samenick = 0;
-
- if (IsServer(source_p))
- {
- /* A server introducing a new client, change source */
- source_p = make_client(client_p);
- dlinkAdd(source_p, &source_p->node, &global_client_list);
-
- if (parc > 2)
- source_p->hopcount = atoi(parv[2]);
- if (newts)
- source_p->tsinfo = newts;
- else
- {
- newts = source_p->tsinfo = CurrentTime;
- ts_warn("Remote nick %s (%s) introduced without a TS", nick, parv[0]);
- }
-
- strlcpy(source_p->svid, svsid, sizeof(source_p->svid));
- strlcpy(source_p->info, ngecos, sizeof(source_p->info));
- /* copy the nick in place */
- strlcpy(source_p->name, nick, sizeof(source_p->name));
- hash_add_client(source_p);
-
- if (parc > 8)
- {
- const char *m;
-
- /* parse usermodes */
- for (m = &parv[4][1]; *m; ++m)
- {
- unsigned int flag = user_modes[(unsigned char)*m];
-
- if ((flag & UMODE_INVISIBLE) && !HasUMode(source_p, UMODE_INVISIBLE))
- ++Count.invisi;
- if ((flag & UMODE_OPER) && !HasUMode(source_p, UMODE_OPER))
- ++Count.oper;
-
- source_p->umodes |= flag & SEND_UMODES;
- }
-
- register_remote_user(source_p, parv[5], parv[6],
- parv[7], ngecos);
- return;
- }
- }
- else if (source_p->name[0])
- {
- samenick = !irccmp(source_p->name, nick);
-
- /* client changing their nick */
- if (!samenick)
- {
- DelUMode(source_p, UMODE_REGISTERED);
- watch_check_hash(source_p, RPL_LOGOFF);
- source_p->tsinfo = newts ? newts : CurrentTime;
- }
-
- sendto_common_channels_local(source_p, 1, 0, ":%s!%s@%s NICK :%s",
- source_p->name,source_p->username,
- source_p->host, nick);
-
- add_history(source_p, 1);
- sendto_server(client_p, CAP_TS6, NOCAPS,
- ":%s NICK %s :%lu",
- ID(source_p), nick, (unsigned long)source_p->tsinfo);
- sendto_server(client_p, NOCAPS, CAP_TS6,
- ":%s NICK %s :%lu",
- source_p->name, nick, (unsigned long)source_p->tsinfo);
- }
-
- /* set the new nick name */
- if (source_p->name[0])
- hash_del_client(source_p);
-
- strlcpy(source_p->name, nick, sizeof(source_p->name));
- hash_add_client(source_p);
-
- if (!samenick)
- watch_check_hash(source_p, RPL_LOGON);
-}
-
-/*
- * client_from_server()
- */
-static void
-uid_from_server(struct Client *client_p, struct Client *source_p, int parc,
- char *parv[], time_t newts, const char *svsid, char *nick, char *ugecos)
-{
- const char *m = NULL;
- const char *servername = source_p->name;
-
- source_p = make_client(client_p);
- dlinkAdd(source_p, &source_p->node, &global_client_list);
-
- source_p->hopcount = atoi(parv[2]);
- source_p->tsinfo = newts;
- strlcpy(source_p->svid, svsid, sizeof(source_p->svid));
-
- /* copy the nick in place */
- strcpy(source_p->name, nick);
- strlcpy(source_p->id, parv[8], sizeof(source_p->id));
- strlcpy(source_p->sockhost, parv[7], sizeof(source_p->sockhost));
- strlcpy(source_p->info, ugecos, sizeof(source_p->info));
-
- hash_add_client(source_p);
- hash_add_id(source_p);
-
- /* parse usermodes */
- for (m = &parv[4][1]; *m; ++m)
- {
- unsigned int flag = user_modes[(unsigned char)*m];
-
- if ((flag & UMODE_INVISIBLE) && !HasUMode(source_p, UMODE_INVISIBLE))
- ++Count.invisi;
- if ((flag & UMODE_OPER) && !HasUMode(source_p, UMODE_OPER))
- ++Count.oper;
-
- source_p->umodes |= flag & SEND_UMODES;
- }
-
- register_remote_user(source_p, parv[5], parv[6],
- servername, ugecos);
-}
-
-static void
-perform_nick_collides(struct Client *source_p, struct Client *client_p,
- struct Client *target_p, int parc, char *parv[],
- time_t newts, const char *svsid, char *nick, char *gecos, char *uid)
-{
- int sameuser;
-
- /* server introducing new nick */
- if (IsServer(source_p))
- {
- /* if we dont have a ts, or their TS's are the same, kill both */
- if (!newts || !target_p->tsinfo || (newts == target_p->tsinfo))
- {
- sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
- "Nick collision on %s(%s <- %s)(both killed)",
- target_p->name, target_p->from->name,
- client_p->name);
-
- /* if we have a UID, issue a kill for it */
- if (uid)
- sendto_one(client_p, ":%s KILL %s :%s (Nick collision (new))",
- me.id, uid, me.name);
-
- kill_client_ll_serv_butone(NULL, target_p,
- "%s (Nick collision (new))",
- me.name);
- ++ServerStats.is_kill;
- sendto_one(target_p, form_str(ERR_NICKCOLLISION),
- me.name, target_p->name, target_p->name);
-
- AddFlag(target_p, FLAGS_KILLED);
- exit_client(target_p, &me, "Nick collision (new)");
- return;
- }
- /* the timestamps are different */
- else
- {
- sameuser = !irccmp(target_p->username, parv[5]) &&
- !irccmp(target_p->host, parv[6]);
-
- /* if the users are the same (loaded a client on a different server)
- * and the new users ts is older, or the users are different and the
- * new users ts is newer, ignore the new client and let it do the kill
- */
- if ((sameuser && newts < target_p->tsinfo) ||
- (!sameuser && newts > target_p->tsinfo))
- {
- if (uid)
- sendto_one(client_p, ":%s KILL %s :%s (Nick collision (new))",
- me.id, uid, me.name);
- return;
- }
- else
- {
- if (sameuser)
- sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
- "Nick collision on %s(%s <- %s)(older killed)",
- target_p->name, target_p->from->name,
- client_p->name);
- else
- sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
- "Nick collision on %s(%s <- %s)(newer killed)",
- target_p->name, target_p->from->name,
- client_p->name);
-
- ++ServerStats.is_kill;
- sendto_one(target_p, form_str(ERR_NICKCOLLISION),
- me.name, target_p->name, target_p->name);
-
- /* if it came from a LL server, itd have been source_p,
- * so we dont need to mark target_p as known
- */
- kill_client_ll_serv_butone(source_p, target_p,
- "%s (Nick collision (new))",
- me.name);
-
- AddFlag(target_p, FLAGS_KILLED);
- exit_client(target_p, &me, "Nick collision");
-
- if (!uid && (parc == 9 || parc == 10))
- nick_from_server(client_p, source_p, parc, parv, newts, svsid, nick, gecos);
- else if (uid && (parc == 10 || parc == 11))
- uid_from_server(client_p, source_p, parc, parv, newts, svsid, nick, gecos);
-
- return;
- }
- }
- }
-
- /* its a client changing nick and causing a collide */
- if (!newts || !target_p->tsinfo || (newts == target_p->tsinfo))
- {
- sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
- "Nick change collision from %s to %s(%s <- %s)(both killed)",
- source_p->name, target_p->name, target_p->from->name,
- client_p->name);
-
- sendto_one(target_p, form_str(ERR_NICKCOLLISION), me.name,
- target_p->name, target_p->name);
-
- ++ServerStats.is_kill;
- kill_client_ll_serv_butone(NULL, source_p, "%s (Nick change collision)",
- me.name);
-
- ++ServerStats.is_kill;
- kill_client_ll_serv_butone(NULL, target_p, "%s (Nick change collision)",
- me.name);
-
- AddFlag(target_p, FLAGS_KILLED);
- exit_client(target_p, &me, "Nick collision (new)");
-
- AddFlag(source_p, FLAGS_KILLED);
- exit_client(source_p, &me, "Nick collision (old)");
- return;
- }
- else
- {
- sameuser = !irccmp(target_p->username, source_p->username) &&
- !irccmp(target_p->host, source_p->host);
-
- if ((sameuser && newts < target_p->tsinfo) ||
- (!sameuser && newts > target_p->tsinfo))
- {
- if (sameuser)
- sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
- "Nick change collision from %s to %s(%s <- %s)(older killed)",
- source_p->name, target_p->name, target_p->from->name,
- client_p->name);
- else
- sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
- "Nick change collision from %s to %s(%s <- %s)(newer killed)",
- source_p->name, target_p->name, target_p->from->name,
- client_p->name);
-
- ++ServerStats.is_kill;
- kill_client_ll_serv_butone(client_p, source_p,
- "%s (Nick change collision)",
- me.name);
-
- AddFlag(source_p, FLAGS_KILLED);
-
- if (sameuser)
- exit_client(source_p, &me, "Nick collision (old)");
- else
- exit_client(source_p, &me, "Nick collision (new)");
- return;
- }
- else
- {
- if (sameuser)
- sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
- "Nick collision on %s(%s <- %s)(older killed)",
- target_p->name, target_p->from->name,
- client_p->name);
- else
- sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
- "Nick collision on %s(%s <- %s)(newer killed)",
- target_p->name, target_p->from->name,
- client_p->name);
-
- kill_client_ll_serv_butone(source_p, target_p,
- "%s (Nick collision)",
- me.name);
-
- ++ServerStats.is_kill;
- sendto_one(target_p, form_str(ERR_NICKCOLLISION),
- me.name, target_p->name, target_p->name);
-
- AddFlag(target_p, FLAGS_KILLED);
- exit_client(target_p, &me, "Nick collision");
- }
- }
-
- /* we should only ever call nick_from_server() here, as
- * this is a client changing nick, not a new client
- */
- nick_from_server(client_p, source_p, parc, parv, newts, svsid, nick, gecos);
}
static struct Message nick_msgtab = {
diff --git a/modules/core/m_server.c b/modules/core/m_server.c
index 39fecd5..f869a37 100644
--- a/modules/core/m_server.c
+++ b/modules/core/m_server.c
@@ -39,7 +39,29 @@
#include "modules.h"
-static void set_server_gecos(struct Client *, const char *);
+/* set_server_gecos()
+ *
+ * input - pointer to client
+ * output - NONE
+ * side effects - servers gecos field is set
+ */
+static void
+set_server_gecos(struct Client *client_p, const char *info)
+{
+ const char *s = info;
+
+ /* check for (H) which is a hidden server */
+ if (!strncmp(s, "(H) ", 4))
+ {
+ SetHidden(client_p);
+ s = s + 4;
+ }
+
+ if (!EmptyString(s))
+ strlcpy(client_p->info, s, sizeof(client_p->info));
+ else
+ strlcpy(client_p->info, "(Unknown Location)", sizeof(client_p->info));
+}
/* mr_server()
* parv[0] = sender prefix
@@ -569,30 +591,6 @@ ms_sid(struct Client *client_p, struct Client *source_p,
target_p->name, source_p->name);
}
-/* set_server_gecos()
- *
- * input - pointer to client
- * output - NONE
- * side effects - servers gecos field is set
- */
-static void
-set_server_gecos(struct Client *client_p, const char *info)
-{
- const char *s = info;
-
- /* check for (H) which is a hidden server */
- if (!strncmp(s, "(H) ", 4))
- {
- SetHidden(client_p);
- s = s + 4;
- }
-
- if (!EmptyString(s))
- strlcpy(client_p->info, s, sizeof(client_p->info));
- else
- strlcpy(client_p->info, "(Unknown Location)", sizeof(client_p->info));
-}
-
static struct Message server_msgtab = {
"SERVER", 0, 0, 4, MAXPARA, MFLG_SLOW, 0,
{mr_server, m_registered, ms_server, m_ignore, m_registered, m_ignore}
diff --git a/modules/m_help.c b/modules/m_help.c
index c104f0c..126c6fe 100644
--- a/modules/m_help.c
+++ b/modules/m_help.c
@@ -34,55 +34,42 @@
#define HELPLEN 400
-static void dohelp(struct Client *, const char *, char *);
-static void sendhelpfile(struct Client *, const char *, const char *);
-
-/*
- * m_help - HELP message handler
- * parv[0] = sender prefix
- */
static void
-m_help(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+sendhelpfile(struct Client *source_p, const char *path, const char *topic)
{
- static time_t last_used = 0;
+ FILE *file;
+ char line[HELPLEN];
- /* HELP is always local */
- if ((last_used + ConfigFileEntry.pace_wait_simple) > CurrentTime)
+ if ((file = fopen(path, "r")) == NULL)
{
- /* safe enough to give this on a local connect only */
- sendto_one(source_p,form_str(RPL_LOAD2HI),
- me.name, source_p->name);
+ sendto_one(source_p, form_str(ERR_HELPNOTFOUND),
+ me.name, source_p->name, topic);
return;
}
- last_used = CurrentTime;
+ if (fgets(line, sizeof(line), file) == NULL)
+ {
+ sendto_one(source_p, form_str(ERR_HELPNOTFOUND),
+ me.name, source_p->name, topic);
+ return;
+ }
- dohelp(source_p, UHPATH, parv[1]);
-}
+ line[strlen(line) - 1] = '\0';
+ sendto_one(source_p, form_str(RPL_HELPSTART),
+ me.name, source_p->name, topic, line);
-/*
- * mo_help - HELP message handler
- * parv[0] = sender prefix
- */
-static void
-mo_help(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
-{
- dohelp(source_p, HPATH, parv[1]);
-}
+ while (fgets(line, sizeof(line), file))
+ {
+ line[strlen(line) - 1] = '\0';
-/*
- * mo_uhelp - HELP message handler
- * This is used so that opers can view the user help file without deopering
- * parv[0] = sender prefix
- */
-static void
-mo_uhelp(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
-{
- dohelp(source_p, UHPATH, parv[1]);
+ sendto_one(source_p, form_str(RPL_HELPTXT),
+ me.name, source_p->name, topic, line);
+ }
+
+ fclose(file);
+ sendto_one(source_p, form_str(RPL_ENDOFHELP),
+ me.name, source_p->name, topic);
}
static void
@@ -132,41 +119,51 @@ dohelp(struct Client *source_p, const char *hpath, char *topic)
sendhelpfile(source_p, path, topic);
}
-static void
-sendhelpfile(struct Client *source_p, const char *path, const char *topic)
+/*
+ * m_help - HELP message handler
+ * parv[0] = sender prefix
+ */
+static void
+m_help(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
{
- FILE *file;
- char line[HELPLEN];
-
- if ((file = fopen(path, "r")) == NULL)
- {
- sendto_one(source_p, form_str(ERR_HELPNOTFOUND),
- me.name, source_p->name, topic);
- return;
- }
+ static time_t last_used = 0;
- if (fgets(line, sizeof(line), file) == NULL)
+ /* HELP is always local */
+ if ((last_used + ConfigFileEntry.pace_wait_simple) > CurrentTime)
{
- sendto_one(source_p, form_str(ERR_HELPNOTFOUND),
- me.name, source_p->name, topic);
+ /* safe enough to give this on a local connect only */
+ sendto_one(source_p,form_str(RPL_LOAD2HI),
+ me.name, source_p->name);
return;
}
- line[strlen(line) - 1] = '\0';
- sendto_one(source_p, form_str(RPL_HELPSTART),
- me.name, source_p->name, topic, line);
+ last_used = CurrentTime;
- while (fgets(line, sizeof(line), file))
- {
- line[strlen(line) - 1] = '\0';
+ dohelp(source_p, UHPATH, parv[1]);
+}
- sendto_one(source_p, form_str(RPL_HELPTXT),
- me.name, source_p->name, topic, line);
- }
+/*
+ * mo_help - HELP message handler
+ * parv[0] = sender prefix
+ */
+static void
+mo_help(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
+{
+ dohelp(source_p, HPATH, parv[1]);
+}
- fclose(file);
- sendto_one(source_p, form_str(RPL_ENDOFHELP),
- me.name, source_p->name, topic);
+/*
+ * mo_uhelp - HELP message handler
+ * This is used so that opers can view the user help file without deopering
+ * parv[0] = sender prefix
+ */
+static void
+mo_uhelp(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
+{
+ dohelp(source_p, UHPATH, parv[1]);
}
static struct Message help_msgtab = {
diff --git a/modules/m_set.c b/modules/m_set.c
index ddd19a7..28d2bf0 100644
--- a/modules/m_set.c
+++ b/modules/m_set.c
@@ -42,96 +42,6 @@
#include "s_misc.h"
-/* Structure used for the SET table itself */
-struct SetStruct
-{
- const char *name;
- void (*handler)();
- const int wants_char; /* 1 if it expects (char *, [int]) */
- const int wants_int; /* 1 if it expects ([char *], int) */
- /* eg: 0, 1 == only an int arg
- * eg: 1, 1 == char and int args */
-};
-
-static void quote_autoconn(struct Client *, const char *, int);
-static void quote_autoconnall(struct Client *, int);
-static void quote_floodcount(struct Client *, int);
-static void quote_identtimeout(struct Client *, int);
-static void quote_max(struct Client *, int);
-static void quote_spamnum(struct Client *, int);
-static void quote_spamtime(struct Client *, int);
-static void quote_splitmode(struct Client *, char *);
-static void quote_splitnum(struct Client *, int);
-static void quote_splitusers(struct Client *, int);
-static void list_quote_commands(struct Client *);
-static void quote_jfloodtime(struct Client *, int);
-static void quote_jfloodcount(struct Client *, int);
-
-/*
- * If this ever needs to be expanded to more than one arg of each
- * type, want_char/want_int could be the count of the arguments,
- * instead of just a boolean flag...
- *
- * -davidt
- */
-
-static const struct SetStruct set_cmd_table[] =
-{
- /* name function string arg int arg */
- /* -------------------------------------------------------- */
- { "AUTOCONN", quote_autoconn, 1, 1 },
- { "AUTOCONNALL", quote_autoconnall, 0, 1 },
- { "FLOODCOUNT", quote_floodcount, 0, 1 },
- { "IDENTTIMEOUT", quote_identtimeout, 0, 1 },
- { "MAX", quote_max, 0, 1 },
- { "SPAMNUM", quote_spamnum, 0, 1 },
- { "SPAMTIME", quote_spamtime, 0, 1 },
- { "SPLITMODE", quote_splitmode, 1, 0 },
- { "SPLITNUM", quote_splitnum, 0, 1 },
- { "SPLITUSERS", quote_splitusers, 0, 1 },
- { "JFLOODTIME", quote_jfloodtime, 0, 1 },
- { "JFLOODCOUNT", quote_jfloodcount, 0, 1 },
- /* -------------------------------------------------------- */
- { NULL, NULL, 0, 0 }
-};
-
-/*
- * list_quote_commands() sends the client all the available commands.
- * Four to a line for now.
- */
-static void
-list_quote_commands(struct Client *source_p)
-{
- int j = 0;
- const struct SetStruct *tab = set_cmd_table;
- const char *names[4] = { "", "", "", "" };
-
- sendto_one(source_p, ":%s NOTICE %s :Available QUOTE SET commands:",
- me.name, source_p->name);
-
- for (; tab->handler; ++tab)
- {
- names[j++] = tab->name;
-
- if (j > 3)
- {
- sendto_one(source_p, ":%s NOTICE %s :%s %s %s %s",
- me.name, source_p->name,
- names[0], names[1],
- names[2], names[3]);
- j = 0;
- names[0] = names[1] = names[2] = names[3] = "";
- }
-
- }
-
- if (j)
- sendto_one(source_p, ":%s NOTICE %s :%s %s %s %s",
- me.name, source_p->name,
- names[0], names[1],
- names[2], names[3]);
-}
-
/* SET AUTOCONN */
static void
quote_autoconn(struct Client *source_p, const char *arg, int newval)
@@ -443,6 +353,81 @@ quote_jfloodcount(struct Client *source_p, int newval)
me.name, source_p->name, GlobalSetOptions.joinfloodcount);
}
+/* Structure used for the SET table itself */
+struct SetStruct
+{
+ const char *name;
+ void (*handler)();
+ const int wants_char; /* 1 if it expects (char *, [int]) */
+ const int wants_int; /* 1 if it expects ([char *], int) */
+ /* eg: 0, 1 == only an int arg
+ * eg: 1, 1 == char and int args */
+};
+
+/*
+ * If this ever needs to be expanded to more than one arg of each
+ * type, want_char/want_int could be the count of the arguments,
+ * instead of just a boolean flag...
+ *
+ * -davidt
+ */
+static const struct SetStruct set_cmd_table[] =
+{
+ /* name function string arg int arg */
+ /* -------------------------------------------------------- */
+ { "AUTOCONN", quote_autoconn, 1, 1 },
+ { "AUTOCONNALL", quote_autoconnall, 0, 1 },
+ { "FLOODCOUNT", quote_floodcount, 0, 1 },
+ { "IDENTTIMEOUT", quote_identtimeout, 0, 1 },
+ { "MAX", quote_max, 0, 1 },
+ { "SPAMNUM", quote_spamnum, 0, 1 },
+ { "SPAMTIME", quote_spamtime, 0, 1 },
+ { "SPLITMODE", quote_splitmode, 1, 0 },
+ { "SPLITNUM", quote_splitnum, 0, 1 },
+ { "SPLITUSERS", quote_splitusers, 0, 1 },
+ { "JFLOODTIME", quote_jfloodtime, 0, 1 },
+ { "JFLOODCOUNT", quote_jfloodcount, 0, 1 },
+ /* -------------------------------------------------------- */
+ { NULL, NULL, 0, 0 }
+};
+
+/*
+ * list_quote_commands() sends the client all the available commands.
+ * Four to a line for now.
+ */
+static void
+list_quote_commands(struct Client *source_p)
+{
+ int j = 0;
+ const struct SetStruct *tab = set_cmd_table;
+ const char *names[4] = { "", "", "", "" };
+
+ sendto_one(source_p, ":%s NOTICE %s :Available QUOTE SET commands:",
+ me.name, source_p->name);
+
+ for (; tab->handler; ++tab)
+ {
+ names[j++] = tab->name;
+
+ if (j > 3)
+ {
+ sendto_one(source_p, ":%s NOTICE %s :%s %s %s %s",
+ me.name, source_p->name,
+ names[0], names[1],
+ names[2], names[3]);
+ j = 0;
+ names[0] = names[1] = names[2] = names[3] = "";
+ }
+
+ }
+
+ if (j)
+ sendto_one(source_p, ":%s NOTICE %s :%s %s %s %s",
+ me.name, source_p->name,
+ names[0], names[1],
+ names[2], names[3]);
+}
+
/*
* mo_set - SET command handler
* set options while running
diff --git a/modules/m_version.c b/modules/m_version.c
index 5a9d9cc..b534c0f 100644
--- a/modules/m_version.c
+++ b/modules/m_version.c
@@ -70,9 +70,7 @@ confopts(struct Client *source_p)
/* might wanna hide this :P */
if (ServerInfo.hub &&
(!ConfigFileEntry.disable_remote || HasUMode(source_p, UMODE_OPER)))
- {
*p++ = 'H';
- }
*p++ = 'I'; /* invex */
*p++ = 'K'; /* knock */
@@ -113,8 +111,8 @@ m_version(struct Client *client_p, struct Client *source_p,
1, parc, parv) != HUNTED_ISME)
return;
- sendto_one(source_p, form_str(RPL_VERSION),
- me.name, source_p->name, ircd_version, serno,
+ sendto_one(source_p, form_str(RPL_VERSION), me.name,
+ source_p->name, ircd_version, serno,
me.name, confopts(source_p), serveropts);
show_isupport(source_p);
}
@@ -134,9 +132,8 @@ mo_version(struct Client *client_p, struct Client *source_p,
return;
sendto_one(source_p, form_str(RPL_VERSION), me.name,
- source_p->name, ircd_version,
- serno, me.name, confopts(source_p), serveropts);
-
+ source_p->name, ircd_version, serno,
+ me.name, confopts(source_p), serveropts);
show_isupport(source_p);
}
@@ -150,15 +147,15 @@ ms_version(struct Client *client_p, struct Client *source_p,
int parc, char *parv[])
{
if (hunt_server(client_p, source_p, ":%s VERSION :%s",
- 1, parc, parv) == HUNTED_ISME)
- {
- sendto_one(source_p, form_str(RPL_VERSION),
- ID_or_name(&me, client_p),
- ID_or_name(source_p, client_p),
- ircd_version, serno,
- me.name, confopts(source_p), serveropts);
- show_isupport(source_p);
- }
+ 1, parc, parv) != HUNTED_ISME)
+ return;
+
+ sendto_one(source_p, form_str(RPL_VERSION),
+ ID_or_name(&me, client_p),
+ ID_or_name(source_p, client_p),
+ ircd_version, serno,
+ me.name, confopts(source_p), serveropts);
+ show_isupport(source_p);
}
static struct Message version_msgtab = {
diff --git a/modules/m_wallops.c b/modules/m_wallops.c
index c05a56d..a35a523 100644
--- a/modules/m_wallops.c
+++ b/modules/m_wallops.c
@@ -41,7 +41,7 @@
*/
static void
mo_wallops(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
+ int parc, char *parv[])
{
const char *message = parv[1];
diff --git a/modules/m_whois.c b/modules/m_whois.c
index 70ca4dd..d0b73ff 100644
--- a/modules/m_whois.c
+++ b/modules/m_whois.c
@@ -39,115 +39,6 @@
#include "modules.h"
-static void do_whois(struct Client *, int, char *[]);
-static void whois_person(struct Client *, struct Client *);
-
-
-/*
-** m_whois
-** parv[0] = sender prefix
-** parv[1] = nickname masklist
-*/
-static void
-m_whois(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
-{
- static time_t last_used = 0;
-
- if (parc < 2 || EmptyString(parv[1]))
- {
- sendto_one(source_p, form_str(ERR_NONICKNAMEGIVEN),
- me.name, source_p->name);
- return;
- }
-
- if (parc > 2 && !EmptyString(parv[2]))
- {
- /* seeing as this is going across servers, we should limit it */
- if ((last_used + ConfigFileEntry.pace_wait_simple) > CurrentTime)
- {
- sendto_one(source_p, form_str(RPL_LOAD2HI),
- me.name, source_p->name);
- return;
- }
-
- last_used = CurrentTime;
-
- /* if we have serverhide enabled, they can either ask the clients
- * server, or our server.. I dont see why they would need to ask
- * anything else for info about the client.. --fl_
- */
- if (ConfigFileEntry.disable_remote)
- parv[1] = parv[2];
-
- if (hunt_server(client_p, source_p, ":%s WHOIS %s :%s", 1,
- parc, parv) != HUNTED_ISME)
- return;
-
- parv[1] = parv[2];
- }
-
- do_whois(source_p, parc, parv);
-}
-
-/*
-** mo_whois
-** parv[0] = sender prefix
-** parv[1] = nickname masklist
-*/
-static void
-mo_whois(struct Client *client_p, struct Client *source_p,
- int parc, char *parv[])
-{
- if (parc < 2 || EmptyString(parv[1]))
- {
- sendto_one(source_p, form_str(ERR_NONICKNAMEGIVEN),
- me.name, source_p->name);
- return;
- }
-
- if (parc > 2 && !EmptyString(parv[2]))
- {
- if (hunt_server(client_p, source_p, ":%s WHOIS %s :%s", 1,
- parc, parv) != HUNTED_ISME)
- return;
-
- parv[1] = parv[2];
- }
-
- do_whois(source_p, parc, parv);
-}
-
-/* do_whois()
- *
- * inputs - pointer to /whois source
- * - number of parameters
- * - pointer to parameters array
- * output - pointer to void
- * side effects - Does whois
- */
-static void
-do_whois(struct Client *source_p, int parc, char *parv[])
-{
- struct Client *target_p = NULL;
- char *nick = parv[1];
- char *p = NULL;
-
- if ((p = strchr(nick, ',')) != NULL)
- *p = '\0';
- if (*nick == '\0')
- return;
-
- if ((target_p = hash_find_client(nick)) && IsClient(target_p))
- whois_person(source_p, target_p);
- else if (!IsDigit(*nick))
- sendto_one(source_p, form_str(ERR_NOSUCHNICK),
- me.name, source_p->name, nick);
-
- sendto_one(source_p, form_str(RPL_ENDOFWHOIS),
- me.name, source_p->name, nick);
-}
-
/* whois_person()
*
* inputs - source_p client to report to
@@ -158,7 +49,7 @@ do_whois(struct Client *source_p, int parc, char *parv[])
static void
whois_person(struct Client *source_p, struct Client *target_p)
{
- char buf[IRCD_BUFSIZE];
+ char buf[IRCD_BUFSIZE] = { '\0' };
const dlink_node *lp = NULL;
char *t = NULL;
int cur_len = 0;
@@ -245,7 +136,7 @@ whois_person(struct Client *source_p, struct Client *target_p)
show_ip ? target_p->sockhost : "255.255.255.255");
}
- if (MyConnect(target_p)) /* Can't do any of this if not local! db */
+ if (MyConnect(target_p))
{
#ifdef HAVE_LIBCRYPTO
if (target_p->localClient->fd.ssl)
@@ -265,6 +156,112 @@ whois_person(struct Client *source_p, struct Client *target_p)
}
}
+/* do_whois()
+ *
+ * inputs - pointer to /whois source
+ * - number of parameters
+ * - pointer to parameters array
+ * output - pointer to void
+ * side effects - Does whois
+ */
+static void
+do_whois(struct Client *source_p, int parc, char *parv[])
+{
+ struct Client *target_p = NULL;
+ char *nick = parv[1];
+ char *p = NULL;
+
+ if ((p = strchr(nick, ',')) != NULL)
+ *p = '\0';
+ if (*nick == '\0')
+ return;
+
+ if ((target_p = hash_find_client(nick)) && IsClient(target_p))
+ whois_person(source_p, target_p);
+ else if (!IsDigit(*nick))
+ sendto_one(source_p, form_str(ERR_NOSUCHNICK),
+ me.name, source_p->name, nick);
+
+ sendto_one(source_p, form_str(RPL_ENDOFWHOIS),
+ me.name, source_p->name, nick);
+}
+
+/*
+** m_whois
+** parv[0] = sender prefix
+** parv[1] = nickname masklist
+*/
+static void
+m_whois(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
+{
+ static time_t last_used = 0;
+
+ if (parc < 2 || EmptyString(parv[1]))
+ {
+ sendto_one(source_p, form_str(ERR_NONICKNAMEGIVEN),
+ me.name, source_p->name);
+ return;
+ }
+
+ if (parc > 2 && !EmptyString(parv[2]))
+ {
+ /* seeing as this is going across servers, we should limit it */
+ if ((last_used + ConfigFileEntry.pace_wait_simple) > CurrentTime)
+ {
+ sendto_one(source_p, form_str(RPL_LOAD2HI),
+ me.name, source_p->name);
+ return;
+ }
+
+ last_used = CurrentTime;
+
+ /*
+ * if we have serverhide enabled, they can either ask the clients
+ * server, or our server.. I dont see why they would need to ask
+ * anything else for info about the client.. --fl_
+ */
+ if (ConfigFileEntry.disable_remote)
+ parv[1] = parv[2];
+
+ if (hunt_server(client_p, source_p, ":%s WHOIS %s :%s", 1,
+ parc, parv) != HUNTED_ISME)
+ return;
+
+ parv[1] = parv[2];
+ }
+
+ do_whois(source_p, parc, parv);
+}
+
+/*
+** mo_whois
+** parv[0] = sender prefix
+** parv[1] = nickname masklist
+*/
+static void
+mo_whois(struct Client *client_p, struct Client *source_p,
+ int parc, char *parv[])
+{
+ if (parc < 2 || EmptyString(parv[1]))
+ {
+ sendto_one(source_p, form_str(ERR_NONICKNAMEGIVEN),
+ me.name, source_p->name);
+ return;
+ }
+
+ if (parc > 2 && !EmptyString(parv[2]))
+ {
+ if (hunt_server(client_p, source_p, ":%s WHOIS %s :%s", 1,
+ parc, parv) != HUNTED_ISME)
+ return;
+
+ parv[1] = parv[2];
+ }
+
+ do_whois(source_p, parc, parv);
+}
+
static struct Message whois_msgtab = {
"WHOIS", 0, 0, 0, MAXPARA, MFLG_SLOW, 0,
{ m_unregistered, m_whois, mo_whois, m_ignore, mo_whois, m_ignore }