Minor changes in parse-resolv.conf.
This commit is contained in:
parent
886b8f7dd1
commit
dbd13f24ab
|
@ -1057,16 +1057,17 @@
|
||||||
|
|
||||||
(define *resolv.conf-cache*)
|
(define *resolv.conf-cache*)
|
||||||
(define *resolv.conf-cache-date* 0)
|
(define *resolv.conf-cache-date* 0)
|
||||||
|
(define *resolv.conf-file* "/etc/resolv.conf")
|
||||||
|
|
||||||
(define (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*)
|
(if (> actual-m-time *resolv.conf-cache-date*)
|
||||||
(parse-resolv.conf!))
|
(parse-resolv.conf!))
|
||||||
*resolv.conf-cache*))
|
*resolv.conf-cache*))
|
||||||
|
|
||||||
(define (parse-resolv.conf!)
|
(define (parse-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*)))
|
||||||
(contents (really-parse-resolv.conf "/etc/resolv.conf")))
|
(contents (really-parse-resolv.conf *resolv.conf-file*)))
|
||||||
(set! *resolv.conf-cache* contents)
|
(set! *resolv.conf-cache* contents)
|
||||||
(set! *resolv.conf-cache-date* actual-m-time)))
|
(set! *resolv.conf-cache-date* actual-m-time)))
|
||||||
|
|
||||||
|
@ -1111,7 +1112,11 @@
|
||||||
((eof-object? l)
|
((eof-object? l)
|
||||||
(adjust-result rev-result #f '()))
|
(adjust-result rev-result #f '()))
|
||||||
((regexp-search
|
((regexp-search
|
||||||
(rx (: "nameserver" (+ (| " " "\t")
|
(rx (: bos ("#;")))
|
||||||
|
l)
|
||||||
|
(loop rev-result))
|
||||||
|
((regexp-search
|
||||||
|
(rx (: bos "nameserver" (+ (| " " "\t")
|
||||||
(submatch (* any))
|
(submatch (* any))
|
||||||
eos)))
|
eos)))
|
||||||
l)
|
l)
|
||||||
|
@ -1119,7 +1124,7 @@
|
||||||
(loop (cons (parse-nameserver (match:substring match 1))
|
(loop (cons (parse-nameserver (match:substring match 1))
|
||||||
rev-result))))
|
rev-result))))
|
||||||
((regexp-search
|
((regexp-search
|
||||||
(rx (: "domain" (+ (| " " "\t")
|
(rx (: bos "domain" (+ (| " " "\t")
|
||||||
(submatch (* any))
|
(submatch (* any))
|
||||||
eos)))
|
eos)))
|
||||||
l)
|
l)
|
||||||
|
@ -1127,7 +1132,7 @@
|
||||||
(loop (cons (parse-domain (match:substring match 1))
|
(loop (cons (parse-domain (match:substring match 1))
|
||||||
rev-result))))
|
rev-result))))
|
||||||
((regexp-search
|
((regexp-search
|
||||||
(rx (: "search" (+ (| " " "\t")
|
(rx (: bos "search" (+ (| " " "\t")
|
||||||
(submatch (* any))
|
(submatch (* any))
|
||||||
eos)))
|
eos)))
|
||||||
l)
|
l)
|
||||||
|
@ -1136,22 +1141,27 @@
|
||||||
rev-result))))
|
rev-result))))
|
||||||
|
|
||||||
((regexp-search
|
((regexp-search
|
||||||
(rx (: "sortlist" (+ (| " " "\t")
|
(rx (: bos "sortlist" (+ (| " " "\t")
|
||||||
(submatch (* any))
|
(submatch (* any))
|
||||||
eos)))
|
eos)))
|
||||||
l)
|
l)
|
||||||
=> (lambda (match)
|
=> (lambda (match)
|
||||||
(parse-sortlist (match:substring match 1))))
|
(loop (cons (parse-sortlist (match:substring match 1))
|
||||||
|
rev-result))))
|
||||||
|
|
||||||
|
|
||||||
((regexp-search
|
((regexp-search
|
||||||
(rx (: "options" (+ (| " " "\t")
|
(rx (: bos "options" (+ (| " " "\t")
|
||||||
(submatch (* any))
|
(submatch (* any))
|
||||||
eos)))
|
eos)))
|
||||||
l)
|
l)
|
||||||
=> (lambda (match)
|
=> (lambda (match)
|
||||||
(parse-options (match:substring match 1))))
|
(loop (cons (parse-options (match:substring match 1))
|
||||||
(else (signal 'resolv.conf-parse-error))))))))
|
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
|
;; Figure out the default name servers
|
||||||
|
@ -1160,7 +1170,7 @@
|
||||||
(cond ((assoc 'nameserver (resolv.conf))
|
(cond ((assoc 'nameserver (resolv.conf))
|
||||||
=> (lambda (nameserver.list)
|
=> (lambda (nameserver.list)
|
||||||
(cdr nameserver.list)))
|
(cdr nameserver.list)))
|
||||||
(else '())))
|
(else '("127.0.0.1"))))
|
||||||
|
|
||||||
;; returns the first found nameserver
|
;; returns the first found nameserver
|
||||||
(define (dns-find-nameserver)
|
(define (dns-find-nameserver)
|
||||||
|
|
Loading…
Reference in New Issue