| 1 |
adx |
30 |
/* |
| 2 |
|
|
* ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). |
| 3 |
|
|
* m_links.c: Shows what servers are currently connected. |
| 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 "irc_string.h" |
| 28 |
|
|
#include "ircd.h" |
| 29 |
|
|
#include "numeric.h" |
| 30 |
|
|
#include "s_serv.h" |
| 31 |
|
|
#include "send.h" |
| 32 |
michael |
1309 |
#include "conf.h" |
| 33 |
adx |
30 |
#include "motd.h" |
| 34 |
|
|
#include "parse.h" |
| 35 |
|
|
#include "modules.h" |
| 36 |
|
|
|
| 37 |
|
|
|
| 38 |
michael |
1144 |
static void |
| 39 |
|
|
do_links(struct Client *source_p, int parc, char *parv[]) |
| 40 |
adx |
30 |
{ |
| 41 |
michael |
1144 |
sendto_realops_flags(UMODE_SPY, L_ALL, |
| 42 |
|
|
"LINKS requested by %s (%s@%s) [%s]", |
| 43 |
|
|
source_p->name, |
| 44 |
|
|
source_p->username, source_p->host, |
| 45 |
|
|
source_p->servptr->name); |
| 46 |
adx |
30 |
|
| 47 |
michael |
1219 |
if (HasUMode(source_p, UMODE_OPER) || !ConfigServerHide.flatten_links) |
| 48 |
adx |
30 |
{ |
| 49 |
michael |
1045 |
const char *mask = (parc > 2 ? parv[2] : parv[1]); |
| 50 |
michael |
1544 |
const char *me_name, *nick; |
| 51 |
adx |
30 |
dlink_node *ptr; |
| 52 |
|
|
|
| 53 |
|
|
me_name = ID_or_name(&me, source_p->from); |
| 54 |
|
|
nick = ID_or_name(source_p, source_p->from); |
| 55 |
|
|
|
| 56 |
|
|
DLINK_FOREACH(ptr, global_serv_list.head) |
| 57 |
|
|
{ |
| 58 |
michael |
1544 |
struct Client *target_p = ptr->data; |
| 59 |
adx |
30 |
|
| 60 |
michael |
1489 |
/* skip hidden servers */ |
| 61 |
michael |
1490 |
if (IsHidden(target_p)) |
| 62 |
|
|
if (!HasUMode(source_p, UMODE_OPER)) |
| 63 |
michael |
1489 |
continue; |
| 64 |
|
|
|
| 65 |
michael |
575 |
if (!EmptyString(mask) && !match(mask, target_p->name)) |
| 66 |
adx |
30 |
continue; |
| 67 |
michael |
575 |
|
| 68 |
michael |
1544 |
/* |
| 69 |
|
|
* We just send the reply, as if they are here there's either no SHIDE, |
| 70 |
adx |
30 |
* or they're an oper.. |
| 71 |
|
|
*/ |
| 72 |
|
|
sendto_one(source_p, form_str(RPL_LINKS), |
| 73 |
|
|
me_name, nick, |
| 74 |
michael |
1544 |
target_p->name, target_p->servptr->name, |
| 75 |
michael |
1546 |
target_p->hopcount, target_p->info); |
| 76 |
adx |
30 |
} |
| 77 |
|
|
|
| 78 |
|
|
sendto_one(source_p, form_str(RPL_ENDOFLINKS), |
| 79 |
|
|
me_name, nick, |
| 80 |
|
|
EmptyString(mask) ? "*" : mask); |
| 81 |
|
|
} |
| 82 |
michael |
1148 |
else |
| 83 |
|
|
{ |
| 84 |
adx |
30 |
/* |
| 85 |
|
|
* Print our own info so at least it looks like a normal links |
| 86 |
|
|
* then print out the file (which may or may not be empty) |
| 87 |
|
|
*/ |
| 88 |
|
|
sendto_one(source_p, form_str(RPL_LINKS), |
| 89 |
|
|
ID_or_name(&me, source_p->from), |
| 90 |
|
|
ID_or_name(source_p, source_p->from), |
| 91 |
|
|
me.name, me.name, 0, me.info); |
| 92 |
|
|
send_message_file(source_p, &ConfigFileEntry.linksfile); |
| 93 |
|
|
sendto_one(source_p, form_str(RPL_ENDOFLINKS), |
| 94 |
adx |
103 |
ID_or_name(&me, source_p->from), |
| 95 |
|
|
ID_or_name(source_p, source_p->from), "*"); |
| 96 |
adx |
30 |
} |
| 97 |
|
|
} |
| 98 |
|
|
|
| 99 |
michael |
1230 |
static void |
| 100 |
|
|
mo_links(struct Client *client_p, struct Client *source_p, |
| 101 |
|
|
int parc, char *parv[]) |
| 102 |
|
|
{ |
| 103 |
|
|
if (parc > 2) |
| 104 |
|
|
if (!ConfigFileEntry.disable_remote || HasUMode(source_p, UMODE_OPER)) |
| 105 |
|
|
if (hunt_server(client_p, source_p, ":%s LINKS %s :%s", 1, |
| 106 |
|
|
parc, parv) != HUNTED_ISME) |
| 107 |
|
|
return; |
| 108 |
|
|
|
| 109 |
|
|
do_links(source_p, parc, parv); |
| 110 |
|
|
} |
| 111 |
|
|
|
| 112 |
adx |
30 |
/* |
| 113 |
|
|
* m_links - LINKS message handler |
| 114 |
|
|
* parv[0] = sender prefix |
| 115 |
|
|
* parv[1] = servername mask |
| 116 |
|
|
* or |
| 117 |
|
|
* parv[0] = sender prefix |
| 118 |
|
|
* parv[1] = server to query |
| 119 |
|
|
* parv[2] = servername mask |
| 120 |
|
|
*/ |
| 121 |
|
|
static void |
| 122 |
|
|
m_links(struct Client *client_p, struct Client *source_p, |
| 123 |
|
|
int parc, char *parv[]) |
| 124 |
|
|
{ |
| 125 |
adx |
269 |
static time_t last_used = 0; |
| 126 |
|
|
|
| 127 |
|
|
if ((last_used + ConfigFileEntry.pace_wait) > CurrentTime) |
| 128 |
|
|
{ |
| 129 |
|
|
sendto_one(source_p, form_str(RPL_LOAD2HI), |
| 130 |
|
|
me.name, source_p->name); |
| 131 |
|
|
return; |
| 132 |
|
|
} |
| 133 |
|
|
|
| 134 |
michael |
1121 |
last_used = CurrentTime; |
| 135 |
|
|
|
| 136 |
adx |
30 |
if (!ConfigServerHide.flatten_links) |
| 137 |
|
|
{ |
| 138 |
|
|
mo_links(client_p, source_p, parc, parv); |
| 139 |
|
|
return; |
| 140 |
|
|
} |
| 141 |
|
|
|
| 142 |
michael |
1144 |
do_links(source_p, parc, parv); |
| 143 |
adx |
30 |
} |
| 144 |
|
|
|
| 145 |
|
|
/* |
| 146 |
|
|
* ms_links - LINKS message handler |
| 147 |
|
|
* parv[0] = sender prefix |
| 148 |
|
|
* parv[1] = servername mask |
| 149 |
|
|
* or |
| 150 |
|
|
* parv[0] = sender prefix |
| 151 |
|
|
* parv[1] = server to query |
| 152 |
|
|
* parv[2] = servername mask |
| 153 |
|
|
*/ |
| 154 |
|
|
static void |
| 155 |
|
|
ms_links(struct Client *client_p, struct Client *source_p, |
| 156 |
|
|
int parc, char *parv[]) |
| 157 |
|
|
{ |
| 158 |
michael |
1144 |
if (hunt_server(client_p, source_p, ":%s LINKS %s :%s", 1, |
| 159 |
|
|
parc, parv) != HUNTED_ISME) |
| 160 |
adx |
30 |
return; |
| 161 |
|
|
|
| 162 |
|
|
if (IsClient(source_p)) |
| 163 |
|
|
m_links(client_p, source_p, parc, parv); |
| 164 |
|
|
} |
| 165 |
michael |
1230 |
|
| 166 |
|
|
static struct Message links_msgtab = { |
| 167 |
|
|
"LINKS", 0, 0, 0, MAXPARA, MFLG_SLOW, 0, |
| 168 |
|
|
{m_unregistered, m_links, ms_links, m_ignore, mo_links, m_ignore} |
| 169 |
|
|
}; |
| 170 |
|
|
|
| 171 |
|
|
static void |
| 172 |
|
|
module_init(void) |
| 173 |
|
|
{ |
| 174 |
|
|
mod_add_cmd(&links_msgtab); |
| 175 |
|
|
} |
| 176 |
|
|
|
| 177 |
|
|
static void |
| 178 |
|
|
module_exit(void) |
| 179 |
|
|
{ |
| 180 |
|
|
mod_del_cmd(&links_msgtab); |
| 181 |
|
|
} |
| 182 |
|
|
|
| 183 |
|
|
struct module module_entry = { |
| 184 |
|
|
.node = { NULL, NULL, NULL }, |
| 185 |
|
|
.name = NULL, |
| 186 |
|
|
.version = "$Revision$", |
| 187 |
|
|
.handle = NULL, |
| 188 |
|
|
.modinit = module_init, |
| 189 |
|
|
.modexit = module_exit, |
| 190 |
|
|
.flags = 0 |
| 191 |
|
|
}; |