Skip to content

Fix macOS Git proxy discovery for system proxies - #4

Merged
jiale-wangOwO merged 2 commits into
jiale-wangOwO:mainfrom
JavisZhangSir-BYR:agent/macos-system-proxy
Aug 6, 2026
Merged

jiale-wangOwO merged 2 commits into
jiale-wangOwO:mainfrom
JavisZhangSir-BYR:agent/macos-system-proxy

Conversation

@JavisZhangSir-BYR

@JavisZhangSir-BYR JavisZhangSir-BYR commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

What changed

This pull request makes GitDrop's external Git subprocess honor proxy settings on macOS.

Proxy resolution now follows this order:

  1. GITDROP_HTTPS_PROXY
  2. HTTPS_PROXY / https_proxy
  3. ALL_PROXY / all_proxy
  4. HTTP_PROXY / http_proxy
  5. macOS system proxy returned by urllib.request.getproxies()

The implementation respects the system proxy bypass list for github.com. A proxy without credentials is passed through both standard proxy environment variables and a per-command configuration:

git -c http.proxy=<proxy> ...

Credentialed proxy URLs are passed only through the subprocess environment so their usernames and passwords never appear in process command-line arguments. This does not modify the user's global Git configuration.

Network failures now include a targeted proxy troubleshooting hint. Git output is defensively scrubbed of the GitHub token, raw proxy credentials, complete credentialed proxy URLs, and their URL-encoded forms.

Why

A macOS app launched from Finder does not normally inherit shell proxy environment variables. When Shadowrocket or another Fake-IP/TUN proxy is enabled, github.com may resolve to an address in 198.18.0.0/15. Without the system proxy, Git attempts to connect directly to that Fake-IP and fails with errors such as:

SSL_ERROR_SYSCALL
Connection reset by peer
Recv failure

Explicitly setting http.proxy=http://127.0.0.1:<port> makes clone and push work, confirming that the problem is missing proxy propagation rather than GitHub TLS, repository permissions, or authentication.

This is a separate network path from the GitHub API certificate and retry fix in #2.

Tests

Added 13 standard-library unittest cases covering:

  • explicit GitDrop proxy priority;
  • standard proxy environment precedence;
  • macOS HTTPS and HTTP system proxy discovery;
  • system proxy bypass behavior;
  • non-macOS fallback behavior;
  • proxy propagation to the Git command and subprocess environment;
  • environment-only propagation for credentialed proxies;
  • unchanged command shape when no proxy is selected;
  • proxy-credential redaction in diagnostics;
  • URL-encoded proxy-credential redaction;
  • GitHub token redaction from errors.

Validation performed:

python3 -m unittest discover -s tests -v
Ran 13 tests ... OK

python3 -m compileall -q gitdrop tests
git diff --check

A local Git integration check also confirmed that the per-command http.proxy value is visible to Git.

Added tests/__init__.py so standard root-level unittest discovery finds the suite. A new pull-request test workflow runs the suite automatically, and release builds now run the same tests before packaging.

Documentation

Added a macOS proxy troubleshooting section covering Shadowrocket, Clash, Surge, Fake-IP/TUN behavior, proxy precedence, and the explicit GITDROP_HTTPS_PROXY override.

Security

TLS verification remains enabled. The implementation does not:

  • disable http.sslVerify;
  • place the GitHub token in command-line arguments;
  • place credentialed proxy URLs in command-line arguments;
  • modify global Git proxy configuration;
  • store proxy credentials in repository remotes or diagnostics.

Closes #3.

@JavisZhangSir-BYR
JavisZhangSir-BYR marked this pull request as ready for review August 6, 2026 03:59

@jiale-wangOwO jiale-wangOwO left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

????:????????(Request changes)?

  1. [P2] ??????????????
    gitdrop/git_sync.py ? _run() ????? URL ?? git -c http.proxy=...???? URL ????????,??????????????????????????????? Git,????????????? URL,???????????????

  2. [P2] ?? Git ????????????
    ????? GitHub Token?? Git ? stderr ?????? URL,_proxy_display_name() ??????????,???????????????????(?? URL ????)???????

  3. [P3] ?????????????
    ?? 11 ???????????,??? unittest discover ????????,Release workflow ???????????? tests/__init__.py,?? CI/release workflow ??????

??????macOS ???????bypass ??? README ?????????????

@jiale-wangOwO
jiale-wangOwO dismissed their stale review August 6, 2026 04:57

The review text was corrupted by an encoding issue. Superseded by a corrected UTF-8 review.

@jiale-wangOwO jiale-wangOwO left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

审阅结论:建议先修改后合并。

  1. [P2] 代理账号密码会出现在进程命令行中。_run() 把完整代理 URL 放进 git -c http.proxy=...。如果 URL 含用户名和密码,其他本地进程可能读取凭据。建议不要把含凭据的代理 URL 放入命令行。

  2. [P2] Git 原始错误可能泄露代理密码。当前只脱敏 Token;如果 stderr 回显完整代理 URL,_proxy_display_name() 只保护追加提示,不能保护原始错误。建议展示错误前同时脱敏代理凭据及其 URL 编码形式。

  3. [P3] 新增测试没有接入自动流程。11 个测试可单独运行并通过,但标准 unittest discover 当前发现不到测试,Release workflow 也没有执行测试。建议增加 tests/__init__.py 并在 CI 中运行测试。

代理优先级、macOS 系统代理读取、bypass 处理和 README 说明暂未发现其他阻塞问题。

@jiale-wangOwO
jiale-wangOwO merged commit e270604 into jiale-wangOwO:main Aug 6, 2026
1 check passed
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.

macOS: Git subprocess does not honor system proxy (Shadowrocket / Fake-IP)

2 participants