-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy paths_debug.c
286 lines (256 loc) · 6.81 KB
/
s_debug.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
/************************************************************************
* IRC - Internet Relay Chat, src/s_debug.c
* Copyright (C) 1990 Jarkko Oikarinen and
* University of Oulu, Computing Center
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 1, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "struct.h"
#include "common.h"
#include "sys.h"
#include "h.h"
#include "patchlevel.h"
#include "numeric.h"
#include "channel.h"
/* This file is hereby declared the nexus of all things ugly and preprocessed */
static char rplisupport1[BUFSIZE];
static char rplisupport2[BUFSIZE];
static char rplisupportoper[BUFSIZE];
static char rplversion[BUFSIZE];
static char scratchbuf[BUFSIZE];
/* send cached RPL_ISUPPORT */
void send_rplisupport(aClient *acptr)
{
sendto_one(acptr, rplisupport1, acptr->name);
sendto_one(acptr, rplisupport2, acptr->name);
}
/* send cached RPL_ISUPPORT for oper limits */
void send_rplisupportoper(aClient *acptr)
{
sendto_one(acptr, rplisupportoper, acptr->name);
}
/* send cached RPL_VERSION */
void send_rplversion(aClient *acptr)
{
sendto_one(acptr, rplversion, acptr->name);
}
/* build and cache complex strings */
void build_rplcache(void)
{
char *s;
/* build RPL_ISUPPORT */
/* Most of this tracks draft-brocklesby-irc-isupport-03, with a
* few differences:
* STD is not sent since there is no RFC
* MAXCHANNELS and MAXBANS are sent for compatibility with old clients
* SILENCE WATCH and ELIST are sent but not documented
*/
/* put MAXBANS and MAXCHANNELS first so better tokens override them */
ircsprintf(scratchbuf,"NETWORK=%s SAFELIST MAXBANS=%i MAXCHANNELS=%i "
"CHANNELLEN=%i KICKLEN=%i NICKLEN=%i TOPICLEN=%i MODES=%i "
"CHANTYPES=# CHANLIMIT=#:%i "
#ifdef USE_HALFOPS
"PREFIX=(ohv)@%%%%+ STATUSMSG=@%%%%+",
#else
"PREFIX=(ov)@+ STATUSMSG=@+",
#endif
Network_Name, MAXBANS, maxchannelsperuser, CHANNELLEN,
TOPICLEN, NICKLEN, TOPICLEN, MAXMODEPARAMSUSER,
maxchannelsperuser);
ircsprintf(rplisupport1, rpl_str(RPL_ISUPPORT), me.name, "%s", scratchbuf);
ircsprintf(scratchbuf,"WATCH=65535 MAXCHANNELS=%i CHANLIMIT=#:%i",
(maxchannelsperuser * 3), (maxchannelsperuser * 3));
ircsprintf(rplisupportoper, rpl_str(RPL_ISUPPORT), me.name, "%s", scratchbuf);
s = scratchbuf;
s += ircsprintf(s, "CASEMAPPING=ascii WATCH=%i SILENCE=%i ELIST=cmntu",
MAXWATCH, MAXSILES);
#ifdef EXEMPT_LISTS
s += ircsprintf(s, " EXCEPTS");
#endif
#ifdef INVITE_LISTS
s += ircsprintf(s, " INVEX");
#endif
s += ircsprintf(s, " CHANMODES=b");
#ifdef EXEMPT_LISTS
*s++ = 'e';
#endif
#ifdef INVITE_LISTS
*s++ = 'I';
#endif
s += ircsprintf(s, ",k,jl,ci");
#ifdef USE_CHANMODE_L
*s++ = 'L';
#endif
#ifdef SPAMFILTER
*s++ = 'P';
#endif
s += ircsprintf(s, "AmMnOprRsSt MAXLIST=b:%i", MAXBANS);
#ifdef EXEMPT_LISTS
s += ircsprintf(s, ",e:%i", MAXEXEMPTLIST);
#endif
#ifdef INVITE_LISTS
s += ircsprintf(s, ",I:%i", MAXINVITELIST);
#endif
s += ircsprintf(s, " TARGMAX=DCCALLOW:,JOIN:,KICK:4,KILL:20,NOTICE:%i,"
"PART:,PRIVMSG:%i,WHOIS:,WHOWAS:", MAXRECIPIENTS,
MAXRECIPIENTS);
ircsprintf(rplisupport2, rpl_str(RPL_ISUPPORT), me.name, "%s", scratchbuf);
/* build RPL_VERSION */
s = scratchbuf;
#ifdef ANTI_SPAMBOT
*s++ = 'a';
#endif
#ifdef ALWAYS_SEND_DURING_SPLIT
*s++ = 'A';
#endif
#ifdef MAXBUFFERS
*s++ = 'B';
#endif
#ifdef CMDLINE_CONFIG
*s++ = 'C';
#endif
#ifdef DO_IDENTD
*s++ = 'd';
#endif
#ifdef DEBUGMODE
*s++ = 'D';
#endif
#ifdef HAVE_ENCRYPTION_ON
*s++ = 'E';
#endif
#ifdef FLUD
*s++ = 'F';
#endif
#ifdef SHOW_HEADERS
*s++ = 'h';
#endif
#ifdef SHOW_INVISIBLE_LUSERS
*s++ = 'i';
#endif
#ifdef NO_DEFAULT_INVISIBLE
*s++ = 'I';
#endif
#ifdef NO_DEFAULT_JOINRATE
*s++ = 'J';
#endif
#ifdef USE_HOOKMODULES
*s++ = 'M';
#endif
#ifdef DNS_DEBUG
*s++ = 'N';
#endif
#ifdef DENY_SERVICES_MSGS
*s++ = 'r';
#endif
#ifdef SUPER_TARGETS_ONLY
*s++ = 's';
#endif
#ifdef MSG_TARGET_LIMIT
*s++ = 't';
#endif
#ifdef THROTTLE_ENABLE
*s++ = 'T';
#endif
#ifdef IRCII_KLUDGE
*s++ = 'u';
#endif
#ifdef USE_SYSLOG
*s++ = 'Y';
#endif
*s++ = '/';
if (confopts & FLAGS_HUB)
*s++ = 'H';
if (confopts & FLAGS_SMOTD)
*s++ = 'm';
if (confopts & FLAGS_SPLITOPOK)
*s++ = 'o';
if (confopts & FLAGS_CRYPTPASS)
*s++ = 'p';
if (confopts & FLAGS_SERVHUB)
*s++ = 'S';
if ((confopts & FLAGS_WGMON) == FLAGS_WGMON)
*s++ = 'w';
s += ircsprintf(s, " TS%iow", TS_CURRENT);
#ifdef RIDICULOUS_PARANOIA_LEVEL
s += ircsprintf(s, " RPL%i", RIDICULOUS_PARANOIA_LEVEL);
#endif
s += ircsprintf(s, " NP[");
#ifdef FORCE_EVERYONE_HIDDEN
*s++ = 'A';
#endif
#ifdef ALLOW_HIDDEN_OPERS
*s++ = 'I';
#endif
#ifdef HIDE_KILL_ORIGINS
*s++ = 'K';
#endif
#ifdef NO_USER_SERVERKILLS
*s++ = 'k';
#endif
if (!(confopts & FLAGS_SHOWLINKS))
*s++ = 'L';
#ifdef HIDE_SERVERMODE_ORIGINS
*s++ = 'M';
#endif
#ifdef HIDE_NUMERIC_SOURCE
*s++ = 'N';
#endif
#ifdef NO_USER_OPERTARGETED_COMMANDS
*s++ = 'O';
#endif
#ifdef HIDE_SPLIT_SERVERS
*s++ = 'P';
#endif
#ifdef NO_USER_STATS
*s++ = 'S';
#endif
#ifdef NO_USER_OPERKILLS
*s++ = 's';
#endif
#ifdef NO_USER_TRACE
*s++ = 'T';
#endif
#ifdef HIDEULINEDSERVS
*s++ = 'U';
#endif
*s++ = ']';
*s++ = 0;
ircsprintf(rplversion, rpl_str(RPL_VERSION), me.name, "%s", version,
debugmode, me.name, scratchbuf);
}
#if defined(DNS_DEBUG) || defined(DEBUGMODE)
static char debugbuf[1024];
void debug(int level, char *pattern, ...)
{
va_list vl;
int err = errno;
va_start(vl, pattern);
(void) vsprintf(debugbuf, pattern, vl);
va_end(vl);
#ifdef USE_SYSLOG
if (level == DEBUG_ERROR)
syslog(LOG_ERR, "%s", debugbuf);
#endif
if ((debuglevel >= 0) && (level <= debuglevel)) {
if (local[2]) {
local[2]->sendM++;
local[2]->sendB += strlen(debugbuf);
}
(void) fprintf(stderr, "%s", debugbuf);
(void) fputc('\n', stderr);
}
errno = err;
}
#endif