~ubuntu-branches/ubuntu/trusty/charybdis/trusty-proposed

« back to all changes in this revision

Viewing changes to modules/m_version.c

  • Committer: Package Import Robot
  • Author(s): Antoine Beaupré
  • Date: 2011-11-10 23:07:37 UTC
  • Revision ID: package-import@ubuntu.com-20111110230737-kqo6qsglp5oh02hr
Tags: upstream-3.3.0
Import upstream version 3.3.0

Show diffs side-by-side

added added

removed removed

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