Control: tags -1 + patch
On Sun, Apr 16, 2023 at 11:08:30AM +0100, Alexander Clouter wrote:
> Though the package functions perfectly (thanks!) when you just run
> auto-apt-proxy on its own, the IPv6 literal is incorrectly concatenated
> to the port.
>
> It should emit:
>
> http://[fd69:dead:beef:1::1]:3142
>
> My local setup has apt-cacher-ng running at apt-proxy:
>
> alex@sarasti:~$ dig ANY apt-proxy
>
> ; <<>> DiG 9.18.12-1-Debian <<>> ANY apt-proxy
> ;; global options: +cmd
> ;; Got answer:
> ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 33640
> ;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1
>
> ;; OPT PSEUDOSECTION:
> ; EDNS: version: 0, flags:; udp: 65494
> ;; QUESTION SECTION:
> ;apt-proxy. IN ANY
>
> ;; ANSWER SECTION:
> apt-proxy.0 IN fd69:dead:beef:1::1
> apt-proxy.0 IN A 192.168.1.1
>
> ;; Query time: 16 msec
> ;; SERVER: 127.0.0.53#53(127.0.0.53) (TCP)
> ;; WHEN: Sun Apr 16 11:00:14 BST 2023
> ;; MSG SIZE rcvd: 82
>
> alex@sarasti:~$ auto-apt-proxy
> http://fd69:dead:beef:1::1:3142
>
>
> If you need anything else, do ask.
I also experience this problem. I'm attaching a patch that makes it work
for me, but I am unsure whether the patch is universally correct as it
may need some quoting of the ip in "Acquire::http::Proxy::${ip}=DIRECT"
if the ip contains "::". In my case, the ip does not and therefore it
works. Could you give the patch a try in your environment where "::"
does happen?
Helmut
--- a/auto-apt-proxy
+++ b/auto-apt-proxy
@@ -24,6 +24,17 @@
}
trap cleanup INT EXIT TERM
+proxy_url() {
+ case "$1" in
+ *:*)
+ echo "http://[$1]:$2";
+ ;;
+ *)
+ echo "http://$1:$2";
+ ;;
+ esac
+}
+
hit() {
timeout 5 /usr/lib/apt/apt-helper \
-o Acquire::http::Proxy=DIRECT -o Acquire::Retries=0 \
@@ -76,7 +87,7 @@
detect_apt_cacher() {
local ip="$1"
- local proxy=http://$ip:3142
+ local proxy="$(proxy_url "$ip" 3142)"
hit -o "Acquire::http::Proxy::${ip}=DIRECT" "$proxy" >/dev/null 2>&1 || true;
if [ -s "$tmpfile" ] && grep -q -i 'Apt-cacher' "$tmpfile"; then
echo "$proxy"
@@ -87,7 +98,7 @@
detect_apt_cacher_ng() {
local ip="$1"
- local proxy=http://$ip:3142
+ local proxy="$(proxy_url "$ip" 3142)"
if hit -o "Acquire::http::Proxy::${ip}=DIRECT" "$proxy" | grep -q -i '406.*usage.information'; then
echo "$proxy"
return 0
@@ -97,7 +108,7 @@
detect_approx() {
local ip="$1"
- local proxy=http://$ip:
+ local proxy="$(proxy_url "$ip" )"
hit -o "Acquire::http::Proxy::${ip}=DIRECT" "$proxy" >/dev/null 2>&1 || true;
if [ -s "$tmpfile" ] && grep -q -i 'approx\s*server' "$tmpfile"; then
echo "$proxy"
@@ -110,7 +121,7 @@
# If you want that, use squid-deb-proxy-client, which depends on avahi.
detect_squid_deb_proxy() {
local ip="$1"
- local proxy=http://$ip:8000
+ local proxy="$(proxy_url "$ip" 8000)"
if hit -oDebug::acquire::http=1 -o "Acquire::http::Proxy::${ip}=DIRECT" "$proxy" 2>&1 | grep -q 'Via: .*squid-deb-proxy'; then
echo "$proxy"
return 0