| 1 |
adx |
30 |
/* |
| 2 |
|
|
* ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). |
| 3 |
|
|
* m_llnick.c: Used to introduce a client on a lazy-link. |
| 4 |
|
|
* |
| 5 |
|
|
* Copyright (C) 2002 by the past and present ircd coders, and others. |
| 6 |
|
|
* |
| 7 |
|
|
* This program is free software; you can redistribute it and/or modify |
| 8 |
|
|
* it under the terms of the GNU General Public License as published by |
| 9 |
|
|
* the Free Software Foundation; either version 2 of the License, or |
| 10 |
|
|
* (at your option) any later version. |
| 11 |
|
|
* |
| 12 |
|
|
* This program is distributed in the hope that it will be useful, |
| 13 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
|
|
* GNU General Public License for more details. |
| 16 |
|
|
* |
| 17 |
|
|
* You should have received a copy of the GNU General Public License |
| 18 |
|
|
* along with this program; if not, write to the Free Software |
| 19 |
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
| 20 |
|
|
* USA |
| 21 |
|
|
* |
| 22 |
knight |
31 |
* $Id$ |
| 23 |
adx |
30 |
*/ |
| 24 |
|
|
|
| 25 |
|
|
#include "stdinc.h" |
| 26 |
|
|
#include "client.h" |
| 27 |
|
|
#include "hash.h" |
| 28 |
|
|
#include "common.h" |
| 29 |
|
|
#include "hash.h" |
| 30 |
|
|
#include "ircd.h" |
| 31 |
|
|
#include "numeric.h" |
| 32 |
|
|
#include "s_serv.h" |
| 33 |
|
|
#include "send.h" |
| 34 |
|
|
#include "handlers.h" |
| 35 |
|
|
#include "msg.h" |
| 36 |
|
|
#include "parse.h" |
| 37 |
|
|
#include "modules.h" |
| 38 |
|
|
|
| 39 |
|
|
|
| 40 |
|
|
static void ms_llnick(struct Client*, struct Client*, int, char**); |
| 41 |
|
|
|
| 42 |
|
|
struct Message llnick_msgtab = { |
| 43 |
|
|
"LLNICK", 0, 0, 3, 0, MFLG_SLOW | MFLG_UNREG, 0L, |
| 44 |
|
|
{m_unregistered, m_ignore, ms_llnick, m_ignore, m_ignore, m_ignore} |
| 45 |
|
|
}; |
| 46 |
|
|
#ifndef STATIC_MODULES |
| 47 |
|
|
|
| 48 |
|
|
void |
| 49 |
|
|
_modinit(void) |
| 50 |
|
|
{ |
| 51 |
|
|
mod_add_cmd(&llnick_msgtab); |
| 52 |
|
|
} |
| 53 |
|
|
|
| 54 |
|
|
void |
| 55 |
|
|
_moddeinit(void) |
| 56 |
|
|
{ |
| 57 |
|
|
mod_del_cmd(&llnick_msgtab); |
| 58 |
|
|
} |
| 59 |
|
|
|
| 60 |
knight |
31 |
const char *_version = "$Revision$"; |
| 61 |
adx |
30 |
#endif |
| 62 |
|
|
/* |
| 63 |
|
|
* m_llnick |
| 64 |
|
|
* parv[0] = sender prefix |
| 65 |
|
|
* parv[1] = status |
| 66 |
|
|
* parv[2] = nick |
| 67 |
|
|
* parv[3] = old nick |
| 68 |
|
|
* |
| 69 |
|
|
*/ |
| 70 |
|
|
static void |
| 71 |
|
|
ms_llnick(struct Client *client_p, struct Client *source_p, |
| 72 |
|
|
int parc, char *parv[]) |
| 73 |
|
|
{ |
| 74 |
|
|
char *nick; |
| 75 |
|
|
char *nick_old = NULL; |
| 76 |
|
|
struct Client *target_p = NULL; |
| 77 |
|
|
int exists = 0; |
| 78 |
|
|
int new = 0; |
| 79 |
|
|
dlink_node *ptr; |
| 80 |
|
|
|
| 81 |
|
|
if(!IsCapable(client_p,CAP_LL) || !IsCapable(client_p, CAP_HUB)) |
| 82 |
|
|
{ |
| 83 |
|
|
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 84 |
|
|
"*** LLNICK requested from non LL server %s", |
| 85 |
|
|
client_p->name); |
| 86 |
|
|
return; |
| 87 |
|
|
} |
| 88 |
|
|
|
| 89 |
|
|
if (parc < 4) |
| 90 |
|
|
return; |
| 91 |
|
|
|
| 92 |
|
|
if (*parv[1] == 'Y') |
| 93 |
|
|
exists = 1; |
| 94 |
|
|
|
| 95 |
|
|
nick = parv[2]; |
| 96 |
|
|
nick_old = parv[3]; |
| 97 |
|
|
|
| 98 |
|
|
if (*nick_old == '!') |
| 99 |
|
|
new = 1; |
| 100 |
|
|
|
| 101 |
|
|
if (new) |
| 102 |
|
|
{ |
| 103 |
|
|
nick_old++; /* skip '!' */ |
| 104 |
|
|
/* New user -- find them */ |
| 105 |
|
|
DLINK_FOREACH(ptr, unknown_list.head) |
| 106 |
|
|
{ |
| 107 |
|
|
if( !strcmp(nick_old, ((struct Client *)ptr->data)->llname) ) |
| 108 |
|
|
{ |
| 109 |
|
|
target_p = ptr->data; |
| 110 |
|
|
*target_p->llname = '\0'; /* unset their temp-nick */ |
| 111 |
|
|
break; |
| 112 |
|
|
} |
| 113 |
|
|
} |
| 114 |
|
|
if (!target_p) /* Can't find them -- maybe they got a different nick */ |
| 115 |
|
|
return; |
| 116 |
|
|
} |
| 117 |
|
|
else |
| 118 |
|
|
{ |
| 119 |
|
|
/* Existing user changing nickname */ |
| 120 |
|
|
target_p = find_client(nick_old); |
| 121 |
|
|
|
| 122 |
|
|
if (!target_p) /* Can't find them -- maybe they got a different nick */ |
| 123 |
|
|
return; |
| 124 |
|
|
} |
| 125 |
|
|
|
| 126 |
|
|
/* Don't try this on a remote client... */ |
| 127 |
|
|
if (!MyConnect(target_p)) |
| 128 |
|
|
return; |
| 129 |
|
|
|
| 130 |
|
|
if(find_client(nick) || exists) |
| 131 |
|
|
{ |
| 132 |
|
|
/* The nick they want is in use. complain */ |
| 133 |
|
|
sendto_one(target_p, form_str(ERR_NICKNAMEINUSE), me.name, |
| 134 |
|
|
new ? "*" : nick_old, |
| 135 |
|
|
nick); |
| 136 |
|
|
return; |
| 137 |
|
|
} |
| 138 |
|
|
|
| 139 |
|
|
if(new) |
| 140 |
|
|
set_initial_nick(target_p, target_p, nick); |
| 141 |
|
|
else |
| 142 |
|
|
change_local_nick(target_p, target_p, nick); |
| 143 |
|
|
} |