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 =
|
||||
let
|
||||
generateRecordsForInterface = ifaceName: ifaceConfig:
|
||||
lib.concatStringsSep "\n" (lib.mapAttrsToList (deviceName: deviceConfig:
|
||||
if deviceConfig.dnsResolvableName != null then
|
||||
lib.concatStringsSep "\n" (lib.mapAttrsToList
|
||||
(deviceName: deviceConfig:
|
||||
if deviceConfig.hostname!= null then
|
||||
let
|
||||
serverIP = deviceConfig.address;
|
||||
interfaceNet = ifaceConfig.net;
|
||||
domain = deviceConfig.dnsResolvableName;
|
||||
deviceAddress = deviceConfig.address;
|
||||
deviceIface = ifaceConfig.net;
|
||||
deviceHost = deviceConfig.hostname;
|
||||
in
|
||||
''
|
||||
${domain} {
|
||||
${deviceHost} {
|
||||
view ${ifaceName} {
|
||||
expr incidr(client_ip(), '${interfaceNet}')
|
||||
expr incidr(client_ip(), '${deviceIface}')
|
||||
}
|
||||
|
||||
template IN A ${domain} {
|
||||
answer "${domain}. 60 IN A ${serverIP}"
|
||||
template IN A ${deviceHost} {
|
||||
answer "${deviceHost}. 60 IN A ${deviceAddress}"
|
||||
}
|
||||
|
||||
cache
|
||||
@ -144,7 +145,8 @@ in
|
||||
}
|
||||
''
|
||||
else ""
|
||||
) ifaceConfig.devices);
|
||||
)
|
||||
ifaceConfig.devices);
|
||||
in
|
||||
lib.concatStringsSep "\n" (lib.mapAttrsToList generateRecordsForInterface config.pepe.core.network.interfaces);
|
||||
in
|
||||
|
@ -42,12 +42,6 @@ in
|
||||
default = false;
|
||||
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 = { };
|
||||
@ -61,7 +55,7 @@ in
|
||||
|
||||
interfacesByType = mkOption {
|
||||
type = types.attrsOf (types.listOf types.str);
|
||||
default = {};
|
||||
default = { };
|
||||
description = "Interfaces grouped by type (lan, wan, vpn) for easy access.";
|
||||
internal = true;
|
||||
};
|
||||
@ -91,7 +85,7 @@ in
|
||||
};
|
||||
};
|
||||
});
|
||||
default = {};
|
||||
default = { };
|
||||
description = "DNS endpoints for each interface.";
|
||||
internal = true;
|
||||
};
|
||||
@ -126,7 +120,7 @@ in
|
||||
(acc: ifaceName:
|
||||
acc // (collectEndpoints ifaceName cfg.interfaces.${ifaceName})
|
||||
)
|
||||
{}
|
||||
{ }
|
||||
(lib.attrNames cfg.interfaces);
|
||||
};
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user