diff --git a/doc/opers.txt b/doc/opers.txt index c4d7aab2..04007216 100755 --- a/doc/opers.txt +++ b/doc/opers.txt @@ -79,6 +79,7 @@ COMMAND - USAGE and DESCRIPTION n - Shows user connection counters o - Shows oper blocks p - Shows opers connected and their idle times + P - Shows listening ports and flags * Q - Shows local nick/chan restrictions * q - Shows network nick/chan restrictions (sqlines) r - Shows resource usage by ircd (only in DEBUGMODE) diff --git a/src/m_stats.c b/src/m_stats.c index 10ca83c4..dd7a0d9f 100644 --- a/src/m_stats.c +++ b/src/m_stats.c @@ -52,11 +52,13 @@ extern void report_fds(aClient *); extern char *oflagtotext(int oflags); /* For stats o */ extern char *cflagtotext(int cflags, int uflags); /* For stats c */ extern char *iflagtotext(int iflags); /* For stats i */ +extern char *pflagtotext(int pflags); /* For stats P */ extern int report_spamfilters(aClient *cptr, aClient *sptr, int parc, char *parv[]); /* For stats S */ /* internal function defines */ static void show_opers(aClient *, char *); +static void show_ports(aClient *, char *); static void show_servers(aClient *, char *); #ifdef DEBUGMODE static void send_usage(aClient *, char *); @@ -65,10 +67,6 @@ static void serv_info(aClient *, char *); static void tstats(aClient *, char *); /* support functions */ -/* show_opers - * replies to stats p requests - */ - #ifdef DEBUGMODE static void @@ -166,7 +164,9 @@ send_usage(aClient *cptr, char *nick) } #endif /* DEBUGMODE */ - +/* show_opers + * replies to stats P requests + */ static void show_opers(aClient *cptr, char *name) { @@ -206,6 +206,35 @@ show_opers(aClient *cptr, char *name) name, j, (j == 1) ? "" : "s"); } +/* show_ports + * replies to stats p requets + */ +static void +show_ports(aClient *cptr, char *name) +{ + aPort *tmp; + int j = 0; + + if(!ports) + sendto_realops("Lost all port configurations!"); + for(tmp = ports; tmp; tmp = tmp->next) + { + if(tmp->lstn) + { + if(IsULine(cptr) || (MyClient(cptr) && IsAdmin(cptr))) + sendto_one(cptr,":%s %d %s :%s %s %i %s %i", me.name, RPL_STATSDEBUG, + name, tmp->address?tmp->address:"*", tmp->allow?tmp->allow:"*", + tmp->port, pflagtotext(tmp->flags), tmp->lstn->clients); + else + sendto_one(cptr,":%s %d %s : %i %s %i", me.name, RPL_STATSDEBUG, + name, tmp->port, pflagtotext(tmp->flags), tmp->lstn->clients); + j++; + } + } + sendto_one(cptr, ":%s %d %s :%d PORT%s", me.name, RPL_STATSDEBUG, + name, j, (j == 1) ? "" : "s"); +} + /* show_servers * replies to stats v requests */ @@ -817,9 +846,14 @@ int m_stats(aClient *cptr, aClient *sptr, int parc, char *parv[]) } case 'p': - case 'P': show_opers(sptr, parv[0]); break; + case 'P': + if(IsAnOper(sptr) || IsULine(sptr)) + show_ports(sptr, parv[0]); + else + sendto_one(sptr, err_str(ERR_NOPRIVILEGES), me.name, parv[0]); + break; case 'Q': if(IsAnOper(sptr)) diff --git a/src/s_conf.c b/src/s_conf.c index 4d684b8d..f4fd0033 100644 --- a/src/s_conf.c +++ b/src/s_conf.c @@ -2571,6 +2571,30 @@ char *iflagtotext(int iflags) return res; } +/* pflagtotext() + * Return the pflags in human readable format. + * May 20 - rasengan + */ +char *pflagtotext(int pflags) +{ + static char res[BUFSIZE + 1]; + int len = 0; + + if(pflags & CONF_FLAGS_P_SSL) + res[len++] = 'S'; + if(pflags & CONF_FLAGS_P_NODNS) + res[len++] = 'n'; + if(pflags & CONF_FLAGS_P_NOIDENT) + res[len++] = 'i'; + + if(!len) + res[len++] = '-'; + + res[len++] = 0; + + return res; +} + u_long memcount_s_conf(MCs_conf *mc) {