25 |
|
*/ |
26 |
|
|
27 |
|
#include "stdinc.h" |
28 |
– |
#include "handlers.h" |
28 |
|
#include "client.h" |
29 |
|
#include "ircd.h" |
30 |
|
#include "numeric.h" |
31 |
< |
#include "s_conf.h" |
31 |
> |
#include "conf.h" |
32 |
|
#include "s_serv.h" |
33 |
|
#include "send.h" |
35 |
– |
#include "msg.h" |
34 |
|
#include "parse.h" |
37 |
– |
#include "hook.h" |
35 |
|
#include "modules.h" |
36 |
|
#include "irc_string.h" |
37 |
|
|
41 |
– |
static void m_admin(struct Client *, struct Client *, int, char *[]); |
42 |
– |
static void mr_admin(struct Client *, struct Client *, int, char *[]); |
43 |
– |
static void ms_admin(struct Client *, struct Client *, int, char *[]); |
44 |
– |
static void do_admin(struct Client *); |
45 |
– |
|
46 |
– |
struct Message admin_msgtab = { |
47 |
– |
"ADMIN", 0, 0, 0, 0, MFLG_SLOW | MFLG_UNREG, 0, |
48 |
– |
{mr_admin, m_admin, ms_admin, m_ignore, ms_admin, m_ignore} |
49 |
– |
}; |
50 |
– |
|
51 |
– |
static struct Callback *admin_cb; |
52 |
– |
const char *_version = "$Revision$"; |
53 |
– |
|
54 |
– |
static void * |
55 |
– |
va_admin(va_list args) |
56 |
– |
{ |
57 |
– |
do_admin(va_arg(args, struct Client *)); |
58 |
– |
return NULL; |
59 |
– |
} |
60 |
– |
|
61 |
– |
void |
62 |
– |
_modinit(void) |
63 |
– |
{ |
64 |
– |
admin_cb = register_callback("doing_admin", va_admin); |
65 |
– |
mod_add_cmd(&admin_msgtab); |
66 |
– |
} |
38 |
|
|
68 |
– |
void |
69 |
– |
_moddeinit(void) |
70 |
– |
{ |
71 |
– |
mod_del_cmd(&admin_msgtab); |
72 |
– |
uninstall_hook(admin_cb, va_admin); |
73 |
– |
} |
39 |
|
|
40 |
< |
/*! \brief ADMIN command handler (called by unregistered, |
76 |
< |
* locally connected clients) |
40 |
> |
/*! \brief Sends administrative information about this server. |
41 |
|
* |
42 |
< |
* \param client_p Pointer to allocated Client struct with physical connection |
79 |
< |
* to this server, i.e. with an open socket connected. |
80 |
< |
* \param source_p Pointer to allocated Client struct from which the message |
81 |
< |
* originally comes from. This can be a local or remote client. |
82 |
< |
* \param parc Integer holding the number of supplied arguments. |
83 |
< |
* \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL |
84 |
< |
* pointers. |
85 |
< |
* \note Valid arguments for this command are: |
86 |
< |
* - parv[0] = sender prefix |
42 |
> |
* \param source_p Pointer to client to report to |
43 |
|
*/ |
44 |
|
static void |
45 |
< |
mr_admin(struct Client *client_p, struct Client *source_p, |
90 |
< |
int parc, char *parv[]) |
45 |
> |
do_admin(struct Client *source_p) |
46 |
|
{ |
47 |
< |
static time_t last_used = 0; |
48 |
< |
|
94 |
< |
ClearCap(client_p, CAP_TS6); |
47 |
> |
const char *me_name = ID_or_name(&me, source_p->from); |
48 |
> |
const char *nick = ID_or_name(source_p, source_p->from); |
49 |
|
|
50 |
< |
if ((last_used + ConfigFileEntry.pace_wait_simple) > CurrentTime) |
51 |
< |
{ |
52 |
< |
sendto_one(source_p, form_str(RPL_LOAD2HI), |
53 |
< |
me.name, EmptyString(parv[0]) ? "*" : parv[0]); |
100 |
< |
return; |
101 |
< |
} |
50 |
> |
sendto_realops_flags(UMODE_SPY, L_ALL, |
51 |
> |
"ADMIN requested by %s (%s@%s) [%s]", |
52 |
> |
source_p->name, source_p->username, |
53 |
> |
source_p->host, source_p->servptr->name); |
54 |
|
|
55 |
< |
last_used = CurrentTime; |
55 |
> |
sendto_one(source_p, form_str(RPL_ADMINME), |
56 |
> |
me_name, nick, me.name); |
57 |
|
|
58 |
< |
execute_callback(admin_cb, source_p, parc, parv); |
58 |
> |
if (AdminInfo.name != NULL) |
59 |
> |
sendto_one(source_p, form_str(RPL_ADMINLOC1), |
60 |
> |
me_name, nick, AdminInfo.name); |
61 |
> |
if (AdminInfo.description != NULL) |
62 |
> |
sendto_one(source_p, form_str(RPL_ADMINLOC2), |
63 |
> |
me_name, nick, AdminInfo.description); |
64 |
> |
if (AdminInfo.email != NULL) |
65 |
> |
sendto_one(source_p, form_str(RPL_ADMINEMAIL), |
66 |
> |
me_name, nick, AdminInfo.email); |
67 |
|
} |
68 |
|
|
69 |
|
/*! \brief NICK command handler (called by already registered, |
100 |
|
parc, parv) != HUNTED_ISME) |
101 |
|
return; |
102 |
|
|
103 |
< |
execute_callback(admin_cb, source_p, parc, parv); |
103 |
> |
do_admin(source_p); |
104 |
|
} |
105 |
|
|
106 |
|
/*! \brief ADMIN command handler (called by operators and |
121 |
|
ms_admin(struct Client *client_p, struct Client *source_p, |
122 |
|
int parc, char *parv[]) |
123 |
|
{ |
124 |
< |
if (hunt_server(client_p, source_p, ":%s ADMIN :%s", 1, parc, parv) |
125 |
< |
!= HUNTED_ISME) |
124 |
> |
if (hunt_server(client_p, source_p, ":%s ADMIN :%s", 1, |
125 |
> |
parc, parv) != HUNTED_ISME) |
126 |
|
return; |
127 |
|
|
128 |
|
if (IsClient(source_p)) |
129 |
< |
execute_callback(admin_cb, source_p, parc, parv); |
129 |
> |
do_admin(source_p); |
130 |
|
} |
131 |
|
|
132 |
< |
/*! \brief Sends administrative information about this server. |
133 |
< |
* |
134 |
< |
* \param source_p Pointer to client to report to |
135 |
< |
*/ |
132 |
> |
static struct Message admin_msgtab = { |
133 |
> |
"ADMIN", 0, 0, 0, MAXPARA, MFLG_SLOW, 0, |
134 |
> |
{ m_unregistered, m_admin, ms_admin, m_ignore, ms_admin, m_ignore } |
135 |
> |
}; |
136 |
> |
|
137 |
|
static void |
138 |
< |
do_admin(struct Client *source_p) |
138 |
> |
module_init(void) |
139 |
|
{ |
140 |
< |
const char *me_name; |
141 |
< |
const char *nick; |
180 |
< |
|
181 |
< |
me_name = ID_or_name(&me, source_p->from); |
182 |
< |
nick = ID_or_name(source_p, source_p->from); |
140 |
> |
mod_add_cmd(&admin_msgtab); |
141 |
> |
} |
142 |
|
|
143 |
< |
sendto_one(source_p, form_str(RPL_ADMINME), |
144 |
< |
me_name, nick, me.name); |
145 |
< |
if (AdminInfo.name != NULL) |
146 |
< |
sendto_one(source_p, form_str(RPL_ADMINLOC1), |
188 |
< |
me_name, nick, AdminInfo.name); |
189 |
< |
if (AdminInfo.description != NULL) |
190 |
< |
sendto_one(source_p, form_str(RPL_ADMINLOC2), |
191 |
< |
me_name, nick, AdminInfo.description); |
192 |
< |
if (AdminInfo.email != NULL) |
193 |
< |
sendto_one(source_p, form_str(RPL_ADMINEMAIL), |
194 |
< |
me_name, nick, AdminInfo.email); |
143 |
> |
static void |
144 |
> |
module_exit(void) |
145 |
> |
{ |
146 |
> |
mod_del_cmd(&admin_msgtab); |
147 |
|
} |
148 |
+ |
|
149 |
+ |
struct module module_entry = { |
150 |
+ |
.node = { NULL, NULL, NULL }, |
151 |
+ |
.name = NULL, |
152 |
+ |
.version = "$Revision$", |
153 |
+ |
.handle = NULL, |
154 |
+ |
.modinit = module_init, |
155 |
+ |
.modexit = module_exit, |
156 |
+ |
.flags = 0 |
157 |
+ |
}; |