--- lib/PXElator/httpd.pm 2009/09/09 09:41:03 407 +++ lib/PXElator/httpd.pm 2009/09/14 21:11:23 433 @@ -36,19 +36,6 @@ }} -sub menu { -qq{ -
-home -server -brctl -ip -nmap -client -
- -}} - our $port = 7777; use server; @@ -78,6 +65,27 @@ use CouchDB; + +sub menu { + my $couch_url = $url; + $couch_url =~ s{:\d+.+}{:5984/_utils/}; +qq{ +
+home +| +server +brctl +ip +| +couchdb +| +nmap +client +
+ +}} + + sub static { my ($client,$path) = @_; @@ -237,7 +245,7 @@ , 'new_clients' => qq|| ); - foreach my $editable ( 'ip', 'netmask', 'ip_from', 'ip_to', 'domain' ) { + foreach my $editable ( 'ip', 'bcast', 'netmask', 'ip_from', 'ip_to', 'domain' ) { my $v = eval '$server::' . $editable; push @table, ( $editable, qq|| ); } @@ -258,7 +266,7 @@ } elsif ( $path =~ m!^/client(?:/$RE{net}{IPv4}{-keep})?! ) { my $ip = $1; - $title = $ip; + $title = $ip if $ip; if ( $param->{action} eq 'remove' ) { client::remove( $param->{change_ip} ); @@ -355,8 +363,10 @@ . '"' if $ping; $style ||= ''; + my $ip_text = qq|$ip|; + $ip_text = qq|$ip| if ip::in_dhcp_range($ip); ( - qq|$ip| + qq|$ip_text| , format::mac( $mac => 'html' ) , $arp->{$mac} , delete $conf->{hostname} @@ -462,7 +472,7 @@ my $server = IO::Socket::INET->new( Proto => 'tcp', - LocalAddr => $server::ip, +# LocalAddr => $server::ip, LocalPort => $httpd::port, Listen => SOMAXCONN, Reuse => 1 @@ -477,7 +487,21 @@ my $client = $server->accept() || next; # ALARM trickle us my $request = <$client>; - warn "request $request\n" if $debug; + my $headers; + + while ( my $header = <$client> ) { + chomp $header; + last if $header =~ m{^\s*$}; + my ( $n, $v ) = split(/:\s*/, $header); + $headers->{ lc $n } = $v; + } + + if ( my $host = $headers->{host} ) { + $url = 'http://' . $host; + $url .= ":$port" unless $url =~ m{:\d+$}; + } + + warn "## $url ## $request", dump( $headers ) if $debug; if ($request =~ m{^GET (/.*) HTTP/1.[01]}) { my $path = $1;