-
-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactoring solver remote class * fixing compiling errors * fixing compiling errors * reverting * fixing compiling errors * fixing compiling errors * release notes * [Gradle Release Plugin] - new version commit: '3.30.3-snapshot'. * refactoring
- Loading branch information
Showing
21 changed files
with
387 additions
and
309 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
version=3.30.2-snapshot | ||
version=3.30.3-snapshot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
src/main/java/com/mageddo/dnsproxyserver/solver/remote/application/RemoteResultSupplier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package com.mageddo.dnsproxyserver.solver.remote.application; | ||
|
||
import com.mageddo.dnsproxyserver.solver.remote.Request; | ||
import com.mageddo.dnsproxyserver.solver.remote.Result; | ||
import com.mageddo.dnsproxyserver.solver.remote.application.mapper.ResultMapper; | ||
import com.mageddo.net.IpAddr; | ||
import com.mageddo.net.NetExecutorWatchdog; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.xbill.DNS.Message; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
import java.util.concurrent.Executor; | ||
|
||
@Slf4j | ||
public class RemoteResultSupplier implements ResultSupplier { | ||
|
||
public static final int PING_TIMEOUT_IN_MS = 1_500; | ||
|
||
private final Request req; | ||
private final Executor executor; | ||
private final NetExecutorWatchdog netWatchdog; | ||
|
||
public RemoteResultSupplier(Request req, Executor executor, NetExecutorWatchdog netWatchdog) { | ||
this.req = req; | ||
this.executor = executor; | ||
this.netWatchdog = netWatchdog; | ||
} | ||
|
||
@Override | ||
public Result get() { | ||
return this.queryResult(this.req); | ||
} | ||
|
||
Result queryResult(Request req) { | ||
final var resFuture = this.sendQueryAsyncToResolver(req); | ||
if (this.isPingWhileGettingQueryResponseActive()) { | ||
this.pingWhileGettingQueryResponse(req, resFuture); | ||
} | ||
return ResultMapper.from(resFuture, req); | ||
} | ||
|
||
CompletableFuture<Message> sendQueryAsyncToResolver(Request req) { | ||
return req.sendQueryAsyncToResolver(this.executor); | ||
} | ||
|
||
boolean isPingWhileGettingQueryResponseActive() { | ||
return Boolean.getBoolean("mg.solverRemote.pingWhileGettingQueryResponse"); | ||
} | ||
|
||
void pingWhileGettingQueryResponse(Request req, CompletableFuture<Message> resFuture) { | ||
this.netWatchdog.watch(req.getResolverAddr(), resFuture, PING_TIMEOUT_IN_MS); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return String.format("server=%s", this.req.getResolverAddr()); | ||
} | ||
|
||
@Override | ||
public IpAddr getRemoteAddress() { | ||
return this.req.getResolverAddr(); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/com/mageddo/dnsproxyserver/solver/remote/application/ResultSupplier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.mageddo.dnsproxyserver.solver.remote.application; | ||
|
||
import com.mageddo.dnsproxyserver.solver.remote.Result; | ||
import com.mageddo.net.IpAddr; | ||
|
||
import java.util.function.Supplier; | ||
|
||
public interface ResultSupplier extends Supplier<Result> { | ||
IpAddr getRemoteAddress(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.