Minor changes in parse-resolv.conf.

This commit is contained in:
cresh 2003-06-30 10:57:26 +00:00
parent 886b8f7dd1
commit dbd13f24ab
1 changed files with 22 additions and 12 deletions

View File

@ -1057,16 +1057,17 @@
(define *resolv.conf-cache*)
(define *resolv.conf-cache-date* 0)
(define *resolv.conf-file* "/etc/resolv.conf")
(define (resolv.conf)
(let ((actual-m-time (file-info:mtime (file-info "/etc/resolv.conf"))))
(let ((actual-m-time (file-info:mtime (file-info *resolv.conf-file*))))
(if (> actual-m-time *resolv.conf-cache-date*)
(parse-resolv.conf!))
*resolv.conf-cache*))
(define (parse-resolv.conf!)
(let ((actual-m-time (file-info:mtime (file-info "/etc/resolv.conf")))
(contents (really-parse-resolv.conf "/etc/resolv.conf")))
(let ((actual-m-time (file-info:mtime (file-info *resolv.conf-file*)))
(contents (really-parse-resolv.conf *resolv.conf-file*)))
(set! *resolv.conf-cache* contents)
(set! *resolv.conf-cache-date* actual-m-time)))
@ -1111,7 +1112,11 @@
((eof-object? l)
(adjust-result rev-result #f '()))
((regexp-search
(rx (: "nameserver" (+ (| " " "\t")
(rx (: bos ("#;")))
l)
(loop rev-result))
((regexp-search
(rx (: bos "nameserver" (+ (| " " "\t")
(submatch (* any))
eos)))
l)
@ -1119,7 +1124,7 @@
(loop (cons (parse-nameserver (match:substring match 1))
rev-result))))
((regexp-search
(rx (: "domain" (+ (| " " "\t")
(rx (: bos "domain" (+ (| " " "\t")
(submatch (* any))
eos)))
l)
@ -1127,7 +1132,7 @@
(loop (cons (parse-domain (match:substring match 1))
rev-result))))
((regexp-search
(rx (: "search" (+ (| " " "\t")
(rx (: bos "search" (+ (| " " "\t")
(submatch (* any))
eos)))
l)
@ -1136,22 +1141,27 @@
rev-result))))
((regexp-search
(rx (: "sortlist" (+ (| " " "\t")
(rx (: bos "sortlist" (+ (| " " "\t")
(submatch (* any))
eos)))
l)
=> (lambda (match)
(parse-sortlist (match:substring match 1))))
(loop (cons (parse-sortlist (match:substring match 1))
rev-result))))
((regexp-search
(rx (: "options" (+ (| " " "\t")
(rx (: bos "options" (+ (| " " "\t")
(submatch (* any))
eos)))
l)
=> (lambda (match)
(parse-options (match:substring match 1))))
(else (signal 'resolv.conf-parse-error))))))))
(loop (cons (parse-options (match:substring match 1))
rev-result))))
;; skips lines with parse errors, instead of
;; raising a 'resolv.conf-parse-error
(else (loop rev-result))))))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Figure out the default name servers
@ -1160,7 +1170,7 @@
(cond ((assoc 'nameserver (resolv.conf))
=> (lambda (nameserver.list)
(cdr nameserver.list)))
(else '())))
(else '("127.0.0.1"))))
;; returns the first found nameserver
(define (dns-find-nameserver)