strip off AS prefix

This commit is contained in:
Matt Simerson 2014-11-05 13:52:21 -08:00
parent f2eda74074
commit 54abd60239
2 changed files with 5 additions and 2 deletions

View File

@ -375,6 +375,9 @@ sub set_asn {
return if ! $self->{GeoIPASNum};
my $asn = $self->{GeoIPASNum}->name_by_addr($ip) or return;
if ('AS' eq substr($asn, 0, 2)) {
$asn = substr($asn, 2);
}
$self->qp->connection->notes('geoip_asn', $asn);
return $asn;
}

View File

@ -176,10 +176,10 @@ sub test_set_asn {
$self->qp->connection->remote_ip('24.24.24.24');
$asn = $self->set_asn();
ok( $self->connection->notes('geoip_asn') =~ /^AS11351/, "note has: $asn");
ok( $self->connection->notes('geoip_asn') =~ /^11351/, "note has: $asn");
$self->qp->connection->remote_ip('66.128.51.163');
$asn = $self->set_asn();
ok( $self->connection->notes('geoip_asn') =~ /^AS7819/, "note has: $asn");
ok( $self->connection->notes('geoip_asn') =~ /^7819/, "note has: $asn");
};