feat: the right width for records will now be auto calculated
This commit is contained in:
parent
15e534c222
commit
1a07781c4d
1 changed files with 19 additions and 8 deletions
|
@ -30,7 +30,18 @@
|
|||
sort_records_ptr = builtins.sort (a: b: (lib.strings.toInt a.record) < (lib.strings.toInt b.record)) (process_ptr (filter_records_type "PTR"));
|
||||
sort_records_srv = builtins.sort (a: b: a.record < b.record) (filter_records_type "SRV");
|
||||
|
||||
format_records = records: offset: lib.strings.concatMapStrings (x: "${padString x.record offset} IN ${padString x.r_type 5} ${x.value}\n") records;
|
||||
max = x: y:
|
||||
assert builtins.isInt x;
|
||||
assert builtins.isInt y;
|
||||
if x < y
|
||||
then y
|
||||
else x;
|
||||
max_len = records: lib.lists.foldr (a: b: (max a b)) 0 (lib.lists.forEach records (record: lib.strings.stringLength record.record));
|
||||
|
||||
format_records = records: let
|
||||
offset = (max_len records) + 1;
|
||||
in
|
||||
lib.strings.concatMapStrings (x: "${padString x.record offset} IN ${padString x.r_type 5} ${x.value}\n") records;
|
||||
|
||||
# small function to trim it down a tad
|
||||
padString = text: length: fixedWidthString_post length " " text;
|
||||
|
@ -72,32 +83,32 @@
|
|||
; ------------------------------------------
|
||||
; Server Names (A Records)
|
||||
; ------------------------------------------
|
||||
${format_records sort_records_server 31}
|
||||
${format_records sort_records_server}
|
||||
|
||||
; ------------------------------------------
|
||||
; A (non server names
|
||||
; ------------------------------------------
|
||||
${format_records sort_records_a 31}
|
||||
${format_records sort_records_a}
|
||||
|
||||
; ------------------------------------------
|
||||
; CNAMES
|
||||
; ------------------------------------------
|
||||
${format_records sort_records_cname 31}
|
||||
${format_records sort_records_cname}
|
||||
|
||||
; ------------------------------------------
|
||||
; TXT
|
||||
; ------------------------------------------
|
||||
${format_records (filter_records_type "TXT") 31}
|
||||
${format_records (filter_records_type "TXT")}
|
||||
|
||||
; ------------------------------------------
|
||||
; MX
|
||||
; ------------------------------------------
|
||||
${format_records (filter_records_type "MX") 31}
|
||||
${format_records (filter_records_type "MX")}
|
||||
|
||||
; ------------------------------------------
|
||||
; SRV
|
||||
; ------------------------------------------
|
||||
${format_records sort_records_srv 65}
|
||||
${format_records sort_records_srv}
|
||||
|
||||
|
||||
''
|
||||
|
@ -125,7 +136,7 @@
|
|||
; ------------------------------------------
|
||||
; PTR
|
||||
; ------------------------------------------
|
||||
${format_records sort_records_ptr 3}
|
||||
${format_records sort_records_ptr}
|
||||
''
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in a new issue