From fa270df87e9dab0a5ac741bb42c15471c161bed5 Mon Sep 17 00:00:00 2001 From: Johannes Lange Date: Mon, 3 Oct 2022 12:27:55 +0200 Subject: [PATCH] aur-update: add option to force IPV4 usage --- aur-update/README.md | 2 ++ aur-update/aur-update | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/aur-update/README.md b/aur-update/README.md index 98e37832..e3cc52f1 100644 --- a/aur-update/README.md +++ b/aur-update/README.md @@ -18,12 +18,14 @@ UPDATE_COLOR=red QUIET=1 IGNORE=root vidyodesktop #CACHE_UPDATES=0 +#FORCE_IPV4=1 ``` Right or middle click sends a notification (via notify-send) with a list of outdated packages and the corresponding version information. If you enable caching (`CACHE_UPDATES=1`), the update list will be cached as an environment variable. This will be read on a (right/middle) click to directly show the notification without the delay caused by updating the list. +Usage of IPV4 can be forced using `FORCE_IPV4=1`. This is useful, because the AUR API often gets timeouts with IPV6 and the call does not return. ## Dependencies diff --git a/aur-update/aur-update b/aur-update/aur-update index de3d1e08..d8c21135 100755 --- a/aur-update/aur-update +++ b/aur-update/aur-update @@ -20,6 +20,7 @@ import json import os import requests +import socket import subprocess as sp block_button = os.environ['BLOCK_BUTTON'] if 'BLOCK_BUTTON' in os.environ else None @@ -43,6 +44,7 @@ args.add_argument('UPDATE_COLOR', 'yellow') args.add_argument('QUIET', False, bool) args.add_argument('IGNORE', [], list) args.add_argument('CACHE_UPDATES', False, bool) +args.add_argument('FORCE_IPV4', 1, int) def version_in_aur(pkg): @@ -75,6 +77,15 @@ def vcs_version(pkg, ver): # no base release to compare, just return None return None +if args.force_ipv4: + # This is useful, because the AUR API often gets timeouts with + # IPV6 and the call does not return. + + # monkey-patch this function to always return the IPV4-version, + # even if capable of IPV6 + requests.packages.urllib3.util.connection.allowed_gai_family = ( + lambda: socket.AF_INET + ) # show the list of updates already cached if args.cache_updates and block_button in [2, 3]: