aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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
@@ -6,2 +6,28 @@ use App::Mangemanche::Command ':exit_codes';
+sub iplist_dumper {
+ my ($self, $kw, $val) = @_;
+ print "$kw <<EOF\n";
+ foreach my $ip (@$val) {
+ print " $ip\n";
+ }
+ print "EOF\n";
+}
+
+sub auth_dumper {
+ my ($self, $kw, $val) = @_;
+ foreach my $s (@$val) {
+ print "$kw $s->{type} $s->{method}";
+ if ($s->{'passwd-file'}) {
+ print " $s->{'passwd-file'} $s->{realm}";
+ }
+ print "\n";
+ }
+}
+
+my %kwdump = (
+ 'ip-list' => \&iplist_dumper,
+ 'trusted-ip' => \&iplist_dumper,
+ 'auth' => \&auth_dumper
+ );
+
sub run {
@@ -18,15 +44,13 @@ sub run {
my $val = $cfg->{$kw} or next;
- print "$kw ";
- if (ref($val) eq 'ARRAY') {
- print "<<EOF\n";
- foreach my $ip (@$val) {
- print " $ip\n";
- }
- print "EOF";
+ if (my $d = $kwdump{$kw}) {
+ $self->${ \$d }($kw, $val);
+ } elsif (ref($val) eq 'ARRAY') {
+ print "# $kw " . JSON::encode_json($val) . "\n";
} elsif (JSON::is_bool($val)) {
+ print "$kw ";
print $val ? "on" : "off";
+ print "\n";
} else {
- print $val
+ print "$kw $val\n";
}
- print "\n";
}

Return to:

Send suggestions and report system problems to the System administrator.