-
-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DPS 3 - Query response not set fix (#295)
* better clone than change the requested object, fixing flags on the response * Fixing headers * adjusting logs * new release
- Loading branch information
Showing
22 changed files
with
257 additions
and
71 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
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
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
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
35 changes: 35 additions & 0 deletions
35
src/main/java/com/mageddo/dnsproxyserver/server/dns/solver/SolverMock.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,35 @@ | ||
package com.mageddo.dnsproxyserver.server.dns.solver; | ||
|
||
import com.mageddo.dnsproxyserver.server.dns.IP; | ||
import com.mageddo.dnsproxyserver.server.dns.Messages; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.apache.commons.lang3.tuple.Pair; | ||
import org.xbill.DNS.Message; | ||
|
||
import java.util.List; | ||
import java.util.stream.Stream; | ||
|
||
@Slf4j | ||
public class SolverMock implements Solver { | ||
|
||
private final List<Pair<String, IP>> mocks; | ||
|
||
public SolverMock(Pair<String, IP>... mocks) { | ||
this(Stream.of(mocks).toList()); | ||
} | ||
|
||
public SolverMock(List<Pair<String, IP>> mocks) { | ||
this.mocks = mocks; | ||
} | ||
|
||
@Override | ||
public Message handle(Message query) { | ||
final var hostname = Messages.findQuestionHostname(query); | ||
for (final var entry : this.mocks) { | ||
if (entry.getKey().equalsIgnoreCase(hostname.getValue())) { | ||
return Messages.aAnswer(query, entry.getValue().raw()); | ||
} | ||
} | ||
return null; | ||
} | ||
} |
Oops, something went wrong.