/** * 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); }
long ip = ipl.longValue(); String uc = ls.getCountry(ip).getCode(); if (!uc.equals(UNKNOWN_COUNTRY_CODE)) { String lc = uc.toLowerCase(Locale.US);
/** * 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())); }
/** * 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); }
/** * 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); }
LookupService cl = new LookupService(dbfile,LookupService.GEOIP_MEMORY_CACHE); System.out.println(cl.getCountry("151.38.39.114").getCode());
/** * 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())); }
/** * 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())); }
/** * 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())); }
/** * 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())); }
/** * 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())); }
/** Converts int value to country code. * * @param host ip address as int type by network byte order(big endian) */ public static String getCountryCode(int host) { return lookup.getCountry(host).getCode(); }
public static String getCountryCode(String host) { return lookup.getCountry(host).getCode(); } }
public static String getCountryCode(String host) { return lookup.getCountry(host).getCode(); }
/** * 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())); }
/** * 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())); }
/** * 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())); }
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; }
/** Converts binary(byte array) to country code. * In case of IPv4, it is 4 bytes length. * * @param host ip address as byte array type by network byte order(big endian) */ public static String getCountryCode(byte [] host) { InetAddress addr; try { addr = InetAddress.getByAddress(host); } catch (UnknownHostException e) { LOG.error("Unknown host: " + IPconvertUtil.bytes2ipstr(host)); return ""; } return lookup.getCountry(addr).getCode(); } }
protected String lookup(String ip, String filename) throws HiveException { try { if (geoloc == null) { URL u = getClass().getClassLoader().getResource(filename); if (u == null) { throw new HiveException("Couldn't find geolocation file '" + filename + "'"); } geoloc = new LookupService(u.getFile(), LookupService.GEOIP_MEMORY_CACHE); } String countryCode = geoloc.getCountry(ip).getCode(); if ("--".equals(countryCode)) { return null; } return countryCode; } catch (IOException e) { throw new HiveException("Caught IO exception", e); } }