Skip to content

feat: add SOCKS5/HTTP proxy support for all provider requests#347

Open
zergzorg wants to merge 2 commits intorobinebers:mainfrom
zergzorg:feat/proxy-support
Open

feat: add SOCKS5/HTTP proxy support for all provider requests#347
zergzorg wants to merge 2 commits intorobinebers:mainfrom
zergzorg:feat/proxy-support

Conversation

@zergzorg
Copy link
Copy Markdown

@zergzorg zergzorg commented Apr 5, 2026

Summary

Add minimal proxy support for personal use — all outgoing HTTP requests from providers/plugins can now be routed through a SOCKS5 or HTTP proxy.

Configuration

Create ~/.openusage/config.json:

{
  "proxy": {
    "enabled": true,
    "url": "socks5://127.0.0.1:10808"
  }
}

Details

  • Zero overhead — config loaded once at startup via OnceLock, cached as pre-resolved reqwest::Proxy
  • Localhost bypasslocalhost, 127.0.0.1, ::1 always bypass the proxy (via reqwest::NoProxy)
  • Graceful fallback — missing file, invalid JSON, or invalid URL → app continues without proxy
  • SOCKS5 + HTTP/HTTPS — supported natively by reqwest
  • No UI changes — file-only config
  • No env vars — hardcoded path ~/.openusage/config.json

Changes

File What
src-tauri/src/config.rs New — config loader with OnceLock caching, NoProxy bypass, URL redaction
src-tauri/Cargo.toml Added socks feature to reqwest
src-tauri/src/lib.rs Early config load during app setup
src-tauri/src/plugin_engine/host_api.rs Proxy applied to the single Client::builder() + connect_timeout

Summary by cubic

Add optional SOCKS5/HTTP proxy support for all provider/plugin HTTP requests, configurable via ~/.openusage/config.json. Defaults off; when enabled, requests use the proxy with a localhost bypass and safe fallback if the config is missing, invalid, or no home directory is found.

  • New Features

    • Apply a pre-resolved reqwest::Proxy to the shared HTTP client (OnceLock; supports SOCKS5/HTTP).
    • Bypass proxy for localhost addresses.
    • Add connect_timeout aligned with the request timeout.
    • Redact credentials when logging the proxy URL.
  • Bug Fixes

    • Avoid relative config path when the home directory is unavailable; proxy stays disabled in that case.

Written for commit 2c27806. Summary will update on new commits.

Add centralized proxy configuration for all provider/plugin HTTP requests.
- Config file at ~/.openusage/config.json with optional proxy settings
- Resolved once at startup via OnceLock, zero per-request overhead
- Localhost bypass (localhost, 127.0.0.1, ::1) via reqwest NoProxy
- Supports SOCKS5 and HTTP/HTTPS proxies
- Graceful fallback if config is missing, disabled, or invalid
- Added reqwest 'socks' feature for SOCKS5 support

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
@github-actions github-actions bot added the rust Pull requests that update rust code label Apr 5, 2026
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 4 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src-tauri/src/config.rs">

<violation number="1" location="src-tauri/src/config.rs:38">
P2: Config path falls back to relative CWD when home directory resolution fails, allowing unintended proxy config loading from `./.openusage/config.json`.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rust Pull requests that update rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant