From 80188330100d74b00a761f6859fad938480d246e Mon Sep 17 00:00:00 2001 From: Duncaen Date: Sat, 15 Jun 2019 18:44:31 +0200 Subject: [PATCH] lib/fetch: add FORCE_IPV{4,6} environment variables --- bin/xbps-fetch/xbps-fetch.1 | 4 ++++ bin/xbps-install/xbps-install.1 | 4 ++++ lib/fetch/common.c | 7 ++++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/bin/xbps-fetch/xbps-fetch.1 b/bin/xbps-fetch/xbps-fetch.1 index 03cd6122..ec4035ac 100644 --- a/bin/xbps-fetch/xbps-fetch.1 +++ b/bin/xbps-fetch/xbps-fetch.1 @@ -33,6 +33,10 @@ Show the version information. .El .Sh ENVIRONMENT .Bl -tag -width -x +.It Sy FORCE_IPV4 +Only use IPv4. +.It Sy FORCE_IPV6 +Only use IPv6. .It Sy FTP_PASSIVE_MODE If set to anything else than .Ar "no" diff --git a/bin/xbps-install/xbps-install.1 b/bin/xbps-install/xbps-install.1 index 5b446cde..e273c806 100644 --- a/bin/xbps-install/xbps-install.1 +++ b/bin/xbps-install/xbps-install.1 @@ -128,6 +128,10 @@ Show the version information. .El .Sh ENVIRONMENT .Bl -tag -width SSL_NO_VERIFY_HOSTNAME +.It Sy FORCE_IPV4 +Only use IPv4. +.It Sy FORCE_IPV6 +Only use IPv6. .It Sy FTP_PASSIVE_MODE If set to anything else than .Ar "no" diff --git a/lib/fetch/common.c b/lib/fetch/common.c index 6f9be7fd..2f56e156 100644 --- a/lib/fetch/common.c +++ b/lib/fetch/common.c @@ -478,8 +478,13 @@ happy_eyeballs_connect(struct addrinfo *res0) fetch_info("got %d A and %d AAAA records", n4, n6); #endif - res = NULL; i4 = i6 = 0; + if (getenv("FORCE_IPV4")) + i6 = n6; + if (getenv("FORCE_IPV6")) + i4 = n4; + + res = NULL; for (;;) { int sd = -1; int ret;