File tree Expand file tree Collapse file tree 1 file changed +25
-1
lines changed Expand file tree Collapse file tree 1 file changed +25
-1
lines changed Original file line number Diff line number Diff line change 23
23
then ''"${ s } "''
24
24
else concatMapStringsSep " " ( x : ''"${ x } "'' ) ( splitInGroupsOf 255 s ) ;
25
25
26
+ # : str -> str, with length 4 (zeros are padded to the left)
27
+ align4Bytes = lib . fixedWidthString 4 "0" ;
28
+
29
+ # : int -> str -> str
30
+ # Expands "" to 4n zeros and aligns the rest on 4 bytes
31
+ align4BytesOrExpand = n : v :
32
+ if v == ""
33
+ then ( lib . fixedWidthString ( 4 * n ) "0" "" )
34
+ else align4Bytes v ;
35
+
36
+ # : str -> [ str ]
37
+ # Returns the record of the ipv6 as a list
38
+ mkRecordAux = v6 :
39
+ let
40
+ splitted = lib . splitString ":" v6 ;
41
+ n = 8 - builtins . length ( lib . filter ( x : x != "" ) splitted ) ;
42
+ in
43
+ lib . stringToCharacters ( lib . concatMapStrings ( align4BytesOrExpand n ) splitted ) ;
44
+
45
+ # : str -> str
46
+ # Returns the reversed record of the ipv6
47
+ mkReverseRecord = v6 :
48
+ lib . concatStringsSep "." ( lib . reverseList ( mkRecordAux v6 ) ) + ".ip6.arpa" ;
49
+
26
50
in {
27
- inherit writeCharacterString ;
51
+ inherit writeCharacterString mkReverseRecord ;
28
52
}
You can’t perform that action at this time.
0 commit comments