emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 00f7744: Check for IPv6 servers in dns.el


From: Robert Pluim
Subject: master 00f7744: Check for IPv6 servers in dns.el
Date: Fri, 3 Apr 2020 11:17:46 -0400 (EDT)

branch: master
commit 00f7744c1b0f3e6aa59634a28ab671b2203e3900
Author: Robert Pluim <address@hidden>
Commit: Robert Pluim <address@hidden>

    Check for IPv6 servers in dns.el
    
    * lisp/net/dns.el (dns-set-servers): Set dns-servers to nil when we
    don't find any DNS servers with nslookup.  Add support for IPv6
    servers.  (Bug#40248).
    (dns-make-network-process): Check for datagram process support before
    creating a datagram process.
    (dns-query): Return nil if dns-servers is nil.
---
 lisp/net/dns.el | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/lisp/net/dns.el b/lisp/net/dns.el
index 78d4827..177df4e 100644
--- a/lisp/net/dns.el
+++ b/lisp/net/dns.el
@@ -315,8 +315,8 @@ If TCP-P, the first two bytes of the package with be the 
length field."
 (defun dns-set-servers ()
   "Set `dns-servers' to a list of DNS servers or nil if none are found.
 Parses \"/etc/resolv.conf\" or calls \"nslookup\"."
+  (setq dns-servers nil)
   (or (when (file-exists-p "/etc/resolv.conf")
-       (setq dns-servers nil)
        (with-temp-buffer
          (insert-file-contents "/etc/resolv.conf")
          (goto-char (point-min))
@@ -327,9 +327,9 @@ Parses \"/etc/resolv.conf\" or calls \"nslookup\"."
        (with-temp-buffer
          (call-process "nslookup" nil t nil "localhost")
          (goto-char (point-min))
-         (re-search-forward
-          "^Address:[ \t]*\\([0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+\\)" nil t)
-         (setq dns-servers (list (match-string 1))))))
+          (when (re-search-forward
+          "^Address:[ 
\t]*\\([0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+\\|[[:xdigit:]:]*\\)" nil t)
+             (setq dns-servers (list (match-string 1)))))))
   (when (fboundp 'network-interface-list)
     (setq dns-servers-valid-for-interfaces (network-interface-list))))
 
@@ -357,7 +357,9 @@ Parses \"/etc/resolv.conf\" or calls \"nslookup\"."
   `(let ((server ,server)
         (coding-system-for-read 'binary)
         (coding-system-for-write 'binary))
-     (if (fboundp 'make-network-process)
+     (if (and
+          (fboundp 'make-network-process)
+          (featurep 'make-network-process '(:type datagram)))
         (make-network-process
          :name "dns"
          :coding 'binary
@@ -365,9 +367,9 @@ Parses \"/etc/resolv.conf\" or calls \"nslookup\"."
          :host server
          :service "domain"
          :type 'datagram)
-       ;; Older versions of Emacs doesn't have
-       ;; `make-network-process', so we fall back on opening a TCP
-       ;; connection to the DNS server.
+       ;; Older versions of Emacs do not have `make-network-process',
+       ;; and on MS-Windows datagram sockets are not supported, so we
+       ;; fall back on opening a TCP connection to the DNS server.
        (open-network-stream "dns" (current-buffer) server "domain"))))
 
 (defvar dns-cache (make-vector 4096 0))
@@ -400,7 +402,9 @@ If REVERSEP, look up an IP address."
          type 'PTR))
 
   (if (not dns-servers)
-      (message "No DNS server configuration found")
+      (progn
+        (message "No DNS server configuration found")
+        nil)
     (with-temp-buffer
       (set-buffer-multibyte nil)
       (let ((process (condition-case ()



reply via email to

[Prev in Thread] Current Thread [Next in Thread]