Changeset 920 for trunk


Ignore:
Timestamp:
10/12/18 13:38:05 (6 years ago)
Author:
Kris Deugau
Message:

/trunk

Add an optional argument to getPoolSelect() to limit the pools returned by IP range

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/cgi-bin/IPDB.pm

    r915 r920  
    13401340  my $pcity = shift;
    13411341
     1342  my $rangelimit = shift;
     1343  if ($rangelimit) {
     1344    if ($rangelimit !~ /^[\d\.\/]+$/) {
     1345      # Just skip limiting on ridiculous range limits
     1346      $rangelimit = '';
     1347    } else {
     1348      # now check for sanity
     1349      $rangelimit = new NetAddr::IP $rangelimit;
     1350      $rangelimit = '' if !$rangelimit;
     1351    }
     1352  }
     1353
    13421354  my ($ptype) = ($iptype =~ /^(.)i$/);
    13431355  return if !$ptype;
    13441356  $ptype .= '_';
     1357
     1358  my @qargs = ($pcity, $ptype);
     1359  push @qargs, "$rangelimit" if $rangelimit;
    13451360
    13461361  my $plist = $dbh->selectall_arrayref( q(
     
    13481363        FROM poolips p
    13491364        JOIN allocations a ON p.parent_id=a.id
    1350         WHERE p.available='y' AND a.city = ? AND p.type LIKE ?
     1365        WHERE p.available='y' AND a.city = ? AND p.type LIKE ?).
     1366        ($rangelimit ? ' AND a.cidr << ?' : '').q(
    13511367        GROUP BY a.id,a.cidr,a.city
    13521368        ORDER BY a.cidr
    13531369        ),
    1354         { Slice => {} }, ($pcity, $ptype) );
     1370        { Slice => {} }, @qargs );
    13551371  return $plist;
    13561372} # end getPoolSelect()
Note: See TracChangeset for help on using the changeset viewer.