| 1 |
/* |
| 2 |
* ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). |
| 3 |
* m_info.c: Sends information about the server. |
| 4 |
* |
| 5 |
* Copyright (C) 2005 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 |
* $Id$ |
| 23 |
*/ |
| 24 |
|
| 25 |
#include "stdinc.h" |
| 26 |
#include "list.h" |
| 27 |
#include "m_info.h" |
| 28 |
#include "channel.h" |
| 29 |
#include "client.h" |
| 30 |
#include "common.h" |
| 31 |
#include "irc_string.h" |
| 32 |
#include "ircd.h" |
| 33 |
#include "hook.h" |
| 34 |
#include "numeric.h" |
| 35 |
#include "s_log.h" |
| 36 |
#include "s_serv.h" |
| 37 |
#include "s_user.h" |
| 38 |
#include "send.h" |
| 39 |
#include "s_conf.h" |
| 40 |
#include "handlers.h" |
| 41 |
#include "msg.h" |
| 42 |
#include "parse.h" |
| 43 |
#include "modules.h" |
| 44 |
|
| 45 |
|
| 46 |
static void send_conf_options(struct Client *); |
| 47 |
static void send_birthdate_online_time(struct Client *); |
| 48 |
static void send_info_text(struct Client *); |
| 49 |
|
| 50 |
/* |
| 51 |
* jdc -- Structure for our configuration value table |
| 52 |
*/ |
| 53 |
struct InfoStruct |
| 54 |
{ |
| 55 |
const char *name; /* Displayed variable name */ |
| 56 |
unsigned int output_type; /* See below #defines */ |
| 57 |
void *option; /* Pointer reference to the value */ |
| 58 |
const char *desc; /* ASCII description of the variable */ |
| 59 |
}; |
| 60 |
|
| 61 |
/* Types for output_type in InfoStruct */ |
| 62 |
#define OUTPUT_STRING 0x0001 /* Output option as %s w/ dereference */ |
| 63 |
#define OUTPUT_STRING_PTR 0x0002 /* Output option as %s w/out deference */ |
| 64 |
#define OUTPUT_DECIMAL 0x0004 /* Output option as decimal (%d) */ |
| 65 |
#define OUTPUT_BOOLEAN 0x0008 /* Output option as "ON" or "OFF" */ |
| 66 |
#define OUTPUT_BOOLEAN_YN 0x0010 /* Output option as "YES" or "NO" */ |
| 67 |
#define OUTPUT_BOOLEAN2 0x0020 /* Output option as "YES/NO/MASKED" */ |
| 68 |
|
| 69 |
static const struct InfoStruct info_table[] = |
| 70 |
{ |
| 71 |
/* --[ START OF TABLE ]-------------------------------------------- */ |
| 72 |
{ |
| 73 |
"network_name", |
| 74 |
OUTPUT_STRING, |
| 75 |
&ServerInfo.network_name, |
| 76 |
"Network name" |
| 77 |
}, |
| 78 |
{ |
| 79 |
"network_desc", |
| 80 |
OUTPUT_STRING, |
| 81 |
&ServerInfo.network_desc, |
| 82 |
"Network description" |
| 83 |
}, |
| 84 |
{ |
| 85 |
"hub", |
| 86 |
OUTPUT_BOOLEAN_YN, |
| 87 |
&ServerInfo.hub, |
| 88 |
"Server is a hub" |
| 89 |
}, |
| 90 |
{ |
| 91 |
"use_logging", |
| 92 |
OUTPUT_BOOLEAN_YN, |
| 93 |
&ConfigLoggingEntry.use_logging, |
| 94 |
"Enable logging" |
| 95 |
}, |
| 96 |
{ |
| 97 |
"fuserlog", |
| 98 |
OUTPUT_STRING_PTR, |
| 99 |
&ConfigLoggingEntry.userlog, |
| 100 |
"User log file" |
| 101 |
}, |
| 102 |
{ |
| 103 |
"foperlog", |
| 104 |
OUTPUT_STRING_PTR, |
| 105 |
&ConfigLoggingEntry.operlog, |
| 106 |
"Operator log file" |
| 107 |
}, |
| 108 |
{ |
| 109 |
"fkilllog", |
| 110 |
OUTPUT_STRING_PTR, |
| 111 |
&ConfigLoggingEntry.killlog, |
| 112 |
"Kill log file" |
| 113 |
}, |
| 114 |
{ |
| 115 |
"fklinelog", |
| 116 |
OUTPUT_STRING_PTR, |
| 117 |
&ConfigLoggingEntry.klinelog, |
| 118 |
"K-Line log file" |
| 119 |
}, |
| 120 |
{ |
| 121 |
"fglinelog", |
| 122 |
OUTPUT_STRING_PTR, |
| 123 |
&ConfigLoggingEntry.glinelog, |
| 124 |
"G-Line log file" |
| 125 |
}, |
| 126 |
{ |
| 127 |
"restrict_channels", |
| 128 |
OUTPUT_BOOLEAN_YN, |
| 129 |
&ConfigChannel.restrict_channels, |
| 130 |
"Only reserved channels are allowed" |
| 131 |
}, |
| 132 |
{ |
| 133 |
"disable_local_channels", |
| 134 |
OUTPUT_BOOLEAN_YN, |
| 135 |
&ConfigChannel.disable_local_channels, |
| 136 |
"Prevent users from joining &channels" |
| 137 |
}, |
| 138 |
{ |
| 139 |
"use_invex", |
| 140 |
OUTPUT_BOOLEAN_YN, |
| 141 |
&ConfigChannel.use_invex, |
| 142 |
"Enable chanmode +I (invite exceptions)" |
| 143 |
}, |
| 144 |
{ |
| 145 |
"use_except", |
| 146 |
OUTPUT_BOOLEAN_YN, |
| 147 |
&ConfigChannel.use_except, |
| 148 |
"Enable chanmode +e (ban exceptions)" |
| 149 |
}, |
| 150 |
{ |
| 151 |
"use_knock", |
| 152 |
OUTPUT_BOOLEAN_YN, |
| 153 |
&ConfigChannel.use_knock, |
| 154 |
"Enable /KNOCK" |
| 155 |
}, |
| 156 |
{ |
| 157 |
"knock_delay", |
| 158 |
OUTPUT_DECIMAL, |
| 159 |
&ConfigChannel.knock_delay, |
| 160 |
"Delay between a users KNOCK attempts" |
| 161 |
}, |
| 162 |
{ |
| 163 |
"knock_delay_channel", |
| 164 |
OUTPUT_DECIMAL, |
| 165 |
&ConfigChannel.knock_delay_channel, |
| 166 |
"Delay between KNOCK attempts to a channel" |
| 167 |
}, |
| 168 |
{ |
| 169 |
"max_chans_per_user", |
| 170 |
OUTPUT_DECIMAL, |
| 171 |
&ConfigChannel.max_chans_per_user, |
| 172 |
"Maximum number of channels a user can join" |
| 173 |
}, |
| 174 |
{ |
| 175 |
"quiet_on_ban", |
| 176 |
OUTPUT_BOOLEAN_YN, |
| 177 |
&ConfigChannel.quiet_on_ban, |
| 178 |
"Banned users may not send text to a channel" |
| 179 |
}, |
| 180 |
{ |
| 181 |
"max_bans", |
| 182 |
OUTPUT_DECIMAL, |
| 183 |
&ConfigChannel.max_bans, |
| 184 |
"Total +b/e/I modes allowed in a channel" |
| 185 |
}, |
| 186 |
{ |
| 187 |
"default_split_user_count", |
| 188 |
OUTPUT_DECIMAL, |
| 189 |
&ConfigChannel.default_split_user_count, |
| 190 |
"Startup value of SPLITUSERS" |
| 191 |
}, |
| 192 |
{ |
| 193 |
"default_split_server_count", |
| 194 |
OUTPUT_DECIMAL, |
| 195 |
&ConfigChannel.default_split_server_count, |
| 196 |
"Startup value of SPLITNUM" |
| 197 |
}, |
| 198 |
{ |
| 199 |
"no_create_on_split", |
| 200 |
OUTPUT_BOOLEAN_YN, |
| 201 |
&ConfigChannel.no_create_on_split, |
| 202 |
"Disallow creation of channels when split" |
| 203 |
}, |
| 204 |
{ |
| 205 |
"no_join_on_split", |
| 206 |
OUTPUT_BOOLEAN_YN, |
| 207 |
&ConfigChannel.no_join_on_split, |
| 208 |
"Disallow joining channels when split" |
| 209 |
}, |
| 210 |
{ |
| 211 |
"burst_topicwho", |
| 212 |
OUTPUT_BOOLEAN_YN, |
| 213 |
&ConfigChannel.burst_topicwho, |
| 214 |
"Enable sending of who set topic on topicburst" |
| 215 |
}, |
| 216 |
{ |
| 217 |
"flatten_links", |
| 218 |
OUTPUT_BOOLEAN_YN, |
| 219 |
&ConfigServerHide.flatten_links, |
| 220 |
"Flatten /links list" |
| 221 |
}, |
| 222 |
{ |
| 223 |
"links_delay", |
| 224 |
OUTPUT_DECIMAL, |
| 225 |
&ConfigServerHide.links_delay, |
| 226 |
"Links rehash delay" |
| 227 |
}, |
| 228 |
{ |
| 229 |
"hidden", |
| 230 |
OUTPUT_BOOLEAN_YN, |
| 231 |
&ConfigServerHide.hidden, |
| 232 |
"Hide this server from a flattened /links on remote servers" |
| 233 |
}, |
| 234 |
{ |
| 235 |
"disable_hidden", |
| 236 |
OUTPUT_BOOLEAN_YN, |
| 237 |
&ConfigServerHide.disable_hidden, |
| 238 |
"Prevent servers from hiding themselves from a flattened /links" |
| 239 |
}, |
| 240 |
{ |
| 241 |
"hide_servers", |
| 242 |
OUTPUT_BOOLEAN_YN, |
| 243 |
&ConfigServerHide.hide_servers, |
| 244 |
"Hide servernames from users" |
| 245 |
}, |
| 246 |
{ |
| 247 |
"hidden_name", |
| 248 |
OUTPUT_STRING, |
| 249 |
&ConfigServerHide.hidden_name, |
| 250 |
"Server name users see if hide_servers = yes" |
| 251 |
}, |
| 252 |
{ |
| 253 |
"hide_server_ips", |
| 254 |
OUTPUT_BOOLEAN_YN, |
| 255 |
&ConfigServerHide.hide_server_ips, |
| 256 |
"Prevent people from seeing server IPs" |
| 257 |
}, |
| 258 |
{ |
| 259 |
"gline_min_cidr", |
| 260 |
OUTPUT_DECIMAL, |
| 261 |
&ConfigFileEntry.gline_min_cidr, |
| 262 |
"Minimum required length of a CIDR bitmask for IPv4 G-Lines" |
| 263 |
}, |
| 264 |
{ |
| 265 |
"gline_min_cidr6", |
| 266 |
OUTPUT_DECIMAL, |
| 267 |
&ConfigFileEntry.gline_min_cidr6, |
| 268 |
"Minimum required length of a CIDR bitmask for IPv6 G-Lines" |
| 269 |
}, |
| 270 |
{ |
| 271 |
"invisible_on_connect", |
| 272 |
OUTPUT_BOOLEAN_YN, |
| 273 |
&ConfigFileEntry.invisible_on_connect, |
| 274 |
"Automatically set mode +i on connecting users" |
| 275 |
}, |
| 276 |
{ |
| 277 |
"burst_away", |
| 278 |
OUTPUT_BOOLEAN_YN, |
| 279 |
&ConfigFileEntry.burst_away, |
| 280 |
"Send /away string that users have set on the server burst" |
| 281 |
}, |
| 282 |
{ |
| 283 |
"use_whois_actually", |
| 284 |
OUTPUT_BOOLEAN_YN, |
| 285 |
&ConfigFileEntry.use_whois_actually, |
| 286 |
"Show IP address on /WHOIS when possible" |
| 287 |
}, |
| 288 |
{ |
| 289 |
"kill_chase_time_limit", |
| 290 |
OUTPUT_DECIMAL, |
| 291 |
&ConfigFileEntry.kill_chase_time_limit, |
| 292 |
"Nick Change Tracker for KILL" |
| 293 |
}, |
| 294 |
{ |
| 295 |
"hide_spoof_ips", |
| 296 |
OUTPUT_BOOLEAN_YN, |
| 297 |
&ConfigFileEntry.hide_spoof_ips, |
| 298 |
"Hide spoofed IP's" |
| 299 |
}, |
| 300 |
{ |
| 301 |
"ignore_bogus_ts", |
| 302 |
OUTPUT_BOOLEAN_YN, |
| 303 |
&ConfigFileEntry.ignore_bogus_ts, |
| 304 |
"Ignore bogus timestamps from other servers" |
| 305 |
}, |
| 306 |
{ |
| 307 |
"disable_auth", |
| 308 |
OUTPUT_BOOLEAN_YN, |
| 309 |
&ConfigFileEntry.disable_auth, |
| 310 |
"Completely disable ident lookups" |
| 311 |
}, |
| 312 |
{ |
| 313 |
"disable_remote_commands", |
| 314 |
OUTPUT_BOOLEAN_YN, |
| 315 |
&ConfigFileEntry.disable_remote, |
| 316 |
"Prevent users issuing commands on remote servers" |
| 317 |
}, |
| 318 |
{ |
| 319 |
"tkline_expire_notices", |
| 320 |
OUTPUT_BOOLEAN_YN, |
| 321 |
&ConfigFileEntry.tkline_expire_notices, |
| 322 |
"Show temporary kline/xline expire notices" |
| 323 |
}, |
| 324 |
{ |
| 325 |
"default_floodcount", |
| 326 |
OUTPUT_DECIMAL, |
| 327 |
&ConfigFileEntry.default_floodcount, |
| 328 |
"Startup value of FLOODCOUNT" |
| 329 |
}, |
| 330 |
{ |
| 331 |
"failed_oper_notice", |
| 332 |
OUTPUT_BOOLEAN, |
| 333 |
&ConfigFileEntry.failed_oper_notice, |
| 334 |
"Inform opers if someone /oper's with the wrong password" |
| 335 |
}, |
| 336 |
{ |
| 337 |
"dots_in_ident", |
| 338 |
OUTPUT_DECIMAL, |
| 339 |
&ConfigFileEntry.dots_in_ident, |
| 340 |
"Number of permissable dots in an ident" |
| 341 |
}, |
| 342 |
{ |
| 343 |
"min_nonwildcard", |
| 344 |
OUTPUT_DECIMAL, |
| 345 |
&ConfigFileEntry.min_nonwildcard, |
| 346 |
"Minimum non-wildcard chars in K/G lines" |
| 347 |
}, |
| 348 |
{ |
| 349 |
"min_nonwildcard_simple", |
| 350 |
OUTPUT_DECIMAL, |
| 351 |
&ConfigFileEntry.min_nonwildcard_simple, |
| 352 |
"Minimum non-wildcards in gecos bans" |
| 353 |
}, |
| 354 |
{ |
| 355 |
"max_accept", |
| 356 |
OUTPUT_DECIMAL, |
| 357 |
&ConfigFileEntry.max_accept, |
| 358 |
"Maximum nicknames on accept list" |
| 359 |
}, |
| 360 |
{ |
| 361 |
"anti_nick_flood", |
| 362 |
OUTPUT_BOOLEAN, |
| 363 |
&ConfigFileEntry.anti_nick_flood, |
| 364 |
"NICK flood protection" |
| 365 |
}, |
| 366 |
{ |
| 367 |
"max_nick_time", |
| 368 |
OUTPUT_DECIMAL, |
| 369 |
&ConfigFileEntry.max_nick_time, |
| 370 |
"NICK flood protection time interval" |
| 371 |
}, |
| 372 |
{ |
| 373 |
"max_nick_changes", |
| 374 |
OUTPUT_DECIMAL, |
| 375 |
&ConfigFileEntry.max_nick_changes, |
| 376 |
"NICK change threshhold setting" |
| 377 |
}, |
| 378 |
{ |
| 379 |
"anti_spam_exit_message_time", |
| 380 |
OUTPUT_DECIMAL, |
| 381 |
&ConfigFileEntry.anti_spam_exit_message_time, |
| 382 |
"Duration a client must be connected for to have an exit message" |
| 383 |
}, |
| 384 |
{ |
| 385 |
"ts_warn_delta", |
| 386 |
OUTPUT_DECIMAL, |
| 387 |
&ConfigFileEntry.ts_warn_delta, |
| 388 |
"Maximum permitted TS delta before displaying a warning" |
| 389 |
}, |
| 390 |
{ |
| 391 |
"ts_max_delta", |
| 392 |
OUTPUT_DECIMAL, |
| 393 |
&ConfigFileEntry.ts_max_delta, |
| 394 |
"Maximum permitted TS delta from another server" |
| 395 |
}, |
| 396 |
{ |
| 397 |
"kline_with_reason", |
| 398 |
OUTPUT_BOOLEAN_YN, |
| 399 |
&ConfigFileEntry.kline_with_reason, |
| 400 |
"Display K-line reason to client on disconnect" |
| 401 |
}, |
| 402 |
{ |
| 403 |
"kline_reason", |
| 404 |
OUTPUT_STRING, |
| 405 |
&ConfigFileEntry.kline_reason, |
| 406 |
"Reason given to K-lined clients on sign off" |
| 407 |
}, |
| 408 |
{ |
| 409 |
"warn_no_nline", |
| 410 |
OUTPUT_BOOLEAN, |
| 411 |
&ConfigFileEntry.warn_no_nline, |
| 412 |
"Display warning if connecting server lacks N-line" |
| 413 |
}, |
| 414 |
{ |
| 415 |
"stats_o_oper_only", |
| 416 |
OUTPUT_BOOLEAN_YN, |
| 417 |
&ConfigFileEntry.stats_o_oper_only, |
| 418 |
"STATS O output is only shown to operators" |
| 419 |
}, |
| 420 |
{ |
| 421 |
"stats_P_oper_only", |
| 422 |
OUTPUT_BOOLEAN_YN, |
| 423 |
&ConfigFileEntry.stats_P_oper_only, |
| 424 |
"STATS P is only shown to operators" |
| 425 |
}, |
| 426 |
{ |
| 427 |
"stats_i_oper_only", |
| 428 |
OUTPUT_BOOLEAN2, |
| 429 |
&ConfigFileEntry.stats_i_oper_only, |
| 430 |
"STATS I output is only shown to operators" |
| 431 |
}, |
| 432 |
{ |
| 433 |
"stats_k_oper_only", |
| 434 |
OUTPUT_BOOLEAN2, |
| 435 |
&ConfigFileEntry.stats_k_oper_only, |
| 436 |
"STATS K output is only shown to operators" |
| 437 |
}, |
| 438 |
{ |
| 439 |
"caller_id_wait", |
| 440 |
OUTPUT_DECIMAL, |
| 441 |
&ConfigFileEntry.caller_id_wait, |
| 442 |
"Minimum delay between notifying UMODE +g users of messages" |
| 443 |
}, |
| 444 |
{ |
| 445 |
"opers_bypass_callerid", |
| 446 |
OUTPUT_BOOLEAN_YN, |
| 447 |
&ConfigFileEntry.opers_bypass_callerid, |
| 448 |
"Allows IRC operators to message users who are +g (callerid)" |
| 449 |
}, |
| 450 |
{ |
| 451 |
"pace_wait_simple", |
| 452 |
OUTPUT_DECIMAL, |
| 453 |
&ConfigFileEntry.pace_wait_simple, |
| 454 |
"Minimum delay between less intensive commands" |
| 455 |
}, |
| 456 |
{ |
| 457 |
"pace_wait", |
| 458 |
OUTPUT_DECIMAL, |
| 459 |
&ConfigFileEntry.pace_wait, |
| 460 |
"Minimum delay between uses of certain commands" |
| 461 |
}, |
| 462 |
{ |
| 463 |
"short_motd", |
| 464 |
OUTPUT_BOOLEAN_YN, |
| 465 |
&ConfigFileEntry.short_motd, |
| 466 |
"Do not show MOTD; only tell clients they should read it" |
| 467 |
}, |
| 468 |
{ |
| 469 |
"ping_cookie", |
| 470 |
OUTPUT_BOOLEAN, |
| 471 |
&ConfigFileEntry.ping_cookie, |
| 472 |
"Require ping cookies to connect" |
| 473 |
}, |
| 474 |
{ |
| 475 |
"no_oper_flood", |
| 476 |
OUTPUT_BOOLEAN, |
| 477 |
&ConfigFileEntry.no_oper_flood, |
| 478 |
"Reduce flood control for operators" |
| 479 |
}, |
| 480 |
{ |
| 481 |
"true_no_oper_flood", |
| 482 |
OUTPUT_BOOLEAN, |
| 483 |
&ConfigFileEntry.true_no_oper_flood, |
| 484 |
"Completely disable flood control for operators" |
| 485 |
}, |
| 486 |
{ |
| 487 |
"oper_pass_resv", |
| 488 |
OUTPUT_BOOLEAN_YN, |
| 489 |
&ConfigFileEntry.oper_pass_resv, |
| 490 |
"Opers can over-ride RESVs" |
| 491 |
}, |
| 492 |
{ |
| 493 |
"max_targets", |
| 494 |
OUTPUT_DECIMAL, |
| 495 |
&ConfigFileEntry.max_targets, |
| 496 |
"The maximum number of PRIVMSG/NOTICE targets" |
| 497 |
}, |
| 498 |
{ |
| 499 |
"client_flood", |
| 500 |
OUTPUT_DECIMAL, |
| 501 |
&ConfigFileEntry.client_flood, |
| 502 |
"Maximum amount of data in a client's queue before they are disconnected" |
| 503 |
}, |
| 504 |
{ |
| 505 |
"throttle_time", |
| 506 |
OUTPUT_DECIMAL, |
| 507 |
&ConfigFileEntry.throttle_time, |
| 508 |
"Minimum time between client reconnects" |
| 509 |
}, |
| 510 |
{ |
| 511 |
"glines", |
| 512 |
OUTPUT_BOOLEAN, |
| 513 |
&ConfigFileEntry.glines, |
| 514 |
"G-line (network-wide K-line) support" |
| 515 |
}, |
| 516 |
{ |
| 517 |
"duration", |
| 518 |
OUTPUT_DECIMAL, |
| 519 |
&ConfigFileEntry.gline_time, |
| 520 |
"Expiry time for G-lines" |
| 521 |
}, |
| 522 |
/* --[ END OF TABLE ]---------------------------------------------- */ |
| 523 |
{ |
| 524 |
NULL, |
| 525 |
0, |
| 526 |
NULL, |
| 527 |
0 |
| 528 |
} |
| 529 |
}; |
| 530 |
|
| 531 |
/* |
| 532 |
** m_info() |
| 533 |
** parv[0] = sender prefix |
| 534 |
** parv[1] = servername |
| 535 |
*/ |
| 536 |
static void |
| 537 |
m_info(struct Client *client_p, struct Client *source_p, |
| 538 |
int parc, char *parv[]) |
| 539 |
{ |
| 540 |
static time_t last_used = 0; |
| 541 |
|
| 542 |
if ((last_used + ConfigFileEntry.pace_wait) > CurrentTime) |
| 543 |
{ |
| 544 |
/* safe enough to give this on a local connect only */ |
| 545 |
sendto_one(source_p, form_str(RPL_LOAD2HI), |
| 546 |
me.name, source_p->name); |
| 547 |
return; |
| 548 |
} |
| 549 |
|
| 550 |
last_used = CurrentTime; |
| 551 |
|
| 552 |
if (!ConfigFileEntry.disable_remote) |
| 553 |
if (hunt_server(client_p,source_p, ":%s INFO :%s", 1, |
| 554 |
parc, parv) != HUNTED_ISME) |
| 555 |
return; |
| 556 |
|
| 557 |
send_info_text(source_p); |
| 558 |
} |
| 559 |
|
| 560 |
/* |
| 561 |
** mo_info() |
| 562 |
** parv[0] = sender prefix |
| 563 |
** parv[1] = servername |
| 564 |
*/ |
| 565 |
static void |
| 566 |
mo_info(struct Client *client_p, struct Client *source_p, |
| 567 |
int parc, char *parv[]) |
| 568 |
{ |
| 569 |
if (hunt_server(client_p, source_p, ":%s INFO :%s", 1, |
| 570 |
parc, parv) != HUNTED_ISME) |
| 571 |
return; |
| 572 |
|
| 573 |
send_info_text(source_p); |
| 574 |
} |
| 575 |
|
| 576 |
/* |
| 577 |
** ms_info() |
| 578 |
** parv[0] = sender prefix |
| 579 |
** parv[1] = servername |
| 580 |
*/ |
| 581 |
static void |
| 582 |
ms_info(struct Client *client_p, struct Client *source_p, |
| 583 |
int parc, char *parv[]) |
| 584 |
{ |
| 585 |
if (!IsClient(source_p)) |
| 586 |
return; |
| 587 |
|
| 588 |
if (hunt_server(client_p, source_p, ":%s INFO :%s", 1, |
| 589 |
parc, parv) != HUNTED_ISME) |
| 590 |
return; |
| 591 |
|
| 592 |
send_info_text(source_p); |
| 593 |
} |
| 594 |
|
| 595 |
/* send_info_text() |
| 596 |
* |
| 597 |
* inputs - client pointer to send info text to |
| 598 |
* output - NONE |
| 599 |
* side effects - info text is sent to client |
| 600 |
*/ |
| 601 |
static void |
| 602 |
send_info_text(struct Client *source_p) |
| 603 |
{ |
| 604 |
const char **text = infotext; |
| 605 |
char *source, *target; |
| 606 |
|
| 607 |
sendto_realops_flags(UMODE_SPY, L_ALL, |
| 608 |
"INFO requested by %s (%s@%s) [%s]", |
| 609 |
source_p->name, source_p->username, |
| 610 |
source_p->host, source_p->servptr->name); |
| 611 |
|
| 612 |
if (!MyClient(source_p) && IsCapable(source_p->from, CAP_TS6) && |
| 613 |
HasID(source_p)) |
| 614 |
source = me.id, target = source_p->id; |
| 615 |
else |
| 616 |
source = me.name, target = source_p->name; |
| 617 |
|
| 618 |
while (*text) |
| 619 |
{ |
| 620 |
const char *line = *text++; |
| 621 |
|
| 622 |
if (*line == '\0') |
| 623 |
line = " "; |
| 624 |
|
| 625 |
sendto_one(source_p, form_str(RPL_INFO), |
| 626 |
source, target, line); |
| 627 |
} |
| 628 |
|
| 629 |
if (HasUMode(source_p, UMODE_OPER)) |
| 630 |
send_conf_options(source_p); |
| 631 |
|
| 632 |
send_birthdate_online_time(source_p); |
| 633 |
|
| 634 |
sendto_one(source_p, form_str(RPL_ENDOFINFO), |
| 635 |
me.name, source_p->name); |
| 636 |
} |
| 637 |
|
| 638 |
/* send_birthdate_online_time() |
| 639 |
* |
| 640 |
* inputs - client pointer to send to |
| 641 |
* output - NONE |
| 642 |
* side effects - birthdate and online time are sent |
| 643 |
*/ |
| 644 |
static void |
| 645 |
send_birthdate_online_time(struct Client *source_p) |
| 646 |
{ |
| 647 |
if (!MyClient(source_p) && IsCapable(source_p->from, CAP_TS6) && HasID(source_p)) |
| 648 |
{ |
| 649 |
sendto_one(source_p, ":%s %d %s :On-line since %s", |
| 650 |
me.id, RPL_INFO, source_p->id, |
| 651 |
myctime(me.localClient->firsttime)); |
| 652 |
} |
| 653 |
else |
| 654 |
{ |
| 655 |
sendto_one(source_p, ":%s %d %s :On-line since %s", |
| 656 |
me.name, RPL_INFO, source_p->name, |
| 657 |
myctime(me.localClient->firsttime)); |
| 658 |
} |
| 659 |
} |
| 660 |
|
| 661 |
/* send_conf_options() |
| 662 |
* |
| 663 |
* inputs - client pointer to send to |
| 664 |
* output - NONE |
| 665 |
* side effects - send config options to client |
| 666 |
*/ |
| 667 |
static void |
| 668 |
send_conf_options(struct Client *source_p) |
| 669 |
{ |
| 670 |
Info *infoptr; |
| 671 |
const char *from, *to; |
| 672 |
const struct InfoStruct *iptr = NULL; |
| 673 |
|
| 674 |
/* Now send them a list of all our configuration options |
| 675 |
* (mostly from defaults.h and config.h) |
| 676 |
*/ |
| 677 |
if (!MyClient(source_p) && IsCapable(source_p->from, CAP_TS6) && HasID(source_p)) |
| 678 |
{ |
| 679 |
from = me.id; |
| 680 |
to = source_p->id; |
| 681 |
} |
| 682 |
else |
| 683 |
{ |
| 684 |
from = me.name; |
| 685 |
to = source_p->name; |
| 686 |
} |
| 687 |
|
| 688 |
for (infoptr = MyInformation; infoptr->name; infoptr++) |
| 689 |
{ |
| 690 |
if (infoptr->intvalue) |
| 691 |
{ |
| 692 |
sendto_one(source_p, ":%s %d %s :%-30s %-5d [%-30s]", |
| 693 |
from, RPL_INFO, to, infoptr->name, |
| 694 |
infoptr->intvalue, infoptr->desc); |
| 695 |
} |
| 696 |
else |
| 697 |
{ |
| 698 |
sendto_one(source_p, ":%s %d %s :%-30s %-5s [%-30s]", |
| 699 |
from, RPL_INFO, to, infoptr->name, |
| 700 |
infoptr->strvalue, infoptr->desc); |
| 701 |
} |
| 702 |
} |
| 703 |
|
| 704 |
/* |
| 705 |
* Parse the info_table[] and do the magic. |
| 706 |
*/ |
| 707 |
for (iptr = info_table; iptr->name; ++iptr) |
| 708 |
{ |
| 709 |
switch (iptr->output_type) |
| 710 |
{ |
| 711 |
/* For "char *" references */ |
| 712 |
case OUTPUT_STRING: |
| 713 |
{ |
| 714 |
const char *option = *((char **)iptr->option); |
| 715 |
|
| 716 |
sendto_one(source_p, ":%s %d %s :%-30s %-5s [%-30s]", |
| 717 |
from, RPL_INFO, to, |
| 718 |
iptr->name, option ? option : "NONE", |
| 719 |
iptr->desc ? iptr->desc : "<none>"); |
| 720 |
break; |
| 721 |
} |
| 722 |
|
| 723 |
/* For "char foo[]" references */ |
| 724 |
case OUTPUT_STRING_PTR: |
| 725 |
{ |
| 726 |
const char *option = iptr->option; |
| 727 |
|
| 728 |
sendto_one(source_p, ":%s %d %s :%-30s %-5s [%-30s]", |
| 729 |
from, RPL_INFO, to, |
| 730 |
iptr->name, option ? option : "NONE", |
| 731 |
iptr->desc ? iptr->desc : "<none>"); |
| 732 |
break; |
| 733 |
} |
| 734 |
|
| 735 |
/* Output info_table[i].option as a decimal value. */ |
| 736 |
case OUTPUT_DECIMAL: |
| 737 |
{ |
| 738 |
const int option = *((int *)iptr->option); |
| 739 |
|
| 740 |
sendto_one(source_p, ":%s %d %s :%-30s %-5d [%-30s]", |
| 741 |
from, RPL_INFO, to, iptr->name, |
| 742 |
option, iptr->desc ? iptr->desc : "<none>"); |
| 743 |
break; |
| 744 |
} |
| 745 |
|
| 746 |
/* Output info_table[i].option as "ON" or "OFF" */ |
| 747 |
case OUTPUT_BOOLEAN: |
| 748 |
{ |
| 749 |
const int option = *((int *)iptr->option); |
| 750 |
|
| 751 |
sendto_one(source_p, ":%s %d %s :%-30s %-5s [%-30s]", |
| 752 |
from, RPL_INFO, to, |
| 753 |
iptr->name, option ? "ON" : "OFF", |
| 754 |
iptr->desc ? iptr->desc : "<none>"); |
| 755 |
|
| 756 |
break; |
| 757 |
} |
| 758 |
|
| 759 |
/* Output info_table[i].option as "YES" or "NO" */ |
| 760 |
case OUTPUT_BOOLEAN_YN: |
| 761 |
{ |
| 762 |
int option = *((int *)iptr->option); |
| 763 |
|
| 764 |
sendto_one(source_p, ":%s %d %s :%-30s %-5s [%-30s]", |
| 765 |
from, RPL_INFO, to, |
| 766 |
iptr->name, option ? "YES" : "NO", |
| 767 |
iptr->desc ? iptr->desc : "<none>"); |
| 768 |
break; |
| 769 |
} |
| 770 |
|
| 771 |
case OUTPUT_BOOLEAN2: |
| 772 |
{ |
| 773 |
int option = *((int *)iptr->option); |
| 774 |
|
| 775 |
sendto_one(source_p, ":%s %d %s :%-30s %-5s [%-30s]", |
| 776 |
from, RPL_INFO, to, |
| 777 |
iptr->name, option ? ((option == 1) ? "MASK" : "YES") : "NO", |
| 778 |
iptr->desc ? iptr->desc : "<none>"); |
| 779 |
break; |
| 780 |
} |
| 781 |
} |
| 782 |
} |
| 783 |
|
| 784 |
/* Don't send oper_only_umodes...it's a bit mask, we will have to decode it |
| 785 |
* in order for it to show up properly to opers who issue INFO |
| 786 |
*/ |
| 787 |
#ifndef EFNET |
| 788 |
/* jdc -- Only send compile information to admins. */ |
| 789 |
if (HasUMode(source_p, UMODE_ADMIN)) |
| 790 |
sendto_one(source_p, ":%s %d %s :Running on [%s]", |
| 791 |
from, RPL_INFO, to, ircd_platform); |
| 792 |
#endif |
| 793 |
sendto_one(source_p, form_str(RPL_INFO), |
| 794 |
from, to, ""); |
| 795 |
} |
| 796 |
|
| 797 |
static struct Message info_msgtab = { |
| 798 |
"INFO", 0, 0, 0, MAXPARA, MFLG_SLOW, 0, |
| 799 |
{ m_unregistered, m_info, ms_info, m_ignore, mo_info, m_ignore } |
| 800 |
}; |
| 801 |
|
| 802 |
static void |
| 803 |
module_init(void) |
| 804 |
{ |
| 805 |
mod_add_cmd(&info_msgtab); |
| 806 |
} |
| 807 |
|
| 808 |
static void |
| 809 |
module_exit(void) |
| 810 |
{ |
| 811 |
mod_del_cmd(&info_msgtab); |
| 812 |
} |
| 813 |
|
| 814 |
struct module module_entry = { |
| 815 |
.node = { NULL, NULL, NULL }, |
| 816 |
.name = NULL, |
| 817 |
.version = "$Revision$", |
| 818 |
.handle = NULL, |
| 819 |
.modinit = module_init, |
| 820 |
.modexit = module_exit, |
| 821 |
.flags = 0 |
| 822 |
}; |