--- lib/PXElator/httpd.pm 2009/09/09 09:41:03 407 +++ lib/PXElator/httpd.pm 2009/09/13 09:54:35 427 @@ -39,12 +39,13 @@ sub menu { qq{
-home -server -brctl -ip -nmap -client +home +server +brctl +ip +nmap +client +couchdb
}} @@ -237,7 +238,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 +259,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 +356,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 +465,7 @@ my $server = IO::Socket::INET->new( Proto => 'tcp', - LocalAddr => $server::ip, +# LocalAddr => $server::ip, LocalPort => $httpd::port, Listen => SOMAXCONN, Reuse => 1 @@ -477,7 +480,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;