From e7934042a43772f63b4c8c53414e82f9eba89e3d Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Sun, 16 Jul 2006 22:20:23 +0000 Subject: Add ipv6 --sync support for bug #37124. Thanks to Bernhard Schmidt for the initial patch. svn path=/main/trunk/; revision=3908 --- bin/emerge | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'bin/emerge') diff --git a/bin/emerge b/bin/emerge index 9e1ac141e..953d9bb58 100755 --- a/bin/emerge +++ b/bin/emerge @@ -2628,14 +2628,28 @@ def action_sync(settings, trees, mtimedb, myopts, myaction): if port is None: port="" updatecache_flg=True - + all_rsync_opts = set(rsync_opts) + all_rsync_opts.update( + settings.get("PORTAGE_RSYNC_EXTRA_OPTS","").split()) + family = socket.AF_UNSPEC + if "-4" in all_rsync_opts or "--ipv4" in all_rsync_opts: + family = socket.AF_INET + elif socket.has_ipv6 and \ + ("-6" in all_rsync_opts or "--ipv6" in all_rsync_opts): + family = socket.AF_INET6 ips=[] while (1): if ips: del ips[0] if ips==[]: try: - ips=socket.gethostbyname_ex(hostname)[2] + for addrinfo in socket.getaddrinfo( + hostname, None, family, socket.SOCK_STREAM): + if addrinfo[0] == socket.AF_INET6: + # IPv6 addresses need to be enclosed in square brackets + ips.append("[%s]" % addrinfo[4][0]) + else: + ips.append(addrinfo[4][0]) except SystemExit, e: raise # Needed else can't exit except Exception, e: -- cgit v1.2.3-1-g7c22