Skip to content

feat: Add proxy pool support for IP rotation#311

Open
keung67 wants to merge 1 commit intochenyme:mainfrom
keung67:main
Open

feat: Add proxy pool support for IP rotation#311
keung67 wants to merge 1 commit intochenyme:mainfrom
keung67:main

Conversation

@keung67
Copy link

@keung67 keung67 commented Mar 11, 2026

Summary

需求/動機與目的: 輪詢代理IP,例如:webshare建立代理池達到流量負載平衡,利用多帳號使用免費計畫中的1GB/月流量

Round-Robin Proxy 實作完成
改動總覽
僅 1 個新檔案 + 1 處修改,所有現有呼叫者零改動。

[NEW]
proxy_pool.py
Thread-safe round-robin proxy pool:

解析逗號分隔的 proxy URL 為列表
每次呼叫回傳下一個 proxy(round-robin)
配置值變更時自動重建 pool
單一 proxy 或空值時行為與原本完全一致

使用方式
在 config.toml 或管理面板中設定:

[proxy]
base_proxy_url = "http://proxy1:8080,http://proxy2:8080,socks5://proxy3:1080"

每次 API 請求會依序使用 proxy1 → proxy2 → proxy3 → proxy1 → ...

Changes

  • 功能新增
  • Bug 修复
  • 重构/清理
  • 文档更新
  • 其他(请说明)

Related Issues

Verification

  • 本地运行验证
  • 单元/集成测试
  • Docker 构建通过
  • 未验证(请说明原因)

验证说明:

  1. Add multiple proxy URLs in the config.
  2. Run the application and observe the outgoing requests rotating through the configured proxy IPs.
- 调用 /v1/chat/completions 返回符合预期

Breaking Changes

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.

1 participant