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