| 1 |
/* |
| 2 |
* ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). |
| 3 |
* m_jupe.c: Jupes a server. |
| 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 |
* $Id$ |
| 23 |
*/ |
| 24 |
|
| 25 |
#include "stdinc.h" |
| 26 |
#include "list.h" |
| 27 |
#include "irc_string.h" |
| 28 |
#include "sprintf_irc.h" |
| 29 |
#include "handlers.h" |
| 30 |
#include "channel.h" |
| 31 |
#include "client.h" |
| 32 |
#include "ircd.h" |
| 33 |
#include "numeric.h" |
| 34 |
#include "s_log.h" |
| 35 |
#include "s_serv.h" |
| 36 |
#include "send.h" |
| 37 |
#include "whowas.h" |
| 38 |
#include "hash.h" |
| 39 |
#include "msg.h" |
| 40 |
#include "parse.h" |
| 41 |
#include "modules.h" |
| 42 |
#include "common.h" |
| 43 |
#include "event.h" |
| 44 |
#include "fdlist.h" |
| 45 |
#include "s_conf.h" |
| 46 |
|
| 47 |
static void mo_jupe(struct Client *, struct Client *, int, char *[]); |
| 48 |
|
| 49 |
struct Message jupe_msgtab = { |
| 50 |
"JUPE", 0, 0, 3, 0, MFLG_SLOW, 0, |
| 51 |
{m_unregistered, m_not_oper, mo_jupe, m_ignore, mo_jupe, m_ignore} |
| 52 |
}; |
| 53 |
|
| 54 |
void |
| 55 |
_modinit(void) |
| 56 |
{ |
| 57 |
mod_add_cmd(&jupe_msgtab); |
| 58 |
} |
| 59 |
|
| 60 |
void |
| 61 |
_moddeinit(void) |
| 62 |
{ |
| 63 |
mod_del_cmd(&jupe_msgtab); |
| 64 |
} |
| 65 |
|
| 66 |
const char *_version = "$Revision$"; |
| 67 |
|
| 68 |
/* |
| 69 |
* mo_jupe() |
| 70 |
* parv[0] = sender prefix |
| 71 |
* parv[1] = server we're juping |
| 72 |
* parv[2] = reason for jupe |
| 73 |
*/ |
| 74 |
static void |
| 75 |
mo_jupe(struct Client *client_p, struct Client *source_p, |
| 76 |
int parc, char *parv[]) |
| 77 |
{ |
| 78 |
struct Client *target_p = NULL; |
| 79 |
struct Client *ajupe = NULL; |
| 80 |
dlink_node *m = NULL; |
| 81 |
char reason[REALLEN + 1]; |
| 82 |
|
| 83 |
if (!IsAdmin(source_p)) |
| 84 |
{ |
| 85 |
sendto_one(source_p, form_str(ERR_NOPRIVILEGES), |
| 86 |
me.name, source_p->name); |
| 87 |
return; |
| 88 |
} |
| 89 |
|
| 90 |
if (EmptyString(parv[2])) |
| 91 |
{ |
| 92 |
sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), |
| 93 |
me.name, source_p->name, "JUPE"); |
| 94 |
return; |
| 95 |
} |
| 96 |
|
| 97 |
if (!ServerInfo.hub) |
| 98 |
{ |
| 99 |
sendto_one(source_p, ":%s NOTICE %s :Must be used from a hub server", |
| 100 |
me.name, source_p->name); |
| 101 |
return; |
| 102 |
} |
| 103 |
|
| 104 |
if (!valid_servname(parv[1])) |
| 105 |
{ |
| 106 |
sendto_one(source_p, ":%s NOTICE %s :Invalid servername: %s", |
| 107 |
me.name, source_p->name, parv[1]); |
| 108 |
return; |
| 109 |
} |
| 110 |
|
| 111 |
if (!irccmp(parv[1], me.name)) |
| 112 |
{ |
| 113 |
sendto_one(source_p, ":%s NOTICE %s :I can't jupe myself!", |
| 114 |
me.name, source_p->name); |
| 115 |
return; |
| 116 |
} |
| 117 |
|
| 118 |
/* we need to give 7 chars to prepend "JUPED: " */ |
| 119 |
if (strlen(parv[2]) > (REALLEN - 7)) |
| 120 |
parv[2][REALLEN - 7] = '\0'; |
| 121 |
|
| 122 |
sendto_wallops_flags(UMODE_WALLOP, &me, |
| 123 |
"JUPE for %s requested by %s: %s", |
| 124 |
parv[1], get_oper_name(source_p), parv[2]); |
| 125 |
|
| 126 |
sendto_server(NULL, NULL, NOCAPS, NOCAPS, |
| 127 |
":%s WALLOPS :JUPE for %s requested by %s!%s@%s: %s", |
| 128 |
me.name, parv[1], source_p->name, |
| 129 |
source_p->username, source_p->host, parv[2]); |
| 130 |
ilog(L_NOTICE, "JUPE for %s requested by %s: %s", |
| 131 |
parv[1], get_oper_name(source_p), parv[2]); |
| 132 |
|
| 133 |
if ((target_p = find_server(parv[1])) != NULL) |
| 134 |
exit_client(target_p, &me, parv[2]); |
| 135 |
|
| 136 |
sendto_server(NULL, NULL, NOCAPS, NOCAPS, |
| 137 |
":%s SERVER %s 1 :JUPED: %s", |
| 138 |
me.name, parv[1], parv[2]); |
| 139 |
|
| 140 |
sendto_realops_flags(UMODE_ALL, L_ALL, |
| 141 |
"Link with %s established: (JUPED) link", |
| 142 |
parv[1]); |
| 143 |
|
| 144 |
ajupe = make_client(NULL); |
| 145 |
|
| 146 |
/* make_client() adds client to unknown_list */ |
| 147 |
if ((m = dlinkFindDelete(&unknown_list, ajupe)) != NULL) |
| 148 |
free_dlink_node(m); |
| 149 |
|
| 150 |
make_server(ajupe); |
| 151 |
|
| 152 |
strlcpy(ajupe->name, parv[1], sizeof(ajupe->name)); |
| 153 |
ircsprintf(reason, "JUPED: %s", parv[2]); |
| 154 |
strlcpy(ajupe->info, reason, sizeof(ajupe->info)); |
| 155 |
|
| 156 |
ajupe->servptr = &me; |
| 157 |
ajupe->hopcount = 1; |
| 158 |
|
| 159 |
SetServer(ajupe); |
| 160 |
SetDead(ajupe); |
| 161 |
|
| 162 |
Count.myserver++; |
| 163 |
|
| 164 |
hash_add_client(ajupe); |
| 165 |
dlinkAdd(ajupe, &ajupe->lnode, &ajupe->servptr->serv->server_list); |
| 166 |
dlinkAdd(ajupe, make_dlink_node(), &global_serv_list); |
| 167 |
|
| 168 |
/* XXX is this really necessary? |
| 169 |
* for now, 'cause of the way squit works |
| 170 |
*/ |
| 171 |
dlinkAdd(ajupe, &ajupe->node, &global_client_list); |
| 172 |
} |