1 |
/* |
2 |
* ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). |
3 |
* m_version.c: Shows ircd version information. |
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 "client.h" |
27 |
#include "ircd.h" |
28 |
#include "numeric.h" |
29 |
#include "conf.h" |
30 |
#include "s_serv.h" |
31 |
#include "s_user.h" |
32 |
#include "send.h" |
33 |
#include "parse.h" |
34 |
#include "modules.h" |
35 |
|
36 |
|
37 |
/* Option string. */ |
38 |
static const char serveropts[] = { |
39 |
'T', |
40 |
'S', |
41 |
#ifdef TS_CURRENT |
42 |
'0' + TS_CURRENT, |
43 |
#endif |
44 |
/* ONLY do TS */ |
45 |
/* ALWAYS do TS_WARNINGS */ |
46 |
'o', |
47 |
'w', |
48 |
'\0' |
49 |
}; |
50 |
|
51 |
/* |
52 |
* m_version - VERSION command handler |
53 |
* parv[0] = sender prefix |
54 |
* parv[1] = remote server |
55 |
*/ |
56 |
static int |
57 |
m_version(struct Client *client_p, struct Client *source_p, |
58 |
int parc, char *parv[]) |
59 |
{ |
60 |
static time_t last_used = 0; |
61 |
|
62 |
if ((last_used + ConfigFileEntry.pace_wait_simple) > CurrentTime) |
63 |
{ |
64 |
/* safe enough to give this on a local connect only */ |
65 |
sendto_one(source_p, form_str(RPL_LOAD2HI), |
66 |
me.name, source_p->name); |
67 |
return 0; |
68 |
} |
69 |
|
70 |
last_used = CurrentTime; |
71 |
|
72 |
if (!ConfigServerHide.disable_remote_commands) |
73 |
if (hunt_server(client_p, source_p, ":%s VERSION :%s", |
74 |
1, parc, parv) != HUNTED_ISME) |
75 |
return 0; |
76 |
|
77 |
sendto_one(source_p, form_str(RPL_VERSION), me.name, |
78 |
source_p->name, ircd_version, serno, |
79 |
me.name, serveropts); |
80 |
show_isupport(source_p); |
81 |
return 0; |
82 |
} |
83 |
|
84 |
/* |
85 |
* mo_version - VERSION command handler |
86 |
* parv[0] = sender prefix |
87 |
* parv[1] = remote server |
88 |
*/ |
89 |
static int |
90 |
mo_version(struct Client *client_p, struct Client *source_p, |
91 |
int parc, char *parv[]) |
92 |
{ |
93 |
|
94 |
if (hunt_server(client_p, source_p, ":%s VERSION :%s", |
95 |
1, parc, parv) != HUNTED_ISME) |
96 |
return 0; |
97 |
|
98 |
sendto_one(source_p, form_str(RPL_VERSION), me.name, |
99 |
source_p->name, ircd_version, serno, |
100 |
me.name, serveropts); |
101 |
show_isupport(source_p); |
102 |
return 0; |
103 |
} |
104 |
|
105 |
/* |
106 |
* ms_version - VERSION command handler |
107 |
* parv[0] = sender prefix |
108 |
* parv[1] = remote server |
109 |
*/ |
110 |
static int |
111 |
ms_version(struct Client *client_p, struct Client *source_p, |
112 |
int parc, char *parv[]) |
113 |
{ |
114 |
if (hunt_server(client_p, source_p, ":%s VERSION :%s", |
115 |
1, parc, parv) != HUNTED_ISME) |
116 |
return 0; |
117 |
|
118 |
sendto_one(source_p, form_str(RPL_VERSION), |
119 |
ID_or_name(&me, client_p), |
120 |
ID_or_name(source_p, client_p), |
121 |
ircd_version, serno, |
122 |
me.name, serveropts); |
123 |
show_isupport(source_p); |
124 |
return 0; |
125 |
} |
126 |
|
127 |
static struct Message version_msgtab = |
128 |
{ |
129 |
"VERSION", 0, 0, 0, MAXPARA, MFLG_SLOW, 0, |
130 |
{ m_unregistered, m_version, ms_version, m_ignore, mo_version, m_ignore } |
131 |
}; |
132 |
|
133 |
static void |
134 |
module_init(void) |
135 |
{ |
136 |
mod_add_cmd(&version_msgtab); |
137 |
} |
138 |
|
139 |
static void |
140 |
module_exit(void) |
141 |
{ |
142 |
mod_del_cmd(&version_msgtab); |
143 |
} |
144 |
|
145 |
struct module module_entry = |
146 |
{ |
147 |
.node = { NULL, NULL, NULL }, |
148 |
.name = NULL, |
149 |
.version = "$Revision$", |
150 |
.handle = NULL, |
151 |
.modinit = module_init, |
152 |
.modexit = module_exit, |
153 |
.flags = 0 |
154 |
}; |