From 2658062d4c176201d0decf03929a89b44761c072 Mon Sep 17 00:00:00 2001 From: Marek Blaha Date: Mon, 3 Apr 2023 12:19:40 +0200 Subject: [PATCH] Backport: automatic: Fix online detection with proxy (RhBz:2022440) In case the proxy is configured (either for a repo of globally) it is used also for detecting whether the system is online. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2022440 --- dnf/automatic/main.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/dnf/automatic/main.py b/dnf/automatic/main.py index b53d9c0..93ce13c 100644 --- a/dnf/automatic/main.py +++ b/dnf/automatic/main.py @@ -251,21 +251,29 @@ def wait_for_network(repos, timeout): 'http': 80, 'https': 443, 'ftp': 21, + 'socks': 1080, + 'socks5': 1080, } def remote_address(url_list): for url in url_list: parsed_url = dnf.pycomp.urlparse.urlparse(url) - if parsed_url.hostname and parsed_url.scheme in remote_schemes: - yield (parsed_url.hostname, - parsed_url.port or remote_schemes[parsed_url.scheme]) + if (not parsed_url.hostname) \ + or (not parsed_url.port and parsed_url.scheme not in remote_schemes): + # skip urls without hostname or without recognized port + continue + yield (parsed_url.hostname, + parsed_url.port or remote_schemes[parsed_url.scheme]) # collect possible remote repositories urls addresses = set() for repo in repos.iter_enabled(): - addresses.update(remote_address(repo.baseurl)) - addresses.update(remote_address([repo.mirrorlist])) - addresses.update(remote_address([repo.metalink])) + if repo.proxy: + addresses.update(remote_address([repo.proxy])) + else: + addresses.update(remote_address(repo.baseurl)) + addresses.update(remote_address([repo.mirrorlist])) + addresses.update(remote_address([repo.metalink])) if not addresses: # there is no remote repository enabled so network connection should not be needed -- libgit2 1.3.2