| 23 |
|
*/ |
| 24 |
|
|
| 25 |
|
#include "stdinc.h" |
| 26 |
< |
#include "fdlist.h" |
| 27 |
< |
#include "tools.h" |
| 28 |
< |
#include "common.h" |
| 29 |
< |
#include "handlers.h" |
| 26 |
> |
#include "list.h" |
| 27 |
|
#include "client.h" |
| 28 |
|
#include "hash.h" |
| 29 |
|
#include "channel.h" |
| 34 |
|
#include "s_misc.h" |
| 35 |
|
#include "s_serv.h" |
| 36 |
|
#include "send.h" |
| 40 |
– |
#include "list.h" |
| 37 |
|
#include "irc_string.h" |
| 38 |
|
#include "sprintf_irc.h" |
| 43 |
– |
#include "msg.h" |
| 39 |
|
#include "parse.h" |
| 40 |
|
#include "modules.h" |
| 46 |
– |
#include "hook.h" |
| 41 |
|
|
| 42 |
< |
static void do_whois(struct Client *, int, char **); |
| 42 |
> |
|
| 43 |
> |
static void do_whois(struct Client *, int, char *[]); |
| 44 |
|
static int single_whois(struct Client *, struct Client *); |
| 45 |
|
static void whois_person(struct Client *, struct Client *); |
| 46 |
|
static int global_whois(struct Client *, const char *); |
| 47 |
|
|
| 53 |
– |
static void m_whois(struct Client *, struct Client *, int, char *[]); |
| 54 |
– |
static void mo_whois(struct Client *, struct Client *, int, char *[]); |
| 55 |
– |
|
| 56 |
– |
struct Message whois_msgtab = { |
| 57 |
– |
"WHOIS", 0, 0, 0, 0, MFLG_SLOW, 0, |
| 58 |
– |
{ m_unregistered, m_whois, mo_whois, m_ignore, mo_whois, m_ignore } |
| 59 |
– |
}; |
| 60 |
– |
|
| 61 |
– |
#ifndef STATIC_MODULES |
| 62 |
– |
const char *_version = "$Revision$"; |
| 63 |
– |
static struct Callback *whois_cb; |
| 64 |
– |
|
| 65 |
– |
static void * |
| 66 |
– |
va_whois(va_list args) |
| 67 |
– |
{ |
| 68 |
– |
struct Client *source_p = va_arg(args, struct Client *); |
| 69 |
– |
int parc = va_arg(args, int); |
| 70 |
– |
char **parv = va_arg(args, char **); |
| 71 |
– |
|
| 72 |
– |
do_whois(source_p, parc, parv); |
| 73 |
– |
return NULL; |
| 74 |
– |
} |
| 75 |
– |
|
| 76 |
– |
void |
| 77 |
– |
_modinit(void) |
| 78 |
– |
{ |
| 79 |
– |
whois_cb = register_callback("doing_whois", va_whois); |
| 80 |
– |
mod_add_cmd(&whois_msgtab); |
| 81 |
– |
} |
| 82 |
– |
|
| 83 |
– |
void |
| 84 |
– |
_moddeinit(void) |
| 85 |
– |
{ |
| 86 |
– |
mod_del_cmd(&whois_msgtab); |
| 87 |
– |
uninstall_hook(whois_cb, va_whois); |
| 88 |
– |
} |
| 89 |
– |
#endif |
| 48 |
|
|
| 49 |
|
/* |
| 50 |
|
** m_whois |
| 64 |
|
return; |
| 65 |
|
} |
| 66 |
|
|
| 67 |
< |
if (parc > 2) |
| 67 |
> |
if (parc > 2 && !EmptyString(parv[2])) |
| 68 |
|
{ |
| 69 |
|
/* seeing as this is going across servers, we should limit it */ |
| 70 |
|
if ((last_used + ConfigFileEntry.pace_wait_simple) > CurrentTime) |
| 73 |
|
me.name, source_p->name); |
| 74 |
|
return; |
| 75 |
|
} |
| 76 |
< |
else |
| 77 |
< |
last_used = CurrentTime; |
| 76 |
> |
|
| 77 |
> |
last_used = CurrentTime; |
| 78 |
|
|
| 79 |
|
/* if we have serverhide enabled, they can either ask the clients |
| 80 |
|
* server, or our server.. I dont see why they would need to ask |
| 90 |
|
parv[1] = parv[2]; |
| 91 |
|
} |
| 92 |
|
|
| 135 |
– |
#ifdef STATIC_MODULES |
| 93 |
|
do_whois(source_p, parc, parv); |
| 137 |
– |
#else |
| 138 |
– |
execute_callback(whois_cb, source_p, parc, parv); |
| 139 |
– |
#endif |
| 94 |
|
} |
| 95 |
|
|
| 96 |
|
/* |
| 109 |
|
return; |
| 110 |
|
} |
| 111 |
|
|
| 112 |
< |
if (parc > 2) |
| 112 |
> |
if (parc > 2 && !EmptyString(parv[2])) |
| 113 |
|
{ |
| 114 |
|
if (hunt_server(client_p, source_p, ":%s WHOIS %s :%s", 1, |
| 115 |
|
parc, parv) != HUNTED_ISME) |
| 118 |
|
parv[1] = parv[2]; |
| 119 |
|
} |
| 120 |
|
|
| 167 |
– |
#ifdef STATIC_MODULES |
| 121 |
|
do_whois(source_p, parc, parv); |
| 169 |
– |
#else |
| 170 |
– |
execute_callback(whois_cb, source_p, parc, parv); |
| 171 |
– |
#endif |
| 122 |
|
} |
| 123 |
|
|
| 124 |
|
/* do_whois() |
| 130 |
|
* side effects - Does whois |
| 131 |
|
*/ |
| 132 |
|
static void |
| 133 |
< |
do_whois(struct Client *source_p, int parc, char **parv) |
| 133 |
> |
do_whois(struct Client *source_p, int parc, char *parv[]) |
| 134 |
|
{ |
| 135 |
+ |
static time_t last_used = 0; |
| 136 |
|
struct Client *target_p; |
| 137 |
|
char *nick; |
| 138 |
|
char *p = NULL; |
| 151 |
|
|
| 152 |
|
if (strpbrk(nick, "?#*") == NULL) |
| 153 |
|
{ |
| 154 |
< |
if ((target_p = find_client(nick)) != NULL) |
| 154 |
> |
if ((target_p = hash_find_client(nick)) != NULL) |
| 155 |
|
{ |
| 205 |
– |
if (IsServer(source_p->from)) |
| 206 |
– |
client_burst_if_needed(source_p->from, target_p); |
| 207 |
– |
|
| 156 |
|
if (IsClient(target_p)) |
| 157 |
|
{ |
| 158 |
< |
whois_person(source_p, target_p); |
| 159 |
< |
found = 1; |
| 158 |
> |
whois_person(source_p, target_p); |
| 159 |
> |
found = 1; |
| 160 |
|
} |
| 161 |
|
} |
| 214 |
– |
else if (!ServerInfo.hub && uplink && IsCapable(uplink, CAP_LL)) |
| 215 |
– |
{ |
| 216 |
– |
if (parc > 2) |
| 217 |
– |
sendto_one(uplink,":%s WHOIS %s :%s", |
| 218 |
– |
source_p->name, nick, nick); |
| 219 |
– |
else |
| 220 |
– |
sendto_one(uplink,":%s WHOIS %s", |
| 221 |
– |
source_p->name, nick); |
| 222 |
– |
return; |
| 223 |
– |
} |
| 162 |
|
} |
| 163 |
|
else /* wilds is true */ |
| 164 |
|
{ |
| 165 |
< |
/* disallow wild card whois on lazylink leafs for now */ |
| 166 |
< |
if (!ServerInfo.hub && uplink && IsCapable(uplink, CAP_LL)) |
| 167 |
< |
return; |
| 165 |
> |
if (!HasUMode(source_p, UMODE_OPER)) |
| 166 |
> |
{ |
| 167 |
> |
if ((last_used + ConfigFileEntry.pace_wait_simple) > CurrentTime) |
| 168 |
> |
{ |
| 169 |
> |
sendto_one(source_p, form_str(RPL_LOAD2HI), |
| 170 |
> |
me.name, source_p->name); |
| 171 |
> |
return; |
| 172 |
> |
} |
| 173 |
> |
else |
| 174 |
> |
last_used = CurrentTime; |
| 175 |
> |
} |
| 176 |
|
|
| 177 |
|
/* Oh-oh wilds is true so have to do it the hard expensive way */ |
| 178 |
|
if (MyClient(source_p)) |
| 232 |
|
found |= single_whois(source_p, target_p); |
| 233 |
|
} |
| 234 |
|
|
| 235 |
< |
return (found); |
| 235 |
> |
return found; |
| 236 |
|
} |
| 237 |
|
|
| 238 |
|
/* single_whois() |
| 246 |
|
static int |
| 247 |
|
single_whois(struct Client *source_p, struct Client *target_p) |
| 248 |
|
{ |
| 249 |
< |
dlink_node *ptr; |
| 304 |
< |
struct Channel *chptr; |
| 249 |
> |
dlink_node *ptr = NULL; |
| 250 |
|
|
| 251 |
< |
if (!IsInvisible(target_p) || target_p == source_p) |
| 251 |
> |
if (!HasUMode(target_p, UMODE_INVISIBLE) || target_p == source_p) |
| 252 |
|
{ |
| 253 |
|
/* always show user if they are visible (no +i) */ |
| 254 |
|
whois_person(source_p, target_p); |
| 258 |
|
/* target_p is +i. Check if it is on any common channels with source_p */ |
| 259 |
|
DLINK_FOREACH(ptr, target_p->channel.head) |
| 260 |
|
{ |
| 261 |
< |
chptr = ((struct Membership *) ptr->data)->chptr; |
| 261 |
> |
struct Channel *chptr = ((struct Membership *) ptr->data)->chptr; |
| 262 |
> |
|
| 263 |
|
if (IsMember(source_p, chptr)) |
| 264 |
|
{ |
| 265 |
|
whois_person(source_p, target_p); |
| 289 |
|
int mlen; |
| 290 |
|
char *t = NULL; |
| 291 |
|
int tlen; |
| 292 |
< |
int reply_to_send = NO; |
| 292 |
> |
int reply_to_send = 0; |
| 293 |
|
|
| 294 |
|
server_p = target_p->servptr; |
| 295 |
|
|
| 297 |
|
me.name, source_p->name, target_p->name, |
| 298 |
|
target_p->username, target_p->host, target_p->info); |
| 299 |
|
|
| 300 |
< |
cur_len = mlen = ircsprintf(buf, form_str(RPL_WHOISCHANNELS), |
| 301 |
< |
me.name, source_p->name, target_p->name, ""); |
| 300 |
> |
cur_len = mlen = snprintf(buf, sizeof(buf), form_str(RPL_WHOISCHANNELS), |
| 301 |
> |
me.name, source_p->name, target_p->name, ""); |
| 302 |
|
t = buf + mlen; |
| 303 |
|
|
| 304 |
|
DLINK_FOREACH(lp, target_p->channel.head) |
| 320 |
|
t = buf + mlen; |
| 321 |
|
} |
| 322 |
|
|
| 323 |
< |
tlen = ircsprintf(t, "%s%s ", get_member_status(ms, YES), chptr->chname); |
| 323 |
> |
tlen = ircsprintf(t, "%s%s ", get_member_status(ms, 1), chptr->chname); |
| 324 |
|
t += tlen; |
| 325 |
|
cur_len += tlen; |
| 326 |
< |
reply_to_send = YES; |
| 326 |
> |
reply_to_send = 1; |
| 327 |
|
} |
| 328 |
|
} |
| 329 |
|
|
| 333 |
|
sendto_one(source_p, "%s", buf); |
| 334 |
|
} |
| 335 |
|
|
| 336 |
< |
if (IsOper(source_p) || !ConfigServerHide.hide_servers || target_p == source_p) |
| 336 |
> |
if (HasUMode(source_p, UMODE_OPER) || !ConfigServerHide.hide_servers || target_p == source_p) |
| 337 |
|
sendto_one(source_p, form_str(RPL_WHOISSERVER), |
| 338 |
|
me.name, source_p->name, target_p->name, |
| 339 |
|
server_p->name, server_p->info); |
| 343 |
|
ConfigServerHide.hidden_name, |
| 344 |
|
ServerInfo.network_desc); |
| 345 |
|
|
| 346 |
+ |
if (HasUMode(target_p, UMODE_REGISTERED)) |
| 347 |
+ |
sendto_one(source_p, form_str(RPL_WHOISREGNICK), |
| 348 |
+ |
me.name, source_p->name, target_p->name); |
| 349 |
+ |
|
| 350 |
|
if (target_p->away != NULL) |
| 351 |
|
sendto_one(source_p, form_str(RPL_AWAY), |
| 352 |
|
me.name, source_p->name, target_p->name, |
| 353 |
|
target_p->away); |
| 354 |
|
|
| 355 |
< |
if (IsOper(target_p)) |
| 356 |
< |
sendto_one(source_p, form_str((IsAdmin(target_p) && |
| 357 |
< |
!IsOperHiddenAdmin(target_p)) ? RPL_WHOISADMIN : |
| 355 |
> |
if (HasUMode(target_p, UMODE_SOFTCALLERID) && !HasUMode(target_p, UMODE_SOFTCALLERID)) |
| 356 |
> |
sendto_one(source_p, form_str(RPL_TARGUMODEG), |
| 357 |
> |
me.name, source_p->name, target_p->name); |
| 358 |
> |
|
| 359 |
> |
if (HasUMode(target_p, UMODE_OPER)) |
| 360 |
> |
sendto_one(source_p, form_str((HasUMode(target_p, UMODE_ADMIN) && |
| 361 |
> |
!HasOFlag(target_p, OPER_FLAG_HIDDEN_ADMIN)) ? RPL_WHOISADMIN : |
| 362 |
|
RPL_WHOISOPERATOR), me.name, source_p->name, target_p->name); |
| 363 |
|
|
| 364 |
< |
if (IsOper(source_p) && IsCaptured(target_p)) |
| 364 |
> |
if (HasUMode(source_p, UMODE_OPER) && IsCaptured(target_p)) |
| 365 |
|
sendto_one(source_p, form_str(RPL_ISCAPTURED), |
| 366 |
|
me.name, source_p->name, target_p->name); |
| 367 |
|
|
| 368 |
< |
if (ConfigFileEntry.use_whois_actually && (target_p->sockhost[0] != '\0') && |
| 415 |
< |
!(ConfigFileEntry.hide_spoof_ips && IsIPSpoof(target_p)) && |
| 416 |
< |
!(target_p->sockhost[0] == '0' && target_p->sockhost[1] == '\0')) |
| 368 |
> |
if (ConfigFileEntry.use_whois_actually) |
| 369 |
|
{ |
| 370 |
< |
if (IsAdmin(source_p) || source_p == target_p) |
| 371 |
< |
sendto_one(source_p, form_str(RPL_WHOISACTUALLY), |
| 372 |
< |
me.name, source_p->name, target_p->name, target_p->sockhost); |
| 373 |
< |
else |
| 370 |
> |
int show_ip = 0; |
| 371 |
> |
|
| 372 |
> |
if ((target_p->sockhost[0] != '\0') && irccmp(target_p->sockhost, "0")) |
| 373 |
> |
{ |
| 374 |
> |
if ((HasUMode(source_p, UMODE_ADMIN) || source_p == target_p)) |
| 375 |
> |
show_ip = 1; |
| 376 |
> |
else if (IsIPSpoof(target_p)) |
| 377 |
> |
show_ip = (HasUMode(source_p, UMODE_OPER) && !ConfigFileEntry.hide_spoof_ips); |
| 378 |
> |
else |
| 379 |
> |
show_ip = 1; |
| 380 |
> |
|
| 381 |
|
sendto_one(source_p, form_str(RPL_WHOISACTUALLY), |
| 382 |
|
me.name, source_p->name, target_p->name, |
| 383 |
< |
IsIPSpoof(target_p) || IsOper(target_p) ? |
| 384 |
< |
"255.255.255.255" : target_p->sockhost); |
| 383 |
> |
show_ip ? target_p->sockhost : "255.255.255.255"); |
| 384 |
> |
} |
| 385 |
|
} |
| 386 |
|
|
| 387 |
|
if (MyConnect(target_p)) /* Can't do any of this if not local! db */ |
| 388 |
|
{ |
| 389 |
|
#ifdef HAVE_LIBCRYPTO |
| 390 |
|
if (target_p->localClient->fd.ssl) |
| 391 |
< |
sendto_one(source_p, form_str(RPL_WHOISSSL), |
| 391 |
> |
sendto_one(source_p, form_str(RPL_WHOISSECURE), |
| 392 |
|
me.name, source_p->name, target_p->name); |
| 393 |
|
#endif |
| 394 |
|
sendto_one(source_p, form_str(RPL_WHOISIDLE), |
| 395 |
|
me.name, source_p->name, target_p->name, |
| 396 |
< |
CurrentTime - target_p->localClient->last, |
| 397 |
< |
target_p->firsttime); |
| 396 |
> |
CurrentTime - target_p->localClient->last_privmsg, |
| 397 |
> |
target_p->localClient->firsttime); |
| 398 |
> |
|
| 399 |
> |
if (HasUMode(target_p, UMODE_OPER) && target_p != source_p) |
| 400 |
> |
if (HasUMode(target_p, UMODE_SPY)) |
| 401 |
> |
sendto_one(target_p, ":%s NOTICE %s :*** Notice -- %s (%s@%s) [%s] is doing " |
| 402 |
> |
"a whois on you", me.name, target_p->name, source_p->name, |
| 403 |
> |
source_p->username, source_p->host, source_p->servptr->name); |
| 404 |
|
} |
| 405 |
|
} |
| 406 |
+ |
|
| 407 |
+ |
static struct Message whois_msgtab = { |
| 408 |
+ |
"WHOIS", 0, 0, 0, MAXPARA, MFLG_SLOW, 0, |
| 409 |
+ |
{ m_unregistered, m_whois, mo_whois, m_ignore, mo_whois, m_ignore } |
| 410 |
+ |
}; |
| 411 |
+ |
|
| 412 |
+ |
static void |
| 413 |
+ |
module_init(void) |
| 414 |
+ |
{ |
| 415 |
+ |
mod_add_cmd(&whois_msgtab); |
| 416 |
+ |
} |
| 417 |
+ |
|
| 418 |
+ |
static void |
| 419 |
+ |
module_exit(void) |
| 420 |
+ |
{ |
| 421 |
+ |
mod_del_cmd(&whois_msgtab); |
| 422 |
+ |
} |
| 423 |
+ |
|
| 424 |
+ |
struct module module_entry = { |
| 425 |
+ |
.node = { NULL, NULL, NULL }, |
| 426 |
+ |
.name = NULL, |
| 427 |
+ |
.version = "$Revision$", |
| 428 |
+ |
.handle = NULL, |
| 429 |
+ |
.modinit = module_init, |
| 430 |
+ |
.modexit = module_exit, |
| 431 |
+ |
.flags = 0 |
| 432 |
+ |
}; |