diff --git a/jDnsProxy/src/main/java/com/moparisthebest/dns/resolve/BaseRequestResponse.java b/jDnsProxy/src/main/java/com/moparisthebest/dns/resolve/BaseRequestResponse.java index a12ba09..defd98c 100644 --- a/jDnsProxy/src/main/java/com/moparisthebest/dns/resolve/BaseRequestResponse.java +++ b/jDnsProxy/src/main/java/com/moparisthebest/dns/resolve/BaseRequestResponse.java @@ -11,8 +11,6 @@ public class BaseRequestResponse implements RequestResponse { private Packet request, response; - private String requestPacketKey; - public BaseRequestResponse() { } @@ -39,22 +37,11 @@ public class BaseRequestResponse implements RequestResponse { this.response = response; } - @Override - public String getRequestPacketKey() { - return requestPacketKey; - } - - @Override - public void setRequestPacketKey(final String requestPacketKey) { - this.requestPacketKey = requestPacketKey; - } - @Override public String toString() { return "BaseRequestResponse{" + "request=" + request + ", response=" + response + - ", requestPacketKey=" + requestPacketKey + '}'; } } diff --git a/jDnsProxy/src/main/java/com/moparisthebest/dns/resolve/CacheResolver.java b/jDnsProxy/src/main/java/com/moparisthebest/dns/resolve/CacheResolver.java index 6573139..19919d8 100644 --- a/jDnsProxy/src/main/java/com/moparisthebest/dns/resolve/CacheResolver.java +++ b/jDnsProxy/src/main/java/com/moparisthebest/dns/resolve/CacheResolver.java @@ -99,8 +99,7 @@ public class CacheResolver extends WrappingResolver { final long currentTime = currentTimeSeconds(); if (response.isExpired(currentTime)) { //System.out.println("cachedPacket isExpired!"); - requestResponse.setRequestPacketKey(key); - final CompletableFuture request = requestAndCache(requestResponse, executor); + final CompletableFuture request = requestAndCache(key, requestResponse, executor); final CompletableFuture stale = supplyAsyncOnTimeOut(scheduledExecutorService, staleResponseTimeout, TimeUnit.MILLISECONDS, () -> { requestResponse.setResponse(response.getStaleResponse().setId(requestResponse.getRequest().getId())); return requestResponse; @@ -113,8 +112,7 @@ public class CacheResolver extends WrappingResolver { } } //System.out.println("no cachedPacket, querying upstream!"); - requestResponse.setRequestPacketKey(key); - return requestAndCache(requestResponse, executor); + return requestAndCache(key, requestResponse, executor); /* // todo: should not have to do this, some upstreams seem to eat stuff though, figure that out, I think readTimeout fixed this final CompletableFuture request = requestAndCache(requestResponse); @@ -125,12 +123,12 @@ public class CacheResolver extends WrappingResolver { */ } - private CompletableFuture requestAndCache(final E requestResponse, final Executor executor) { + private CompletableFuture requestAndCache(final String key, final E requestResponse, final Executor executor) { final CompletableFuture request = delegate.resolveAsync(requestResponse, executor); request.thenAcceptAsync(s -> { final Packet response = s.getResponse().copy(); // todo: do we need to copy? final long currentTime = currentTimeSeconds(); - cache.put(s.getRequestPacketKey(), new CachedPacket(response, currentTime, currentTime + response.getLowestTtl())); + cache.put(key, new CachedPacket(response, currentTime, currentTime + response.getLowestTtl())); }, executor); return request; } diff --git a/jDnsProxy/src/main/java/com/moparisthebest/dns/resolve/RequestResponse.java b/jDnsProxy/src/main/java/com/moparisthebest/dns/resolve/RequestResponse.java index bc2d7de..c915ef1 100644 --- a/jDnsProxy/src/main/java/com/moparisthebest/dns/resolve/RequestResponse.java +++ b/jDnsProxy/src/main/java/com/moparisthebest/dns/resolve/RequestResponse.java @@ -8,10 +8,4 @@ public interface RequestResponse { Packet getRequest(); Packet getResponse(); void setResponse(Packet response); - - /** - * These should only be used by resolvers, may be null - */ - String getRequestPacketKey(); - void setRequestPacketKey(String key); }