Files
mdg-filius/tools/java-oracle/src/DnsRun.java
T
julian.kiedaischandClaude Opus 5.5 313786e738 feat(core): recursive DNS server after Java, measured with Java FILIUS
The resolver runs on the events now (a query, its dnsQueryTimeout, its
answer at the socket); the blocking resolveDns waits for it, and a
recursive server uses it: its own records, else the zone's name server
from its records, else its own DNS server, else a referral
(DNSServer.answerWithRemoteData).

DnsRun plays five stories on the new dns-recursive network. Measured and
not taken: a server that is its zone's name server asks itself, which asks
itself again, without end (the client times out, then every level floods
its own DNS server); Java guards only the step through its own DNS server.
The core asks itself in neither step. That story is compared up to the
client's query (JAVA_UNTIL).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 18:46:32 +00:00

98 lines
4.0 KiB
Java

// Runs a DNS lookup on dns-lan's network in Java FILIUS (ScenarioNetwork)
// and records what really happens: every frame each card saw, and when the
// resolver's call started and what it returned (or that it failed).
//
// DnsRun <scenario.json> <story> <milliseconds> <out.json>
//
// Server 192.168.0.10 knows web.filius.de, filius.de's mail exchange and
// refers schule.de to 192.168.0.11, which knows www.schule.de. The stories,
// each the resolver of a client (Resolver, as FILIUS' programs call it):
// address 192.168.0.20 asks for web.filius.de (A)
// mail 192.168.0.20 asks for filius.de's mail server (MX, then its A)
// referral 192.168.0.20 asks for www.schule.de (A), referred to .11
// unknown 192.168.0.20 asks for x.unbekannt.org, which no one knows
// noServer 192.168.0.21 asks its DNS server 192.168.0.99, which is not there
//
// On dns-recursive's network .10 resolves recursively, its own DNS server is
// .11, and it holds filius.de's NS record, which names itself. There also:
// unknownInZone 192.168.0.20 asks for nix.schule.de, which .11 does not know
// unknownInOwnZone 192.168.0.20 asks for nix.filius.de, in .10's own zone
import filius.software.dns.Resolver;
import java.util.ArrayList;
import java.util.List;
public class DnsRun {
static final String CLIENT = "00000000-0000-0000-0000-000000000101";
static final String LOST_CLIENT = "00000000-0000-0000-0000-000000000104";
static ScenarioNetwork network;
static final List<Object[]> events = new ArrayList<>();
interface Call {
String run() throws Exception;
}
static void event(String what) {
events.add(new Object[] { System.currentTimeMillis() - network.start, what });
}
static void call(String label, Call call) {
event(label + " called");
try {
event(label + " returned " + call.run());
} catch (Exception e) {
event(label + " failed " + e.getClass().getSimpleName());
}
}
public static void main(String[] args) throws Exception {
network = ScenarioNetwork.read(args[0]);
String story = args[1];
long end = Long.parseLong(args[2]);
network.start();
Thread.sleep(500);
Resolver client = network.system(CLIENT).holeDNSClient();
switch (story) {
case "address":
call("holeIPAdresse web.filius.de", () -> client.holeIPAdresse("web.filius.de"));
break;
case "mail":
call("holeIPAdresseMailServer filius.de", () -> client.holeIPAdresseMailServer("filius.de"));
break;
case "referral":
call("holeIPAdresse www.schule.de", () -> client.holeIPAdresse("www.schule.de"));
break;
case "unknown":
call("holeIPAdresse x.unbekannt.org", () -> client.holeIPAdresse("x.unbekannt.org"));
break;
case "unknownInZone":
call("holeIPAdresse nix.schule.de", () -> client.holeIPAdresse("nix.schule.de"));
break;
case "unknownInOwnZone":
call("holeIPAdresse nix.filius.de", () -> client.holeIPAdresse("nix.filius.de"));
break;
case "noServer":
Resolver lost = network.system(LOST_CLIENT).holeDNSClient();
call("holeIPAdresse web.filius.de", () -> lost.holeIPAdresse("web.filius.de"));
break;
default:
throw new IllegalArgumentException("unknown story " + story);
}
long rest = network.start + end - System.currentTimeMillis();
if (rest > 0) Thread.sleep(rest);
ScenarioNetwork.Json out = new ScenarioNetwork.Json();
out.open('{');
network.writeFrames(out);
out.key("events").open('[');
for (Object[] each : events) out.open('[').number((Long) each[0]).string((String) each[1]).close(']');
out.close(']');
out.close('}');
network.stop();
ScenarioNetwork.write(args[3], out);
System.exit(0);
}
}