Nlookup: new option -o to show configured overrides
This commit is contained in:
parent
c5dc00c084
commit
64cfc794dc
@ -329,7 +329,7 @@ void printf_usage(const char *ident, const char *fmt, ...)
|
|||||||
else
|
else
|
||||||
printf("Sorry, no usage information available\n\n");
|
printf("Sorry, no usage information available\n\n");
|
||||||
|
|
||||||
printf("Mail bug reports to <adb@newmail.ru>\n");
|
printf("Mail bug reports to <zx@zxalexis.ru>\n");
|
||||||
|
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
|
@ -28,11 +28,12 @@ bool eventexpr(s_expr *expr)
|
|||||||
static void usage(void)
|
static void usage(void)
|
||||||
{
|
{
|
||||||
printf_usage("nodelist lookup utility",
|
printf_usage("nodelist lookup utility",
|
||||||
"usage: nlookup [-C config] [-rmh] <address>\n"
|
"usage: nlookup [-C config] [-romh] <address>\n"
|
||||||
"\n"
|
"\n"
|
||||||
"options:\n"
|
"options:\n"
|
||||||
" -r show nodelist string\n"
|
" -r show nodelist string\n"
|
||||||
" -m show email address\n"
|
" -m show email address\n"
|
||||||
|
" -o show overrides\n"
|
||||||
" -h show this help message\n"
|
" -h show this help message\n"
|
||||||
" -C config use config file\n"
|
" -C config use config file\n"
|
||||||
"\n"
|
"\n"
|
||||||
@ -123,22 +124,48 @@ void print_nodeinfo(const s_node *node)
|
|||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void print_overrides(const s_override *override_info)
|
||||||
|
{
|
||||||
|
s_override *p;
|
||||||
|
char abuf[BF_MAXADDRSTR+1];
|
||||||
|
int lin = 0;
|
||||||
|
printf("----------- Overrides ------------\n");
|
||||||
|
printf("Address : %s\n", ftn_addrstr(abuf, override_info->addr));
|
||||||
|
printf("IpAddr : %s\n", override_info->sIpaddr);
|
||||||
|
printf("Phone : %s\n", override_info->sPhone);
|
||||||
|
printf("Flags : %s\n", override_info->sFlags);
|
||||||
|
printf("Run before: %s\n", override_info->run);
|
||||||
|
p = override_info->hidden;
|
||||||
|
if (p) {
|
||||||
|
printf("Hidden lines:\n");
|
||||||
|
while( p )
|
||||||
|
{
|
||||||
|
printf(" Hidden IpAddr : %s\n", p->sIpaddr);
|
||||||
|
printf(" Hidden Phone : %s\n", p->sPhone);
|
||||||
|
printf(" Hidden Flags : %s\n", p->sFlags);
|
||||||
|
p = p->hidden;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
s_node node;
|
s_node node;
|
||||||
s_faddr addr;
|
s_faddr addr;
|
||||||
|
s_override *ovr;
|
||||||
char ch;
|
char ch;
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
char *confname = NULL;
|
char *confname = NULL;
|
||||||
bool rawstring = FALSE;
|
bool rawstring = FALSE;
|
||||||
bool emailaddr = FALSE;
|
bool emailaddr = FALSE;
|
||||||
|
bool overrides = FALSE;
|
||||||
|
|
||||||
/* Initialise random number generation */
|
/* Initialise random number generation */
|
||||||
(void)srand((unsigned)time(0));
|
(void)srand((unsigned)time(0));
|
||||||
/* Initialise current locale */
|
/* Initialise current locale */
|
||||||
(void)setlocale(LC_ALL, "");
|
(void)setlocale(LC_ALL, "");
|
||||||
|
|
||||||
while( (ch=getopt(argc, argv, "hdrmC:")) != (char)-1 )
|
while( (ch=getopt(argc, argv, "hdrmoC:")) != (char)-1 )
|
||||||
{
|
{
|
||||||
switch( ch ) {
|
switch( ch ) {
|
||||||
case 'h':
|
case 'h':
|
||||||
@ -150,6 +177,9 @@ int main(int argc, char *argv[])
|
|||||||
case 'm':
|
case 'm':
|
||||||
emailaddr = TRUE;
|
emailaddr = TRUE;
|
||||||
break;
|
break;
|
||||||
|
case 'o':
|
||||||
|
overrides = TRUE;
|
||||||
|
break;
|
||||||
case 'C':
|
case 'C':
|
||||||
if( confname || !optarg ) { usage(); exit(BFERR_FATALERROR); }
|
if( confname || !optarg ) { usage(); exit(BFERR_FATALERROR); }
|
||||||
confname = (char *)xstrcpy(optarg);
|
confname = (char *)xstrcpy(optarg);
|
||||||
@ -188,6 +218,9 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
else if( nodelist_lookup(&node, addr) == 0 )
|
else if( nodelist_lookup(&node, addr) == 0 )
|
||||||
{
|
{
|
||||||
|
// Overrides
|
||||||
|
ovr = conf_override(cf_override, addr);
|
||||||
|
|
||||||
if (addr.point == 0) {
|
if (addr.point == 0) {
|
||||||
if( emailaddr )
|
if( emailaddr )
|
||||||
print_nodemail(&node);
|
print_nodemail(&node);
|
||||||
@ -198,6 +231,17 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
print_nodeinfo(&node);
|
print_nodeinfo(&node);
|
||||||
}
|
}
|
||||||
|
if (overrides && ovr) {
|
||||||
|
print_overrides(ovr);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (overrides) {
|
||||||
|
ovr = conf_override(cf_override, addr);
|
||||||
|
if (ovr) {
|
||||||
|
printf ("-- No nodelist info, only overrides --");
|
||||||
|
print_overrides(ovr);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
deinit_conf();
|
deinit_conf();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user