static void stats_access(struct Client* to, struct StatDesc* sd, int stat, char* param) { struct ConfItem *aconf; int wilds = 0; int count = 1000; if (!param) { stats_configured_links(to, sd, stat, param); return; } wilds = string_has_wildcards(param); for (aconf = GlobalConfList; aconf; aconf = aconf->next) { if (CONF_CLIENT == aconf->status) { if ((!wilds && (!match(aconf->host, param) || !match(aconf->name, param))) || (wilds && (!mmatch(param, aconf->host) || !mmatch(param, aconf->name)))) { send_reply(to, RPL_STATSILINE, 'I', aconf->host, aconf->name, aconf->port, get_conf_class(aconf)); if (--count == 0) break; } } } }
static void stats_configured_links(struct Client* sptr, struct StatDesc* sd, int stat, char* param) { static char null[] = "<NULL>"; struct ConfItem *tmp; int mask; unsigned int *p; unsigned short int port; char c, *host, *pass, *name; mask = sd->sd_funcdata; for (tmp = GlobalConfList; tmp; tmp = tmp->next) { if ((tmp->status & mask)) { for (p = &report_array[0][0]; *p; p += 3) if (*p == tmp->status) break; if (!*p) continue; c = (char)*(p + 2); host = BadPtr(tmp->host) ? null : tmp->host; pass = BadPtr(tmp->passwd) ? null : tmp->passwd; name = BadPtr(tmp->name) ? null : tmp->name; port = tmp->port; /* * On K line the passwd contents can be * displayed on STATS reply. -Vesa */ /* Special-case 'k' or 'K' lines as appropriate... -Kev */ if ((tmp->status & CONF_UWORLD)) send_reply(sptr, p[1], c, host, pass, name, port, get_conf_class(tmp)); else if ((tmp->status & (CONF_SERVER | CONF_HUB))) send_reply(sptr, p[1], c, "*", name, port, get_conf_class(tmp)); else send_reply(sptr, p[1], c, host, name, port, get_conf_class(tmp)); } } }
static void report_sub_mtrie(aClient *sptr, int flags, DOMAIN_LEVEL *dl_ptr) { DOMAIN_PIECE *dp_ptr; aConfItem *aconf; int i; char *p; char *host; char *pass; char *name; char *mask; int port; char c; if(!dl_ptr) return; for(i=0; i < MAX_PIECE_LIST; i++) { for(dp_ptr=dl_ptr->piece_list[i];dp_ptr; dp_ptr = dp_ptr->next_piece) { report_sub_mtrie(sptr,flags,dp_ptr->next_level); if(dp_ptr->conf_ptr) { /* Only show desired I/K lines */ aconf = dp_ptr->conf_ptr; if(aconf->status & flags) { host = BadPtr(aconf->host) ? null : aconf->host; pass = BadPtr(aconf->passwd) ? null : aconf->passwd; name = BadPtr(aconf->name) ? null : aconf->name; mask = BadPtr(aconf->mask) ? null : aconf->mask; port = (int)aconf->port; if (aconf->status == CONF_KILL) { sendto_one(sptr, rpl_str(RPL_STATSKLINE), me.name, sptr->name, 'K', host, name, pass); } else { c = 'I'; #ifdef LITTLE_I_LINES if(IsConfLittleI(aconf)) c = 'i'; #endif sendto_one(sptr, rpl_str(RPL_STATSILINE), me.name, sptr->name, c, mask, show_iline_prefix(sptr,aconf,name), host, port, get_conf_class(aconf)); } } } if(dp_ptr->wild_conf_ptr) { aconf = dp_ptr->wild_conf_ptr; if(aconf->status & flags) { host = BadPtr(aconf->host) ? null : aconf->host; pass = BadPtr(aconf->passwd) ? null : aconf->passwd; name = BadPtr(aconf->name) ? null : aconf->name; mask = BadPtr(aconf->mask) ? null : aconf->mask; port = (int)aconf->port; if (aconf->status == CONF_KILL) { sendto_one(sptr, rpl_str(RPL_STATSKLINE), me.name, sptr->name, 'K', host, name, pass); } else { sendto_one(sptr, rpl_str(RPL_STATSILINE), me.name, sptr->name, c, mask, show_iline_prefix(sptr,aconf,name), host, port, get_conf_class(aconf)); } } } } } }
void report_mtrie_conf_links(aClient *sptr, int flags) { aConfItem *found_conf; char *host; char *pass; char *name; char *mask; int port; char c; /* conf char used for CONF_CLIENT only */ if(trie_list) report_sub_mtrie(sptr,flags,trie_list); /* If requesting I lines do this */ if(flags & CONF_CLIENT) { for(found_conf = unsortable_list_ilines; found_conf;found_conf=found_conf->next) { host = BadPtr(found_conf->host) ? null : found_conf->host; pass = BadPtr(found_conf->passwd) ? null : found_conf->passwd; name = BadPtr(found_conf->name) ? null : found_conf->name; mask = BadPtr(found_conf->mask) ? null : found_conf->mask; port = (int)found_conf->port; c = 'I'; #ifdef LITTLE_I_LINES if(IsConfLittleI(found_conf)) c = 'i'; #endif sendto_one(sptr, rpl_str(RPL_STATSILINE), me.name, sptr->name, c, mask, show_iline_prefix(sptr,found_conf,name), host, port, get_conf_class(found_conf)); } for(found_conf = wild_card_ilines; found_conf;found_conf=found_conf->next) { host = BadPtr(found_conf->host) ? null : found_conf->host; pass = BadPtr(found_conf->passwd) ? null : found_conf->passwd; name = BadPtr(found_conf->name) ? null : found_conf->name; mask = BadPtr(found_conf->mask) ? null : found_conf->mask; port = (int)found_conf->port; if(!(found_conf->status&CONF_CLIENT)) continue; c = 'I'; #ifdef LITTLE_I_LINES if(IsConfLittleI(found_conf)) c = 'i'; #endif sendto_one(sptr, rpl_str(RPL_STATSILINE), me.name, sptr->name, c, mask, show_iline_prefix(sptr,found_conf,name), host, port, get_conf_class(found_conf)); } } else { report_dline_hash(sptr,CONF_KILL); for(found_conf = unsortable_list_klines; found_conf;found_conf=found_conf->next) { host = BadPtr(found_conf->host) ? null : found_conf->host; pass = BadPtr(found_conf->passwd) ? null : found_conf->passwd; name = BadPtr(found_conf->name) ? null : found_conf->name; port = (int)found_conf->port; sendto_one(sptr, rpl_str(RPL_STATSKLINE), me.name, sptr->name, 'K', host, name, pass); } } }