# File lib/geoip.rb, line 289 def asn(hostname) ip = lookup_ip(hostname) # Convert numeric IP address to an integer ipnum = iptonum(ip) if (@database_type != GEOIP_ASNUM_EDITION) throw "Invalid GeoIP database type, can't look up ASN by IP" end pos = seek_record(ipnum) off = pos + (2*@record_length - 1) * @database_segments[0] record = atomic_read(MAX_ASN_RECORD_LENGTH, off) record = record.sub(/\000.*/n, '') # AS####, Description ASN.new($1, $2) if record =~ /^(AS\d+)\s(.*)$/ end