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