46 |
static void *do_stats(va_list args); |
static void *do_stats(va_list args); |
47 |
static void m_stats(struct Client *, struct Client *, int, char *[]); |
static void m_stats(struct Client *, struct Client *, int, char *[]); |
48 |
static void mo_stats(struct Client *, struct Client *, int, char *[]); |
static void mo_stats(struct Client *, struct Client *, int, char *[]); |
|
static void ms_stats(struct Client *, struct Client *, int, char *[]); |
|
49 |
|
|
50 |
struct Message stats_msgtab = { |
struct Message stats_msgtab = { |
51 |
"STATS", 0, 0, 2, 0, MFLG_SLOW, 0, |
"STATS", 0, 0, 2, 0, MFLG_SLOW, 0, |
52 |
{ m_unregistered, m_stats, ms_stats, m_ignore, mo_stats, m_ignore } |
{ m_unregistered, m_stats, mo_stats, m_ignore, mo_stats, m_ignore } |
53 |
}; |
}; |
54 |
|
|
55 |
static struct Callback *stats_cb; |
static struct Callback *stats_cb; |
223 |
/* Is the stats meant for us? */ |
/* Is the stats meant for us? */ |
224 |
if (!ConfigFileEntry.disable_remote) |
if (!ConfigFileEntry.disable_remote) |
225 |
if (hunt_server(client_p, source_p, ":%s STATS %s :%s", 2, |
if (hunt_server(client_p, source_p, ":%s STATS %s :%s", 2, |
226 |
parc,parv) != HUNTED_ISME) |
parc, parv) != HUNTED_ISME) |
227 |
return; |
return; |
228 |
|
|
229 |
if (!MyClient(source_p) && IsCapable(source_p->from, CAP_TS6) && HasID(source_p)) |
if (!MyClient(source_p) && IsCapable(source_p->from, CAP_TS6) && HasID(source_p)) |
244 |
from, to); |
from, to); |
245 |
return; |
return; |
246 |
} |
} |
247 |
else |
|
248 |
last_used = CurrentTime; |
last_used = CurrentTime; |
249 |
|
|
250 |
execute_callback(stats_cb, source_p, parc, parv); |
execute_callback(stats_cb, source_p, parc, parv); |
251 |
} |
} |
263 |
mo_stats(struct Client *client_p, struct Client *source_p, |
mo_stats(struct Client *client_p, struct Client *source_p, |
264 |
int parc, char *parv[]) |
int parc, char *parv[]) |
265 |
{ |
{ |
266 |
|
if (!IsClient(source_p)) |
267 |
|
return; |
268 |
|
|
269 |
if (hunt_server(client_p, source_p, ":%s STATS %s :%s", 2, |
if (hunt_server(client_p, source_p, ":%s STATS %s :%s", 2, |
270 |
parc, parv) != HUNTED_ISME) |
parc, parv) != HUNTED_ISME) |
271 |
return; |
return; |
495 |
} |
} |
496 |
} |
} |
497 |
|
|
|
#if 0 |
|
|
/* XXX THIS has to be fixed !!!! -db */ |
|
|
/* count up all config items */ |
|
|
DLINK_FOREACH(dlink, ConfigItemList.head) |
|
|
{ |
|
|
aconf = dlink->data; |
|
|
conf_memory += aconf->host ? strlen(aconf->host)+1 : 0; |
|
|
conf_memory += aconf->passwd ? strlen(aconf->passwd)+1 : 0; |
|
|
conf_memory += aconf->name ? strlen(aconf->name)+1 : 0; |
|
|
conf_memory += sizeof(struct AccessItem); |
|
|
} |
|
|
#endif |
|
498 |
count_watch_memory(&wlh, &wlhm); |
count_watch_memory(&wlh, &wlhm); |
499 |
|
|
500 |
sendto_one(source_p, ":%s %d %s z :WATCH headers %u(%u) entries %d(%d)", |
sendto_one(source_p, ":%s %d %s z :WATCH headers %u(%u) entries %d(%d)", |
619 |
struct AccessItem *aconf; |
struct AccessItem *aconf; |
620 |
int i; |
int i; |
621 |
|
|
622 |
for (i = 0; i < ATABLE_SIZE; i++) |
for (i = 0; i < ATABLE_SIZE; ++i) |
623 |
{ |
{ |
624 |
for (arec = atable[i]; arec; arec=arec->next) |
for (arec = atable[i]; arec; arec=arec->next) |
625 |
{ |
{ |
655 |
struct AccessItem *aconf; |
struct AccessItem *aconf; |
656 |
int i; |
int i; |
657 |
|
|
658 |
for (i = 0; i < ATABLE_SIZE; i++) |
for (i = 0; i < ATABLE_SIZE; ++i) |
659 |
{ |
{ |
660 |
for (arec = atable[i]; arec; arec=arec->next) |
for (arec = atable[i]; arec; arec=arec->next) |
661 |
{ |
{ |
691 |
struct AccessItem *aconf; |
struct AccessItem *aconf; |
692 |
int i; |
int i; |
693 |
|
|
694 |
for (i = 0; i < ATABLE_SIZE; i++) |
for (i = 0; i < ATABLE_SIZE; ++i) |
695 |
{ |
{ |
696 |
for (arec = atable[i]; arec; arec=arec->next) |
for (arec = atable[i]; arec; arec=arec->next) |
697 |
{ |
{ |
910 |
to, "k", aconf->host, aconf->user, aconf->reason, ""); |
to, "k", aconf->host, aconf->user, aconf->reason, ""); |
911 |
} |
} |
912 |
/* Theyre opered, or allowed to see all klines */ |
/* Theyre opered, or allowed to see all klines */ |
913 |
else { |
else |
914 |
|
{ |
915 |
report_Klines(source_p, 1); |
report_Klines(source_p, 1); |
916 |
report_confitem_types(source_p, RKLINE_TYPE, 1); |
report_confitem_types(source_p, RKLINE_TYPE, 1); |
917 |
} |
} |
931 |
struct AccessItem *aconf; |
struct AccessItem *aconf; |
932 |
|
|
933 |
/* search for a kline */ |
/* search for a kline */ |
934 |
if(MyConnect(source_p)) |
if (MyConnect(source_p)) |
935 |
aconf = find_conf_by_address(source_p->host, |
aconf = find_conf_by_address(source_p->host, |
936 |
&source_p->localClient->ip, |
&source_p->localClient->ip, |
937 |
CONF_KILL, |
CONF_KILL, |
941 |
aconf = find_conf_by_address(source_p->host, NULL, CONF_KILL, |
aconf = find_conf_by_address(source_p->host, NULL, CONF_KILL, |
942 |
0, source_p->username, NULL); |
0, source_p->username, NULL); |
943 |
|
|
944 |
if(aconf == NULL) |
if (aconf == NULL) |
945 |
return; |
return; |
946 |
|
|
947 |
/* dont report a tkline as a kline */ |
/* dont report a tkline as a kline */ |
948 |
if(aconf->flags & CONF_FLAGS_TEMPORARY) |
if (aconf->flags & CONF_FLAGS_TEMPORARY) |
949 |
return; |
return; |
950 |
|
|
951 |
sendto_one(source_p, form_str(RPL_STATSKLINE), from, |
sendto_one(source_p, form_str(RPL_STATSKLINE), from, |
953 |
aconf->oper_reason); |
aconf->oper_reason); |
954 |
} |
} |
955 |
/* Theyre opered, or allowed to see all klines */ |
/* Theyre opered, or allowed to see all klines */ |
956 |
else { |
else |
957 |
|
{ |
958 |
report_Klines(source_p, 0); |
report_Klines(source_p, 0); |
959 |
report_confitem_types(source_p, RKLINE_TYPE, 0); |
report_confitem_types(source_p, RKLINE_TYPE, 0); |
960 |
} |
} |
1132 |
static void |
static void |
1133 |
stats_servers(struct Client *source_p) |
stats_servers(struct Client *source_p) |
1134 |
{ |
{ |
1135 |
struct Client *target_p; |
dlink_node *ptr = NULL; |
|
dlink_node *ptr; |
|
|
int j = 0; |
|
1136 |
|
|
1137 |
DLINK_FOREACH(ptr, serv_list.head) |
DLINK_FOREACH(ptr, serv_list.head) |
1138 |
{ |
{ |
1139 |
target_p = ptr->data; |
const struct Client *target_p = ptr->data; |
|
|
|
|
j++; |
|
1140 |
|
|
1141 |
sendto_one(source_p, ":%s %d %s v :%s (%s!%s@%s) Idle: %d", |
sendto_one(source_p, ":%s %d %s v :%s (%s!%s@%s) Idle: %d", |
1142 |
from, RPL_STATSDEBUG, to, |
from, RPL_STATSDEBUG, to, |
1145 |
"*", "*", (int)(CurrentTime - target_p->lasttime)); |
"*", "*", (int)(CurrentTime - target_p->lasttime)); |
1146 |
} |
} |
1147 |
|
|
1148 |
sendto_one(source_p, ":%s %d %s v :%d Server(s)", |
sendto_one(source_p, ":%s %d %s v :%lu Server(s)", |
1149 |
from, RPL_STATSDEBUG, to, j); |
from, RPL_STATSDEBUG, to, |
1150 |
|
dlink_list_length(&serv_list)); |
1151 |
} |
} |
1152 |
|
|
1153 |
static void |
static void |
1208 |
{ |
{ |
1209 |
uint64_t sendB = 0, recvB = 0; |
uint64_t sendB = 0, recvB = 0; |
1210 |
time_t uptime = 0; |
time_t uptime = 0; |
1211 |
int j = 0; |
dlink_node *ptr = NULL; |
|
struct Client *target_p = NULL; |
|
|
dlink_node *ptr; |
|
1212 |
|
|
1213 |
if (ConfigServerHide.flatten_links && !IsOper(source_p)) |
if (ConfigServerHide.flatten_links && !IsOper(source_p)) |
1214 |
{ |
{ |
1219 |
|
|
1220 |
DLINK_FOREACH(ptr, serv_list.head) |
DLINK_FOREACH(ptr, serv_list.head) |
1221 |
{ |
{ |
1222 |
target_p = ptr->data; |
struct Client *target_p = ptr->data; |
1223 |
|
|
|
++j; |
|
1224 |
sendB += target_p->localClient->send.bytes; |
sendB += target_p->localClient->send.bytes; |
1225 |
recvB += target_p->localClient->recv.bytes; |
recvB += target_p->localClient->recv.bytes; |
1226 |
|
|
1242 |
recvB >>= 10; |
recvB >>= 10; |
1243 |
|
|
1244 |
sendto_one(source_p, ":%s %d %s ? :%u total server(s)", |
sendto_one(source_p, ":%s %d %s ? :%u total server(s)", |
1245 |
from, RPL_STATSDEBUG, to, j); |
from, RPL_STATSDEBUG, to, dlink_list_length(&serv_list)); |
1246 |
sendto_one(source_p, ":%s %d %s ? :Sent total : %7.2f %s", |
sendto_one(source_p, ":%s %d %s ? :Sent total : %7.2f %s", |
1247 |
from, RPL_STATSDEBUG, to, |
from, RPL_STATSDEBUG, to, |
1248 |
_GMKv((signed)sendB), _GMKs((signed)sendB)); |
_GMKv((signed)sendB), _GMKs((signed)sendB)); |
1276 |
|
|
1277 |
if ((name = parse_stats_args(parc, parv, &doall, &wilds)) != NULL) |
if ((name = parse_stats_args(parc, parv, &doall, &wilds)) != NULL) |
1278 |
{ |
{ |
1279 |
statchar = parv[1][0]; |
statchar = *parv[1]; |
1280 |
|
|
1281 |
stats_L(source_p, name, doall, wilds, statchar); |
stats_L(source_p, name, doall, wilds, statchar); |
1282 |
} |
} |
1326 |
sendto_one(source_p, ":%s %d %s :Last event to run: %s", |
sendto_one(source_p, ":%s %d %s :Last event to run: %s", |
1327 |
me.name, RPL_STATSDEBUG, source_p->name, last_event_ran); |
me.name, RPL_STATSDEBUG, source_p->name, last_event_ran); |
1328 |
sendto_one(source_p, ":%s %d %s : ", |
sendto_one(source_p, ":%s %d %s : ", |
1329 |
me.name, RPL_STATSDEBUG, source_p->name); |
me.name, RPL_STATSDEBUG, source_p->name); |
1330 |
} |
} |
1331 |
|
|
1332 |
sendto_one(source_p, |
sendto_one(source_p, |
1346 |
} |
} |
1347 |
|
|
1348 |
sendto_one(source_p, ":%s %d %s : ", |
sendto_one(source_p, ":%s %d %s : ", |
1349 |
me.name, RPL_STATSDEBUG, source_p->name); |
me.name, RPL_STATSDEBUG, source_p->name); |
1350 |
} |
} |
1351 |
|
|
1352 |
static void |
static void |
1355 |
int i; |
int i; |
1356 |
char ipaddr[HOSTIPLEN]; |
char ipaddr[HOSTIPLEN]; |
1357 |
|
|
1358 |
for (i = 0; i < irc_nscount; i++) |
for (i = 0; i < irc_nscount; ++i) |
1359 |
{ |
{ |
1360 |
irc_getnameinfo((struct sockaddr *)&(irc_nsaddr_list[i]), |
irc_getnameinfo((struct sockaddr *)&(irc_nsaddr_list[i]), |
1361 |
irc_nsaddr_list[i].ss_len, ipaddr, HOSTIPLEN, NULL, 0, |
irc_nsaddr_list[i].ss_len, ipaddr, sizeof(ipaddr), NULL, 0, |
1362 |
NI_NUMERICHOST); |
NI_NUMERICHOST); |
1363 |
sendto_one(source_p, form_str(RPL_STATSALINE), |
sendto_one(source_p, form_str(RPL_STATSALINE), |
1364 |
me.name, source_p->name, ipaddr); |
me.name, source_p->name, ipaddr); |
1379 |
} |
} |
1380 |
|
|
1381 |
/* |
/* |
|
* ms_stats - STATS message handler |
|
|
* parv[0] = sender prefix |
|
|
* parv[1] = statistics selector (defaults to Message frequency) |
|
|
* parv[2] = server name (current server defaulted, if omitted) |
|
|
*/ |
|
|
static void |
|
|
ms_stats(struct Client *client_p, struct Client *source_p, |
|
|
int parc, char *parv[]) |
|
|
{ |
|
|
if (hunt_server(client_p,source_p,":%s STATS %s :%s",2,parc,parv)!=HUNTED_ISME) |
|
|
return; |
|
|
|
|
|
if (IsClient(source_p)) |
|
|
mo_stats(client_p, source_p, parc, parv); |
|
|
} |
|
|
|
|
|
/* |
|
1382 |
* stats_L |
* stats_L |
1383 |
* |
* |
1384 |
* inputs - pointer to client to report to |
* inputs - pointer to client to report to |
1397 |
} |
} |
1398 |
|
|
1399 |
static void |
static void |
1400 |
stats_L_list(struct Client *source_p,char *name, int doall, int wilds, |
stats_L_list(struct Client *source_p, char *name, int doall, int wilds, |
1401 |
dlink_list *list,char statchar) |
dlink_list *list, char statchar) |
1402 |
{ |
{ |
1403 |
dlink_node *ptr; |
dlink_node *ptr = NULL; |
|
struct Client *target_p; |
|
1404 |
|
|
1405 |
/* |
/* |
1406 |
* send info about connections which match, or all if the |
* send info about connections which match, or all if the |
1410 |
*/ |
*/ |
1411 |
DLINK_FOREACH(ptr, list->head) |
DLINK_FOREACH(ptr, list->head) |
1412 |
{ |
{ |
1413 |
target_p = ptr->data; |
int ip_action = 0; |
1414 |
|
const struct Client *target_p = ptr->data; |
1415 |
|
|
1416 |
if (IsInvisible(target_p) && (doall || wilds) && |
if (IsInvisible(target_p) && (doall || wilds) && |
1417 |
!(MyConnect(source_p) && IsOper(source_p)) && |
!(MyConnect(source_p) && IsOper(source_p)) && |
1422 |
if (!(doall || wilds) && irccmp(name, target_p->name)) |
if (!(doall || wilds) && irccmp(name, target_p->name)) |
1423 |
continue; |
continue; |
1424 |
|
|
1425 |
/* This basically shows ips for our opers if its not a server/admin, or |
if (IsIPSpoof(target_p) || IsServer(target_p) || IsAdmin(target_p) || |
1426 |
* its one of our admins. */ |
IsHandshake(target_p) || IsConnecting(target_p)) |
1427 |
if(MyClient(source_p) && IsOper(source_p) && |
ip_action = MASK_IP; |
1428 |
(IsAdmin(source_p) || |
else if (IsUpper(statchar)) |
1429 |
(!IsServer(target_p) && !IsAdmin(target_p) && |
ip_action = SHOW_IP; |
|
!IsHandshake(target_p) && !IsConnecting(target_p)))) |
|
|
{ |
|
|
sendto_one(source_p, form_str(RPL_STATSLINKINFO), |
|
|
from, to, |
|
|
(IsUpper(statchar)) ? |
|
|
get_client_name(target_p, SHOW_IP) : |
|
|
get_client_name(target_p, HIDE_IP), |
|
|
dbuf_length(&target_p->localClient->buf_sendq), |
|
|
target_p->localClient->send.messages, |
|
|
target_p->localClient->send.bytes>>10, |
|
|
target_p->localClient->recv.messages, |
|
|
target_p->localClient->recv.bytes>>10, |
|
|
(unsigned)(CurrentTime - target_p->firsttime), |
|
|
(CurrentTime > target_p->since) ? (unsigned)(CurrentTime - target_p->since):0, |
|
|
IsServer(target_p) ? show_capabilities(target_p) : "-"); |
|
|
} |
|
1430 |
else |
else |
1431 |
{ |
ip_action = HIDE_IP; |
1432 |
/* If its a hidden ip, an admin, or a server, mask the real IP */ |
|
1433 |
if(IsIPSpoof(target_p) || IsServer(target_p) || IsAdmin(target_p) |
sendto_one(source_p, form_str(RPL_STATSLINKINFO), |
1434 |
|| IsHandshake(target_p) || IsConnecting(target_p)) |
from, to, get_client_name(target_p, ip_action), |
1435 |
sendto_one(source_p, form_str(RPL_STATSLINKINFO), |
dbuf_length(&target_p->localClient->buf_sendq), |
1436 |
from, to, |
target_p->localClient->send.messages, |
1437 |
get_client_name(target_p, MASK_IP), |
target_p->localClient->send.bytes>>10, |
1438 |
dbuf_length(&target_p->localClient->buf_sendq), |
target_p->localClient->recv.messages, |
1439 |
target_p->localClient->send.messages, |
target_p->localClient->recv.bytes>>10, |
1440 |
target_p->localClient->send.bytes>>10, |
(unsigned)(CurrentTime - target_p->firsttime), |
1441 |
target_p->localClient->recv.messages, |
(CurrentTime > target_p->since) ? (unsigned)(CurrentTime - target_p->since):0, |
1442 |
target_p->localClient->recv.bytes>>10, |
IsServer(target_p) ? show_capabilities(target_p) : "-"); |
|
(unsigned)(CurrentTime - target_p->firsttime), |
|
|
(CurrentTime > target_p->since) ? (unsigned)(CurrentTime - target_p->since):0, |
|
|
IsServer(target_p) ? show_capabilities(target_p) : "-"); |
|
|
else /* show the real IP */ |
|
|
sendto_one(source_p, form_str(RPL_STATSLINKINFO), |
|
|
from, to, |
|
|
(IsUpper(statchar)) ? |
|
|
get_client_name(target_p, SHOW_IP) : |
|
|
get_client_name(target_p, HIDE_IP), |
|
|
dbuf_length(&target_p->localClient->buf_sendq), |
|
|
target_p->localClient->send.messages, |
|
|
target_p->localClient->send.bytes>>10, |
|
|
target_p->localClient->recv.messages, |
|
|
target_p->localClient->recv.bytes>>10, |
|
|
(unsigned)(CurrentTime - target_p->firsttime), |
|
|
(CurrentTime > target_p->since) ? (unsigned)(CurrentTime - target_p->since):0, |
|
|
IsServer(target_p) ? show_capabilities(target_p) : "-"); |
|
|
} |
|
1443 |
} |
} |
1444 |
} |
} |
1445 |
|
|
1468 |
else if (match(name, from)) |
else if (match(name, from)) |
1469 |
*doall = 1; |
*doall = 1; |
1470 |
|
|
1471 |
if (strchr(name, '*') || |
if (has_wildcards(name)) |
|
strchr(name, '?')) |
|
1472 |
*wilds = 1; |
*wilds = 1; |
1473 |
|
|
1474 |
return name; |
return name; |
1475 |
} |
} |
1476 |
else |
|
1477 |
return NULL; |
return NULL; |
1478 |
} |
} |