Subject: Re: bug#40343: 28.0.50; dns-set-servers fails on IPv6 available Windows

From: Robert Pluim <[email-masked]>
Date: Tue, 31 Mar 2020 15:01:05 +0200

>>>>> On Tue, 31 Mar 2020 20:06:50 +0900, Kazuhiro Ito <[email-masked]> said:

    Kazuhiro> dns-set-servers function fails to set dns-servers on Windows with IPv6
    Kazuhiro> available network.
    Kazuhiro> (progn
    Kazuhiro> (require 'dns)
    Kazuhiro> (dns-set-servers)
    Kazuhiro> dns-servers)
    -> (nil)
    >> 
    >> dns.el isnʼt going to work on Windows anyway, since Emacs doesnʼt
    >> support UDP network processes on Windows.

    Kazuhiro> Cygwin's Emacs, which seems to support UDP network processes, uses
    Kazuhiro> Windows's nslookup.exe, so has this problem too.  

Thatʼs not a Windows Emacs :-)

    Kazuhiro> # Actually I don't directly use dns.el.  It is gravatar.el which uses
    Kazuhiro> # dns.el.

True. We should teach emacs about res_query.

Does this work for you:

diff --git a/lisp/net/dns.el b/lisp/net/dns.el
index 78d4827162..fd2ea99ac6 100644
--- a/lisp/net/dns.el
+++ b/lisp/net/dns.el
@@ -328,7 +328,7 @@ dns-set-servers
 	  (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)
+	   "^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))))