https://salsa.debian.org/debian/auto-apt-proxy
It try to find apt proxy on localhost, gateway or askind DNS for SRV record.
https://packages.debian.org/jessie/squid-deb-proxy-client
Main code: https://github.com/wrouesnel/squid-deb-proxy-desktop/blob/master/apt-avahi-discover
It is using avahi discover ONLY. It simply calls: <code bash>avahi-browse -kprtv _apt_proxy._tcp<code> and use the results. Not working in routed and firewalled environment.
https://askubuntu.com/questions/53443/how-do-i-ignore-a-proxy-if-not-available Requires `nc` NetCat package.