From: Zooko O'Whielacronx Date: Mon, 16 Apr 2007 22:12:01 +0000 (-0700) Subject: oops -- the previous commit of iputil wasn't the right version X-Git-Url: https://git.rkrishnan.org/%5B/%5D%20/file/reliability?a=commitdiff_plain;h=234951041f5e02586445221abf7d5ce2902fe60b;p=tahoe-lafs%2Ftahoe-lafs.git oops -- the previous commit of iputil wasn't the right version Too bad synchronizing pyutil and allmydata.util includes a manual step. --- diff --git a/src/allmydata/util/iputil.py b/src/allmydata/util/iputil.py index a0bb274c..0f2cb8c1 100644 --- a/src/allmydata/util/iputil.py +++ b/src/allmydata/util/iputil.py @@ -24,12 +24,12 @@ def get_local_addresses_async(target='A.ROOT-SERVERS.NET'): pass the address of a host that you are actually trying to be reachable to. """ - addresses = [] - addresses.append(get_local_ip_for(target)) + addresses = set() + addresses.add(get_local_ip_for(target)) d = _find_addresses_via_config() def _collect(res): - addresses.extend(res) + addresses.update(res) return addresses d.addCallback(_collect) @@ -79,11 +79,11 @@ class UnsupportedPlatformError(Exception): # ... thus wrote Greg Smith in time immemorial... _win32_path = 'route.exe' _win32_args = ('print',) -_win32_re = re.compile('^\s*0\.0\.0\.0\s.+\s(?P
\d+\.\d+\.\d+\.\d+)\s+(?P\d+)\s*$', flags=re.M|re.I|re.S) +_win32_re = re.compile('^\s*\d+\.\d+\.\d+\.\d+\s.+\s(?P
\d+\.\d+\.\d+\.\d+)\s+(?P\d+)\s*$', flags=re.M|re.I|re.S) # These work in Redhat 6.x and Debian 2.2 potato _linux_path = '/sbin/ifconfig' -_linux_re = re.compile('^(?P\w+)\s.+\sinet addr:(?P
\d+\.\d+\.\d+\.\d+)\s.+$', flags=re.M|re.I|re.S) +_linux_re = re.compile('^\s*inet addr:(?P
\d+\.\d+\.\d+\.\d+)\s.+$', flags=re.M|re.I|re.S) # NetBSD 1.4 (submitted by Rhialto), Darwin, Mac OS X _netbsd_path = '/sbin/ifconfig -a' @@ -108,10 +108,10 @@ def _find_addresses_via_config(): l.append(_query(executable, _win32_re, _win32_args)) dl = defer.DeferredList(l) def _gather_results(res): - addresses = [] + addresses = set() for r in res: if r[0]: - addresses.extend(r[1]) + addresses.update(r[1]) return addresses dl.addCallback(_gather_results) return dl @@ -127,13 +127,13 @@ def _find_addresses_via_config(): def _query(path, regex, args=()): d = getProcessOutput(path, args) def _parse(output): - addresses = [] + addresses = set() outputsplit = output.split('\n') - for output in outputsplit: - m = regex.match(output) + for outline in outputsplit: + m = regex.match(outline) if m: d = m.groupdict() - addresses.append(d['address']) + addresses.add(d['address']) return addresses d.addCallback(_parse)