]>
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 | ||
29c92cf9 | 37 | static char *confopts(void); |
212380e3 | 38 | |
428ca87b AC |
39 | static int m_version(struct MsgBuf *, struct Client *, struct Client *, int, const char **); |
40 | static int mo_version(struct MsgBuf *, struct Client *, struct Client *, int, const char **); | |
212380e3 AC |
41 | |
42 | struct Message version_msgtab = { | |
7baa37a9 | 43 | "VERSION", 0, 0, 0, 0, |
212380e3 AC |
44 | {mg_unreg, {m_version, 0}, {mo_version, 0}, {mo_version, 0}, mg_ignore, {mo_version, 0}} |
45 | }; | |
46 | ||
47 | mapi_clist_av1 version_clist[] = { &version_msgtab, NULL }; | |
48 | DECLARE_MODULE_AV1(version, NULL, NULL, version_clist, NULL, NULL, "$Revision: 1887 $"); | |
49 | ||
50 | /* | |
51 | * m_version - VERSION command handler | |
212380e3 AC |
52 | * parv[1] = remote server |
53 | */ | |
54 | static int | |
428ca87b | 55 | m_version(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) |
212380e3 AC |
56 | { |
57 | static time_t last_used = 0L; | |
58 | ||
59 | if(parc > 1) | |
60 | { | |
e3354945 | 61 | if((last_used + ConfigFileEntry.pace_wait) > rb_current_time()) |
212380e3 AC |
62 | { |
63 | /* safe enough to give this on a local connect only */ | |
64 | sendto_one(source_p, form_str(RPL_LOAD2HI), | |
65 | me.name, source_p->name, "VERSION"); | |
66 | return 0; | |
67 | } | |
68 | else | |
e3354945 | 69 | last_used = rb_current_time(); |
212380e3 AC |
70 | |
71 | if(hunt_server(client_p, source_p, ":%s VERSION :%s", 1, parc, parv) != HUNTED_ISME) | |
72 | return 0; | |
73 | } | |
74 | ||
75 | sendto_one_numeric(source_p, RPL_VERSION, form_str(RPL_VERSION), | |
76 | ircd_version, serno, | |
0f4ed405 | 77 | #ifdef CUSTOM_BRANDING |
c72f15bc | 78 | PACKAGE_NAME "-" PACKAGE_VERSION, |
0f4ed405 | 79 | #endif |
29c92cf9 | 80 | me.name, confopts(), TS_CURRENT, |
212380e3 AC |
81 | ServerInfo.sid); |
82 | ||
83 | show_isupport(source_p); | |
84 | ||
85 | return 0; | |
86 | } | |
87 | ||
88 | /* | |
89 | * mo_version - VERSION command handler | |
212380e3 AC |
90 | * parv[1] = remote server |
91 | */ | |
92 | static int | |
428ca87b | 93 | mo_version(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) |
212380e3 AC |
94 | { |
95 | if(hunt_server(client_p, source_p, ":%s VERSION :%s", 1, parc, parv) == HUNTED_ISME) | |
96 | { | |
97 | sendto_one_numeric(source_p, RPL_VERSION, form_str(RPL_VERSION), | |
55abcbb2 | 98 | ircd_version, serno, |
f5493691 | 99 | #ifdef CUSTOM_BRANDING |
c72f15bc | 100 | PACKAGE_NAME "-" PACKAGE_VERSION, |
f5493691 | 101 | #endif |
29c92cf9 | 102 | me.name, confopts(), TS_CURRENT, |
212380e3 AC |
103 | ServerInfo.sid); |
104 | show_isupport(source_p); | |
105 | } | |
106 | ||
107 | return 0; | |
108 | } | |
109 | ||
110 | /* confopts() | |
29c92cf9 | 111 | * input - none |
212380e3 AC |
112 | * output - ircd.conf option string |
113 | * side effects - none | |
114 | */ | |
115 | static char * | |
29c92cf9 | 116 | confopts(void) |
212380e3 AC |
117 | { |
118 | static char result[15]; | |
119 | char *p; | |
120 | ||
121 | result[0] = '\0'; | |
122 | p = result; | |
123 | ||
124 | if(ConfigChannel.use_except) | |
125 | *p++ = 'e'; | |
126 | ||
212380e3 AC |
127 | /* might wanna hide this :P */ |
128 | if(ServerInfo.hub) | |
129 | *p++ = 'H'; | |
130 | ||
131 | if(ConfigChannel.use_invex) | |
132 | *p++ = 'I'; | |
133 | ||
134 | if(ConfigChannel.use_knock) | |
135 | *p++ = 'K'; | |
136 | ||
137 | *p++ = 'M'; | |
138 | *p++ = 'p'; | |
139 | ||
140 | if(opers_see_all_users || ConfigFileEntry.operspy_dont_care_user_info) | |
141 | *p++ = 'S'; | |
142 | #ifdef IGNORE_BOGUS_TS | |
143 | *p++ = 'T'; | |
144 | #endif | |
145 | ||
146 | #ifdef HAVE_LIBZ | |
147 | *p++ = 'Z'; | |
148 | #endif | |
149 | ||
ccda6e3f | 150 | #ifdef RB_IPV6 |
212380e3 AC |
151 | *p++ = '6'; |
152 | #endif | |
153 | ||
154 | *p = '\0'; | |
155 | ||
156 | return result; | |
157 | } |