projects
/
spider.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
allow pc73 for DXNet
[spider.git]
/
perl
/
Filter.pm
diff --git
a/perl/Filter.pm
b/perl/Filter.pm
index 37d9de6c2ed13551d1e7950b73e753b67a29d36a..226aff4a22987f820934fcbfef9b11f7f4b124dc 100644
(file)
--- a/
perl/Filter.pm
+++ b/
perl/Filter.pm
@@
-143,12
+143,15
@@
sub getfilkeys
# The filter returns 0 if an entry is matched by any reject rule and also if any
# accept rule fails otherwise it returns 1
#
# The filter returns 0 if an entry is matched by any reject rule and also if any
# accept rule fails otherwise it returns 1
#
-# Either set of rules may be missing meaning an implicit 'ok'
+# Either set of rules may be missing meaning an implicit 'opposite' ie if it
+# a reject then ok else if an accept then not ok.
+#
+# you can set a default with either an accept/xxxx all or reject/xxxx all
#
# Unlike the old system, this is kept as a hash of hashes so that you can
# easily change them by program.
#
#
# Unlike the old system, this is kept as a hash of hashes so that you can
# easily change them by program.
#
-# You can have
a [any] number of 'filters', they are tried in random
order until
+# You can have
10 filter lines (0->9), they are tried in
order until
# one matches
#
# There is a parser that takes a Filter::Cmd object which describes all the possible
# one matches
#
# There is a parser that takes a Filter::Cmd object which describes all the possible
@@
-178,19
+181,29
@@
sub it
my $self = shift;
my $hops = undef;
my $self = shift;
my $hops = undef;
- my $r = 1;
my $filter;
my $filter;
- foreach $filter ($self->getfilters) {
- $r = 0;
+ my @keys = sort $self->getfilkeys;
+ my $key;
+ my $r = @keys > 0 ? 0 : 1;
+ foreach $key (@keys) {
+ $filter = $self->{$key};
if ($filter->{reject} && exists $filter->{reject}->{code}) {
if ($filter->{reject} && exists $filter->{reject}->{code}) {
- next if &{$filter->{reject}->{code}}(\@_);
+ if (&{$filter->{reject}->{code}}(\@_)) {
+ $r = 0;
+ last;
+ } else {
+ $r = 1;
+ }
}
if ($filter->{accept} && exists $filter->{accept}->{code}) {
}
if ($filter->{accept} && exists $filter->{accept}->{code}) {
- next unless &{$filter->{accept}->{code}}(\@_);
+ if (&{$filter->{accept}->{code}}(\@_)) {
+ $r = 1;
+ last;
+ } else {
+ $r = 0;
+ }
}
}
- $r = 1;
- last;
}
# hops are done differently
}
# hops are done differently
@@
-379,6
+392,10
@@
sub parse
$s .= $tok;
$user .= $tok;
next;
$s .= $tok;
$user .= $tok;
next;
+ } elsif ($tok eq 'all') {
+ $s .= '1';
+ $user .= $tok;
+ last;
} elsif ($tok eq 'or') {
$conj = ' || ' if $conj ne ' || ';
next;
} elsif ($tok eq 'or') {
$conj = ' || ' if $conj ne ' || ';
next;
@@
-464,7
+481,7
@@
sub parse
$user =~ s/\!/ not /g;
$user =~ s/\s+/ /g;
$user =~ s/\!/ not /g;
$user =~ s/\s+/ /g;
- return (0, $filter, $fno, $user, "sub { my \$r = shift; return
$s
}");
+ return (0, $filter, $fno, $user, "sub { my \$r = shift; return
($s) ? 1 : 0
}");
}
package Filter::Old;
}
package Filter::Old;