aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/App/Mangemanche/Command/inspect.pm42
1 files changed, 33 insertions, 9 deletions
diff --git a/lib/App/Mangemanche/Command/inspect.pm b/lib/App/Mangemanche/Command/inspect.pm
index 24b8df9..d5a62a3 100644
--- a/lib/App/Mangemanche/Command/inspect.pm
+++ b/lib/App/Mangemanche/Command/inspect.pm
@@ -4,6 +4,32 @@ use warnings;
4use parent 'App::Mangemanche::Command'; 4use parent 'App::Mangemanche::Command';
5use App::Mangemanche::Command ':exit_codes'; 5use App::Mangemanche::Command ':exit_codes';
6 6
7sub iplist_dumper {
8 my ($self, $kw, $val) = @_;
9 print "$kw <<EOF\n";
10 foreach my $ip (@$val) {
11 print " $ip\n";
12 }
13 print "EOF\n";
14}
15
16sub auth_dumper {
17 my ($self, $kw, $val) = @_;
18 foreach my $s (@$val) {
19 print "$kw $s->{type} $s->{method}";
20 if ($s->{'passwd-file'}) {
21 print " $s->{'passwd-file'} $s->{realm}";
22 }
23 print "\n";
24 }
25}
26
27my %kwdump = (
28 'ip-list' => \&iplist_dumper,
29 'trusted-ip' => \&iplist_dumper,
30 'auth' => \&auth_dumper
31 );
32
7sub run { 33sub run {
8 my $self = shift; 34 my $self = shift;
9 $self->SUPER::run; 35 $self->SUPER::run;
@@ -16,19 +42,17 @@ sub run {
16 42
17 foreach my $kw (sort keys %$cfg) { 43 foreach my $kw (sort keys %$cfg) {
18 my $val = $cfg->{$kw} or next; 44 my $val = $cfg->{$kw} or next;
19 print "$kw "; 45 if (my $d = $kwdump{$kw}) {
20 if (ref($val) eq 'ARRAY') { 46 $self->${ \$d }($kw, $val);
21 print "<<EOF\n"; 47 } elsif (ref($val) eq 'ARRAY') {
22 foreach my $ip (@$val) { 48 print "# $kw " . JSON::encode_json($val) . "\n";
23 print " $ip\n";
24 }
25 print "EOF";
26 } elsif (JSON::is_bool($val)) { 49 } elsif (JSON::is_bool($val)) {
50 print "$kw ";
27 print $val ? "on" : "off"; 51 print $val ? "on" : "off";
52 print "\n";
28 } else { 53 } else {
29 print $val 54 print "$kw $val\n";
30 } 55 }
31 print "\n";
32 } 56 }
33} 57}
34 58

Return to:

Send suggestions and report system problems to the System administrator.