diff --git a/KinanCity-captcha-AntiCaptcha/src/main/java/com/kinancity/core/captcha/antiCaptcha/AntiCaptchaProvider.java b/KinanCity-captcha-AntiCaptcha/src/main/java/com/kinancity/core/captcha/antiCaptcha/AntiCaptchaProvider.java index f974922..b29c5b5 100644 --- a/KinanCity-captcha-AntiCaptcha/src/main/java/com/kinancity/core/captcha/antiCaptcha/AntiCaptchaProvider.java +++ b/KinanCity-captcha-AntiCaptcha/src/main/java/com/kinancity/core/captcha/antiCaptcha/AntiCaptchaProvider.java @@ -367,5 +367,4 @@ private Request buildBalanceCheckequestGet() throws JsonProcessingException { .build(); return request; } - } diff --git a/KinanCity-captcha-client/src/main/java/com/kinancity/captcha/client/ClientProvider.java b/KinanCity-captcha-client/src/main/java/com/kinancity/captcha/client/ClientProvider.java index 0769784..36efce6 100644 --- a/KinanCity-captcha-client/src/main/java/com/kinancity/captcha/client/ClientProvider.java +++ b/KinanCity-captcha-client/src/main/java/com/kinancity/captcha/client/ClientProvider.java @@ -7,11 +7,17 @@ public class ClientProvider extends AntiCaptchaProvider { - private String captchaInUrl = "http://localhost:8888/captcha/in"; - private String captchaOutUrl = "http://localhost:8888/captcha/out"; + private static final String CAPTCHA_RETRIEIVE_URL = "http://localhost:8888/captcha/retrieive"; + private static final String CAPTCHA_SUBMIT_URL = "http://localhost:8888/captcha/submit"; + private static final String CAPTCHA_BALANCE_URL = "http://localhost:8888/captcha/balance"; public static CaptchaProvider getInstance(CaptchaQueue queue) throws CaptchaException { - return new ClientProvider(queue); + ClientProvider provider = new ClientProvider(queue); + provider.setCaptchaBalanceUrl(CAPTCHA_BALANCE_URL); + provider.setCaptchaSubmitUrl(CAPTCHA_SUBMIT_URL); + provider.setCaptchaRetrieveUrl(CAPTCHA_RETRIEIVE_URL); + provider.setWaitBeforeRetry(200); + return provider; } public ClientProvider(CaptchaQueue queue) throws CaptchaException { diff --git a/KinanCity-captcha-server/src/main/java/com/kinancity/captcha/server/SolvingService.java b/KinanCity-captcha-server/src/main/java/com/kinancity/captcha/server/SolvingService.java index 70b38b8..c820b86 100644 --- a/KinanCity-captcha-server/src/main/java/com/kinancity/captcha/server/SolvingService.java +++ b/KinanCity-captcha-server/src/main/java/com/kinancity/captcha/server/SolvingService.java @@ -48,7 +48,7 @@ public void addSolutionToSite(String googleSiteKey, String solution) { } public void addSolution(String solution) { - CaptchaJob job = jobs.values().stream().findFirst().orElse(null); + CaptchaJob job = jobs.values().stream().filter(j -> j.getSolution() == null).findFirst().orElse(null); if (job != null) { job.setSolution(solution); } @@ -60,7 +60,7 @@ public CaptchaJob getNextJob(){ private Integer nextAvailableJobId() { log.debug("Get next available counter value"); - counter = counter++ % max; + counter = (counter + 1) % max; return counter; } }