3 Parses /etc/resolv.conf
5 Author: Raphael Pinson <raphink@gmail.com>
8 This lens tries to keep as close as possible to `man resolv.conf` where possible.
11 This file is licensed under the LGPLv2+, like the rest of Augeas.
15 About: Configuration files
16 This lens applies to /etc/resolv.conf. See <filter>.
22 (************************************************************************
23 * Group: USEFUL PRIMITIVES
24 *************************************************************************)
27 let comment = Util.comment_generic /[ \t]*[;#][ \t]*/ "# "
29 (* View: comment_eol *)
30 let comment_eol = Util.comment_generic /[ \t]*[;#][ \t]*/ " # "
33 let empty = Util.empty
36 (************************************************************************
38 *************************************************************************)
41 A network mask for IP addresses *)
42 let netmask = [ label "netmask" . Util.del_str "/" . store Rx.ip ]
45 An IP address or range with an optional mask *)
46 let ipaddr = [label "ipaddr" . store Rx.ip . netmask?]
51 let nameserver = Build.key_value_line_comment
52 "nameserver" Sep.space (store Rx.ip) comment_eol
55 let domain = Build.key_value_line_comment
56 "domain" Sep.space (store Rx.word) comment_eol
59 let search = Build.key_value_line_comment
62 [label "domain" . store Rx.word]
67 let sortlist = Build.key_value_line_comment
74 (************************************************************************
75 * Group: SPECIAL OPTIONS
76 *************************************************************************)
79 ip6-dotint option, which supports negation *)
81 let negate = [ del "no-" "no-" . label "negate" ]
82 in [ negate? . key "ip6-dotint" ]
87 let options_entry = Build.key_value ("ndots"|"timeout"|"attempts")
88 (Util.del_str ":") (store Rx.integer)
89 | Build.flag ("debug"|"rotate"|"no-check-names"
90 |"inet6"|"ip6-bytestring"|"edns0")
93 in Build.key_value_line_comment
101 let entry = nameserver
108 let lns = ( empty | comment | entry )*
110 (* Variable: filter *)
111 let filter = (incl "/etc/resolv.conf")
114 let xfm = transform lns filter