summaryrefslogtreecommitdiff
path: root/methods/connect.cc
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2013-03-22 21:46:53 +0100
committerMichael Vogt <michael.vogt@ubuntu.com>2013-03-22 21:46:53 +0100
commit45d02095cbd425c741b69810f91bc2282bf9230b (patch)
treec0f2c36f77d03c401d2c5daf3194ecfc3e4e0f03 /methods/connect.cc
parentccd01d7e09ff595233d4ed6dff1a1c73bd2b5193 (diff)
add new config options "Acquire::ForceIPv4" and
"Acquire::ForceIPv6" to allow focing one or the other (closes: #611891)
Diffstat (limited to 'methods/connect.cc')
-rw-r--r--methods/connect.cc8
1 files changed, 8 insertions, 0 deletions
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 <apt-pkg/fileutl.h>
#include <apt-pkg/strutl.h>
#include <apt-pkg/acquire-method.h>
+#include <apt-pkg/configuration.h>
#include <stdio.h>
#include <errno.h>
@@ -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());