summaryrefslogtreecommitdiff
path: root/FS/FS/svc_hardware.pm
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2013-04-05 12:13:45 -0700
committerMark Wells <mark@freeside.biz>2013-04-05 12:14:23 -0700
commitfd67c768f2f59f7883197889ef02bb3e1fb2b0c7 (patch)
tree11fe85c259de4302e87236e3950c61ed43461a19 /FS/FS/svc_hardware.pm
parentce27e05645c490fb75c21395b4f6f79d8f4e81e7 (diff)
speed up service search
Diffstat (limited to 'FS/FS/svc_hardware.pm')
-rw-r--r--FS/FS/svc_hardware.pm10
1 files changed, 7 insertions, 3 deletions
diff --git a/FS/FS/svc_hardware.pm b/FS/FS/svc_hardware.pm
index 96502e4..b28cc9e 100644
--- a/FS/FS/svc_hardware.pm
+++ b/FS/FS/svc_hardware.pm
@@ -105,9 +105,13 @@ sub search_sql {
my ($class, $string) = @_;
my @where = ();
- my $ip = NetAddr::IP->new($string);
- if ( $ip ) {
- push @where, $class->search_sql_field('ip_addr', $ip->addr);
+ if ( $string =~ /^[\d\.:]+$/ ) {
+ # if the string isn't an IP address, this will waste several seconds
+ # attempting a DNS lookup. so try to filter those out.
+ my $ip = NetAddr::IP->new($string);
+ if ( $ip ) {
+ push @where, $class->search_sql_field('ip_addr', $ip->addr);
+ }
}
if ( $string =~ /^(\w+)$/ ) {