/[pxelator]/lib/PXElator/client.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/client.pm

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

revision 329 by dpavlin, Fri Aug 28 21:55:41 2009 UTC revision 391 by dpavlin, Mon Sep 7 21:53:45 2009 UTC
# Line 5  use strict; Line 5  use strict;
5  use autodie;  use autodie;
6    
7  use File::Slurp;  use File::Slurp;
 use Net::Ping;  
8  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
9    
10  use server;  use server;
11  use format;  use format;
12  use ip;  use ip;
13    use ping;
14    
15  our $debug = $server::debug;  our $debug = $server::debug;
16    
# Line 83  sub next_ip($) { Line 83  sub next_ip($) {
83          my $mac = shift;          my $mac = shift;
84          $mac = format::mac($mac);          $mac = format::mac($mac);
85    
86          my $p = Net::Ping->new;          if ( my $clients_left = server::shared( 'new_clients' ) ) {
87                    server::shared( 'new_clients', $clients_left - 1 );
88            } else {
89                    warn "W: no new clients accepted";
90                    return '0.0.0.0';
91            }
92    
93          my $prefix = $server::ip;          my $prefix = $server::ip;
94          $prefix =~ s{\.\d+$}{.};          $prefix =~ s{\.\d+$}{.};
95          my $addr = $server::ip_from || die;          my $addr = $server::ip_from || die;
96          my $ip = $prefix . $addr;          my $ip = $prefix . $addr;
97    
98          while ( -e ip_path($ip) || $p->ping( $ip, 0.7 ) ) {          while ( -e ip_path($ip) || ping::host($ip) ) {
99                  $ip = $prefix . $addr++;                  $ip = $prefix . $addr++;
100                  die "all addresses allocated!" if $addr == $server::ip_to;                  die "all addresses allocated!" if $addr == $server::ip_to;
101                  warn "skip $ip\n";                  warn "skip $ip\n";

Legend:
Removed from v.329  
changed lines
  Added in v.391

  ViewVC Help
Powered by ViewVC 1.1.26