/[pxelator]/lib/PXElator/httpd.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /lib/PXElator/httpd.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 207 by dpavlin, Wed Aug 12 22:56:45 2009 UTC revision 224 by dpavlin, Sat Aug 15 22:38:02 2009 UTC
# Line 24  sub menu {qq{ Line 24  sub menu {qq{
24  <div style="font-size: 80%; color: #888">  <div style="font-size: 80%; color: #888">
25  <a href=/>home</a>  <a href=/>home</a>
26  <a href=/server>server</a>  <a href=/server>server</a>
27    <a href=/ip>ip</a>
28  <a href=/client>client</a>  <a href=/client>client</a>
29  </div>  </div>
30    
# Line 49  use daemons; Line 50  use daemons;
50  use kvm;  use kvm;
51  use browser;  use browser;
52  use network;  use network;
53    use ip;
54    
55  use CouchDB;  use CouchDB;
56    
# Line 63  sub static { Line 65  sub static {
65                  # parent                  # parent
66                  close($client);                  close($client);
67                  $static_pids->{$pid} = $path;                  $static_pids->{$pid} = $path;
                 CouchDB::audit('static', 'parent', { pid => $pid, path => $path });  
68                  return 1;                  return 1;
69          }          }
70    
# Line 82  sub static { Line 83  sub static {
83          my $buff;          my $buff;
84          my $pos = 0;          my $pos = 0;
85    
86          CouchDB::audit( 'static', 'child', { pid => $$, path => $path, type => $type, size => $size, block => $block });          CouchDB::audit( 'static', { pid => $$, path => $path, type => $type, size => $size, block => $block, peerhost => $client->peerhost });
87    
88          progress_bar::start;          progress_bar::start;
89    
# Line 97  sub static { Line 98  sub static {
98    
99          print STDERR "\n";          print STDERR "\n";
100    
         CouchDB::audit( 'static', 'child', 'exit', { pid => $$ } );  
   
101          exit(0);          exit(0);
102  }  }
103    
# Line 117  sub get_request { Line 116  sub get_request {
116    
117          server->refresh;          server->refresh;
118    
119          CouchDB::audit( 'request', { path => $path, param => $param } );          CouchDB::audit( 'request', { path => $path, param => $param, peerhost => $client->peerhost } );
120    
121          if ( my $found = static( $client,$path ) ) {          if ( my $found = static( $client,$path ) ) {
122                  warn "static $found" if $debug;                  warn "static $found" if $debug;
# Line 206  sub get_request { Line 205  sub get_request {
205    
206                          my $deploy;                          my $deploy;
207    
208                          if ( my $mac = client::mac( $ip ) ) {                          if ( my $mac = client::mac_from_ip( $ip ) ) {
209                                  $deploy = client::conf( $ip, 'deploy' => $param->{deploy} );                                  $deploy = client::conf( $ip, 'deploy' => $param->{deploy} );
210                                  push @table, (                                  push @table, (
211                                          'mac' => $mac,                                          'mac' => format::mac( $mac => 'html' ),
212                                          'deploy' => html::select( 'deploy', $deploy, config::available )                                          'deploy' => html::select( 'deploy', $deploy, config::available )
213                                  );                                  );
214                                  $deploy = qq|<h2>PXElinux</h2>| . html::pre( config::for_ip( $ip ) );                                  $deploy = qq|<h2>PXElinux</h2>| . html::pre( config::for_ip( $ip ) );
# Line 246  sub get_request { Line 245  sub get_request {
245                                          map {                                          map {
246                                                  my $ip = $_;                                                  my $ip = $_;
247                                                  $ip =~ s{^.+/ip/}{};                                                  $ip =~ s{^.+/ip/}{};
248                                                  my $arp = $arp->{ client::mac $ip, 'clean' };                                                  my $mac = client::mac_from_ip $ip;
249                                                    my $arp = $arp->{ $mac };
250                                                  $arp = $arp ? $arp->[1] : '';                                                  $arp = $arp ? $arp->[1] : '';
251                                                  $arp =~ s{$ip}{};                                                  $arp =~ s{$ip}{};
252                                                  (                                                  (
253                                                          qq|<a href=/client/$ip>$ip</a>|                                                          qq|<a href=/client/$ip>$ip</a>|
254                                                          , client::conf( $ip, 'hostname' )                                                          , client::conf( $ip, 'hostname' )
255                                                          , client::mac( $ip )                                                          , format::mac( $mac => 'html' )
256                                                          , html::tt( client::conf( $ip, 'deploy' ) )                                                          , html::tt( client::conf( $ip, 'deploy' ) )
257                                                          , $arp                                                          , $arp
258                                                  );                                                  );
# Line 263  sub get_request { Line 263  sub get_request {
263                                  , html::table( -3, 'mac', 'dev', 'ip',                                  , html::table( -3, 'mac', 'dev', 'ip',
264                                          map {                                          map {
265                                                  my $c = $arp->{$_};                                                  my $c = $arp->{$_};
266                                                  ( html::tt( $_ ), $c->[1], $c->[0] )                                                  ( format::mac( $_ => 'html' ), $c->[1], $c->[0] )
267                                          } sort keys %$arp                                          } sort keys %$arp
268                                  )                                  )
269                                  ;                                  ;
270                  }                  }
271            } elsif ( $path =~ m{^/ip/?(\w+)?} ) {
272                    print $client ok
273                            , join("\n", map { qq|<a href=/ip/$_>$_</a>| } ( qw/link addr route neigh ntable tunnel maddr mroute xfrm/ ))
274                            , ip::html( $1 )
275                            ;
276          } elsif ( $path =~ m{^/our/(\w+)/(\S+)} ) {          } elsif ( $path =~ m{^/our/(\w+)/(\S+)} ) {
277                  eval 'our $' . $1 . ' = ' . $2;                  eval 'our $' . $1 . ' = ' . $2;
278                  warn $@ if $@;                  warn $@ if $@;

Legend:
Removed from v.207  
changed lines
  Added in v.224

  ViewVC Help
Powered by ViewVC 1.1.26