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 "s_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 |
' ', |
40 |
'T', |
41 |
'S', |
42 |
#ifdef TS_CURRENT |
43 |
'0' + TS_CURRENT, |
44 |
#endif |
45 |
/* ONLY do TS */ |
46 |
/* ALWAYS do TS_WARNINGS */ |
47 |
'o', |
48 |
'w', |
49 |
'\0' |
50 |
}; |
51 |
|
52 |
/* confopts() |
53 |
* |
54 |
* input - client pointer |
55 |
* output - ircd.conf option string |
56 |
* side effects - none |
57 |
*/ |
58 |
static char * |
59 |
confopts(struct Client *source_p) |
60 |
{ |
61 |
static char result[12]; |
62 |
char *p = result; |
63 |
|
64 |
if (ConfigChannel.use_except) |
65 |
*p++ = 'e'; |
66 |
if (ConfigFileEntry.glines) |
67 |
*p++ = 'G'; |
68 |
*p++ = 'g'; |
69 |
|
70 |
/* might wanna hide this :P */ |
71 |
if (ServerInfo.hub && |
72 |
(!ConfigFileEntry.disable_remote || HasUMode(source_p, UMODE_OPER))) |
73 |
{ |
74 |
*p++ = 'H'; |
75 |
} |
76 |
|
77 |
if (ConfigChannel.use_invex) |
78 |
*p++ = 'I'; |
79 |
if (ConfigChannel.use_knock) |
80 |
*p++ = 'K'; |
81 |
*p++ = 'M'; |
82 |
|
83 |
if (ConfigFileEntry.ignore_bogus_ts) |
84 |
*p++ = 'T'; |
85 |
#ifdef HAVE_LIBZ |
86 |
*p++ = 'Z'; |
87 |
#endif |
88 |
*p++ = '6'; |
89 |
|
90 |
*p = '\0'; |
91 |
|
92 |
return result; |
93 |
} |
94 |
|
95 |
/* |
96 |
* m_version - VERSION command handler |
97 |
* parv[0] = sender prefix |
98 |
* parv[1] = remote server |
99 |
*/ |
100 |
static void |
101 |
m_version(struct Client *client_p, struct Client *source_p, |
102 |
int parc, char *parv[]) |
103 |
{ |
104 |
static time_t last_used = 0; |
105 |
|
106 |
if ((last_used + ConfigFileEntry.pace_wait_simple) > CurrentTime) |
107 |
{ |
108 |
/* safe enough to give this on a local connect only */ |
109 |
sendto_one(source_p, form_str(RPL_LOAD2HI), |
110 |
me.name, source_p->name); |
111 |
return; |
112 |
} |
113 |
|
114 |
last_used = CurrentTime; |
115 |
|
116 |
if (!ConfigFileEntry.disable_remote) |
117 |
if (hunt_server(client_p, source_p, ":%s VERSION :%s", |
118 |
1, parc, parv) != HUNTED_ISME) |
119 |
return; |
120 |
|
121 |
sendto_one(source_p, form_str(RPL_VERSION), |
122 |
me.name, source_p->name, ircd_version, serno, |
123 |
me.name, confopts(source_p), serveropts); |
124 |
show_isupport(source_p); |
125 |
} |
126 |
|
127 |
/* |
128 |
* mo_version - VERSION command handler |
129 |
* parv[0] = sender prefix |
130 |
* parv[1] = remote server |
131 |
*/ |
132 |
static void |
133 |
mo_version(struct Client *client_p, struct Client *source_p, |
134 |
int parc, char *parv[]) |
135 |
{ |
136 |
|
137 |
if (hunt_server(client_p, source_p, ":%s VERSION :%s", |
138 |
1, parc, parv) != HUNTED_ISME) |
139 |
return; |
140 |
|
141 |
sendto_one(source_p, form_str(RPL_VERSION), me.name, |
142 |
source_p->name, ircd_version, |
143 |
serno, me.name, confopts(source_p), serveropts); |
144 |
|
145 |
show_isupport(source_p); |
146 |
} |
147 |
|
148 |
/* |
149 |
* ms_version - VERSION command handler |
150 |
* parv[0] = sender prefix |
151 |
* parv[1] = remote server |
152 |
*/ |
153 |
static void |
154 |
ms_version(struct Client *client_p, struct Client *source_p, |
155 |
int parc, char *parv[]) |
156 |
{ |
157 |
if (hunt_server(client_p, source_p, ":%s VERSION :%s", |
158 |
1, parc, parv) == HUNTED_ISME) |
159 |
{ |
160 |
sendto_one(source_p, form_str(RPL_VERSION), |
161 |
ID_or_name(&me, client_p), |
162 |
ID_or_name(source_p, client_p), |
163 |
ircd_version, serno, |
164 |
me.name, confopts(source_p), serveropts); |
165 |
show_isupport(source_p); |
166 |
} |
167 |
} |
168 |
|
169 |
static struct Message version_msgtab = { |
170 |
"VERSION", 0, 0, 0, MAXPARA, MFLG_SLOW, 0, |
171 |
{ m_unregistered, m_version, ms_version, m_ignore, mo_version, m_ignore } |
172 |
}; |
173 |
|
174 |
static void |
175 |
module_init(void) |
176 |
{ |
177 |
mod_add_cmd(&version_msgtab); |
178 |
} |
179 |
|
180 |
static void |
181 |
module_exit(void) |
182 |
{ |
183 |
mod_del_cmd(&version_msgtab); |
184 |
} |
185 |
|
186 |
struct module module_entry = { |
187 |
.node = { NULL, NULL, NULL }, |
188 |
.name = NULL, |
189 |
.version = "$Revision$", |
190 |
.handle = NULL, |
191 |
.modinit = module_init, |
192 |
.modexit = module_exit, |
193 |
.flags = 0 |
194 |
}; |