Commit c7e18483 authored by Liang Ding's avatar Liang Ding

🔒 加入社区黑名单 IP

parent 43dfbd5a
......@@ -36,7 +36,7 @@ public class BeforeRequestHandler implements Handler {
public void handle(final RequestContext context) {
final String remoteAddr = Requests.getRemoteAddr(context.getRequest());
if (Solos.BLACKLIST_IPS.contains(remoteAddr)) {
context.sendStatus(200);
context.sendStatus(429);
context.abort();
return;
......
......@@ -103,7 +103,7 @@ public class CronMgmtService {
} finally {
Stopwatchs.release();
}
}, delay, 30, TimeUnit.MINUTES);
}, delay, 1000 * 60 * 30, TimeUnit.MILLISECONDS);
delay += 2000;
SCHEDULED_EXECUTOR_SERVICE.scheduleAtFixedRate(() -> {
......
......@@ -125,7 +125,7 @@ public final class Solos {
* Reloads blacklist IPs.
*/
public static void reloadBlacklistIPs() {
final HttpResponse res = HttpRequest.post("https://hacpai.com/apis/blacklist/ip").trustAllCerts(true).
final HttpResponse res = HttpRequest.get("https://hacpai.com/apis/blacklist/ip").trustAllCerts(true).
connectionTimeout(3000).timeout(7000).header("User-Agent", Solos.USER_AGENT).send();
if (200 != res.statusCode()) {
return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment