From e2150d729239c42e358482a3fdfa52246c48ac05 Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Thu, 3 Feb 2022 08:28:29 +0100 Subject: merged with 2021.11 upstream --- Reflector.py | 18 ++++++++++++++++++ man/reflector.1.gz | Bin 892 -> 895 bytes reflector.service | 5 +++-- setup.py | 6 +++--- 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/Reflector.py b/Reflector.py index dee77dd..e0e0c00 100644 --- a/Reflector.py +++ b/Reflector.py @@ -497,6 +497,7 @@ class MirrorStatusFilter(): # pylint: disable=too-many-instance-attributes,too- include=None, exclude=None, age=None, + delay=None, isos=False, ipv4=False, ipv6=False @@ -507,6 +508,7 @@ class MirrorStatusFilter(): # pylint: disable=too-many-instance-attributes,too- self.include = tuple(re.compile(r) for r in include) if include else tuple() self.exclude = tuple(re.compile(r) for r in exclude) if exclude else tuple() self.age = age + self.delay = delay self.isos = isos self.ipv4 = ipv4 self.ipv6 = ipv6 @@ -551,6 +553,12 @@ class MirrorStatusFilter(): # pylint: disable=too-many-instance-attributes,too- age = self.age * 60**2 mirrors = (m for m in mirrors if (m['last_sync'] + age) >= tim) + # Filter by delay. The delay is given as a float of hours and must be + # converted to seconds. + if self.delay is not None: + delay = self.delay * 3600 + mirrors = (m for m in mirrors if m['delay'] <= delay) + # Filter by ISO hosing. if self.isos: mirrors = (m for m in mirrors if m['isos']) @@ -885,6 +893,15 @@ def add_arguments(parser): ) ) + filters.add_argument( + '--delay', type=float, metavar='n', + help=( + '''Only return mirrors with a reported sync delay of n hours or + less, where n is a float. For example. to limit the results to + mirrors with a reported delay of 15 minutes or less, pass 0.25.''' + ) + ) + filters.add_argument( '-c', '--country', dest='countries', action='append', metavar='', help=( @@ -1047,6 +1064,7 @@ def process_options(options, mirrorstatus=None, mirrors=None): include=options.include, exclude=options.exclude, age=options.age, + delay=options.delay, protocols=options.protocols, isos=options.isos, ipv4=options.ipv4, diff --git a/man/reflector.1.gz b/man/reflector.1.gz index 680c67f..ead01f9 100644 Binary files a/man/reflector.1.gz and b/man/reflector.1.gz differ diff --git a/reflector.service b/reflector.service index 893f664..8503048 100644 --- a/reflector.service +++ b/reflector.service @@ -8,7 +8,8 @@ After=network-online.target nss-lookup.target Type=oneshot ExecStart=/usr/bin/reflector @/etc/xdg/reflector/reflector.conf CacheDirectory=reflector -CapabilityBoundingSet=~CAP_SETUID CAP_SETGID CAP_SETPCAP CAP_SYS_ADMIN CAP_SYS_PTRACE CAP_CHOWN CAP_FSETID CAP_SETFCAP CAP_DAC_OVERRIDE CAP_DAC_READ_SEARCH CAP_FOWNER CAP_IPC_OWNER CAP_NET_ADMIN CAP_SYS_TIME CAP_AUDIT_CONTROL CAP_AUDIT_READ CAP_AUDIT_WRITE CAP_KILL CAP_NET_BIND_SERVICE CAP_NET_BROADCAST CAP_NET_RAW CAP_SYS_NICE CAP_SYS_RESOURCE CAP_MAC_ADMIN CAP_MAC_OVERRIDE CAP_SYS_BOOT CAP_LINUX_IMMUTABLE CAP_IPC_LOCK CAP_SYS_CHROOT CAP_BLOCK_SUSPEND CAP_LEASE CAP_SYS_PACCT CAP_SYS_TTY_CONFIG CAP_WAKE_ALARM +# CapabilityBoundingSet=~CAP_SETUID CAP_SETGID CAP_SETPCAP CAP_SYS_ADMIN CAP_SYS_PTRACE CAP_CHOWN CAP_FSETID CAP_SETFCAP CAP_DAC_OVERRIDE CAP_DAC_READ_SEARCH CAP_FOWNER CAP_IPC_OWNER CAP_NET_ADMIN CAP_SYS_TIME CAP_AUDIT_CONTROL CAP_AUDIT_READ CAP_AUDIT_WRITE CAP_KILL CAP_NET_BIND_SERVICE CAP_NET_BROADCAST CAP_NET_RAW CAP_SYS_NICE CAP_SYS_RESOURCE CAP_MAC_ADMIN CAP_MAC_OVERRIDE CAP_SYS_BOOT CAP_LINUX_IMMUTABLE CAP_IPC_LOCK CAP_SYS_CHROOT CAP_BLOCK_SUSPEND CAP_LEASE CAP_SYS_PACCT CAP_SYS_TTY_CONFIG CAP_WAKE_ALARM +CapabilityBoundingSet= Environment=XDG_CACHE_HOME=/var/cache/reflector LockPersonality=true MemoryDenyWriteExecute=true @@ -27,7 +28,7 @@ ProtectSystem=strict ReadOnlyPaths=/etc/xdg/reflector/reflector.conf ReadWritePaths=/etc/pacman.d/mirrorlist RemoveIPC=true -RestrictAddressFamilies=~AF_AX25 AF_IPX AF_APPLETALK AF_X25 AF_DECnet AF_KEY AF_NETLINK AF_PACKET AF_RDS AF_PPPOX AF_LLC AF_IB AF_MPLS AF_CAN AF_TIPC AF_BLUETOOTH AF_ALG AF_VSOCK AF_KCM AF_UNIX AF_XDP +RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX RestrictNamespaces=true RestrictRealtime=true RestrictSUIDSGID=true diff --git a/setup.py b/setup.py index d1a90ed..f25911b 100644 --- a/setup.py +++ b/setup.py @@ -5,11 +5,11 @@ import time setup( name='Reflector', - version=time.strftime('%Y.%m.%d.%H.%M.%S', time.gmtime( 1617446608)), + version=time.strftime('%Y.%m.%d.%H.%M.%S', time.gmtime( 1637376063)), description='''A Python 3 module and script to retrieve and filter the latest Pacman mirror list.''', author='Xyne', - author_email='ac xunilhcra enyx, backwards', - url='''http://xyne.archlinux.ca/projects/reflector''', + author_email='gro xunilhcra enyx, backwards', + url='''http://xyne.dev/projects/reflector''', py_modules=['Reflector'], scripts=['reflector'] ) -- cgit v1.2.3-54-g00ecf