diff options
author | michael <michael@82007160-df01-0410-b94d-b575c5fd34c7> | 2013-05-11 17:34:41 +0000 |
---|---|---|
committer | michael <michael@82007160-df01-0410-b94d-b575c5fd34c7> | 2013-05-11 17:34:41 +0000 |
commit | f4a54d2f96562e7ba54b45e976b3de1ab8f204df (patch) | |
tree | ace7c21f608e2b726e09b134d1a02ed955afce7f /modules/core | |
parent | a7e6544569aff97f362030000b72330b4fa2fa48 (diff) |
- Mostly style cleanups & whitespace changes
git-svn-id: svn://svn.ircd-hybrid.org/svnroot/ircd-hybrid/branches/8.1.x@1996 82007160-df01-0410-b94d-b575c5fd34c7
Diffstat (limited to 'modules/core')
-rw-r--r-- | modules/core/m_nick.c | 895 | ||||
-rw-r--r-- | modules/core/m_server.c | 48 |
2 files changed, 461 insertions, 482 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} |