feat: Allow network devices to define DNS resolvable names
This commit is contained in:
parent
9e8e7169d3
commit
44af2887a5
@ -117,8 +117,41 @@ in
|
|||||||
|
|
||||||
allDomains = config.pepe.core.vhost.hosts // cfg.extraDomains;
|
allDomains = config.pepe.core.vhost.hosts // cfg.extraDomains;
|
||||||
in
|
in
|
||||||
|
let
|
||||||
|
# Function to generate DNS records for individual devices based on dnsResolvableName
|
||||||
|
generateDeviceHostRecords =
|
||||||
|
let
|
||||||
|
generateRecordsForInterface = ifaceName: ifaceConfig:
|
||||||
|
lib.concatStringsSep "\n" (lib.mapAttrsToList (deviceName: deviceConfig:
|
||||||
|
if deviceConfig.dnsResolvableName != null then
|
||||||
|
let
|
||||||
|
serverIP = deviceConfig.address;
|
||||||
|
interfaceNet = ifaceConfig.net;
|
||||||
|
domain = deviceConfig.dnsResolvableName;
|
||||||
|
in
|
||||||
|
''
|
||||||
|
${domain} {
|
||||||
|
view ${ifaceName} {
|
||||||
|
expr incidr(client_ip(), '${interfaceNet}')
|
||||||
|
}
|
||||||
|
|
||||||
|
template IN A ${domain} {
|
||||||
|
answer "${domain}. 60 IN A ${serverIP}"
|
||||||
|
}
|
||||||
|
|
||||||
|
cache
|
||||||
|
log
|
||||||
|
}
|
||||||
|
''
|
||||||
|
else ""
|
||||||
|
) ifaceConfig.devices);
|
||||||
|
in
|
||||||
|
lib.concatStringsSep "\n" (lib.mapAttrsToList generateRecordsForInterface config.pepe.core.network.interfaces);
|
||||||
|
in
|
||||||
''
|
''
|
||||||
${generateCoreDNSConfig allDomains}
|
${generateCoreDNSConfig allDomains}
|
||||||
|
|
||||||
|
${generateDeviceHostRecords}
|
||||||
|
|
||||||
${allDeviceViews}
|
${allDeviceViews}
|
||||||
|
|
||||||
|
@ -41,7 +41,13 @@ in
|
|||||||
type = types.bool;
|
type = types.bool;
|
||||||
default = false;
|
default = false;
|
||||||
description = "Whether this device serves as a DNS endpoint for this interface.";
|
description = "Whether this device serves as a DNS endpoint for this interface.";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
dnsResolvableName = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = null;
|
||||||
|
description = "The fully qualified domain name that should resolve to this device's IP address. e.g., my-device.lan.example.com";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
default = { };
|
default = { };
|
||||||
|
Loading…
x
Reference in New Issue
Block a user