18 |
#use JSON; |
#use JSON; |
19 |
use IO::Socket::INET; |
use IO::Socket::INET; |
20 |
use Regexp::Common qw/net/; |
use Regexp::Common qw/net/; |
21 |
|
use POSIX qw(strftime); |
22 |
|
|
23 |
sub menu {qq{ |
our $title; |
24 |
|
|
25 |
<div style="font-size: 80%; color: #888"> |
sub html_start { |
26 |
<a href=/>home</a> |
qq{ |
27 |
<a href=/server>server</a> |
<html> |
28 |
<a href=/brctl>brctl</a> |
<head> |
29 |
<a href=/ip>ip</a> |
<title>$title</title> |
30 |
<a href=/nmap>nmap</a> |
</head> |
31 |
<a href=/client>client</a> |
<body> |
32 |
</div> |
}} |
33 |
|
|
34 |
|
sub html_end { |
35 |
|
qq{ |
36 |
|
</body> |
37 |
|
</html> |
38 |
}} |
}} |
39 |
|
|
40 |
our $port = 7777; |
our $port = 7777; |
51 |
use log; |
use log; |
52 |
use x11; |
use x11; |
53 |
use amt; |
use amt; |
|
use boolean; |
|
54 |
use daemons; |
use daemons; |
55 |
|
|
56 |
use kvm; |
use kvm; |
63 |
use ping; |
use ping; |
64 |
use wol; |
use wol; |
65 |
|
|
66 |
use CouchDB; |
use store; |
67 |
|
|
68 |
|
|
69 |
|
sub menu { |
70 |
|
my $store_url = $url; |
71 |
|
$store_url =~ s{:\d+.+}{:28017}; |
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=store href=$store_url >MongoDB</a> |
81 |
|
<a target=store href=/store/latest >latest</a> |
82 |
|
| |
83 |
|
<a target=client href=/nmap >nmap</a> |
84 |
|
<a target=client href=/client >client</a> |
85 |
|
</div> |
86 |
|
|
87 |
|
}} |
88 |
|
|
89 |
|
|
90 |
sub static { |
sub static { |
91 |
my ($client,$path) = @_; |
my ($client,$path) = @_; |
94 |
|
|
95 |
return if ! -f $full; |
return if ! -f $full; |
96 |
|
|
97 |
|
return if $full =~ m{\.ico$}; |
98 |
|
|
99 |
if ( my $pid = fork ) { |
if ( my $pid = fork ) { |
100 |
# parent |
# parent |
101 |
close($client); |
close($client); |
118 |
my $buff; |
my $buff; |
119 |
my $pos = 0; |
my $pos = 0; |
120 |
|
|
121 |
CouchDB::audit( 'static', { pid => $$, path => $path, type => $type, size => $size, block => $block, peerhost => $client->peerhost }); |
store::audit( 'static', { pid => $$, path => $path, type => $type, size => $size, block => $block, peerhost => $client->peerhost }); |
122 |
|
|
123 |
progress_bar::start; |
progress_bar::start; |
124 |
|
|
137 |
} |
} |
138 |
|
|
139 |
sub ok { |
sub ok { |
140 |
qq|HTTP/1.0 200 OK\r\nContent-Type: text/html\r\nConnection: close\r\n\r\n| . menu() |
qq|HTTP/1.0 200 OK\r\nContent-Type: text/html\r\nConnection: close\r\n\r\n| . html_start() . menu() |
141 |
} |
} |
142 |
|
|
143 |
sub redirect { |
sub redirect { |
146 |
qq|HTTP/1.1 302 Found\r\nContent-type: text/html\r\nLocation: $to\r\n\r\n| |
qq|HTTP/1.1 302 Found\r\nContent-type: text/html\r\nLocation: $to\r\n\r\n| |
147 |
} |
} |
148 |
|
|
149 |
|
sub toggle { |
150 |
|
my $v = shift; |
151 |
|
return $v ? 0 : 1; |
152 |
|
} |
153 |
|
|
154 |
sub get_request { |
sub get_request { |
155 |
my ( $client, $path, $param ) = @_; |
my ( $client, $path, $param ) = @_; |
156 |
|
|
157 |
server->refresh; |
server->refresh; |
158 |
|
|
159 |
CouchDB::audit( 'request', { path => $path, param => $param, peerhost => $client->peerhost } ); |
store::audit( 'request', { path => $path, param => $param, peerhost => $client->peerhost } ); |
160 |
|
|
161 |
|
$title = $path; |
162 |
|
|
163 |
if ( my $found = static( $client,$path ) ) { |
if ( my $found = static( $client,$path ) ) { |
164 |
warn "static $found" if $debug; |
warn "static $found" if $debug; |
189 |
; |
; |
190 |
} |
} |
191 |
|
|
192 |
if ( $name->can('fork_if_active') ) { |
my $class = $name; |
193 |
$html .= qq| <a href=/start_stop/$name/$_>$_</a>| foreach $name->fork_if_active; |
$class =~ s{\.\d+$}{}; |
194 |
|
|
195 |
|
if ( $class->can('fork_if_active') ) { |
196 |
|
$html .= qq| <a href=/start_stop/$name/$_>$_</a>| foreach $class->fork_if_active; |
197 |
} |
} |
198 |
|
|
199 |
if ( $name->can('actions') ) { |
if ( $class->can('actions') ) { |
200 |
$html .= qq| <a href=/action/$name/$_>$_</a>| foreach $name->actions; |
$html .= qq| <a href=/action/$name/$_>$_</a>| foreach $class->actions; |
201 |
} |
} |
202 |
} else { |
} else { |
203 |
if ( $pid =~ m{^\d+$} ) { |
if ( $pid =~ m{^\d+$} ) { |
231 |
} |
} |
232 |
} |
} |
233 |
|
|
234 |
|
my $kvm = kvm::next_nr; |
235 |
|
$kvm = qq|<div><a href=/start_stop/kvm?nr=$kvm>create new kvm $kvm</a></div>|; |
236 |
|
|
237 |
print $client ok |
print $client ok |
238 |
, html::table( 2, @rows ) |
, html::table( 2, @rows ) |
239 |
, $below_table |
, $below_table |
240 |
|
, $kvm |
241 |
, html::tabs( log::mac_changes ) |
, html::tabs( log::mac_changes ) |
242 |
, $debug_proc |
, $debug_proc |
243 |
; |
; |
244 |
|
|
245 |
} elsif ( $path =~ m{^/server} ) { |
} elsif ( $path =~ m{^/server} ) { |
246 |
|
foreach my $name ( keys %$param ) { |
247 |
|
eval '$server::' . $name . '= $param->{$name}'; |
248 |
|
} |
249 |
|
my @table = ( |
250 |
|
'debug' => qq|<a href=/our/debug/| . toggle($debug) . qq|>$debug</a>|, |
251 |
|
, 'new_clients' => qq|<input type=text name=new_clients size=3 value="$server::new_clients">| |
252 |
|
); |
253 |
|
|
254 |
|
foreach my $editable ( 'ip', 'bcast', 'netmask', 'ip_from', 'ip_to', 'domain' ) { |
255 |
|
my $v = eval '$server::' . $editable; |
256 |
|
push @table, ( $editable, qq|<input type=text name=$editable value="$v">| ); |
257 |
|
} |
258 |
|
|
259 |
|
foreach my $readonly ( 'base_dir', 'conf' ) { |
260 |
|
my $v = eval '$server::' . $readonly; |
261 |
|
push @table, ( $readonly, html::tt $v ); |
262 |
|
} |
263 |
|
|
264 |
print $client ok |
print $client ok |
265 |
, html::table( 2, |
, qq|<form method=get>| |
266 |
'debug' => qq|<a href=/our/debug/| . boolean::toggle($debug) . qq|>$debug</a>|, |
, html::table( 2, @table ) |
267 |
map { |
, qq| |
268 |
( $_, html::tt eval '$server::'.$_ ) |
<input type=submit name=action value=change> |
269 |
} ( 'ip', 'netmask', 'ip_from', 'ip_to', 'domain_name', 'base_dir', 'conf' ) |
</form> |
270 |
) |
| |
271 |
; |
; |
272 |
|
|
273 |
|
} elsif ( $path =~ m{^/store/latest} ) { |
274 |
|
print $client ok |
275 |
|
, qq| |
276 |
|
<style type=text/css> |
277 |
|
.z { |
278 |
|
background: #eee; |
279 |
|
} |
280 |
|
td > pre { |
281 |
|
margin: 0; |
282 |
|
max-height: 3em; |
283 |
|
overflow: hidden; |
284 |
|
} |
285 |
|
td:hover > pre { |
286 |
|
max-height: 100%; |
287 |
|
overflow: show; |
288 |
|
} |
289 |
|
</style> |
290 |
|
| |
291 |
|
, qq|<table>| |
292 |
|
; |
293 |
|
my ( $s1,$s2 ) = ( ' class=z', '' ); |
294 |
|
my @cols; |
295 |
|
|
296 |
|
store::query( sub { |
297 |
|
my $o = shift; |
298 |
|
my $p = delete( $o->{package} ); |
299 |
|
delete( $o->{_id} ); |
300 |
|
|
301 |
|
if ( ! @cols ) { |
302 |
|
#@cols = keys %$p; |
303 |
|
@cols = qw( time name ); |
304 |
|
print $client qq|<tr><th>| |
305 |
|
, join(qq|</th><th>|, @cols) |
306 |
|
, qq|</th><th></th></tr>| |
307 |
|
; |
308 |
|
} |
309 |
|
|
310 |
|
# XXX sigh, dump dies if we don't do this |
311 |
|
# delete $o->{$_} foreach ( grep { ! defined $o->{$_} } keys %$o ); |
312 |
|
|
313 |
|
print $client qq|<tr$s1>| |
314 |
|
, strftime( qq|<td title="%Y-%m-%d">%H:%M:%S</td>|, localtime($p->{time}) ) |
315 |
|
, map { qq|<td>$_<td>| } ( $p->{name} , html::pre_dump($o) ) |
316 |
|
, qq|</tr>\n| |
317 |
|
; |
318 |
|
( $s1, $s2 ) = ( $s2, $s1 ); |
319 |
|
}); |
320 |
|
print $client qq|</table>|; |
321 |
|
|
322 |
} elsif ( $path =~ m!^/client(?:/$RE{net}{IPv4}{-keep})?! ) { |
} elsif ( $path =~ m!^/client(?:/$RE{net}{IPv4}{-keep})?! ) { |
323 |
my $ip = $1; |
my $ip = $1; |
324 |
|
$title = $ip if $ip; |
325 |
|
|
326 |
if ( $param->{action} eq 'remove' ) { |
if ( $param->{action} eq 'remove' ) { |
327 |
client::remove( $param->{change_ip} ); |
client::remove( $param->{change_ip} ); |
351 |
|
|
352 |
if ( $ip && $ip ne $server::ip ) { |
if ( $ip && $ip ne $server::ip ) { |
353 |
|
|
354 |
my @editable = ( qw/hostname deploy homepage/ ); |
my @editable = ( qw/hostname config homepage/ ); |
355 |
|
|
356 |
client::conf( $ip, $_ => $param->{$_} ) foreach @editable; |
client::conf( $ip, $_ => $param->{$_} ) foreach @editable; |
357 |
|
|
358 |
my $conf = client::all_conf( $ip ); |
my $conf = client::all_conf( $ip ); |
359 |
my $deploy = delete $conf->{deploy}; |
my $config = delete $conf->{config}; |
360 |
|
|
361 |
my $nmap = qq|<a href=/nmap?scan=$ip>nmap</a>|; |
my $nmap = qq|<a href=/nmap?scan=$ip>nmap</a>|; |
362 |
my @table = ( |
my @table = ( |
363 |
|
'ping' => ping::host($ip) |
364 |
|
? qq|<span style="color:green">up</span> $nmap| |
365 |
|
: qq|<span style="color: red">down</span> <a href=/wol/$ip>wol</a> $nmap| |
366 |
|
, |
367 |
'ip' => qq|<input type=text name=change_ip value="$ip" onChange="document.getElementById('old_ip').style.display = '';"><span id=old_ip style="display: none; color: #888;">old: $ip<span>|, |
'ip' => qq|<input type=text name=change_ip value="$ip" onChange="document.getElementById('old_ip').style.display = '';"><span id=old_ip style="display: none; color: #888;">old: $ip<span>|, |
368 |
'mac' => format::mac( delete $conf->{mac}, 'html' ), |
'mac' => format::mac( delete $conf->{mac}, 'html' ), |
369 |
'hostname' => qq|<input type=text name=hostname value="| . delete($conf->{hostname}) . qq|">|, |
'hostname' => qq|<input type=text name=hostname value="| . delete($conf->{hostname}) . qq|">|, |
370 |
'ping' => ping::host($ip) ? qq|<span style="color:green">up</span> $nmap| : qq|<span style="color: red">down</span> <a href=/wol/$ip>wol</a> $nmap|, |
'config' => html::select( 'config', $config, config::available ), |
|
'deploy' => html::select( 'deploy', $deploy, config::available ), |
|
371 |
html::conf( $ip, $conf, 'edit', @editable ) |
html::conf( $ip, $conf, 'edit', @editable ) |
372 |
); |
); |
373 |
|
|
|
warn "XX conf ",dump( $conf ); |
|
|
|
|
|
my $config = ''; |
|
|
|
|
|
if ( $deploy ) { |
|
|
if ( $config = config::for_ip( $ip ) ) { |
|
|
$config = qq|<h2>config</h2>| . html::pre( $config ); |
|
|
} |
|
|
} |
|
|
|
|
374 |
print $client ok |
print $client ok |
375 |
, qq|<form method=get>| |
, qq|<form method=get>| |
376 |
, html::table( 2, @table ), |
, html::table( 2, @table ), |
378 |
<input type=submit name=action value=change> |
<input type=submit name=action value=change> |
379 |
<input type=submit name=action value=remove style="color: red"> |
<input type=submit name=action value=remove style="color: red"> |
380 |
</form>| |
</form>| |
|
, $config |
|
381 |
; |
; |
382 |
|
|
383 |
if ( my $amt = client::conf( $ip, 'amt' ) ) { |
if ( $config ) { |
384 |
print $client qq|<h2>AMT</h2>|, amt::info( $amt, $ip ); |
if ( my $for_ip = config::for_ip( $ip ) ) { |
385 |
|
print $client qq|<h2>config::for_ip</h2>| . html::pre( $for_ip ); |
386 |
|
} |
387 |
|
} |
388 |
|
|
389 |
|
if ( $conf->{amt} ) { |
390 |
|
print $client qq|<h2>amt network</h2>|, html::pre_dump( amt::network( $ip ) ); |
391 |
|
print $client qq|<h2>amt log</h2>|, html::pre_dump( amt::log( $ip ) ); |
392 |
} |
} |
393 |
|
|
394 |
} else { |
} else { |
395 |
|
|
396 |
|
print $client ok qq|<h2>Clients on $server::ip</h2>|; |
397 |
|
|
398 |
my @ping; |
my @ping; |
399 |
if ( my $host = $param->{ping_target} ) { |
if ( my $host = $param->{ping_target} ) { |
400 |
@ping = ( $host ); |
@ping = ( $host ); |
405 |
my $ping = ping::fping( @ping ) if @ping; |
my $ping = ping::fping( @ping ) if @ping; |
406 |
my $arp = client::arp_mac_dev; |
my $arp = client::arp_mac_dev; |
407 |
|
|
408 |
print $client ok |
my @clients; |
409 |
, qq|<h2>Clients on $server::ip</h2>| |
|
410 |
, html::table( -5, |
foreach my $ip ( client::all_ips ) { |
411 |
'ip', 'mac', 'dev', 'hostname', 'conf', |
|
412 |
map { |
my $conf = client::all_conf( $ip ); |
413 |
my $ip = $_; |
my $mac = delete $conf->{mac} || ''; |
414 |
my $conf = client::all_conf( $ip ); |
my $dev = $arp->{$mac}; |
415 |
my $mac = delete $conf->{mac} || ''; |
|
416 |
my $style; |
next unless $dev || $param->{all}; |
417 |
$style |
|
418 |
= 'style="color:' |
my $style |
419 |
. ( $ping->{$ip} ? 'green' : 'red' ) |
= 'style="color:' |
420 |
. '"' |
. ( $ping->{$ip} ? 'green' : 'red' ) |
421 |
if $ping; |
. '"' |
422 |
$style ||= ''; |
if $ping; |
423 |
( |
|
424 |
qq|<a $style name=$ip href=/client/$ip>$ip</a>| |
$style ||= ''; |
425 |
, format::mac( $mac => 'html' ) |
my $ip_text = qq|<tt>$ip</tt>|; |
426 |
, $arp->{$mac} |
$ip_text = qq|<tt><b>$ip</b></tt>| if ip::in_dhcp_range($ip); |
427 |
, delete $conf->{hostname} |
|
428 |
, html::conf( $ip, $conf, 'inline' ) |
$dev = qq|<tt>$dev</tt>| if $dev; |
429 |
) |
|
430 |
} client::all_ips |
push @clients |
431 |
) |
, qq|<a $style name=$ip target=client href=/client/$ip>$ip_text</a>| |
432 |
|
, format::mac( $mac => 'html' ) |
433 |
|
, $dev |
434 |
|
, delete $conf->{hostname} |
435 |
|
, html::conf( $ip, $conf, 'inline' ) |
436 |
; |
; |
437 |
|
} |
438 |
|
|
439 |
|
my $all = $param->{all} ? 0 : 1; |
440 |
|
|
441 |
|
print $client html::table( -5, 'ip', 'mac', qq|<a href="?all=$all">dev</a>|, 'hostname', 'conf', @clients ); |
442 |
print $client qq| |
print $client qq| |
443 |
<form method=get> |
<form method=get> |
444 |
<input type=text name=ping_target size=15> |
<input type=text name=ping_target size=15> |
446 |
</form> |
</form> |
447 |
|; |
|; |
448 |
} |
} |
449 |
|
|
450 |
|
|
451 |
} elsif ( $path =~ m{^/brctl} ) { |
} elsif ( $path =~ m{^/brctl} ) { |
452 |
print $client ok, html::table( -4, |
|
453 |
|
system 'brctl addif virtual ' . $param->{addif} if $param->{addif}; |
454 |
|
system 'brctl delif virtual ' . $param->{delif} if $param->{delif}; |
455 |
|
|
456 |
|
my $in_virtual; |
457 |
|
|
458 |
|
my @table = |
459 |
map { |
map { |
460 |
my @c = split(/\t+/,$_,4); |
my @c = split(/\t+/,$_,4); |
461 |
if ( $#c == 1 ) { |
if ( $#c == 1 ) { |
462 |
( '', '', '', $c[1] ) |
$in_virtual->{ $c[1] }++; |
463 |
|
@c = ( '', '', '', $c[1] ); |
464 |
} else { |
} else { |
465 |
@c |
$in_virtual->{ $c[3] }++; |
466 |
|
} |
467 |
|
if ( $c[3] =~ m{\d$} ) { |
468 |
|
$c[3] = qq|<input type=submit name=delif value=$c[3] style="color:red" title="remove $c[3] from bridge">|; |
469 |
} |
} |
470 |
|
@c |
471 |
} split(/\n/, `brctl show`) |
} split(/\n/, `brctl show`) |
472 |
); |
; |
473 |
|
|
474 |
|
my @add_ifs = grep { ! $in_virtual->{$_} && $_ ne 'virtual' } ip::devices_up; |
475 |
|
|
476 |
|
push @table, ( '', '', '', html::select( 'addif', @add_ifs ) . qq|<input type=submit value=add></form>| ); |
477 |
|
|
478 |
|
print $client ok |
479 |
|
, qq|<form>| |
480 |
|
, html::table( -4, @table ) |
481 |
|
, qq|</form>| |
482 |
|
; |
483 |
|
|
484 |
|
|
485 |
} elsif ( $path =~ m{^/ip/?(\w+)?} ) { |
} elsif ( $path =~ m{^/ip/?(\w+)?} ) { |
486 |
print $client ok |
print $client ok |
487 |
, join("\n", map { qq|<a href=/ip/$_>$_</a>| } ( qw/link addr route neigh ntable tunnel maddr mroute xfrm/ )) |
, join("\n", map { qq|<a href=/ip/$_>$_</a>| } ( qw/link addr route neigh ntable tunnel maddr mroute xfrm/ )) |
501 |
} |
} |
502 |
} elsif ( $path =~ m{^/wol/(\S+)} ) { |
} elsif ( $path =~ m{^/wol/(\S+)} ) { |
503 |
print $client redirect( "$url/client/$1" ), wol::power_on($1); |
print $client redirect( "$url/client/$1" ), wol::power_on($1); |
504 |
|
} elsif ( $path =~ m!^/amt/(\w+)/$RE{net}{IPv4}{-keep}! ) { |
505 |
|
my ( $run, $ip ) = ( $1, $2 ); |
506 |
|
print $client redirect( "$url/client/$ip" ), amt::RemoteControl( $ip, $run ); |
507 |
} elsif ( $path =~ m{^/our/(\w+)/(\S+)} ) { |
} elsif ( $path =~ m{^/our/(\w+)/(\S+)} ) { |
508 |
eval 'our $' . $1 . ' = ' . $2; |
eval 'our $' . $1 . ' = ' . $2; |
509 |
warn $@ if $@; |
warn $@ if $@; |
510 |
print $client redirect($url), qq|<big>$1 = $2</big><br>Location: <a href="$url">$url</a>|; |
print $client redirect($url), qq|<big>$1 = $2</big><br>Location: <a href="$url">$url</a>|; |
511 |
server::debug( $debug ) if $1 eq 'debug'; |
server::debug( $debug ) if $1 eq 'debug'; |
512 |
} elsif ( $path =~ m{^/start_stop/(\S+)} ) { |
} elsif ( $path =~ m{^/start_stop/(\S+)} ) { |
513 |
print $client redirect, daemons::start_stop($1); |
print $client redirect, daemons::start_stop($1,$param); |
514 |
} elsif ( $path =~ m{^/action/([^/]+)/(.+)} ) { |
} elsif ( $path =~ m{^/action/([^/]+)/(.+)} ) { |
515 |
$1->$2(); |
my ( $package, $method ) = ( $1, $2 ); |
516 |
|
$ENV{nr} = $1 if $package =~ s{\.(\d+)$}{}; |
517 |
|
$package->$method(); |
518 |
print $client redirect; |
print $client redirect; |
519 |
} elsif ( $path =~ m{^/kill/static/(\d+)} ) { |
} elsif ( $path =~ m{^/kill/static/(\d+)} ) { |
520 |
print $client redirect; |
print $client redirect; |
530 |
|
|
531 |
warn 'network ', network::setup(); |
warn 'network ', network::setup(); |
532 |
|
|
533 |
daemons::start_stop 'browser', $url; |
daemons::start_stop 'browser', { url => $url }; |
534 |
daemons::start_stop $_ foreach ( qw/dhcpd tftpd dnsd syslogd/ ); |
daemons::start_stop $_ foreach ( qw/dhcpd tftpd dnsd syslogd/ ); |
535 |
daemons::start_stop 'kvm' unless $ENV{DEV}; # skip kvm statup when running on real device |
# daemons::start_stop 'kvm' unless $ENV{DEV}; # skip kvm statup when running on real device |
536 |
|
|
537 |
my $server = IO::Socket::INET->new( |
my $server = IO::Socket::INET->new( |
538 |
Proto => 'tcp', |
Proto => 'tcp', |
539 |
LocalAddr => $server::ip, |
# LocalAddr => $server::ip, |
540 |
LocalPort => $httpd::port, |
LocalPort => $httpd::port, |
541 |
Listen => SOMAXCONN, |
Listen => SOMAXCONN, |
542 |
Reuse => 1 |
Reuse => 1 |
544 |
|
|
545 |
print "url $url\n"; |
print "url $url\n"; |
546 |
|
|
547 |
|
syslogd::install_local; |
548 |
|
client::rebuild_mac_links; |
549 |
|
|
550 |
while (1) { |
while (1) { |
551 |
my $client = $server->accept() || next; # ALARM trickle us |
my $client = $server->accept() || next; # ALARM trickle us |
552 |
my $request = <$client>; |
my $request = <$client>; |
553 |
|
|
554 |
warn "request $request\n" if $debug; |
my $headers; |
555 |
|
|
556 |
|
while ( my $header = <$client> ) { |
557 |
|
chomp $header; |
558 |
|
last if $header =~ m{^\s*$}; |
559 |
|
my ( $n, $v ) = split(/:\s*/, $header); |
560 |
|
$headers->{ lc $n } = $v; |
561 |
|
} |
562 |
|
|
563 |
|
if ( my $host = $headers->{host} ) { |
564 |
|
$url = 'http://' . $host; |
565 |
|
$url .= ":$port" unless $url =~ m{:\d+$}; |
566 |
|
} |
567 |
|
|
568 |
|
warn "## $url ## $request", dump( $headers ) if $debug; |
569 |
|
|
570 |
if ($request =~ m{^GET (/.*) HTTP/1.[01]}) { |
if ($request =~ m{^GET (/.*) HTTP/1.[01]}) { |
571 |
my $path = $1; |
my $path = $1; |
584 |
warn "500 $request"; |
warn "500 $request"; |
585 |
} |
} |
586 |
|
|
587 |
print $client menu() if $client->connected; |
print $client menu() . html_end() if $client->connected; |
588 |
|
|
589 |
} |
} |
590 |
|
|