Class LocalIPLookupManager
- All Implemented Interfaces:
ChatPluginManager
IPLookup
requests to the local database.
Only used when IPLookupManager.getMethod()
==
IPLookupMethod.LOCAL
.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Represents the type of a local database. -
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract void
Downloads an up to date copy of the database files from MaxMind's website.abstract URL
Formats the MaxMind website's database download URL with your license key.Gets the MaxMind's ASN local database file.abstract Object
Gets the MaxMind's ASN local database reader.Gets the MaxMind's city local database file.abstract Object
Gets the MaxMind's city local database reader.static LocalIPLookupManager
Gets this manager's instance.Gets the .lock file associated with this server's databases.boolean
Checks if this manager is enabled.abstract void
Refreshes the specified database type's file.abstract void
Updates an existing lookup with the local database's information.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface me.remigio07.chatplugin.api.common.util.manager.ChatPluginManager
checkAvailability, isReloadable, load, reload, unload
-
Field Details
-
LIBRARIES
Array containing all the libraries required for this module to work.Content: [
Library.MAXMIND_DB_READER
,Library.MAXMIND_GEOIP2
,Library.APACHE_HTTPCLIENT
,Library.APACHE_COMMONS_CODEC
,Library.APACHE_COMMONS_LOGGING
,Library.APACHE_HTTPCORE
,Library.JACKSON_CORE
,Library.JACKSON_ANNOTATIONS
,Library.JACKSON_DATABIND
,Library.ACTIVATION_FRAMEWORK
,Library.ICE_TAR
]
-
-
Constructor Details
-
LocalIPLookupManager
public LocalIPLookupManager()
-
-
Method Details
-
isEnabled
public boolean isEnabled()Description copied from interface:ChatPluginManager
Checks if this manager is enabled.- Specified by:
isEnabled
in interfaceChatPluginManager
- Returns:
- Whether this manager is enabled
-
getCityDatabaseFile
Gets the MaxMind's city local database file.- Returns:
- City database file
-
getASNDatabaseFile
Gets the MaxMind's ASN local database file.- Returns:
- ASN database file
-
getLockFile
Gets the .lock file associated with this server's databases.- Returns:
- Databases' .lock file
-
getInstance
Gets this manager's instance.- Returns:
- Manager's instance
-
update
Updates an existing lookup with the local database's information.- Parameters:
lookup
- Lookup to update
-
downloadDatabase
Downloads an up to date copy of the database files from MaxMind's website.- Parameters:
type
- The database to download- Throws:
IOException
- If something goes wrong
-
formatURL
Formats the MaxMind website's database download URL with your license key.- Parameters:
type
- The database to download- Returns:
- direct URL to the database file
-
getCityDatabaseReader
Gets the MaxMind's city local database reader.This is an instance of
DatabaseReader
, but the method returns just anObject
because you cannot directly access the libraries' classes. You can safely cast it to that class, but make sure the current class loader has loaded it.- Returns:
- The city database reader
-
getASNDatabaseReader
Gets the MaxMind's ASN local database reader.This is an instance of
DatabaseReader
, but the method returns just anObject
because you cannot directly access the libraries' classes. You can safely cast it to that class, but make sure the current class loader has loaded it.- Returns:
- The ASN database reader
-
refreshDatabaseFile
Refreshes the specified database type's file.The following operations (in this order) are performed:
- check if the file exists already
- if it does, delete it and create a new one
- download the .tar.gz database and extract it
- transfer its content to the file's location
- Parameters:
type
- Database's type- Throws:
IOException
- If something goes wrong
-