]>
Commit | Line | Data |
---|---|---|
212380e3 AC |
1 | /* |
2 | * ircd-ratbox: A slightly useful ircd. | |
3 | * m_version.c: Shows ircd version information. | |
4 | * | |
5 | * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center | |
6 | * Copyright (C) 1996-2002 Hybrid Development Team | |
7 | * Copyright (C) 2002-2005 ircd-ratbox development team | |
8 | * | |
9 | * This program is free software; you can redistribute it and/or modify | |
10 | * it under the terms of the GNU General Public License as published by | |
11 | * the Free Software Foundation; either version 2 of the License, or | |
12 | * (at your option) any later version. | |
13 | * | |
14 | * This program is distributed in the hope that it will be useful, | |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | * GNU General Public License for more details. | |
18 | * | |
19 | * You should have received a copy of the GNU General Public License | |
20 | * along with this program; if not, write to the Free Software | |
21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 | |
22 | * USA | |
212380e3 AC |
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 "supported.h" | |
32 | #include "send.h" | |
33 | #include "msg.h" | |
34 | #include "parse.h" | |
35 | #include "modules.h" | |
36 | ||
eeabf33a EM |
37 | static const char version_desc[] = |
38 | "Provides the VERSION command to display server version information"; | |
39 | ||
29c92cf9 | 40 | static char *confopts(void); |
212380e3 | 41 | |
3c7d6fcc EM |
42 | static void m_version(struct MsgBuf *, struct Client *, struct Client *, int, const char **); |
43 | static void mo_version(struct MsgBuf *, struct Client *, struct Client *, int, const char **); | |
212380e3 AC |
44 | |
45 | struct Message version_msgtab = { | |
7baa37a9 | 46 | "VERSION", 0, 0, 0, 0, |
212380e3 AC |
47 | {mg_unreg, {m_version, 0}, {mo_version, 0}, {mo_version, 0}, mg_ignore, {mo_version, 0}} |
48 | }; | |
49 | ||
50 | mapi_clist_av1 version_clist[] = { &version_msgtab, NULL }; | |
eeabf33a | 51 | |
78624ddf | 52 | DECLARE_MODULE_AV2(version, NULL, NULL, version_clist, NULL, NULL, NULL, NULL, version_desc); |
212380e3 AC |
53 | |
54 | /* | |
55 | * m_version - VERSION command handler | |
212380e3 AC |
56 | * parv[1] = remote server |
57 | */ | |
3c7d6fcc | 58 | static void |
428ca87b | 59 | m_version(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) |
212380e3 AC |
60 | { |
61 | static time_t last_used = 0L; | |
62 | ||
63 | if(parc > 1) | |
64 | { | |
e3354945 | 65 | if((last_used + ConfigFileEntry.pace_wait) > rb_current_time()) |
212380e3 AC |
66 | { |
67 | /* safe enough to give this on a local connect only */ | |
68 | sendto_one(source_p, form_str(RPL_LOAD2HI), | |
69 | me.name, source_p->name, "VERSION"); | |
3c7d6fcc | 70 | return; |
212380e3 AC |
71 | } |
72 | else | |
e3354945 | 73 | last_used = rb_current_time(); |
212380e3 AC |
74 | |
75 | if(hunt_server(client_p, source_p, ":%s VERSION :%s", 1, parc, parv) != HUNTED_ISME) | |
3c7d6fcc | 76 | return; |
212380e3 AC |
77 | } |
78 | ||
79 | sendto_one_numeric(source_p, RPL_VERSION, form_str(RPL_VERSION), | |
80 | ircd_version, serno, | |
0f4ed405 | 81 | #ifdef CUSTOM_BRANDING |
c72f15bc | 82 | PACKAGE_NAME "-" PACKAGE_VERSION, |
0f4ed405 | 83 | #endif |
f8838806 | 84 | me.name, confopts(), TS_CURRENT); |
212380e3 AC |
85 | |
86 | show_isupport(source_p); | |
212380e3 AC |
87 | } |
88 | ||
89 | /* | |
90 | * mo_version - VERSION command handler | |
212380e3 AC |
91 | * parv[1] = remote server |
92 | */ | |
3c7d6fcc | 93 | static void |
428ca87b | 94 | mo_version(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) |
212380e3 AC |
95 | { |
96 | if(hunt_server(client_p, source_p, ":%s VERSION :%s", 1, parc, parv) == HUNTED_ISME) | |
97 | { | |
98 | sendto_one_numeric(source_p, RPL_VERSION, form_str(RPL_VERSION), | |
55abcbb2 | 99 | ircd_version, serno, |
f5493691 | 100 | #ifdef CUSTOM_BRANDING |
c72f15bc | 101 | PACKAGE_NAME "-" PACKAGE_VERSION, |
f5493691 | 102 | #endif |
f8838806 | 103 | me.name, confopts(), TS_CURRENT); |
212380e3 AC |
104 | show_isupport(source_p); |
105 | } | |
212380e3 AC |
106 | } |
107 | ||
108 | /* confopts() | |
29c92cf9 | 109 | * input - none |
212380e3 AC |
110 | * output - ircd.conf option string |
111 | * side effects - none | |
112 | */ | |
113 | static char * | |
29c92cf9 | 114 | confopts(void) |
212380e3 AC |
115 | { |
116 | static char result[15]; | |
117 | char *p; | |
118 | ||
119 | result[0] = '\0'; | |
120 | p = result; | |
121 | ||
122 | if(ConfigChannel.use_except) | |
123 | *p++ = 'e'; | |
124 | ||
212380e3 AC |
125 | if(ConfigChannel.use_invex) |
126 | *p++ = 'I'; | |
127 | ||
128 | if(ConfigChannel.use_knock) | |
129 | *p++ = 'K'; | |
130 | ||
131 | *p++ = 'M'; | |
132 | *p++ = 'p'; | |
133 | ||
134 | if(opers_see_all_users || ConfigFileEntry.operspy_dont_care_user_info) | |
135 | *p++ = 'S'; | |
212380e3 AC |
136 | |
137 | #ifdef HAVE_LIBZ | |
138 | *p++ = 'Z'; | |
139 | #endif | |
140 | ||
212380e3 | 141 | *p++ = '6'; |
212380e3 AC |
142 | |
143 | *p = '\0'; | |
144 | ||
145 | return result; | |
146 | } |