Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public DefaultKnownCrawlerDetector(@NotNull List<KnownHostBotVerifier> verifiers

@NotNull
@Override
public Optional<KnownCrawlerResult> detect(@NotNull String userAgent, @NotNull String ip) {
public Optional<KnownCrawlerResult> detect(String userAgent, @NotNull String ip) {
for (KnownHostBotVerifier verifier : verifiers) {
BotCheckerResult check = verifier.check(userAgent, ip);
if (check != BotCheckerResult.IS_NOT) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ public interface KnownCrawlerDetector {
* @return absent if none detected.
*/
@NotNull
Optional<KnownCrawlerResult> detect(@NotNull String userAgent, @NotNull String ip);
Optional<KnownCrawlerResult> detect(String userAgent, @NotNull String ip);

}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ public interface KnownHostBotVerifier {
* @return
*/
@NotNull
BotCheckerResult check(@NotNull String userAgent, @NotNull String ip);
BotCheckerResult check(String userAgent, @NotNull String ip);

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

import java.util.Set;

import static com.google.common.base.Strings.isNullOrEmpty;

/**
*
*/
Expand Down Expand Up @@ -38,8 +40,8 @@ public String getIdentifier() {

@Override
@NotNull
public BotCheckerResult check(@NotNull String userAgent, @NotNull String ip) {
if (!crawlerData.getUserAgentChecker().apply(userAgent)) {
public BotCheckerResult check(String userAgent, @NotNull String ip) {
if (isNullOrEmpty(userAgent) || !crawlerData.getUserAgentChecker().apply(userAgent)) {
return BotCheckerResult.IS_NOT;
} else {
Set<String> permittedIps = crawlerData.getIps();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class DefaultKnownCrawlerDetectorTest {
public void none() throws Exception {
DefaultKnownCrawlerDetector detector = all();
assertFalse(detector.detect("", "127.0.0.1").isPresent());
assertFalse(detector.detect(null, "127.0.0.1").isPresent());
}

/**
Expand Down