|
|
@ -7,13 +7,8 @@ my @nics = grep { $_ !~ m/^\./ } readdir($dh); |
|
|
|
closedir($dh); |
|
|
|
closedir($dh); |
|
|
|
my $json; |
|
|
|
my $json; |
|
|
|
foreach my $nic (@nics){ |
|
|
|
foreach my $nic (@nics){ |
|
|
|
# Untaint $nic and makes sure the name looks OK |
|
|
|
next unless ($nic =~ m/^(\w+[\.:]?(\d+)?)$/); |
|
|
|
next unless ($nic =~ m/^(\w+[\.:]?\d+)$/); |
|
|
|
|
|
|
|
$nic = $1; |
|
|
|
$nic = $1; |
|
|
|
next if ( |
|
|
|
|
|
|
|
# skip non links |
|
|
|
|
|
|
|
!-l "/sys/class/net/$nic" |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
push @{$json->{data}}, { "{#IFNAME}" => $nic}; |
|
|
|
push @{$json->{data}}, { "{#IFNAME}" => $nic}; |
|
|
|
} |
|
|
|
} |
|
|
|
print to_json($json) if (defined $json->{data}); |
|
|
|
print to_json($json) if (defined $json->{data}); |
|
|
|