Method: GeoIP#netspeed
- Defined in:
- lib/geoip.rb
#netspeed(hostname) ⇒ Object
Search a GeoIP Connection Type (Netspeed) database for the specified host, returning the speed code.
hostname is a String holding the host’s DNS name or numeric IP address.
292 293 294 295 296 297 298 299 300 301 302 |
# File 'lib/geoip.rb', line 292 def netspeed(hostname) unless (@database_type == Edition::NETSPEED || @database_type == Edition::NETSPEED_REV1) throw "Invalid GeoIP database type #{@database_type}, can't look up Netspeed by IP" end # Convert numeric IP address to an integer ip = lookup_ip(hostname) ipnum = iptonum(ip) pos = seek_record(ipnum) read_netspeed(pos-@database_segments[0]) end |