X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fsvc_hardware.pm;h=d9c3c464e3c88f66a4fc587c9a9a6f3f5093c28b;hb=4c6648c06d62df50aeb39baf81552ecde0a5f6ba;hp=af6865f12ab8d5a43b7beff1c15fe464d8a42610;hpb=69bf020f03918910e0e34260d6e5a9d984f0414d;p=freeside.git diff --git a/FS/FS/svc_hardware.pm b/FS/FS/svc_hardware.pm index af6865f12..d9c3c464e 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+)$/ ) { @@ -129,7 +133,17 @@ sub search_sql { sub label { my $self = shift; - $self->serial || $self->display_hw_addr; + my @label = (); + if (my $type = $self->hardware_type) { + push @label, 'Type:' . $type->description; + } + if (my $ser = $self->serial) { + push @label, 'Serial#' . $ser; + } + if (my $mac = $self->display_hw_addr) { + push @label, 'MAC:'. $mac; + } + return join(', ', @label); } =item insert @@ -164,7 +178,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}$/