*/
#include "config.h"
-#if 0
-/*
- * No need to include handlers.h here the signatures must match
- * and we don't need to force a rebuild of all the handlers everytime
- * we add a new one to the list. --Bleep
- */
-#include "handlers.h"
-#endif /* 0 */
#include "IPcheck.h"
#include "client.h"
#include "hash.h"
assert(0 != sptr);
return set_nick_name(cptr, sptr, nick, parc, parv);
}
-
-#if 0
-/*
- * m_nick
- *
- * parv[0] = sender prefix
- * parv[1] = nickname
- *
- * If from server, source is client:
- * parv[2] = timestamp
- *
- * Source is server:
- * parv[2] = hopcount
- * parv[3] = timestamp
- * parv[4] = username
- * parv[5] = hostname
- * parv[6] = umode (optional)
- * parv[parc-3] = IP# <- Only Protocol >= 10
- * parv[parc-2] = YXX, numeric nick <- Only Protocol >= 10
- * parv[parc-1] = info
- * parv[0] = server
- */
-int m_nick(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
-{
- struct Client* acptr;
- char nick[NICKLEN + 2];
- char* s;
- time_t lastnick = 0;
- int differ = 1;
-
- if (parc < 2) {
- sendto_one(sptr, err_str(ERR_NONICKNAMEGIVEN), me.name, parv[0]); /* XXX DEAD */
- return 0;
- }
- else if ((IsServer(sptr) && parc < 8) || (IsServer(cptr) && parc < 3))
- {
- need_more_params(sptr, "NICK");
- sendto_ops("bad NICK param count for %s from %s", parv[1], cptr->name); /* XXX DEAD */
- return 0;
- }
- if (MyConnect(sptr) && (s = strchr(parv[1], '~')))
- *s = '\0';
- ircd_strncpy(nick, parv[1], NICKLEN);
- nick[NICKLEN] = '\0';
- if (IsServer(cptr)) {
- if (IsServer(sptr)) {
- lastnick = atoi(parv[3]);
- if (lastnick > OLDEST_TS)
- sptr->serv->lag = TStime() - lastnick;
- } else {
- lastnick = atoi(parv[2]);
- if (lastnick > OLDEST_TS)
- sptr->user->server->serv->lag = TStime() - lastnick;
- }
- }
- /*
- * If do_nick_name() returns a null name OR if the server sent a nick
- * name and do_nick_name() changed it in some way (due to rules of nick
- * creation) then reject it. If from a server and we reject it,
- * and KILL it. -avalon 4/4/92
- */
- if (do_nick_name(nick) == 0 || (IsServer(cptr) && strcmp(nick, parv[1])))
- {
- sendto_one(sptr, err_str(ERR_ERRONEUSNICKNAME), me.name, parv[0], parv[1]); /* XXX DEAD */
-
- if (IsServer(cptr))
- {
- ServerStats->is_kill++;
- sendto_ops("Bad Nick: %s From: %s %s", /* XXX DEAD */
- parv[1], parv[0], cptr->name);
- sendto_one(cptr, "%s " TOK_KILL " %s :%s (%s <- %s[%s])", /* XXX DEAD */
- NumServ(&me), IsServer(sptr) ? parv[parc - 2] : parv[0], me.name,
- parv[1], nick, cptr->name);
- if (!IsServer(sptr)) /* bad nick _change_ */
- {
- sendto_highprot_butone(&me, 10, "%s " TOK_KILL " %s :%s (%s <- %s!%s@%s)", /* XXX DEAD */
- NumServ(&me), parv[0], me.name, cptr->name,
- parv[0], sptr->user ? sptr->username : "",
- sptr->user ? sptr->user->server->name : cptr->name);
- }
- }
- return 0;
- }
-
- /*
- * Check if this is a LOCAL user trying to use a reserved (Juped)
- * nick, if so tell him that it's a nick in use...
- */
- if ((!IsServer(cptr)) && isNickJuped(nick))
- {
- sendto_one(sptr, err_str(ERR_NICKNAMEINUSE), me.name, /* XXX DEAD */
- /* parv[0] is empty when connecting */
- EmptyString(parv[0]) ? "*" : parv[0], nick);
- return 0; /* NICK message ignored */
- }
-
- /*
- * Check against nick name collisions.
- *
- * Put this 'if' here so that the nesting goes nicely on the screen :)
- * We check against server name list before determining if the nickname
- * is present in the nicklist (due to the way the below for loop is
- * constructed). -avalon
- */
-
- acptr = FindServer(nick);
-
- if (acptr) { /* There is a nick collision with a server */
- if (MyConnect(sptr))
- {
- /* Local user trying to use a nick thats a server
- * Return an error message and ignore the command
- */
- sendto_one(sptr, err_str(ERR_NICKNAMEINUSE), me.name, /* XXX DEAD */
- EmptyString(parv[0]) ? "*" : parv[0], nick);
- return 0; /* NICK message ignored */
- }
-
- /*
- * We have a nickname trying to use the same name as
- * a server. Send out a nick collision KILL to remove
- * the nickname. As long as only a KILL is sent out,
- * there is no danger of the server being disconnected.
- * Ultimate way to jupiter a nick ? >;-). -avalon
- */
- sendto_ops("Nick collision on %s(%s <- %s)", /* XXX DEAD */
- sptr->name, acptr->from->name, cptr->name);
- ServerStats->is_kill++;
- sendto_one(cptr, "%s " TOK_KILL " %s%s :%s (%s <- %s)", /* XXX DEAD */
- NumServ(&me), NumNick(sptr), me.name, acptr->from->name,
- cptr->name);
- sptr->flags |= FLAGS_KILLED;
- return exit_client(cptr, sptr, &me, "Nick/Server collision");
- }
-
- acptr = FindClient(nick);
-
- /* No collisions? Set the nick name and we're done */
- if (!acptr)
- return set_nick_name(cptr, sptr, nick, parc, parv);
- /*
- * If acptr == sptr, then we have a client doing a nick
- * change between *equivalent* nicknames as far as server
- * is concerned (user is changing the case of his/her
- * nickname or somesuch)
- */
- if (acptr == sptr)
- {
- if (strcmp(acptr->name, nick) != 0)
- /*
- * Allows change of case in his/her nick
- */
- return set_nick_name(cptr, sptr, nick, parc, parv);
- else
- /*
- * This is just ':old NICK old' type thing.
- * Just forget the whole thing here. There is
- * no point forwarding it to anywhere,
- * especially since servers prior to this
- * version would treat it as nick collision.
- */
- return 0; /* NICK Message ignored */
- }
-
- /*
- * Note: From this point forward it can be assumed that
- * acptr != sptr (point to different client structures).
- */
- /*
- * If the older one is "non-person", the new entry is just
- * allowed to overwrite it. Just silently drop non-person,
- * and proceed with the nick. This should take care of the
- * "dormant nick" way of generating collisions...
- */
- if (IsUnknown(acptr) && MyConnect(acptr))
- {
- ++ServerStats->is_ref;
- IPcheck_connect_fail(acptr->ip);
- exit_client(cptr, acptr, &me, "Overridden by other sign on");
- return set_nick_name(cptr, sptr, nick, parc, parv);
- }
- /*
- * Decide, we really have a nick collision and deal with it
- */
- if (!IsServer(cptr))
- {
- /*
- * NICK is coming from local client connection. Just
- * send error reply and ignore the command.
- */
- sendto_one(sptr, err_str(ERR_NICKNAMEINUSE), me.name, /* XXX DEAD */
- /* parv[0] is empty when connecting */
- EmptyString(parv[0]) ? "*" : parv[0], nick);
- return 0; /* NICK message ignored */
- }
- /*
- * NICK was coming from a server connection.
- * This means we have a race condition (two users signing on
- * at the same time), or two net fragments reconnecting with the same nick.
- * The latter can happen because two different users connected
- * or because one and the same user switched server during a net break.
- * If the TimeStamps are equal, we kill both (or only 'new'
- * if it was a ":server NICK new ...").
- * Otherwise we kill the youngest when user@host differ,
- * or the oldest when they are the same.
- * We treat user and ~user as different, because if it wasn't
- * a faked ~user the AUTH wouldn't have added the '~'.
- * --Run
- *
- */
- if (IsServer(sptr))
- {
- /*
- * A new NICK being introduced by a neighbouring
- * server (e.g. message type ":server NICK new ..." received)
- */
- differ = (acptr->ip.s_addr != htonl(base64toint(parv[parc - 3]))) ||
- (0 != ircd_strcmp(acptr->user->username, parv[4]));
- sendto_ops("Nick collision on %s (%s " TIME_T_FMT " <- %s " TIME_T_FMT /* XXX DEAD */
- " (%s user@host))", acptr->name, acptr->from->name, acptr->lastnick,
- cptr->name, lastnick, differ ? "Different" : "Same");
- }
- else
- {
- /*
- * A NICK change has collided (e.g. message type ":old NICK new").
- */
- lastnick = atoi(parv[2]);
- differ = (acptr->ip.s_addr != sptr->ip.s_addr) ||
- (0 != ircd_strcmp(acptr->user->username, sptr->user->username));
- sendto_ops("Nick change collision from %s to %s (%s " TIME_T_FMT " <- %s " /* XXX DEAD */
- TIME_T_FMT ")", sptr->name, acptr->name, acptr->from->name,
- acptr->lastnick, cptr->name, lastnick);
- }
- /*
- * Now remove (kill) the nick on our side if it is the youngest.
- * If no timestamp was received, we ignore the incoming nick
- * (and expect a KILL for our legit nick soon ):
- * When the timestamps are equal we kill both nicks. --Run
- * acptr->from != cptr should *always* be true (?).
- */
- if (acptr->from != cptr)
- {
- if ((differ && lastnick >= acptr->lastnick) ||
- (!differ && lastnick <= acptr->lastnick))
- {
- if (!IsServer(sptr))
- {
- ServerStats->is_kill++;
- sendto_highprot_butone(cptr, 10, /* Kill old from outgoing servers */ /* XXX DEAD */
- "%s " TOK_KILL " %s%s :%s (%s <- %s (Nick collision))",
- NumServ(&me), NumNick(sptr), me.name, acptr->from->name,
- cptr->name);
- if (MyConnect(sptr) && IsServer(cptr) && Protocol(cptr) > 9)
- sendto_one(cptr, "%s " TOK_KILL " %s%s :%s (Ghost2)", /* XXX DEAD */
- NumServ(&me), NumNick(sptr), me.name);
- sptr->flags |= FLAGS_KILLED;
- exit_client(cptr, sptr, &me, "Nick collision (you're a ghost)");
- }
- if (lastnick != acptr->lastnick)
- return 0; /* Ignore the NICK */
- }
- sendto_one(acptr, err_str(ERR_NICKCOLLISION), me.name, acptr->name, nick); /* XXX DEAD */
- }
- ServerStats->is_kill++;
- acptr->flags |= FLAGS_KILLED;
- if (differ)
- {
- sendto_highprot_butone(cptr, 10, /* Kill our old from outgoing servers */ /* XXX DEAD */
- "%s " TOK_KILL " %s%s :%s (%s <- %s (older nick overruled))",
- NumServ(&me), NumNick(acptr), me.name, acptr->from->name,
- cptr->name);
- if (MyConnect(acptr) && IsServer(cptr) && Protocol(cptr) > 9)
- sendto_one(cptr, "%s%s " TOK_QUIT " :Local kill by %s (Ghost)", /* XXX DEAD */
- NumNick(acptr), me.name);
- exit_client(cptr, acptr, &me, "Nick collision (older nick overruled)");
- }
- else
- {
- sendto_highprot_butone(cptr, 10, /* Kill our old from outgoing servers */ /* XXX DEAD */
- "%s " TOK_KILL " %s%s :%s (%s <- %s (nick collision from same user@host))",
- NumServ(&me), NumNick(acptr), me.name, acptr->from->name,
- cptr->name);
- if (MyConnect(acptr) && IsServer(cptr) && Protocol(cptr) > 9)
- sendto_one(cptr, /* XXX DEAD */
- "%s%s " TOK_QUIT " :Local kill by %s (Ghost: switched servers too fast)",
- NumNick(acptr), me.name);
- exit_client(cptr, acptr, &me, "Nick collision (You collided yourself)");
- }
- if (lastnick == acptr->lastnick)
- return 0;
-
- return set_nick_name(cptr, sptr, nick, parc, parv);
-}
-
-#endif /* 0 */