diff --git a/src/main/java/me/ishift/epicguard/core/check/impl/ProxyCheck.java b/src/main/java/me/ishift/epicguard/core/check/impl/ProxyCheck.java index f293346d..c6791540 100644 --- a/src/main/java/me/ishift/epicguard/core/check/impl/ProxyCheck.java +++ b/src/main/java/me/ishift/epicguard/core/check/impl/ProxyCheck.java @@ -8,6 +8,8 @@ import java.util.List; public class ProxyCheck extends Check { + private int requests; + public ProxyCheck(EpicGuard epicGuard) { super(epicGuard); } @@ -15,21 +17,34 @@ public ProxyCheck(EpicGuard epicGuard) { @Override public boolean check(String address, String nickname) { CheckMode mode = CheckMode.valueOf(this.getConfig().proxyCheck); - String url = "http://proxycheck.io/v2/" + address + "?key=" + this.getConfig().proxyCheckKey + "&vpn=1"; switch (mode) { case NEVER: return false; case ALWAYS: - return URLUtils.readString(url).contains("yes"); + return this.proxyCheck(address); case ATTACK: if (this.getEpicGuard().isAttack()) { - return URLUtils.readString(url).contains("yes"); + return this.proxyCheck(address); } } return false; } + private boolean proxyCheck(String address) { + if (this.requests > this.getConfig().requestLimit) { + return false; + } + + String url = "http://proxycheck.io/v2/" + address + "?key=" + this.getConfig().proxyCheckKey + "&vpn=1"; + if (!this.getConfig().customProxyCheck.equals("disabled")) { + url = this.getConfig().customProxyCheck.replace("%ip%", address); + } + + this.requests++; + return URLUtils.readString(url).contains("yes"); + } + @Override public List getKickMessage() { return this.getEpicGuard().getMessages().kickMessageProxy; diff --git a/src/main/java/me/ishift/epicguard/core/config/PluginConfiguration.java b/src/main/java/me/ishift/epicguard/core/config/PluginConfiguration.java index 00940e66..e627afb7 100644 --- a/src/main/java/me/ishift/epicguard/core/config/PluginConfiguration.java +++ b/src/main/java/me/ishift/epicguard/core/config/PluginConfiguration.java @@ -112,6 +112,18 @@ public class PluginConfiguration { @CfgComment(" ") @CfgComment("") + @CfgComment("If you want to use other proxy/vpn checker") + @CfgComment("than default (proxycheck.io), you can set it here.") + @CfgComment("Available placeholders: %ip%") + @CfgStringStyle(CfgStringStyle.StringStyle.ALWAYS_QUOTED) + @CfgName("custom-proxy-check-url") + public String customProxyCheck = "disabled"; + + @CfgComment("Limit of requests sent by the proxy/vpn checker.") + @CfgComment("Default (1000) is limit for proxycheck.io with free key.") + @CfgComment("request-limit") + public int requestLimit = 1000; + @CfgComment("If log message contains one of these words, it will") @CfgComment("be hidden. This can save a lot of CPU on big attacks.") @CfgCollectionStyle(CfgCollectionStyle.CollectionStyle.ALWAYS_NEW_LINE) diff --git a/src/main/java/me/ishift/epicguard/core/user/Account.java b/src/main/java/me/ishift/epicguard/core/user/Account.java index f0734f2e..6ccd4082 100644 --- a/src/main/java/me/ishift/epicguard/core/user/Account.java +++ b/src/main/java/me/ishift/epicguard/core/user/Account.java @@ -8,11 +8,12 @@ public class Account { private final List nicknames; public Account(EpicGuard epicGuard, String address, String nickname) { - this.nicknames = epicGuard.getStorageManager().getData().getStringList("account-limiter." + address); + String ip = address.replace(".", "@"); + this.nicknames = epicGuard.getStorageManager().getData().getStringList("account-limiter." + ip); if (!this.nicknames.contains(nickname)) { this.nicknames.add(nickname); } - epicGuard.getStorageManager().getData().set("account-limiter." + address, this.nicknames); + epicGuard.getStorageManager().getData().set("account-limiter." + ip, this.nicknames); } public List getNicknames() {