Changeset 549 for branches


Ignore:
Timestamp:
11/09/12 11:57:22 (12 years ago)
Author:
Kris Deugau
Message:

/branches/stable

Minimal server-meltdown-prevention patch for IPv6; create the
block but don't populate IP pools. See #22, sort of.

Location:
branches/stable/cgi-bin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/stable/cgi-bin/IPDB.pm

    r509 r549  
    375375  } else { # end IP-from-pool allocation
    376376
     377    my $errcode = 'OK';
    377378    if ($cidr == $alloc_from) {
    378379      # Easiest case- insert in one table, delete in the other, and go home.  More or less.
     
    415416            my ($code,$rmsg) = initPool($dbh,$cidr,$type,$city,"all");
    416417            die $rmsg if $code eq 'FAIL';
     418            $msg = $rmsg;
     419            $errcode = $code;
    417420          } elsif ($type =~ /^.d$/) {
    418421            $msg = "Could not initialize IPs in new $disp_alloctypes{$type} $cidr";
    419422            my ($code,$rmsg) = initPool($dbh,$cidr,$type,$city,"normal");
    420423            die $rmsg if $code eq 'FAIL';
     424            $msg = $rmsg;
     425            $errcode = $code;
    421426          }
    422427
     
    436441        return ('FAIL',$msg);
    437442      } else {
    438         return ('OK',"OK");
     443        return ($errcode,($type =~ /^.[pd]$/ ? $msg : "OK"));
    439444      }
    440445
     
    546551        return ('FAIL',$msg);
    547552      } else {
    548         return ('OK',"OK");
     553        return ($errcode,($type =~ /^.[pd]$/ ? $msg : "OK"));
    549554      }
    550555
     
    566571  my ($dbh,undef,$type,$city,$class) = @_;
    567572  my $pool = new NetAddr::IP $_[1];
     573
     574  return ('WARN','Refusing to melt server with IPv6 IP pool') if $pool->bits == 128;
    568575
    569576##fixme Need to just replace 2nd char of type with i rather than capturing 1st char of type
  • branches/stable/cgi-bin/main.cgi

    r508 r549  
    888888        $webvar{circid}, $webvar{privdata}, $webvar{node});
    889889
    890   if ($code eq 'OK') {
     890  if ($code eq 'OK' || $code eq 'WARN') {
    891891    if ($webvar{alloctype} =~ /^.i$/) {
    892892      $msg =~ s|/32||;
     
    902902    } else {
    903903      my $netblock = new NetAddr::IP $webvar{fullcidr};
    904       print qq(<div class="center"><div class="heading">The block $webvar{fullcidr} was ).
    905         "sucessfully added as: $disp_alloctypes{$webvar{alloctype}}</div>".
    906         ( ($webvar{alloctype} eq 'pr' && $webvar{billinguser}) ?
     904      if ($code eq 'OK') {
     905        print qq(<div class="center"><div class="heading">The block $webvar{fullcidr} was ).
     906                "sucessfully added as: $disp_alloctypes{$webvar{alloctype}}</div>";
     907      } else {
     908        print qq(<div class="center"><div class="heading">The block $webvar{fullcidr} was ).
     909                " added as $disp_alloctypes{$webvar{alloctype}} with a warning:<br>$msg</div>";
     910      }
     911      print ( ($webvar{alloctype} eq 'pr' && $webvar{billinguser}) ?
    907912                qq(<div><a href="https://billing.example.com/radius.pl?).
    908913                "action=new_radius_user&custid=$webvar{custid}&userid=$webvar{billinguser}".
Note: See TracChangeset for help on using the changeset viewer.