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+)$/ ) {
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