Examples

In this page, you can find some code examples on how you can use the API.

Find the country/city of an address

You can find the country codes on the MaxMind site: https://dev.maxmind.com/geoip/legacy/codes

EpicGuardAPI api = EpicGuardAPI.INSTANCE; // obtain the EpicGuardAPI instance.

GeoManager geoManager = api.getGeoManager(); // GeoManager instance.
String countryCode = geoManager.countryCode("127.0.0.1"); // ISO code of the country.
String city = geoManager.city("127.0.0.1"); // city's name

Blacklisting and checking whitelist

This example will check if an address is whitelisted, and then will blacklist it.

EpicGuardAPI api = EpicGuardAPI.INSTANCE; // obtain the EpicGuardAPI instance.
String address = "127.0.0.1";

if (api.getWhitelistedAddresses().contains(address)) {
    api.blacklistAddress(address);
}

Checking attack status

This example will check if the server is under attack, and print the current connections per second.

EpicGuardAPI api = EpicGuardAPI.INSTANCE; // obtain the EpicGuardAPI instance.

if (api.isUnderAttack()) {
    System.out.println("Current connections/s: " + api.getConnectionsPerSecond())
}

Last updated