/[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 309 by dpavlin, Thu Aug 27 16:47:42 2009 UTC revision 322 by dpavlin, Fri Aug 28 16:41:46 2009 UTC
# Line 26  sub menu {qq{ Line 26  sub menu {qq{
26  <a href=/server>server</a>  <a href=/server>server</a>
27  <a href=/brctl>brctl</a>  <a href=/brctl>brctl</a>
28  <a href=/ip>ip</a>  <a href=/ip>ip</a>
29    <a href=/nmap>nmap</a>
30  <a href=/client>client</a>  <a href=/client>client</a>
31  </div>  </div>
32    
# Line 54  use network; Line 55  use network;
55  use ip;  use ip;
56  use wireshark;  use wireshark;
57  use syslogd;  use syslogd;
58    use nmap;
59    
60  use CouchDB;  use CouchDB;
61    
# Line 206  warn "XXX pids = ", dump( $daemons::pids Line 208  warn "XXX pids = ", dump( $daemons::pids
208                          )                          )
209                          ;                          ;
210          } elsif ( $path =~ m!^/client(?:/$RE{net}{IPv4}{-keep})?! ) {          } elsif ( $path =~ m!^/client(?:/$RE{net}{IPv4}{-keep})?! ) {
211                  my $ip = $1 || $client->peerhost;                  my $ip = $1;
212    
213                  if ( my $new_ip = $param->{change_ip} ) {                  if ( my $new_ip = $param->{change_ip} ) {
214                          client::change_ip( $ip, $new_ip );                          client::change_ip( $ip, $new_ip );
215                          $ip = $new_ip;                          $ip = $new_ip;
216                  }                  }
217    
218                  my $ip_short = (split(/\./, $ip, 4))[3];                  if ( ! $ip ) {
219                            my $peer_ip = $client->peerhost;
220    
221                  # if ( $ip ne $server::ip ) -- not flexible enough for tunnel endpoints  warn "XXX peer_ip $peer_ip";
222                  if ( $ip_short >= $server::ip_from && $ip_short <= $server::ip_to ) {  
223                            my $netmask = ip::to_int $server::netmask;
224                            my $network = ip::to_int $server::ip & $netmask;
225                            my ( $from, $to ) = ( $network | $server::ip_from, $network | $server::ip_to );
226                            my $ip_int  = ip::to_int $peer_ip;
227    
228    warn dump( $ip_int, $from, $to );
229    
230                            # show edit for our our class
231                            if ( $ip_int >= ( $network | $server::ip_from ) && $ip_int <= ( $network | $server::ip_to ) ) {
232                                    $ip = $peer_ip;
233                            }
234                    }
235    
236                    if ( $ip && $ip ne $server::ip ) {
237                          my $hostname = client::conf( $ip, 'hostname' => $param->{hostname} );                          my $hostname = client::conf( $ip, 'hostname' => $param->{hostname} );
238    
239                          my @table = (                          my @table = (
# Line 253  warn "XXX pids = ", dump( $daemons::pids Line 270  warn "XXX pids = ", dump( $daemons::pids
270                                  map {                                  map {
271                                          my @c = split(/\s+/,$_);                                          my @c = split(/\s+/,$_);
272                                          if ( $#c == 5 ) {                                          if ( $#c == 5 ) {
273                                                    client::save_ip_mac( $c[0], $c[3] );
274                                                  ( uc $c[3] => [ $c[0] , $c[5] ] )                                                  ( uc $c[3] => [ $c[0] , $c[5] ] )
275                                          } else {                                          } else {
276                                          }                                          }
# Line 270  warn "XXX pids = ", dump( $daemons::pids Line 288  warn "XXX pids = ", dump( $daemons::pids
288                                                  my $conf = client::all_conf( $ip );                                                  my $conf = client::all_conf( $ip );
289                                                  my $mac = delete $conf->{mac} || '';                                                  my $mac = delete $conf->{mac} || '';
290                                                  (                                                  (
291                                                          qq|<a href=/client/$ip>$ip</a>|                                                          qq|<a name=$ip href=/client/$ip>$ip</a>|
292                                                          , format::mac( $mac => 'html' )                                                          , format::mac( $mac => 'html' )
293                                                          , ( $arp->{$mac} ? $arp->{$mac}->[1] : '' )                                                          , ( $arp->{$mac} ? $arp->{$mac}->[1] : '' )
294                                                          , delete $conf->{hostname}                                                          , delete $conf->{hostname}
295                                                          , delete $conf->{deploy}                                                          , delete $conf->{deploy}
296                                                          , html::pre_dump( $conf )                                                          , ( %$conf ? html::pre_dump( $conf ) : qq|<a href=/nmap?scan=$ip>nmap</a>| )
297                                                  );                                                  );
298                                          }                                          } client::all_ips
                                         sort { ip::to_int($a) cmp ip::to_int($b) }  
                                         map {  
                                                 my $ip = $_;  
                                                 $ip =~ s{^.+/ip/}{};  
                                                 $ip;  
                                         } glob("$server::conf/ip/*")  
                                 )  
                                 , qq|<h2>ARP</h2>|  
                                 , html::table( -3, 'ip', 'mac', 'dev',  
                                         map {  
                                                 my $c = $arp->{$_};  
                                                 ( $c->[0], format::mac( $_ => 'html' ), $c->[1] )  
                                         } sort keys %$arp  
299                                  )                                  )
300                                  ;                                  ;
301                  }                  }
# Line 303  warn "XXX pids = ", dump( $daemons::pids Line 308  warn "XXX pids = ", dump( $daemons::pids
308                          , 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/ ))
309                          , ip::html( $1 )                          , ip::html( $1 )
310                          ;                          ;
311            } elsif ( $path =~ m{^/nmap} ) {
312                    if ( my $scan = $param->{scan} ) {
313                            nmap::scan( $scan );
314                            print $client redirect("$url/client#$scan");
315                    } else {
316                            print $client ok, qq|
317                                    <form method=get>
318                                    <input type=text name=scan>
319                                    <input type=submit value=scan>
320                                    </form>
321                            |;
322                    }
323          } elsif ( $path =~ m{^/our/(\w+)/(\S+)} ) {          } elsif ( $path =~ m{^/our/(\w+)/(\S+)} ) {
324                  eval 'our $' . $1 . ' = ' . $2;                  eval 'our $' . $1 . ' = ' . $2;
325                  warn $@ if $@;                  warn $@ if $@;

Legend:
Removed from v.309  
changed lines
  Added in v.322

  ViewVC Help
Powered by ViewVC 1.1.26