Package: squid-deb-proxy-client Version: 0.7.2 Severity: wishlist Tags: patch
This patch has two hunks, that do two things: 1. Pass -f to avahi-browse to not produce error messages if it cannot find a service 2. Connect to a proxy with a timeout of 1 second before returning it. The latter hunk ensures that the proxy is actually up. In my case, I have a laptop that has a proxy, and is not up all the time. This is useful, as it allows clients to use my laptop if available in the network or switch to no proxy otherwise. It might be a good idea to make the timeout configurable using an apt.conf entry, but I did not add this (yet). Should I? diff --git a/usr/share/squid-deb-proxy-client/apt-avahi-discover b/usr/share/squid-deb-proxy-client/apt-avahi-discover index 2a3860f..de210c7 100755 --- a/usr/share/squid-deb-proxy-client/apt-avahi-discover +++ b/usr/share/squid-deb-proxy-client/apt-avahi-discover @@ -21,7 +21,7 @@ def get_proxy_host_port_from_avahi(): # addresses to the top. addr4 = [] addr6 = [] - p = Popen(['avahi-browse', '-kprt', service], stdout=PIPE) + p = Popen(['avahi-browse', '-kprtf', service], stdout=PIPE) for line in p.stdout: if line.startswith('='): tokens = line.split(';') @@ -40,10 +40,14 @@ def get_proxy_host_port_from_avahi(): for (ip, port) in addr6 + addr4: try: res = socket.getaddrinfo(ip, port, 0, 0, 0, socket.AI_ADDRCONFIG) - if res: - return (ip, port) + if not res: + continue + sock = socket.create_connection((ip, port), 1).close() + return (ip, port) except socket.gaierror: pass + except socket.timeout: + pass # nothing found return None -- System Information: Debian Release: jessie/sid APT prefers unstable APT policy: (980, 'unstable'), (500, 'unstable') Architecture: amd64 (x86_64) Kernel: Linux 3.10-2-amd64 (SMP w/4 CPU cores) Locale: LANG=de_DE.utf8, LC_CTYPE=de_DE.utf8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Versions of packages squid-deb-proxy-client depends on: ii apt 0.9.11.2 ii avahi-utils 0.6.31-2 ii python 2.7.5-4 squid-deb-proxy-client recommends no packages. squid-deb-proxy-client suggests no packages. -- no debconf information -- Julian Andres Klode - Debian Developer, Ubuntu Member See http://wiki.debian.org/JulianAndresKlode and http://jak-linux.org/.
pgp0W4NSwli02.pgp
Description: PGP signature