36 |
</html> |
</html> |
37 |
}} |
}} |
38 |
|
|
|
sub menu { |
|
|
qq{ |
|
|
<div style="font-size: 80%; color: #888"> |
|
|
<a href=/ target=/>home</a> |
|
|
<a href=/server target=server>server</a> |
|
|
<a href=/brctl target=brctl>brctl</a> |
|
|
<a href=/ip target=ip>ip</a> |
|
|
<a href=/nmap target=nmap>nmap</a> |
|
|
<a href=/client target=client>client</a> |
|
|
<a href=http://$server::ip:5984/_utils/ target=couchdb>couchdb</a> |
|
|
</div> |
|
|
|
|
|
}} |
|
|
|
|
39 |
our $port = 7777; |
our $port = 7777; |
40 |
|
|
41 |
use server; |
use server; |
65 |
|
|
66 |
use CouchDB; |
use CouchDB; |
67 |
|
|
68 |
|
|
69 |
|
sub menu { |
70 |
|
my $couch_url = $url; |
71 |
|
$couch_url =~ s{:\d+.+}{:5984/_utils/}; |
72 |
|
qq{ |
73 |
|
<div style="font-size: 80%; color: #888"> |
74 |
|
<a target=pids href=/ >home</a> |
75 |
|
| |
76 |
|
<a target=server href=/server >server</a> |
77 |
|
<a target=server href=/brctl >brctl</a> |
78 |
|
<a target=server href=/ip >ip</a> |
79 |
|
| |
80 |
|
<a target=couch href=$couch_url >couchdb</a> |
81 |
|
| |
82 |
|
<a target=client href=/nmap >nmap</a> |
83 |
|
<a target=client href=/client >client</a> |
84 |
|
</div> |
85 |
|
|
86 |
|
}} |
87 |
|
|
88 |
|
|
89 |
sub static { |
sub static { |
90 |
my ($client,$path) = @_; |
my ($client,$path) = @_; |
91 |
|
|
245 |
, 'new_clients' => qq|<input type=text name=new_clients size=3 value="$server::new_clients">| |
, 'new_clients' => qq|<input type=text name=new_clients size=3 value="$server::new_clients">| |
246 |
); |
); |
247 |
|
|
248 |
foreach my $editable ( 'ip', 'netmask', 'ip_from', 'ip_to', 'domain' ) { |
foreach my $editable ( 'ip', 'bcast', 'netmask', 'ip_from', 'ip_to', 'domain' ) { |
249 |
my $v = eval '$server::' . $editable; |
my $v = eval '$server::' . $editable; |
250 |
push @table, ( $editable, qq|<input type=text name=$editable value="$v">| ); |
push @table, ( $editable, qq|<input type=text name=$editable value="$v">| ); |
251 |
} |
} |
338 |
|
|
339 |
} else { |
} else { |
340 |
|
|
341 |
|
print $client ok qq|<h2>Clients on $server::ip</h2>|; |
342 |
|
|
343 |
my @ping; |
my @ping; |
344 |
if ( my $host = $param->{ping_target} ) { |
if ( my $host = $param->{ping_target} ) { |
345 |
@ping = ( $host ); |
@ping = ( $host ); |
350 |
my $ping = ping::fping( @ping ) if @ping; |
my $ping = ping::fping( @ping ) if @ping; |
351 |
my $arp = client::arp_mac_dev; |
my $arp = client::arp_mac_dev; |
352 |
|
|
353 |
print $client ok |
my @clients; |
354 |
, qq|<h2>Clients on $server::ip</h2>| |
|
355 |
, html::table( -5, |
foreach my $ip ( client::all_ips ) { |
356 |
'ip', 'mac', 'dev', 'hostname', 'conf', |
|
357 |
map { |
my $conf = client::all_conf( $ip ); |
358 |
my $ip = $_; |
my $mac = delete $conf->{mac} || ''; |
359 |
my $conf = client::all_conf( $ip ); |
|
360 |
my $mac = delete $conf->{mac} || ''; |
next unless $arp->{$mac} || $param->{all}; |
361 |
my $style; |
|
362 |
$style |
my $style |
363 |
= 'style="color:' |
= 'style="color:' |
364 |
. ( $ping->{$ip} ? 'green' : 'red' ) |
. ( $ping->{$ip} ? 'green' : 'red' ) |
365 |
. '"' |
. '"' |
366 |
if $ping; |
if $ping; |
367 |
$style ||= ''; |
|
368 |
my $ip_text = qq|<tt>$ip</tt>|; |
$style ||= ''; |
369 |
$ip_text = qq|<tt><b>$ip</b></tt>| if ip::in_dhcp_range($ip); |
my $ip_text = qq|<tt>$ip</tt>|; |
370 |
( |
$ip_text = qq|<tt><b>$ip</b></tt>| if ip::in_dhcp_range($ip); |
371 |
qq|<a $style name=$ip target=$ip href=/client/$ip>$ip_text</a>| |
|
372 |
, format::mac( $mac => 'html' ) |
push @clients |
373 |
, $arp->{$mac} |
, qq|<a $style name=$ip target=client href=/client/$ip>$ip_text</a>| |
374 |
, delete $conf->{hostname} |
, format::mac( $mac => 'html' ) |
375 |
, html::conf( $ip, $conf, 'inline' ) |
, $arp->{$mac} |
376 |
) |
, delete $conf->{hostname} |
377 |
} client::all_ips |
, html::conf( $ip, $conf, 'inline' ) |
|
) |
|
378 |
; |
; |
379 |
|
} |
380 |
|
|
381 |
|
my $all = $param->{all} ? 0 : 1; |
382 |
|
|
383 |
|
print $client html::table( -5, 'ip', 'mac', qq|<a href="?all=$all">dev</a>|, 'hostname', 'conf', @clients ); |
384 |
print $client qq| |
print $client qq| |
385 |
<form method=get> |
<form method=get> |
386 |
<input type=text name=ping_target size=15> |
<input type=text name=ping_target size=15> |