From dd52cbe9a3eb21c183599116209ff47c02d3b2fa Mon Sep 17 00:00:00 2001 From: Andrei Smaliak Date: Thu, 29 Oct 2026 15:46:33 +0100 Subject: [PATCH] Identify OS updater requests for the new Git proxy --- docs/releases/console-3.1.29.md | 1 + install_iomatex_edge.sh | 2 +- offline/git_delivery.py | 2 +- offline/test_bootstrap_fallback.py | 1 + offline/test_git_delivery.py | 1 + 5 files changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/releases/console-3.1.29.md b/docs/releases/console-3.1.29.md index 88c6c3a..a5a1fd6 100644 --- a/docs/releases/console-3.1.29.md +++ b/docs/releases/console-3.1.29.md @@ -3,3 +3,4 @@ - Install shared Git delivery with git.iomatex.com as its canonical HTTPS host. - Normalize legacy saved hosts in stage checks and package downloads; retain exact-host trust, TLS verification, pinned commits and checksums. - Bootstrap defaults to git.iomatex.com; legacy installer URLs and virtual APT paths remain accepted. +- Identify bootstrap and package requests as IomatexOS-Updater/1.0; avoid the new proxy rejecting the default Python user agent with Cloudflare 1010. diff --git a/install_iomatex_edge.sh b/install_iomatex_edge.sh index 7e0ac93..4e20d61 100755 --- a/install_iomatex_edge.sh +++ b/install_iomatex_edge.sh @@ -56,7 +56,7 @@ repo = parsed.path.strip('/').removesuffix('.git') class NoRedirect(urllib.request.HTTPRedirectHandler): def redirect_request(self, *args, **kwargs): raise RuntimeError('Git download redirect refused') -headers = {'Authorization': 'Basic ' + base64.b64encode((os.environ['IOMATEX_GIT_USERNAME'] + ':' + os.environ['IOMATEX_GIT_PASSWORD']).encode()).decode()} +headers = {'User-Agent': 'IomatexOS-Updater/1.0', 'Authorization': 'Basic ' + base64.b64encode((os.environ['IOMATEX_GIT_USERNAME'] + ':' + os.environ['IOMATEX_GIT_PASSWORD']).encode()).decode()} opener = urllib.request.build_opener(NoRedirect) hosts = [parsed.netloc] + [h for h in ('git.it-screen.com', 'git.iomatex.com') if h != parsed.netloc] commit = None diff --git a/offline/git_delivery.py b/offline/git_delivery.py index b7ca250..3347015 100644 --- a/offline/git_delivery.py +++ b/offline/git_delivery.py @@ -68,7 +68,7 @@ def auth_from_env(): def open_git(repo, endpoint, auth, timeout=120): url = 'https://' + git_host(auth.get('host', HOST)) + '/api/v1/repos/' + repo + '/' + endpoint token = base64.b64encode((auth['username'] + ':' + auth['password']).encode()).decode() - req = urllib.request.Request(url, headers={'Authorization': 'Basic ' + token}) + req = urllib.request.Request(url, headers={'Authorization': 'Basic ' + token, 'User-Agent': 'IomatexOS-Updater/1.0'}) return urllib.request.build_opener(NoRedirect).open(req, timeout=timeout) def raw_endpoint(path, commit): diff --git a/offline/test_bootstrap_fallback.py b/offline/test_bootstrap_fallback.py index 40d4833..c9930f8 100644 --- a/offline/test_bootstrap_fallback.py +++ b/offline/test_bootstrap_fallback.py @@ -39,6 +39,7 @@ class BootstrapFallbackTest(unittest.TestCase): def test_explicit_alternate_is_tried_first(self): _, opener = self.run_bootstrap([io.BytesIO(BRANCH), io.BytesIO(b'loader')], 'git.iomatex.com') self.assertIn('git.iomatex.com', opener.open.call_args_list[0].args[0].full_url) + self.assertEqual('IomatexOS-Updater/1.0', opener.open.call_args_list[0].args[0].get_header('User-agent')) def test_auth_and_tls_fail_without_switch(self): for error in [HTTPError('url', 401, 'Unauthorized', {}, None), URLError(ssl.SSLCertVerificationError('invalid certificate'))]: diff --git a/offline/test_git_delivery.py b/offline/test_git_delivery.py index 4ee55c6..7ebebdf 100644 --- a/offline/test_git_delivery.py +++ b/offline/test_git_delivery.py @@ -17,6 +17,7 @@ class DeliveryTest(unittest.TestCase): with patch.object(d.urllib.request, 'build_opener') as opener: d.open_git('An-J/Iomatex_OS', 'branches/ci-cd', {'username': 'u', 'password': 'p', 'host': host}) request = opener.return_value.open.call_args.args[0] + self.assertEqual('IomatexOS-Updater/1.0', request.get_header('User-agent')) self.assertEqual('https://git.iomatex.com/api/v1/repos/An-J/Iomatex_OS/branches/ci-cd', request.full_url) for host in ['evil.example', 'git.iomatex.com.evil', 'user@git.iomatex.com', 'git.iomatex.com:443']: with self.assertRaises(ValueError):