Skip to content

Honor ArkOS4Clone HTTP proxy settings across sudo - #347

Merged
kloptops merged 3 commits into
PortsMaster:mainfrom
Godalin:fix/arkos4clone-http-proxy
Oct 23, 2026
Merged

kloptops merged 3 commits into
PortsMaster:mainfrom
Godalin:fix/arkos4clone-http-proxy

Conversation

@Godalin

@Godalin Godalin commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

When an HTTP proxy is enabled in ArkOS4Clone's Wi-Fi settings, PortMaster can still attempt direct connections and time out downloading games. This was reproduced on an XF40H running ArkOS4Clone 09152026 with PortMaster 2026.07.28-1212 beta.

EmulationStation saves the proxy in es_settings.cfg and applies it to its own curl requests, without exporting standard proxy variables. PortMaster's sudo launch also filters inherited proxy variables.

This change reads enabled ArkOS HTTP settings before privilege escalation and passes the resulting proxy/bypass assignments to pugwash through env after sudo. Existing explicitly supplied HTTP(S)/ALL_PROXY variables take precedence and are passed through, including empty values; explicit bypass variables are also preserved. Missing or disabled settings leave the importer inactive.

The helper uses only the Python standard library, handles ES settings with multiple XML roots, and validates host/port and control characters before emitting any assignments. Bash passes values as array elements without evaluating shell text. Configuration errors do not abort startup, and warnings do not log proxy values or credentials. The helper is outside pylibs so it is available before pugwash extracts pylibs.zip, and is included by the existing release packaging.

Validation:

  • python3 -m unittest discover -s tests -v: all 9 tests passed locally and on the XF40H (Python 3.7).
  • bash -n PortMaster/PortMaster.sh and git diff --check passed.
  • The final launcher setup was exercised on the handheld with PortMaster's actual sudo preserve-env arguments and bundled Requests library; a proxied HTTPS request to the GitHub API returned HTTP 200.
  • Tests cover XML parsing, missing/disabled/malformed settings, IPv6, credentials, explicit environment precedence, bypass precedence, invalid values, and passing literal arguments through an environment-clearing sudo substitute.

Scope: the ArkOS settings importer supports HTTP proxies. SOCKS5 import is deliberately excluded because PySocks is not bundled. No read-timeout change is included. Full graphical startup and an uninterrupted large download through the patched GUI have not been tested.

Godalin and others added 3 commits October 5, 2026 14:37
PortMaster.sh is a stub since PortsMaster#350; the launch loop is in
utils/pm_launch.txt. Takes main's stub, the proxy import is reworked
in the next commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NxABmR1rUUgi4iicVLZchY
Reworks the launcher-side import onto the restructured launcher
(PortsMaster#350). Instead of a helper run before sudo and passed through `env`
on the GUI's launch line, harbourmaster.util.setup_proxy() runs at the
start of both main()s:

- pugwash's (the GUI and fifo_control, so autoinstall's runtime
  downloads too) and harbourmaster's CLI, which the launch line alone
  missed.
- No extra python process on every launch, on every CFW.
- es_settings.cfg is found from SUDO_USER's home, then HOME, then
  /home/ark.

Kept from the original: the multi-root XML parsing, HTTP only (no
PySocks), host/port/control character checks, credentials kept out of
the log, and a proxy already in the environment (even an empty one)
winning, with an explicit no_proxy kept. A host with a bad port of
its own ("proxy:abc") is now refused even when ProxyPort is set.

Tests move to pytest (tests/test_proxy.py), including that the bundled
requests picks the proxy up and that both main()s set it up before
HarbourMaster. conftest keeps main() away from the real settings files.

Co-Authored-By: Linyu Yang <yly1228@foxmail.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NxABmR1rUUgi4iicVLZchY
@kloptops

Copy link
Copy Markdown
Member

Thanks for this, it's a real problem, and your validation, logging and precedence rules all carried over.

I've pushed a rework onto your branch. The launcher was restructured in #350 (PortMaster.sh is now a stub, and the launch loop is in utils/pm_launch.txt), so instead of passing the proxy through env on the launch line, PortMaster now reads it in Python after sudo:

  • harbourmaster.util.setup_proxy() runs at the start of pugwash's and harbourmaster's main(). That covers the GUI, autoinstall (whose runtime downloads the launch line missed) and the CLI.
  • es_settings.cfg is found from SUDO_USER's home, then HOME, then /home/ark.
  • There's no extra python3 process at launch, which would have run on every CFW.
  • Your XML parsing, HTTP-only rule, host/port/control-character checks, credential-free logging and environment precedence are kept. One addition: a host with its own bad port (proxy:abc) is now refused even when ProxyPort is set.
  • The tests moved to pytest in tests/test_proxy.py.

Tested on a device through a real HTTP proxy, with the device's default route removed: a port installs through the proxy, and fails without the settings.

@kloptops
kloptops merged commit f62d392 into PortsMaster:main Oct 23, 2026
4 checks passed
@Godalin

Godalin commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for reviewing and merging this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants