1 import ../make-test-python.nix ({ lib, pkgs, ... }:
4 dnstapSocket = "/var/run/vector/dnstap.sock";
7 name = "vector-dnstap";
8 meta.maintainers = [ pkgs.lib.maintainers.happysalada ];
11 unbound = { config, pkgs, ... }: {
12 networking.firewall.allowedUDPPorts = [ 53 ];
23 lowercase_hostnames = true;
24 socket_file_mode = 504;
25 socket_path = "${dnstapSocket}";
32 inputs = [ "dnstap" ];
33 path = "/var/lib/vector/logs.log";
34 encoding = { codec = "json"; };
40 systemd.services.vector.serviceConfig = {
41 RuntimeDirectory = "vector";
42 RuntimeDirectoryMode = "0770";
47 enableRootTrustAnchor = false;
48 package = pkgs.unbound-full;
51 interface = [ "0.0.0.0" "::" ];
52 access-control = [ "192.168.0.0/24 allow" "::/0 allow" ];
54 domain-insecure = "local";
55 private-domain = "local";
57 local-zone = "local. static";
59 ''"test.local. 10800 IN A 192.168.123.5"''
64 dnstap-enable = "yes";
65 dnstap-socket-path = "${dnstapSocket}";
66 dnstap-send-identity = "yes";
67 dnstap-send-version = "yes";
68 dnstap-log-client-query-messages = "yes";
69 dnstap-log-client-response-messages = "yes";
74 systemd.services.unbound = {
75 after = [ "vector.service" ];
76 wants = [ "vector.service" ];
79 ReadWritePaths = [ "/var/run/vector" ];
80 SupplementaryGroups = [ "vector" ];
85 dnsclient = { config, pkgs, ... }: {
86 environment.systemPackages = [ pkgs.dig ];
91 unbound.wait_for_unit("unbound")
92 unbound.wait_for_unit("vector")
94 unbound.wait_until_succeeds(
95 "journalctl -o cat -u vector.service | grep 'Socket permissions updated to 0o770'"
97 unbound.wait_until_succeeds(
98 "journalctl -o cat -u vector.service | grep 'component_type=dnstap' | grep 'Listening... path=\"${dnstapSocket}\"'"
101 unbound.wait_for_file("${dnstapSocket}")
102 unbound.succeed("test 770 -eq $(stat -c '%a' ${dnstapSocket})")
104 dnsclient.wait_for_unit("network-online.target")
106 "dig @unbound test.local"
109 unbound.wait_for_file("/var/lib/vector/logs.log")
111 unbound.wait_until_succeeds(
112 "grep ClientQuery /var/lib/vector/logs.log | grep '\"domainName\":\"test.local.\"' | grep '\"rcodeName\":\"NoError\"'"
114 unbound.wait_until_succeeds(
115 "grep ClientResponse /var/lib/vector/logs.log | grep '\"domainName\":\"test.local.\"' | grep '\"rData\":\"192.168.123.5\"'"