--- lib/PXElator/httpd.pm 2009/08/10 16:36:16 193 +++ lib/PXElator/httpd.pm 2009/08/11 15:55:26 200 @@ -101,8 +101,15 @@ exit(0); } -my $ok = qq|HTTP/1.0 200 OK\r\nContent-Type: text/html\r\nConnection: close\r\n\r\n| . menu(); -my $redirect = qq|HTTP/1.1 302 Found\r\nContent-type: text/html\r\nLocation: $url\r\n\r\n|; +sub ok { + qq|HTTP/1.0 200 OK\r\nContent-Type: text/html\r\nConnection: close\r\n\r\n| . menu() +} + +sub redirect { + my $to = shift; + $to ||= $url; + qq|HTTP/1.1 302 Found\r\nContent-type: text/html\r\nLocation: $to\r\n\r\n| +} sub get_request { my ( $client, $path, $param ) = @_; @@ -169,7 +176,7 @@ } } - print $client $ok + print $client ok , html::table( 2, @rows ) , $below_table , html::tabs( log::mac_changes ) @@ -177,17 +184,23 @@ ; } elsif ( $path =~ m{^/server} ) { - print $client $ok + print $client ok , html::table( 2, map { ( $_, html::tt eval '$server::'.$_ ) } ( 'ip', 'netmask', 'ip_from', 'ip_to', 'domain_name', 'base_dir', 'conf' ) ) ; } elsif ( $path =~ m!^/client(?:/$RE{net}{IPv4}{-keep})?! ) { my $ip = $1 || $client->peerhost; + + if ( my $new_ip = $param->{change_ip} ) { + client::change_ip( $ip, $new_ip ); + $ip = $new_ip; + } + if ( $ip ne $server::ip ) { my $hostname = client::conf( $ip, 'hostname' => $param->{hostname} ); my @table = ( - 'ip' => $ip, - 'hostname' => qq||, + 'ip' => qq|