refactor(dns/network): replace dnsResolvableName
with hostname
and restructure DNS record generation
- Replaced `dnsResolvableName` with `hostname` in device configuration options - Updated DNS record generation logic to use `hostname` instead of domain-based naming - Removed deprecated `dnsResolvableName` option from network module - Restructured DNS record templates to use consistent formatting - Simplified code structure by removing redundant whitespace and reorganizing attribute definitions - Updated `generateDeviceHostRecords` to use new naming convention and improved template syntax
This commit is contained in:
parent
0e513e1c69
commit
184f039e40
@ -122,21 +122,22 @@ in
|
|||||||
generateDeviceHostRecords =
|
generateDeviceHostRecords =
|
||||||
let
|
let
|
||||||
generateRecordsForInterface = ifaceName: ifaceConfig:
|
generateRecordsForInterface = ifaceName: ifaceConfig:
|
||||||
lib.concatStringsSep "\n" (lib.mapAttrsToList (deviceName: deviceConfig:
|
lib.concatStringsSep "\n" (lib.mapAttrsToList
|
||||||
if deviceConfig.dnsResolvableName != null then
|
(deviceName: deviceConfig:
|
||||||
|
if deviceConfig.hostname!= null then
|
||||||
let
|
let
|
||||||
serverIP = deviceConfig.address;
|
deviceAddress = deviceConfig.address;
|
||||||
interfaceNet = ifaceConfig.net;
|
deviceIface = ifaceConfig.net;
|
||||||
domain = deviceConfig.dnsResolvableName;
|
deviceHost = deviceConfig.hostname;
|
||||||
in
|
in
|
||||||
''
|
''
|
||||||
${domain} {
|
${deviceHost} {
|
||||||
view ${ifaceName} {
|
view ${ifaceName} {
|
||||||
expr incidr(client_ip(), '${interfaceNet}')
|
expr incidr(client_ip(), '${deviceIface}')
|
||||||
}
|
}
|
||||||
|
|
||||||
template IN A ${domain} {
|
template IN A ${deviceHost} {
|
||||||
answer "${domain}. 60 IN A ${serverIP}"
|
answer "${deviceHost}. 60 IN A ${deviceAddress}"
|
||||||
}
|
}
|
||||||
|
|
||||||
cache
|
cache
|
||||||
@ -144,7 +145,8 @@ in
|
|||||||
}
|
}
|
||||||
''
|
''
|
||||||
else ""
|
else ""
|
||||||
) ifaceConfig.devices);
|
)
|
||||||
|
ifaceConfig.devices);
|
||||||
in
|
in
|
||||||
lib.concatStringsSep "\n" (lib.mapAttrsToList generateRecordsForInterface config.pepe.core.network.interfaces);
|
lib.concatStringsSep "\n" (lib.mapAttrsToList generateRecordsForInterface config.pepe.core.network.interfaces);
|
||||||
in
|
in
|
||||||
|
@ -42,12 +42,6 @@ in
|
|||||||
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