Bump to 1.14.1
[platform/upstream/augeas.git] / lenses / resolv.aug
1 (*
2 Module: Resolv
3   Parses /etc/resolv.conf
4
5 Author: Raphael Pinson <raphink@gmail.com>
6
7 About: Reference
8   This lens tries to keep as close as possible to `man resolv.conf` where possible.
9
10 About: Licence
11   This file is licensed under the LGPL v2+, like the rest of Augeas.
12
13 About: Lens Usage
14
15 About: Configuration files
16   This lens applies to /etc/resolv.conf. See <filter>.
17 *)
18
19 module Resolv =
20 autoload xfm
21
22 (************************************************************************
23  * Group:                 USEFUL PRIMITIVES
24  *************************************************************************)
25
26 (* View: comment *)
27 let comment = Util.comment_generic /[ \t]*[;#][ \t]*/ "# "
28
29 (* View: comment_eol *)
30 let comment_eol = Util.comment_generic /[ \t]*[;#][ \t]*/ " # "
31
32 (* View: empty *)
33 let empty = Util.empty_generic_dos /[ \t]*[#;]?[ \t]*/
34
35
36 (************************************************************************
37  * Group:                 MAIN OPTIONS
38  *************************************************************************)
39
40 (* View: netmask
41 A network mask for IP addresses *)
42 let netmask = [ label "netmask" . Util.del_str "/" . store Rx.ip ]
43
44 (* View: ipaddr
45 An IP address or range with an optional mask *)
46 let ipaddr = [label "ipaddr" . store Rx.ip . netmask?]
47
48
49 (* View: nameserver
50      A nameserver entry *)
51 let nameserver = Build.key_value_line_comment
52                     "nameserver" Sep.space (store Rx.ip) comment_eol
53
54 (* View: domain *)
55 let domain = Build.key_value_line_comment
56                     "domain" Sep.space (store Rx.word) comment_eol
57
58 (* View: search *)
59 let search = Build.key_value_line_comment
60                     "search" Sep.space
61                     (Build.opt_list
62                            [label "domain" . store Rx.word]
63                             Sep.space)
64                     comment_eol
65
66 (* View: sortlist *)
67 let sortlist = Build.key_value_line_comment
68                     "sortlist" Sep.space
69                     (Build.opt_list
70                            ipaddr
71                            Sep.space)
72                     comment_eol
73
74 (* View: lookup *)
75 let lookup =
76   let lookup_entry = Build.flag("bind"|"file"|"yp")
77     in Build.key_value_line_comment
78              "lookup" Sep.space
79              (Build.opt_list
80                     lookup_entry
81                     Sep.space)
82              comment_eol
83
84 (* View: family *)
85 let family =
86   let family_entry = Build.flag("inet4"|"inet6")
87     in Build.key_value_line_comment
88              "family" Sep.space
89              (Build.opt_list
90                     family_entry
91                     Sep.space)
92              comment_eol
93
94 (************************************************************************
95  * Group:                 SPECIAL OPTIONS
96  *************************************************************************)
97
98 (* View: ip6_dotint
99      ip6-dotint option, which supports negation *)
100 let ip6_dotint =
101   let negate = [ del "no-" "no-" . label "negate" ]
102     in [ negate? . key "ip6-dotint" ]
103
104 (* View: options
105      Options values *)
106 let options =
107       let options_entry = Build.key_value ("ndots"|"timeout"|"attempts")
108                                           (Util.del_str ":") (store Rx.integer)
109                         | Build.flag ("debug"|"rotate"|"no-check-names"
110                                      |"inet6"|"ip6-bytestring"|"edns0"
111                                      |"single-request"|"single-request-reopen"
112                                      |"no-tld-query"|"use-vc"|"no-reload"
113                                      |"trust-ad")
114                         | ip6_dotint
115
116             in Build.key_value_line_comment
117                     "options" Sep.space
118                     (Build.opt_list
119                            options_entry
120                            Sep.space)
121                     comment_eol
122
123 (* View: entry *)
124 let entry = nameserver
125           | domain
126           | search
127           | sortlist
128           | options
129           | lookup
130           | family
131
132 (* View: lns *)
133 let lns = ( empty | comment | entry )*
134
135 (* Variable: filter *)
136 let filter = (incl "/etc/resolv.conf")
137
138 let xfm = transform lns filter