| 1 |
|
/* |
| 2 |
< |
* ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). |
| 3 |
< |
* m_links.c: Shows what servers are currently connected. |
| 2 |
> |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
| 3 |
|
* |
| 4 |
< |
* Copyright (C) 2002 by the past and present ircd coders, and others. |
| 4 |
> |
* Copyright (c) 1997-2015 ircd-hybrid development team |
| 5 |
|
* |
| 6 |
|
* This program is free software; you can redistribute it and/or modify |
| 7 |
|
* it under the terms of the GNU General Public License as published by |
| 15 |
|
* |
| 16 |
|
* You should have received a copy of the GNU General Public License |
| 17 |
|
* along with this program; if not, write to the Free Software |
| 18 |
< |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
| 18 |
> |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 |
| 19 |
|
* USA |
| 20 |
< |
* |
| 21 |
< |
* $Id$ |
| 20 |
> |
*/ |
| 21 |
> |
|
| 22 |
> |
/*! \file m_links.c |
| 23 |
> |
* \brief Includes required functions for processing the LINKS command. |
| 24 |
> |
* \version $Id$ |
| 25 |
|
*/ |
| 26 |
|
|
| 27 |
|
#include "stdinc.h" |
| 29 |
|
#include "irc_string.h" |
| 30 |
|
#include "ircd.h" |
| 31 |
|
#include "numeric.h" |
| 32 |
< |
#include "s_serv.h" |
| 32 |
> |
#include "server.h" |
| 33 |
|
#include "send.h" |
| 34 |
|
#include "conf.h" |
| 33 |
– |
#include "motd.h" |
| 35 |
|
#include "parse.h" |
| 36 |
|
#include "modules.h" |
| 37 |
|
|
| 38 |
|
|
| 39 |
+ |
/*! \brief Shows a list of linked servers and notifies irc-operators |
| 40 |
+ |
* about the LINKS request |
| 41 |
+ |
* |
| 42 |
+ |
* \param source_p Pointer to client to report to |
| 43 |
+ |
*/ |
| 44 |
|
static void |
| 45 |
|
do_links(struct Client *source_p, int parc, char *parv[]) |
| 46 |
|
{ |
| 47 |
< |
dlink_node *ptr = NULL; |
| 47 |
> |
dlink_node *node = NULL; |
| 48 |
|
|
| 49 |
|
sendto_realops_flags(UMODE_SPY, L_ALL, SEND_NOTICE, |
| 50 |
|
"LINKS requested by %s (%s@%s) [%s]", |
| 55 |
|
if (HasUMode(source_p, UMODE_OPER) || !ConfigServerHide.flatten_links) |
| 56 |
|
{ |
| 57 |
|
const char *mask = (parc > 2 ? parv[2] : parv[1]); |
| 52 |
– |
const char *me_name, *nick; |
| 58 |
|
|
| 59 |
< |
me_name = ID_or_name(&me, source_p->from); |
| 55 |
< |
nick = ID_or_name(source_p, source_p->from); |
| 56 |
< |
|
| 57 |
< |
DLINK_FOREACH(ptr, global_serv_list.head) |
| 59 |
> |
DLINK_FOREACH(node, global_server_list.head) |
| 60 |
|
{ |
| 61 |
< |
struct Client *target_p = ptr->data; |
| 61 |
> |
struct Client *target_p = node->data; |
| 62 |
|
|
| 63 |
|
/* skip hidden servers */ |
| 64 |
|
if (IsHidden(target_p)) |
| 74 |
|
|
| 75 |
|
/* |
| 76 |
|
* We just send the reply, as if they are here there's either no SHIDE, |
| 77 |
< |
* or they're an oper.. |
| 77 |
> |
* or they're an oper.. |
| 78 |
|
*/ |
| 79 |
< |
sendto_one(source_p, form_str(RPL_LINKS), |
| 80 |
< |
me_name, nick, |
| 81 |
< |
target_p->name, target_p->servptr->name, |
| 80 |
< |
target_p->hopcount, target_p->info); |
| 79 |
> |
sendto_one_numeric(source_p, &me, RPL_LINKS, |
| 80 |
> |
target_p->name, target_p->servptr->name, |
| 81 |
> |
target_p->hopcount, target_p->info); |
| 82 |
|
} |
| 83 |
< |
|
| 84 |
< |
sendto_one(source_p, form_str(RPL_ENDOFLINKS), |
| 85 |
< |
me_name, nick, |
| 85 |
< |
EmptyString(mask) ? "*" : mask); |
| 83 |
> |
|
| 84 |
> |
sendto_one_numeric(source_p, &me, RPL_ENDOFLINKS, |
| 85 |
> |
EmptyString(mask) ? "*" : mask); |
| 86 |
|
} |
| 87 |
|
else |
| 88 |
|
{ |
| 90 |
|
* Print our own info so at least it looks like a normal links |
| 91 |
|
* then print out the file (which may or may not be empty) |
| 92 |
|
*/ |
| 93 |
< |
sendto_one(source_p, form_str(RPL_LINKS), |
| 94 |
< |
ID_or_name(&me, source_p->from), |
| 95 |
< |
ID_or_name(source_p, source_p->from), |
| 96 |
< |
me.name, me.name, 0, me.info); |
| 97 |
< |
|
| 98 |
< |
DLINK_FOREACH(ptr, flatten_links.head) |
| 99 |
< |
sendto_one(source_p, ":%s %d %s %s", |
| 100 |
< |
ID_or_name(&me, source_p->from), RPL_LINKS, |
| 101 |
< |
ID_or_name(source_p, source_p->from), |
| 102 |
< |
ptr->data); |
| 103 |
< |
sendto_one(source_p, form_str(RPL_ENDOFLINKS), |
| 104 |
< |
ID_or_name(&me, source_p->from), |
| 105 |
< |
ID_or_name(source_p, source_p->from), "*"); |
| 93 |
> |
sendto_one_numeric(source_p, &me, RPL_LINKS, me.name, me.name, 0, me.info); |
| 94 |
> |
|
| 95 |
> |
DLINK_FOREACH(node, flatten_links.head) |
| 96 |
> |
sendto_one_numeric(source_p, &me, RPL_LINKS|SND_EXPLICIT, "%s", node->data); |
| 97 |
> |
sendto_one_numeric(source_p, &me, RPL_ENDOFLINKS, "*"); |
| 98 |
|
} |
| 99 |
|
} |
| 100 |
|
|
| 101 |
< |
static void |
| 102 |
< |
mo_links(struct Client *client_p, struct Client *source_p, |
| 111 |
< |
int parc, char *parv[]) |
| 101 |
> |
static int |
| 102 |
> |
mo_links(struct Client *source_p, int parc, char *parv[]) |
| 103 |
|
{ |
| 104 |
|
if (parc > 2) |
| 105 |
|
if (!ConfigServerHide.disable_remote_commands || HasUMode(source_p, UMODE_OPER)) |
| 106 |
< |
if (hunt_server(client_p, source_p, ":%s LINKS %s :%s", 1, |
| 106 |
> |
if (hunt_server(source_p, ":%s LINKS %s :%s", 1, |
| 107 |
|
parc, parv) != HUNTED_ISME) |
| 108 |
< |
return; |
| 108 |
> |
return 0; |
| 109 |
|
|
| 110 |
|
do_links(source_p, parc, parv); |
| 111 |
+ |
return 0; |
| 112 |
|
} |
| 113 |
|
|
| 114 |
< |
/* |
| 115 |
< |
* m_links - LINKS message handler |
| 116 |
< |
* parv[0] = sender prefix |
| 117 |
< |
* parv[1] = servername mask |
| 114 |
> |
/*! \brief LINKS command handler |
| 115 |
> |
* |
| 116 |
> |
* \param source_p Pointer to allocated Client struct from which the message |
| 117 |
> |
* originally comes from. This can be a local or remote client. |
| 118 |
> |
* \param parc Integer holding the number of supplied arguments. |
| 119 |
> |
* \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL |
| 120 |
> |
* pointers. |
| 121 |
> |
* \note Valid arguments for this command are: |
| 122 |
> |
* - parv[0] = command |
| 123 |
> |
* - parv[1] = servername mask |
| 124 |
|
* or |
| 125 |
< |
* parv[0] = sender prefix |
| 126 |
< |
* parv[1] = server to query |
| 127 |
< |
* parv[2] = servername mask |
| 125 |
> |
* - parv[0] = command |
| 126 |
> |
* - parv[1] = server to query |
| 127 |
> |
* - parv[2] = servername mask |
| 128 |
|
*/ |
| 129 |
< |
static void |
| 130 |
< |
m_links(struct Client *client_p, struct Client *source_p, |
| 133 |
< |
int parc, char *parv[]) |
| 129 |
> |
static int |
| 130 |
> |
m_links(struct Client *source_p, int parc, char *parv[]) |
| 131 |
|
{ |
| 132 |
|
static time_t last_used = 0; |
| 133 |
|
|
| 134 |
< |
if ((last_used + ConfigFileEntry.pace_wait) > CurrentTime) |
| 134 |
> |
if ((last_used + ConfigGeneral.pace_wait) > CurrentTime) |
| 135 |
|
{ |
| 136 |
< |
sendto_one(source_p, form_str(RPL_LOAD2HI), |
| 137 |
< |
me.name, source_p->name); |
| 141 |
< |
return; |
| 136 |
> |
sendto_one_numeric(source_p, &me, RPL_LOAD2HI, "LINKS"); |
| 137 |
> |
return 0; |
| 138 |
|
} |
| 139 |
|
|
| 140 |
|
last_used = CurrentTime; |
| 141 |
|
|
| 142 |
|
if (!ConfigServerHide.flatten_links) |
| 143 |
< |
{ |
| 148 |
< |
mo_links(client_p, source_p, parc, parv); |
| 149 |
< |
return; |
| 150 |
< |
} |
| 143 |
> |
return mo_links(source_p, parc, parv); |
| 144 |
|
|
| 145 |
|
do_links(source_p, parc, parv); |
| 146 |
+ |
return 0; |
| 147 |
|
} |
| 148 |
|
|
| 149 |
< |
/* |
| 150 |
< |
* ms_links - LINKS message handler |
| 151 |
< |
* parv[0] = sender prefix |
| 152 |
< |
* parv[1] = servername mask |
| 149 |
> |
/*! \brief LINKS command handler |
| 150 |
> |
* |
| 151 |
> |
* \param source_p Pointer to allocated Client struct from which the message |
| 152 |
> |
* originally comes from. This can be a local or remote client. |
| 153 |
> |
* \param parc Integer holding the number of supplied arguments. |
| 154 |
> |
* \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL |
| 155 |
> |
* pointers. |
| 156 |
> |
* \note Valid arguments for this command are: |
| 157 |
> |
* - parv[0] = command |
| 158 |
> |
* - parv[1] = servername mask |
| 159 |
|
* or |
| 160 |
< |
* parv[0] = sender prefix |
| 161 |
< |
* parv[1] = server to query |
| 162 |
< |
* parv[2] = servername mask |
| 160 |
> |
* - parv[0] = command |
| 161 |
> |
* - parv[1] = server to query |
| 162 |
> |
* - parv[2] = servername mask |
| 163 |
|
*/ |
| 164 |
< |
static void |
| 165 |
< |
ms_links(struct Client *client_p, struct Client *source_p, |
| 166 |
< |
int parc, char *parv[]) |
| 164 |
> |
static int |
| 165 |
> |
ms_links(struct Client *source_p, int parc, char *parv[]) |
| 166 |
|
{ |
| 167 |
< |
if (hunt_server(client_p, source_p, ":%s LINKS %s :%s", 1, |
| 168 |
< |
parc, parv) != HUNTED_ISME) |
| 170 |
< |
return; |
| 167 |
> |
if (hunt_server(source_p, ":%s LINKS %s :%s", 1, parc, parv) != HUNTED_ISME) |
| 168 |
> |
return 0; |
| 169 |
|
|
| 170 |
< |
m_links(client_p, source_p, parc, parv); |
| 170 |
> |
return m_links(source_p, parc, parv); |
| 171 |
|
} |
| 172 |
|
|
| 173 |
< |
static struct Message links_msgtab = { |
| 174 |
< |
"LINKS", 0, 0, 0, MAXPARA, MFLG_SLOW, 0, |
| 175 |
< |
{m_unregistered, m_links, ms_links, m_ignore, mo_links, m_ignore} |
| 173 |
> |
static struct Message links_msgtab = |
| 174 |
> |
{ |
| 175 |
> |
"LINKS", NULL, 0, 0, 0, MAXPARA, MFLG_SLOW, 0, |
| 176 |
> |
{ m_unregistered, m_links, ms_links, m_ignore, mo_links, m_ignore } |
| 177 |
|
}; |
| 178 |
|
|
| 179 |
|
static void |
| 188 |
|
mod_del_cmd(&links_msgtab); |
| 189 |
|
} |
| 190 |
|
|
| 191 |
< |
struct module module_entry = { |
| 191 |
> |
struct module module_entry = |
| 192 |
> |
{ |
| 193 |
|
.node = { NULL, NULL, NULL }, |
| 194 |
|
.name = NULL, |
| 195 |
|
.version = "$Revision$", |