- Timestamp:
- 03/30/22 14:48:23 (3 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/DNSDB.pm
r831 r832 4461 4461 # Filtering on host/val (mainly normal record list) 4462 4462 if ($args{filter}) { 4463 $sql .= " AND (r.host ~* ? OR r.val ~* ? OR r.host ~* ? OR r.val ~* ?)"; 4464 my $tmp = join('.',reverse(split(/\./,$args{filter}))); 4465 push @bindvars, ($args{filter},$args{filter}); 4466 push @bindvars, ($tmp, $tmp); 4463 # not much use to end users, but internal callers may want more fine-grained restriction on CIDR ranges 4464 # we'll only support the value-comparison operators; bitwise/add/subtract don't make much sense in this context 4465 my $ipfilt = 0; 4466 if ($args{filter} =~ /^\s*(<|<=|=|>=|>|<>|<<|<<=|>>|>>=)\s*([\da-fA-F].+)\s*$/) { 4467 my $filt_op = $1; 4468 my $filt_val = $2; 4469 # do we have an IP-ish value? 4470 if ($filt_val =~ m,^(?:[\d.]+|[0-9a-f]+)(?:/\d+)?$,) { 4471 # now make sure 4472 my $tmp = new NetAddr::IP $filt_val; 4473 if ($tmp) { 4474 $sql .= " AND inetlazy(r.val) $filt_op ?"; 4475 push @bindvars, $filt_val; 4476 $ipfilt = 1; 4477 } # really looks like a valid IP/CIDR 4478 } # looks IPish 4479 } # has CIDR operator 4480 if (!$ipfilt) { 4481 # simple text matching, with a bit of mix-n-match to account for .arpa names 4482 $sql .= " AND (r.host ~* ? OR r.val ~* ? OR r.host ~* ? OR r.val ~* ?)"; 4483 my $tmp = join('.',reverse(split(/\./,$args{filter}))); 4484 push @bindvars, ($args{filter},$args{filter}); 4485 push @bindvars, ($tmp, $tmp); 4486 } 4467 4487 } 4468 4488 … … 4538 4558 # Filtering on host/val (mainly normal record list) 4539 4559 if ($args{filter}) { 4540 $sql .= " AND (r.host ~* ? OR r.val ~* ? OR r.host ~* ? OR r.val ~* ?)"; 4541 my $tmp = join('.',reverse(split(/\./,$args{filter}))); 4542 push @bindvars, ($args{filter},$args{filter}); 4543 push @bindvars, ($tmp, $tmp); 4560 # not much use to end users, but internal callers may want more fine-grained restriction on CIDR ranges 4561 # we'll only support the value-comparison operators; bitwise/add/subtract don't make much sense in this context 4562 my $ipfilt = 0; 4563 if ($args{filter} =~ /^\s*(<|<=|=|>=|>|<>|<<|<<=|>>|>>=)\s*([\da-fA-F].+)\s*$/) { 4564 my $filt_op = $1; 4565 my $filt_val = $2; 4566 # do we have an IP-ish value? 4567 if ($filt_val =~ m,^(?:[\d.]+|[0-9a-f]+)(?:/\d+)?$,) { 4568 # now make sure 4569 my $tmp = new NetAddr::IP $filt_val; 4570 if ($tmp) { 4571 $sql .= " AND inetlazy(r.val) $filt_op ?"; 4572 push @bindvars, $filt_val; 4573 $ipfilt = 1; 4574 } # really looks like a valid IP/CIDR 4575 } # looks IPish 4576 } # has CIDR operator 4577 if (!$ipfilt) { 4578 # simple text matching, with a bit of mix-n-match to account for .arpa names 4579 $sql .= " AND (r.host ~* ? OR r.val ~* ? OR r.host ~* ? OR r.val ~* ?)"; 4580 my $tmp = join('.',reverse(split(/\./,$args{filter}))); 4581 push @bindvars, ($args{filter},$args{filter}); 4582 push @bindvars, ($tmp, $tmp); 4583 } 4544 4584 } 4545 4585 -
trunk/dns-rpc.cgi
r829 r832 1631 1631 # Delete ALL EVARYTHING!!one11!! in $args{cidr} 1632 1632 1633 # Use offset => 'all' to make sure we actually find all the records we need to remove, 1634 # otherwise the record(s) that need to be deleted may be more than 75 records down the 1635 # list and won't get caught. We also do a crude filter based on the /24 of $args{cidr} 1636 # to reduce the remote's cost for the operation - if the revzone is large, it'll iterate 1637 # over a Very Large Number(TM) of records, just to delete a small handful. Bad juju. 1638 my $filt = $args{cidr}; 1639 $filt =~ s,\.\d+(?:/\d+)?$,,; 1633 # Deleting a small $args{cidr} from a large reverse zone will sometimes 1634 # silently fail by not finding the appropriate record(s). Prepend a 1635 # Postgres CIDR operator to assist in filtering 1636 my $filt = "<<= $args{cidr}"; 1637 1640 1638 my $reclist = $dnsdb->getRecList(rpc => 1, defrec => 'n', revrec => 'y', id => $zonelist->[0]->{rdns_id}, 1641 1639 filter => $filt, offset => 'all');
Note:
See TracChangeset
for help on using the changeset viewer.