download: Always use AI_ADDRCONFIG when resolving host names.

* guix/build/download.scm (open-socket-for-uri): Always pass
  AI_ADDRCONFIG to 'getaddrinfo' as recommended in the fine Guile
  manual.
* guix/ftp-client.scm (ftp-open): Ditto.
This commit is contained in:
Ludovic Courtès 2015-11-12 23:15:18 +01:00
parent 60fd51222f
commit 1b9aefa394
2 changed files with 8 additions and 6 deletions

View file

@ -298,8 +298,8 @@ (define* (open-socket-for-uri uri-or-string #:key timeout)
in seconds to wait for the connection to complete; passed TIMEOUT, an in seconds to wait for the connection to complete; passed TIMEOUT, an
ETIMEDOUT error is raised." ETIMEDOUT error is raised."
;; Includes a fix for <http://bugs.gnu.org/15368> which affects Guile's ;; Includes a fix for <http://bugs.gnu.org/15368> which affects Guile's
;; 'open-socket-for-uri' up to 2.0.11 included, and uses 'connect*' instead ;; 'open-socket-for-uri' up to 2.0.11 included, uses 'connect*' instead
;; of 'connect'. ;; of 'connect', and uses AI_ADDRCONFIG.
(define http-proxy (current-http-proxy)) (define http-proxy (current-http-proxy))
(define uri (ensure-uri (or http-proxy uri-or-string))) (define uri (ensure-uri (or http-proxy uri-or-string)))
@ -309,9 +309,9 @@ (define addresses
(getaddrinfo (uri-host uri) (getaddrinfo (uri-host uri)
(cond (port => number->string) (cond (port => number->string)
(else (symbol->string (uri-scheme uri)))) (else (symbol->string (uri-scheme uri))))
(if port (if (number? port)
AI_NUMERICSERV (logior AI_ADDRCONFIG AI_NUMERICSERV)
0)) AI_ADDRCONFIG))
(lambda (ai1 ai2) (lambda (ai1 ai2)
(equal? (addrinfo:addr ai1) (addrinfo:addr ai2)))))) (equal? (addrinfo:addr ai1) (addrinfo:addr ai2))))))

View file

@ -134,7 +134,9 @@ (define* (ftp-open host #:optional (port 21) #:key timeout)
(define addresses (define addresses
(getaddrinfo host (getaddrinfo host
(if (number? port) (number->string port) port) (if (number? port) (number->string port) port)
(if (number? port) AI_NUMERICSERV 0))) (if (number? port)
(logior AI_ADDRCONFIG AI_NUMERICSERV)
AI_ADDRCONFIG)))
(let loop ((addresses addresses)) (let loop ((addresses addresses))
(let* ((ai (car addresses)) (let* ((ai (car addresses))