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