X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fsvc_hardware.pm;h=b28cc9ef5b131c88a1a4a9a1dbdab9fd861e431c;hb=8447fe46bb96c6774b709b5c3341ae35587a35f8;hp=af6865f12ab8d5a43b7beff1c15fe464d8a42610;hpb=69bf020f03918910e0e34260d6e5a9d984f0414d;p=freeside.git diff --git a/FS/FS/svc_hardware.pm b/FS/FS/svc_hardware.pm index af6865f12..b28cc9ef5 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+)$/ ) { @@ -164,7 +168,7 @@ sub check { return $x unless ref $x; my $hw_addr = $self->getfield('hw_addr'); - $hw_addr = join('', split(/\W/, $hw_addr)); + $hw_addr = join('', split(/[_\W]/, $hw_addr)); if ( $conf->exists('svc_hardware-check_mac_addr') ) { $hw_addr = uc($hw_addr); $hw_addr =~ /^[0-9A-F]{12}$/