From 3e0ff9e134ef1e4c5be64aa52f1d7a716d6ee59c Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Wed, 6 Oct 2021 15:45:48 +0100 Subject: [PATCH] #808 avoid dns for node search on IPish thing --- lib/App/Netdisco/Web/Plugin/Search/Node.pm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/App/Netdisco/Web/Plugin/Search/Node.pm b/lib/App/Netdisco/Web/Plugin/Search/Node.pm index 438a0f58..88aeea53 100644 --- a/lib/App/Netdisco/Web/Plugin/Search/Node.pm +++ b/lib/App/Netdisco/Web/Plugin/Search/Node.pm @@ -211,7 +211,9 @@ get '/ajax/content/search/node' => require_login sub { ->search_by_name({nbname => $likeval, @active, @times}); unless ( $set->has_rows ) { - if (my $ip = NetAddr::IP::Lite->new($node)) { + if ($node =~ m{^(?:$RE{net}{IPv4}|$RE{net}{IPv6})(?:/\d+)?$}i + and my $ip = NetAddr::IP::Lite->new($node)) { + # search_by_ip() will extract cidr notation if necessary $set = schema('netdisco')->resultset('NodeIp') ->search_by_ip({ip => $ip, @active, @times});