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 boolean apply(String userAgent) {
}
};

private static final ImmutableSet<String> HOSTNAMES = ImmutableSet.of("googlebot.com");
private static final ImmutableSet<String> HOSTNAMES = ImmutableSet.of("googlebot.com", "google.com");


private static final GooglebotData INSTANCE = new GooglebotData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,19 @@ public class KnownHostBotVerifierBuilder {


public KnownHostBotVerifierBuilder crawlerData(@NotNull CrawlerData crawlerData) {
if (this.crawlerData!=null) throw new IllegalStateException("The crawlerData was set already!");
if (this.crawlerData != null) throw new IllegalStateException("The crawlerData was set already!");
this.crawlerData = crawlerData;
return this;
}

/**
*/
public KnownHostBotVerifierBuilder dnsVerifier(@NotNull ReverseDnsVerifier dnsVerifier) {
if (this.dnsVerifier!=null) throw new IllegalStateException("The dnsVerifier was set already!");
if (this.dnsVerifier != null) throw new IllegalStateException("The dnsVerifier was set already!");
this.dnsVerifier = dnsVerifier;
return this;
}

/**
* Uses the {@link DnsjavaReverseDnsVerifier} with the default name server(s) provided by the system.
*/
Expand All @@ -43,26 +44,27 @@ public KnownHostBotVerifierBuilder dnsVerifierDefault() {
* If you must, for testing, then pass in a dummy cache that drops all.
*/
public KnownHostBotVerifierBuilder dnsResultCache(@NotNull Cache<String, BotCheckerResult> dnsResultCache) {
if (this.dnsResultCache !=null) throw new IllegalStateException("The dnsResultCache was set already!");
if (this.dnsResultCache != null) throw new IllegalStateException("The dnsResultCache was set already!");
this.dnsResultCache = dnsResultCache;
return this;
}

/**
* Uses maximumSize(1_000) and expireAfterWrite(3*24, TimeUnit.HOURS)
*/
public KnownHostBotVerifierBuilder dnsResultCacheDefault() {
Cache<String, BotCheckerResult> cache = CacheBuilder.newBuilder()
.maximumSize(1_000)
.expireAfterWrite(3*24, TimeUnit.HOURS)
.expireAfterWrite(3 * 24, TimeUnit.HOURS)
.build();
return dnsResultCache(cache);
}


@NotNull
public KnownHostBotVerifierImpl build() {
if (dnsVerifier==null) throw new IllegalArgumentException("No dnsVerifier provided!");
if (dnsResultCache ==null) throw new IllegalArgumentException("No cache provided!");
public KnownHostBotVerifier build() {
if (dnsVerifier == null) throw new IllegalArgumentException("No dnsVerifier provided!");
if (dnsResultCache == null) throw new IllegalArgumentException("No cache provided!");
return new KnownHostBotVerifierImpl(crawlerData, dnsVerifier, dnsResultCache);
}

Expand Down