change server dump to work like user/chan dumps and take an optional parameter to dump a single server
This commit is contained in:
parent
1e1e66ea1e
commit
792497bcc8
5 changed files with 41 additions and 16 deletions
|
@ -372,10 +372,12 @@ Example:
|
|||
2.3.15 SERVERDUMP
|
||||
-----------------
|
||||
Syntax:
|
||||
/msg NeoStats SERVERDUMP
|
||||
/msg NeoStats SERVERDUMP [name]
|
||||
Description:
|
||||
When in debug mode, Neostats will echo its server table to
|
||||
the services channel. Only useful for debugging Neostats
|
||||
If name is passed, only the information for that server is
|
||||
returned, otherwise the entire server list is dumped.
|
||||
Example:
|
||||
/msg NeoStats SERVERDUMP
|
||||
|
||||
|
|
|
@ -186,9 +186,12 @@ const char *ns_help_userdump[] = {
|
|||
|
||||
const char *ns_help_serverdump[] = {
|
||||
"Syntax: \2SERVERDUMP\2",
|
||||
"Syntax: \2SERVERDUMP <name>\2",
|
||||
"",
|
||||
"When in debug mode, Neostats will echo its server table to",
|
||||
"the services channel. Only useful for debugging Neostats",
|
||||
"If name is passed, only the information for that server is",
|
||||
"returned, otherwise the entire server list is dumped.",
|
||||
NULL
|
||||
};
|
||||
|
||||
|
|
39
server.c
39
server.c
|
@ -167,25 +167,40 @@ findserver (const char *name)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
dumpserver (Server *s)
|
||||
{
|
||||
#ifdef BASE64SERVERNAME
|
||||
debugtochannel("Server: %s (%s)", s->name, s->name64);
|
||||
#else
|
||||
debugtochannel("Server: %s", s->name);
|
||||
#endif
|
||||
debugtochannel("Flags: %lx", s->flags);
|
||||
debugtochannel("Uplink: %s", s->uplink);
|
||||
debugtochannel("========================================");
|
||||
}
|
||||
|
||||
void
|
||||
ServerDump (void)
|
||||
ServerDump (const char *name)
|
||||
{
|
||||
Server *s;
|
||||
hscan_t ss;
|
||||
hnode_t *sn;
|
||||
|
||||
debugtochannel("================SERVDUMP================");
|
||||
hash_scan_begin (&ss, sh);
|
||||
while ((sn = hash_scan_next (&ss)) != NULL) {
|
||||
s = hnode_get (sn);
|
||||
#ifdef BASE64SERVERNAME
|
||||
debugtochannel("Server: %s (%s)", s->name, s->name64);
|
||||
#else
|
||||
debugtochannel("Server: %s", s->name);
|
||||
#endif
|
||||
debugtochannel("Flags: %lx", s->flags);
|
||||
debugtochannel("Uplink: %s", s->uplink);
|
||||
debugtochannel("========================================");
|
||||
if (!name) {
|
||||
hash_scan_begin (&ss, sh);
|
||||
while ((sn = hash_scan_next (&ss)) != NULL) {
|
||||
s = hnode_get (sn);
|
||||
dumpserver (s);
|
||||
}
|
||||
} else {
|
||||
s = findserver (name);
|
||||
if (s) {
|
||||
dumpserver (s);
|
||||
} else {
|
||||
debugtochannel("ServerDump: can't find server %s", name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
2
server.h
2
server.h
|
@ -26,7 +26,7 @@
|
|||
|
||||
Server *AddServer (const char *name, const char *uplink, const char* hops, const char *numeric, const char *infoline);
|
||||
void DelServer(const char *name, const char* reason);
|
||||
void ServerDump (void);
|
||||
void ServerDump (const char *name);
|
||||
int init_server_hash (void);
|
||||
void PingServers (void);
|
||||
void FreeServers();
|
||||
|
|
|
@ -332,8 +332,13 @@ ns_serverdump (User * u, char **av, int ac)
|
|||
prefmsg (u->nick, s_Services, "\2Error:\2 Debug Mode Disabled");
|
||||
return 0;
|
||||
}
|
||||
chanalert (s_Services, "\2DEBUG\2 \2%s\2 Requested a ServerDump!", u->nick);
|
||||
ServerDump ();
|
||||
if(ac < 3) {
|
||||
chanalert (s_Services, "\2DEBUG\2 \2%s\2 Requested a ServerDump!", u->nick);
|
||||
ServerDump (NULL);
|
||||
} else {
|
||||
chanalert (s_Services, "\2DEBUG\2 \2%s\2 Requested a ServerDump for %s!", u->nick, av[2]);
|
||||
ServerDump (av[2]);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue