added windows support to dns-find-nameserver
original commit: 2b67432b43888c7c93f5384616a5bb2defba7170
This commit is contained in:
parent
bdeea7c188
commit
d3f8bb4d7d
|
@ -321,18 +321,35 @@
|
||||||
|
|
||||||
(define (dns-find-nameserver)
|
(define (dns-find-nameserver)
|
||||||
(case (system-type)
|
(case (system-type)
|
||||||
[(unix macosx)
|
[(unix macosx)
|
||||||
(with-handlers ([void (lambda (x) #f)])
|
(with-handlers ([void (lambda (x) #f)])
|
||||||
(with-input-from-file "/etc/resolv.conf"
|
(with-input-from-file "/etc/resolv.conf"
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(let loop ()
|
(let loop ()
|
||||||
(let ([l (read-line)])
|
(let ([l (read-line)])
|
||||||
(or (and (string? l)
|
(or (and (string? l)
|
||||||
(let ([m (regexp-match
|
(let ([m (regexp-match
|
||||||
(format "nameserver[ ~a]+([0-9]+[.][0-9]+[.][0-9]+[.][0-9]+)" #\tab)
|
(format "nameserver[ ~a]+([0-9]+[.][0-9]+[.][0-9]+[.][0-9]+)" #\tab)
|
||||||
l)])
|
l)])
|
||||||
(and m (cadr m))))
|
(and m (cadr m))))
|
||||||
(and (not (eof-object? l))
|
(and (not (eof-object? l))
|
||||||
(loop))))))))]
|
(loop))))))))]
|
||||||
|
[(windows)
|
||||||
|
(let ([nslookup (find-executable-path "nslookup.exe" #f)])
|
||||||
|
(and nslookup
|
||||||
|
(let-values ([(p pout pin perr)
|
||||||
|
(subprocess
|
||||||
|
#f (open-input-file "NUL") (current-error-port)
|
||||||
|
nslookup)])
|
||||||
|
(let loop ([dns #f])
|
||||||
|
(let ([line (read-line pout 'any)])
|
||||||
|
(cond [(eof-object? line)
|
||||||
|
(subprocess-wait p)
|
||||||
|
dns]
|
||||||
|
[(and (not dns)
|
||||||
|
(regexp-match #rx"^Default Server: +(.*)$"
|
||||||
|
line))
|
||||||
|
=> (lambda (m) (loop (cadr m)))]
|
||||||
|
[else (loop dns)]))))))]
|
||||||
[else #f])))))
|
[else #f])))))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user