From: Michael Vogt Date: Fri, 22 Mar 2013 20:46:53 +0000 (+0100) Subject: add new config options "Acquire::ForceIPv4" and X-Git-Tag: 0.9.8~32 X-Git-Url: https://git.saurik.com/apt.git/commitdiff_plain/45d02095cbd425c741b69810f91bc2282bf9230b add new config options "Acquire::ForceIPv4" and "Acquire::ForceIPv6" to allow focing one or the other (closes: #611891) --- diff --git a/debian/changelog b/debian/changelog index a4a0b4c6d..4c830afe9 100644 --- a/debian/changelog +++ b/debian/changelog @@ -15,6 +15,11 @@ apt (0.9.7.8~exp3) UNRELEASEDexperimental; urgency=low * methods/connect.cc: - provide useful error message in case of EAI_SYSTEM (closes: #703603) + + [ Michael Vogt ] + * add new config options "Acquire::ForceIPv4" and + "Acquire::ForceIPv6" to allow focing one or the other + (closes: #611891) -- Michael Vogt Sun, 17 Mar 2013 19:46:23 +0100 diff --git a/methods/connect.cc b/methods/connect.cc index 3573d3cbf..35f4723ce 100644 --- a/methods/connect.cc +++ b/methods/connect.cc @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -167,6 +168,13 @@ bool Connect(std::string Host,int Port,const char *Service,int DefPort,int &Fd, Hints.ai_flags = AI_ADDRCONFIG; Hints.ai_protocol = 0; + if(_config->FindB("Acquire::ForceIPv4", false) == true) + Hints.ai_family = AF_INET; + else if(_config->FindB("Acquire::ForceIPv6", false) == true) + Hints.ai_family = AF_INET6; + else + Hints.ai_family = AF_UNSPEC; + // if we couldn't resolve the host before, we don't try now if(bad_addr.find(Host) != bad_addr.end()) return _error->Error(_("Could not resolve '%s'"),Host.c_str());