Skip to content

Commit

Permalink
aur-update: add option to force IPV4 usage
Browse files Browse the repository at this point in the history
  • Loading branch information
jolange committed Oct 3, 2022
1 parent 448a3f9 commit fa270df
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions aur-update/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions aur-update/aur-update
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down Expand Up @@ -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]:
Expand Down

0 comments on commit fa270df

Please sign in to comment.