diff options
| author | Robert Pluim | 2020-04-03 14:56:08 +0200 |
|---|---|---|
| committer | Robert Pluim | 2020-04-03 17:09:00 +0200 |
| commit | 00f7744c1b0f3e6aa59634a28ab671b2203e3900 (patch) | |
| tree | 60bd82580b580b2998c62b456329abfdd4a43e78 | |
| parent | d08e81ce5a19a0394c2efbdfeb4ebb246d609635 (diff) | |
| download | emacs-00f7744c1b0f3e6aa59634a28ab671b2203e3900.tar.gz emacs-00f7744c1b0f3e6aa59634a28ab671b2203e3900.zip | |
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.
| -rw-r--r-- | lisp/net/dns.el | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/lisp/net/dns.el b/lisp/net/dns.el index 78d48271629..177df4e3329 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." | |||
| 315 | (defun dns-set-servers () | 315 | (defun dns-set-servers () |
| 316 | "Set `dns-servers' to a list of DNS servers or nil if none are found. | 316 | "Set `dns-servers' to a list of DNS servers or nil if none are found. |
| 317 | Parses \"/etc/resolv.conf\" or calls \"nslookup\"." | 317 | Parses \"/etc/resolv.conf\" or calls \"nslookup\"." |
| 318 | (setq dns-servers nil) | ||
| 318 | (or (when (file-exists-p "/etc/resolv.conf") | 319 | (or (when (file-exists-p "/etc/resolv.conf") |
| 319 | (setq dns-servers nil) | ||
| 320 | (with-temp-buffer | 320 | (with-temp-buffer |
| 321 | (insert-file-contents "/etc/resolv.conf") | 321 | (insert-file-contents "/etc/resolv.conf") |
| 322 | (goto-char (point-min)) | 322 | (goto-char (point-min)) |
| @@ -327,9 +327,9 @@ Parses \"/etc/resolv.conf\" or calls \"nslookup\"." | |||
| 327 | (with-temp-buffer | 327 | (with-temp-buffer |
| 328 | (call-process "nslookup" nil t nil "localhost") | 328 | (call-process "nslookup" nil t nil "localhost") |
| 329 | (goto-char (point-min)) | 329 | (goto-char (point-min)) |
| 330 | (re-search-forward | 330 | (when (re-search-forward |
| 331 | "^Address:[ \t]*\\([0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+\\)" nil t) | 331 | "^Address:[ \t]*\\([0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+\\|[[:xdigit:]:]*\\)" nil t) |
| 332 | (setq dns-servers (list (match-string 1)))))) | 332 | (setq dns-servers (list (match-string 1))))))) |
| 333 | (when (fboundp 'network-interface-list) | 333 | (when (fboundp 'network-interface-list) |
| 334 | (setq dns-servers-valid-for-interfaces (network-interface-list)))) | 334 | (setq dns-servers-valid-for-interfaces (network-interface-list)))) |
| 335 | 335 | ||
| @@ -357,7 +357,9 @@ Parses \"/etc/resolv.conf\" or calls \"nslookup\"." | |||
| 357 | `(let ((server ,server) | 357 | `(let ((server ,server) |
| 358 | (coding-system-for-read 'binary) | 358 | (coding-system-for-read 'binary) |
| 359 | (coding-system-for-write 'binary)) | 359 | (coding-system-for-write 'binary)) |
| 360 | (if (fboundp 'make-network-process) | 360 | (if (and |
| 361 | (fboundp 'make-network-process) | ||
| 362 | (featurep 'make-network-process '(:type datagram))) | ||
| 361 | (make-network-process | 363 | (make-network-process |
| 362 | :name "dns" | 364 | :name "dns" |
| 363 | :coding 'binary | 365 | :coding 'binary |
| @@ -365,9 +367,9 @@ Parses \"/etc/resolv.conf\" or calls \"nslookup\"." | |||
| 365 | :host server | 367 | :host server |
| 366 | :service "domain" | 368 | :service "domain" |
| 367 | :type 'datagram) | 369 | :type 'datagram) |
| 368 | ;; Older versions of Emacs doesn't have | 370 | ;; Older versions of Emacs do not have `make-network-process', |
| 369 | ;; `make-network-process', so we fall back on opening a TCP | 371 | ;; and on MS-Windows datagram sockets are not supported, so we |
| 370 | ;; connection to the DNS server. | 372 | ;; fall back on opening a TCP connection to the DNS server. |
| 371 | (open-network-stream "dns" (current-buffer) server "domain")))) | 373 | (open-network-stream "dns" (current-buffer) server "domain")))) |
| 372 | 374 | ||
| 373 | (defvar dns-cache (make-vector 4096 0)) | 375 | (defvar dns-cache (make-vector 4096 0)) |
| @@ -400,7 +402,9 @@ If REVERSEP, look up an IP address." | |||
| 400 | type 'PTR)) | 402 | type 'PTR)) |
| 401 | 403 | ||
| 402 | (if (not dns-servers) | 404 | (if (not dns-servers) |
| 403 | (message "No DNS server configuration found") | 405 | (progn |
| 406 | (message "No DNS server configuration found") | ||
| 407 | nil) | ||
| 404 | (with-temp-buffer | 408 | (with-temp-buffer |
| 405 | (set-buffer-multibyte nil) | 409 | (set-buffer-multibyte nil) |
| 406 | (let ((process (condition-case () | 410 | (let ((process (condition-case () |