1 |
/* |
2 |
* ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). |
3 |
* m_motd.c: Shows the current message of the day. |
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 "client.h" |
28 |
#include "motd.h" |
29 |
#include "ircd.h" |
30 |
#include "send.h" |
31 |
#include "numeric.h" |
32 |
#include "handlers.h" |
33 |
#include "msg.h" |
34 |
#include "s_serv.h" /* hunt_server */ |
35 |
#include "parse.h" |
36 |
#include "modules.h" |
37 |
#include "s_conf.h" |
38 |
|
39 |
static void m_motd(struct Client *, struct Client *, int, char *[]); |
40 |
static void mo_motd(struct Client *, struct Client *, int, char *[]); |
41 |
|
42 |
/* |
43 |
* note regarding mo_motd being used twice: |
44 |
* this is not a kludge. any rate limiting, shide, or whatever |
45 |
* other access restrictions should be done by the source's server. |
46 |
* for security's sake, still check that the source is an oper |
47 |
* for 'oper only' information in the mo_ function(s). |
48 |
*/ |
49 |
struct Message motd_msgtab = { |
50 |
"MOTD", 0, 0, 0, 1, MFLG_SLOW, 0, |
51 |
{ m_unregistered, m_motd, mo_motd, m_ignore, mo_motd, m_ignore } |
52 |
}; |
53 |
|
54 |
const char *_version = "$Revision$"; |
55 |
|
56 |
static void |
57 |
do_motd(struct Client *source_p) |
58 |
{ |
59 |
sendto_realops_flags(UMODE_SPY, L_ALL, |
60 |
"MOTD requested by %s (%s@%s) [%s]", |
61 |
source_p->name, source_p->username, |
62 |
source_p->host, source_p->servptr->name); |
63 |
send_message_file(source_p, &ConfigFileEntry.motd); |
64 |
} |
65 |
|
66 |
void |
67 |
_modinit(void) |
68 |
{ |
69 |
mod_add_cmd(&motd_msgtab); |
70 |
} |
71 |
|
72 |
void |
73 |
_moddeinit(void) |
74 |
{ |
75 |
mod_del_cmd(&motd_msgtab); |
76 |
} |
77 |
|
78 |
/* |
79 |
** m_motd |
80 |
** parv[0] = sender prefix |
81 |
** parv[1] = servername |
82 |
*/ |
83 |
static void |
84 |
m_motd(struct Client *client_p, struct Client *source_p, |
85 |
int parc, char *parv[]) |
86 |
{ |
87 |
static time_t last_used = 0; |
88 |
|
89 |
if ((last_used + ConfigFileEntry.pace_wait) > CurrentTime) |
90 |
{ |
91 |
/* safe enough to give this on a local connect only */ |
92 |
sendto_one(source_p, form_str(RPL_LOAD2HI), |
93 |
me.name, source_p->name); |
94 |
return; |
95 |
} |
96 |
|
97 |
last_used = CurrentTime; |
98 |
|
99 |
/* This is safe enough to use during non hidden server mode */ |
100 |
if (!ConfigFileEntry.disable_remote && !ConfigServerHide.hide_servers) |
101 |
if (hunt_server(client_p, source_p, ":%s MOTD :%s", 1, |
102 |
parc, parv) != HUNTED_ISME) |
103 |
return; |
104 |
|
105 |
do_motd(source_p); |
106 |
} |
107 |
|
108 |
/* |
109 |
** mo_motd |
110 |
** parv[0] = sender prefix |
111 |
** parv[1] = servername |
112 |
*/ |
113 |
static void |
114 |
mo_motd(struct Client *client_p, struct Client *source_p, |
115 |
int parc, char *parv[]) |
116 |
{ |
117 |
if (!IsClient(source_p)) |
118 |
return; |
119 |
|
120 |
if (hunt_server(client_p, source_p, ":%s MOTD :%s", 1, |
121 |
parc, parv) != HUNTED_ISME) |
122 |
return; |
123 |
|
124 |
do_motd(source_p); |
125 |
} |