Changeset 832 for trunk/DNSDB.pm
- Timestamp:
- 03/30/22 14:48:23 (2 years ago)
- File:
-
- 1 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
Note:
See TracChangeset
for help on using the changeset viewer.