package cloud.swiftnode.ksecurity.module.kspam.abstraction.checker;


import cloud.swiftnode.ksecurity.module.kspam.abstraction.Info;
import cloud.swiftnode.ksecurity.module.kspam.abstraction.SpamChecker;
import cloud.swiftnode.ksecurity.util.Static;
import cloud.swiftnode.ksecurity.util.URLs;

import java.net.URL;

/**
 * Created by EntryPoint on 2017-01-05.
 */
public class BotscoutChecker extends SpamChecker {
    public BotscoutChecker(Info info) {
        super(info);
    }

    @Override
    public Result spamCheck() throws Exception {
        URL url = URLs.BOTSCOUT_API.toUrl(lastInfo = info.getIp());
        String contents = Static.readAllText(url);
        if (contents.contains("Y|")) {
            return Result.DENY;
        } else if (contents.contains("N|")) {
            return Result.PASS;
        } else {
            return Result.ERROR;
        }
    }
}

@@ -658,16 +658,23 @@
 ext(url)
+.trim()
 ;%0A      
@@ -688,24 +688,26 @@
 ontents.
-contains
+startsWith
 (%22Y%7C%22)) 
@@ -772,16 +772,18 @@
 nts.
-contains
+startsWith
 (%22N%7C

Fix BotscoutChecker