#591 domain_suffix can be list and supports (simple) regexp
Squashed commit of the following: commit975e4c6afcAuthor: Oliver Gorwits <oliver@cpan.org> Date: Tue Sep 3 13:35:26 2019 +0100 also support regexp in domain_suffix commit0a2b5c8fa2Author: Oliver Gorwits <oliver@cpan.org> Date: Tue Sep 3 13:17:17 2019 +0100 fix rancid, graph, and nodemonitor commit6d881de3ffAuthor: Oliver Gorwits <oliver@cpan.org> Date: Tue Sep 3 13:11:54 2019 +0100 improve docs and set default domain_suffix to be list commit1dcafc08a8Merge:9a752e0214ac69dcAuthor: Oliver Gorwits <oliver@cpan.org> Date: Tue Sep 3 13:00:39 2019 +0100 Merge branch 'master' into og-multiple-domain-suffix commit9a752e0298Merge:c836619f82a99ea9Author: Oliver Gorwits <oliver@cpan.org> Date: Tue Sep 3 09:45:25 2019 +0100 Merge branch 'master' into og-multiple-domain-suffix commitc836619f8cAuthor: Oliver Gorwits <oliver@cpan.org> Date: Thu Jun 13 07:52:45 2019 +0100 hokey fix for nodes with domains commitfed14bd810Author: Oliver Gorwits <oliver@cpan.org> Date: Thu Jun 13 07:02:09 2019 +0100 basic implementation, rancid graph and nodemonitor missing
This commit is contained in:
@@ -97,9 +97,13 @@ sub search_by_ip {
|
||||
->search($cond, $attrs);
|
||||
}
|
||||
|
||||
=head1 search_by_name( \%cond, \%attrs? )
|
||||
=head1 search_by_dns( \%cond, \%attrs? )
|
||||
|
||||
my $set = $rs->search_by_name({dns => 'foo.example.com', active => 1});
|
||||
my $set = $rs->search_by_dns({
|
||||
dns => 'foo.example.com',
|
||||
suffix => qr/(?:\.example\..com|\.local)$/,
|
||||
active => 1
|
||||
});
|
||||
|
||||
Like C<search()>, this returns a ResultSet of matching rows from the
|
||||
NodeIp table.
|
||||
@@ -118,6 +122,11 @@ to search for. The value may optionally include SQL wildcard characters.
|
||||
|
||||
=item *
|
||||
|
||||
The C<cond> parameter may optionally have a C<suffix> parameter which is a
|
||||
regular expression of domain names - one of which must match the results.
|
||||
|
||||
=item *
|
||||
|
||||
Results are ordered by time last seen.
|
||||
|
||||
=item *
|
||||
@@ -141,7 +150,13 @@ sub search_by_dns {
|
||||
die "dns field required for search_by_dns\n"
|
||||
if ref {} ne ref $cond or !exists $cond->{dns};
|
||||
|
||||
$cond->{dns} = { '-ilike' => delete $cond->{dns} };
|
||||
(my $suffix = (delete $cond->{suffix} || ''))
|
||||
=~ s|\Q(?^\Eu?|(?|g;
|
||||
|
||||
$cond->{dns} = [ -and =>
|
||||
{ '-ilike' => delete $cond->{dns} },
|
||||
{ '~*' => "***:$suffix" },
|
||||
];
|
||||
|
||||
return $rs
|
||||
->search_rs({}, $search_attr)
|
||||
|
||||
Reference in New Issue
Block a user