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; }
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; }
private void readNode(byte[] buf, int[] x, int offset) { if ((dboptions & GEOIP_MEMORY_CACHE) == 1) { // read from memory System.arraycopy(dbbuffer, (2 * recordLength * offset), buf, 0, 2 * recordLength); } else if ((dboptions & GEOIP_INDEX_CACHE) != 0) { // read from index cache System.arraycopy(index_cache, (2 * recordLength * offset), buf, 0, 2 * recordLength); } else { // read from disk try { file.seek(2 * recordLength * offset); file.read(buf); } catch (IOException e) { throw new InvalidDatabaseException("Error seeking in database", e); } } for (int i = 0; i < 2; i++) { x[i] = 0; for (int j = 0; j < recordLength; j++) { int y = buf[i * recordLength + j]; if (y < 0) { y += 256; } x[i] += (y << (j * 8)); } } }
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); } }
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); } }
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 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 synchronized String getOrgV6(InetAddress addr) { try { int seekOrg = seekCountryV6(addr); return readOrgRecord(seekOrg); } catch (IOException e) { throw new InvalidDatabaseException("Error while reading org", e); } }
throw new InvalidDatabaseException("Error reading database info", e);
throw new InvalidDatabaseException("Error seeking country while searching for " + addr.getHostAddress());
throw new InvalidDatabaseException("Error seeking country while searching for " + ipAddress);
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; }
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; }
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; }
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 synchronized Location getLocation(long ipnum) { int seekCountry; try { seekCountry = seekCountry(ipnum); return readCityRecord(seekCountry); } catch (IOException e) { throw new InvalidDatabaseException("Error while seting up segments", e); } }
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 String getOrg(long ipnum) { try { int seekOrg = seekCountry(ipnum); return readOrgRecord(seekOrg); } catch (IOException e) { throw new InvalidDatabaseException("Error while reading org", e); } }
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); } }