Refine search
ls = new LookupService(f, LookupService.GEOIP_STANDARD); for (int i = 0; i < search.length; i++) { Long ipl = search[i]; long ip = ipl.longValue(); String uc = ls.getCountry(ip).getCode(); if (!uc.equals(UNKNOWN_COUNTRY_CODE)) { String lc = uc.toLowerCase(Locale.US); _log.error("GeoIP failure", ide); } finally { if (ls != null) ls.close(); ls = new LookupService(f, LookupService.GEOIP_STANDARD); for (int i = 0; i < search.length; i++) { Long ipl = search[i]; String ipv6 = toV6(ip); String uc = ls.getCountryV6(ipv6).getCode(); if (!uc.equals(UNKNOWN_COUNTRY_CODE)) { String lc = uc.toLowerCase(Locale.US); _log.error("GeoIP failure", ide); } finally { if (ls != null) ls.close();
public Location getLocation(String str) { InetAddress addr; try { addr = InetAddress.getByName(str); } catch (UnknownHostException e) { return null; } return getLocation(addr); }
byte[] v6vec = addr.getAddress(); int[] x = new int[2]; int offset = 0; _check_mtime(); for (int depth = 127; depth >= 0; depth--) { readNode(buf, x, offset); + addr.getHostAddress());
/** * Returns the country the IP address is in. * * @param ipAddress * the IP address. * @return the country the IP address is from. */ public synchronized Country getCountry(InetAddress ipAddress) { return getCountry(bytesToLong(ipAddress.getAddress())); }
public Location getLocation(InetAddress addr) { return getLocation(bytesToLong(addr.getAddress())); }
public int getID(String ipAddress) { InetAddress addr; try { addr = InetAddress.getByName(ipAddress); } catch (UnknownHostException e) { return 0; } return getID(bytesToLong(addr.getAddress())); }
/** * Returns the country the IP address is in. * * @param ipAddress String version of an IP address, i.e. "127.0.0.1" * @return the country the IP address is from. */ public Country getCountry(String ipAddress) { InetAddress addr; try { addr = InetAddress.getByName(ipAddress); } catch (UnknownHostException e) { return UNKNOWN_COUNTRY; } return getCountry(bytesToLong(addr.getAddress())); }
byte[] v6vec = addr.getAddress(); byte[] buf = new byte[2 * MAX_RECORD_LENGTH]; int[] x = new int[2]; int offset = 0; _check_mtime(); for (int depth = 127; depth >= 0; depth--) { if ((dboptions & GEOIP_MEMORY_CACHE) == 1) { System.err.println("Error seeking country while seeking " + addr.getHostAddress()); return 0;
public synchronized Region getRegion(String str) { InetAddress addr; try { addr = InetAddress.getByName(str); } catch (UnknownHostException e) { return null; } return getRegion(bytesToLong(addr.getAddress())); }
/** * Returns the country the IP address is in. * * @param ipAddress * String version of an IPv6 address, i.e. "::127.0.0.1" * @return the country the IP address is from. */ public Country getCountryV6(String ipAddress) { InetAddress addr; try { addr = InetAddress.getByName(ipAddress); } catch (UnknownHostException e) { return UNKNOWN_COUNTRY; } return getCountryV6(addr); }
/** * Returns the country the IP address is in. * * @param ipAddress * String version of an IP address, i.e. "127.0.0.1" * @return the country the IP address is from. */ public Country getCountry(String ipAddress) { InetAddress addr; try { addr = InetAddress.getByName(ipAddress); } catch (UnknownHostException e) { return UNKNOWN_COUNTRY; } return getCountry(addr); }
public Location getLocation(String str) { if (dnsService == 0) { InetAddress addr; try { addr = InetAddress.getByName(str); } catch (UnknownHostException e) { return null; } return getLocation(addr); } else { String str2 = getDnsAttributes(str); return getLocationwithdnsservice(str2); // TODO if DNS is not available, go to local file as backup } }
public int getID(InetAddress ipAddress) { return getID(bytesToLong(ipAddress.getAddress())); }
public String getOrg(InetAddress addr) { return getOrg(bytesToLong(addr.getAddress())); }
public synchronized Region getRegion(InetAddress addr) { return getRegion(bytesToLong(addr.getAddress())); }
LookupService lookupService = new LookupService("./GeoIP.dat");
protected String lookup(String ip) throws IOException { if (geoloc == null) { geoloc = new LookupService("./" + DIST_CACHE_GEOIP_NAME, LookupService.GEOIP_MEMORY_CACHE); } String country = geoloc.getCountry(ip).getName(); if ("N/A".equals(country)) { return null; } return country; }
lookupService = new LookupService(file, LookupService.GEOIP_MEMORY_CACHE | LookupService.GEOIP_CHECK_CACHE); databases.put(databaseName, lookupService); } catch (IOException ex) { try { Location location = lookupService.getLocation(ip); if (attributeName.equals(COUNTRY_NAME)) { retVal = location.countryName; retVal = RegionName.regionNameByCode(location.countryCode, location.region); } else if (attributeName.equals(ORG)) { retVal = lookupService.getOrg(ip); } else if (attributeName.equals(ID)) { retVal = lookupService.getID(ip) + "";
LookupService cl = new LookupService("/var/geolite/GeoLiteCity.dat", LookupService.GEOIP_MEMORY_CACHE | LookupService.GEOIP_CHECK_CACHE); Location location = cl.getLocation("some ip address");
synchronized void _check_mtime() { try { if ((dboptions & GEOIP_CHECK_CACHE) != 0) { long t = databaseFile.lastModified(); if (t != mtime) { /* GeoIP Database file updated */ /* refresh filehandle */ close(); file = new RandomAccessFile(databaseFile, "r"); databaseInfo = null; init(); } } } catch (IOException e) { throw new InvalidDatabaseException("Database not found", e); } }