--- lib/PXElator/httpd.pm 2009/08/10 16:36:16 193
+++ lib/PXElator/httpd.pm 2009/08/11 15:13:19 199
@@ -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,7 +184,7 @@
;
} 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})?! ) {
@@ -186,8 +193,8 @@
my $hostname = client::conf( $ip, 'hostname' => $param->{hostname} );
my @table = (
- 'ip' => $ip,
- 'hostname' => qq||,
+ 'ip' => qq|old: $ip|,
+ 'hostname' => qq||,
);
my $deploy;
@@ -201,7 +208,7 @@
$deploy = qq|PXElinux
| . html::pre( config::for_ip( $ip ) );
}
- print $client $ok
+ print $client ok
, qq||
@@ -225,7 +232,7 @@
warn "# arp ",dump( $arp );
- print $client $ok
+ print $client ok
, qq|Clients on $server::ip
|
, html::table( -5,
'ip', 'hostname', 'mac', 'deploy', 'arp',
@@ -257,15 +264,15 @@
} elsif ( $path =~ m{^/our/(\w+)/(\S+)} ) {
eval 'our $' . $1 . ' = ' . $2;
warn $@ if $@;
- print $client $redirect, qq|$1 = $2
Location: $url|;
+ print $client redirect($url), qq|$1 = $2
Location: $url|;
server::debug( $debug ) if $1 eq 'debug';
} elsif ( $path =~ m{^/start_stop/(\S+)} ) {
- print $client $redirect, daemons::start_stop($1);
+ print $client redirect, daemons::start_stop($1);
} elsif ( $path =~ m{^/action/([^/]+)/(.+)} ) {
$1->$2();
- print $client $redirect;
+ print $client redirect;
} elsif ( $path =~ m{^/kill/static/(\d+)} ) {
- print $client $redirect;
+ print $client redirect;
kill 1, $1 || kill 9, $2 && warn "killed $1";
} else {
print $client "HTTP/1.0 404 $path\r\nConnection: close\r\nContent-type: text/html\r\n\r\n404 $path";