--- /dev/null
+! Copyright (C) 2019 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: tools.test resolv-conf ;
+IN: resolv-conf.tests
+{
+ T{ resolv.conf
+ { nameserver V{ "127.0.0.53" } }
+ { domain V{ } }
+ { lookup V{ } }
+ { search V{ "localdomain" } }
+ { sortlist V{ } }
+ { options T{ options { edns0? t } } }
+ }
+} [
+ "nameserver 127.0.0.53
+ options edns0
+ search localdomain" string>resolv.conf
+] unit-test
\ No newline at end of file
{ [ "rotate" ?head ] [ drop t >>rotate? ] }
{ [ "no-check-names" ?head ] [ drop t >>no-check-names? ] }
{ [ "inet6" ?head ] [ drop t >>inet6? ] }
+ { [ "edns0" ?head ] [ drop t >>edns0? ] }
[ unsupported-resolv.conf-option ]
} cond drop ;
PRIVATE>
-: parse-resolve.conf ( path -- resolv.conf )
+: lines>resolv.conf ( lines -- resolv.conf )
[ <resolv.conf> ] dip
- utf8 file-lines
[ [ blank? ] trim ] map harvest
[ "#" head? ] reject
[ parse-resolv.conf-line ] each ;
+: string>resolv.conf ( string -- resolv.conf )
+ string-lines lines>resolv.conf ;
+
+: path>resolv.conf ( path -- resolv.conf )
+ utf8 file-lines lines>resolv.conf ;
+
: default-resolv.conf ( -- resolv.conf )
- "/etc/resolv.conf" parse-resolve.conf ;
+ "/etc/resolv.conf" path>resolv.conf ;