Method: GeoIP#isp

Defined in:
lib/geoip.rb

#isp(hostname) ⇒ Object Also known as: organization

Search a ISP GeoIP database for the specified host, returning the ISP Not all GeoIP databases contain ISP information. Check maxmind.com

hostname is a String holding the host’s DNS name or numeric IP address.

Returns the ISP name.



390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
# File 'lib/geoip.rb', line 390

def isp(hostname)
  ip = lookup_ip(hostname)

  # Convert numeric IP address to an integer
  ipnum = iptonum(ip)

  case @database_type
  when Edition::ORG,
Edition::ISP,
Edition::DOMAIN,
Edition::ASNUM,
Edition::ACCURACYRADIUS,
Edition::NETSPEED,
Edition::USERTYPE,
Edition::REGISTRAR,
Edition::LOCATIONA,
Edition::CITYCONF,
Edition::COUNTRYCONF,
Edition::REGIONCONF,
Edition::POSTALCONF
    pos = seek_record(ipnum)
    read_isp(pos-@database_segments[0])
  else
    throw "Invalid GeoIP database type, can't look up Organization/ISP by IP"
  end
end