public synchronized String getOrgV6(InetAddress addr) { try { int seekOrg = seekCountryV6(addr); return readOrgRecord(seekOrg); } catch (IOException e) { throw new InvalidDatabaseException("Error while reading org", e); } }
public synchronized Location getLocationV6(InetAddress addr) { int seek_country; try { seek_country = seekCountryV6(addr); return readCityRecord(seek_country); } catch (IOException e) { throw new InvalidDatabaseException("Error while seting up segments", e); } }
public synchronized Location getLocation(long ipnum) { int seek_country; try { seek_country = seekCountry(ipnum); return readCityRecord(seek_country); } catch (IOException e) { throw new InvalidDatabaseException("Error while seting up segments", e); } }
public Location getLocation(InetAddress addr) { return getLocation(bytesToLong(addr.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())); }
public Location getLocation(String str) { InetAddress addr; try { addr = InetAddress.getByName(str); } catch (UnknownHostException e) { return null; } return getLocation(addr); }
/** * Returns the country the IP address is in. * * @param ipAddress * the IP address in long format. * @return the country the IP address is from. */ public synchronized Country getCountry(long ipAddress) { if (file == null && (dboptions & GEOIP_MEMORY_CACHE) == 0) { throw new IllegalStateException("Database has been closed."); } int ret = seekCountry(ipAddress) - COUNTRY_BEGIN; if (ret == 0) { return UNKNOWN_COUNTRY; } else { return new Country(countryCode[ret], countryName[ret]); } }
/** * Returns the country the IP address is in. * * @param addr * the IP address as Inet6Address. * @return the country the IP address is from. */ public synchronized Country getCountryV6(InetAddress addr) { if (file == null && (dboptions & GEOIP_MEMORY_CACHE) == 0) { throw new IllegalStateException("Database has been closed."); } int ret = seekCountryV6(addr) - COUNTRY_BEGIN; if (ret == 0) { return UNKNOWN_COUNTRY; } else { return new Country(countryCode[ret], countryName[ret]); } }
public synchronized String getOrg(long ipnum) { try { int seekOrg = seekCountry(ipnum); return readOrgRecord(seekOrg); } catch (IOException e) { throw new InvalidDatabaseException("Error while reading org", e); } }
public String getOrg(InetAddress addr) { return getOrg(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())); }
public synchronized Region getRegion(String str) { InetAddress addr; try { addr = InetAddress.getByName(str); } catch (UnknownHostException e) { return null; } return getRegion(bytesToLong(addr.getAddress())); }
private static float readAngle(ByteBuffer buffer) { if (buffer.remaining() < 3) { throw new InvalidDatabaseException("Unexpected end of data record when reading angle"); } double num = 0; for (int j = 0; j < 3; j++) { num += unsignedByteToInt(buffer.get()) << (j * 8); } return (float) num / 10000 - 180; }
public synchronized int getID(long ipAddress) { if (file == null && (dboptions & GEOIP_MEMORY_CACHE) == 0) { throw new IllegalStateException("Database has been closed."); } return seekCountry(ipAddress) - databaseSegments[0]; }
public String getOrg(String str) { InetAddress addr; try { addr = InetAddress.getByName(str); } catch (UnknownHostException e) { return null; } return getOrg(addr); }
public String getOrgV6(String str) { InetAddress addr; try { addr = InetAddress.getByName(str); } catch (UnknownHostException e) { return null; } return getOrgV6(addr); }
public Location getLocationV6(String str) { InetAddress addr; try { addr = InetAddress.getByName(str); } catch (UnknownHostException e) { return null; } return getLocationV6(addr); }
/** * Create a new lookup service using the specified database file. * * @param databaseFile * the database file. * @throws IOException * if an error occured creating the lookup service from the * database file. */ public LookupService(File databaseFile) throws IOException { this.databaseFile = databaseFile; file = new RandomAccessFile(databaseFile, "r"); init(); }
private String readOrgRecord(int seekOrg) throws IOException { if (seekOrg == databaseSegments[0]) { return null; } ByteBuffer buf = readRecordBuf(seekOrg, MAX_ORG_RECORD_LENGTH); return readString(buf); }
private static int readMetroAreaCombo(ByteBuffer buffer) { if (buffer.remaining() < 3) { throw new InvalidDatabaseException("Unexpected end of data record when reading metro area"); } int metroareaCombo = 0; for (int j = 0; j < 3; j++) { metroareaCombo += unsignedByteToInt(buffer.get()) << (j * 8); } return metroareaCombo; }