Implement HTTP relay proxy with upstream load balancing (round-robin/best/priority), captive-style health checking, domain blacklist/whitelist routing with domain-expression matching, and hot reload#1
Conversation
… reload Co-authored-by: MejiroRina <70424266+MejiroRina@users.noreply.github.com> Agent-Logs-Url: https://github.com/Team-Haruki/http-proxy-lb/sessions/f3748e80-1418-4394-a40c-a54bceb41f43
…sed parameters Co-authored-by: MejiroRina <70424266+MejiroRina@users.noreply.github.com> Agent-Logs-Url: https://github.com/Team-Haruki/http-proxy-lb/sessions/f3748e80-1418-4394-a40c-a54bceb41f43
|
@copilot 再加一个优先级模式,为每个上游节点做优先级标记,根据节点存活状态切换 |
|
@MejiroRina The model You can try again without specifying a model (just If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: |
5 similar comments
|
@MejiroRina The model You can try again without specifying a model (just If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: |
|
@MejiroRina The model You can try again without specifying a model (just If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: |
|
@MejiroRina The model You can try again without specifying a model (just If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: |
|
@MejiroRina The model You can try again without specifying a model (just If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: |
|
@MejiroRina The model You can try again without specifying a model (just If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: |
|
@copilot 再加一个优先级模式,为每个上游节点做优先级标记,根据节点存活状态切换 |
|
@MejiroRina The model You can try again without specifying a model (just If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: |
2 similar comments
|
@MejiroRina The model You can try again without specifying a model (just If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: |
|
@MejiroRina The model You can try again without specifying a model (just If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: |
|
@copilot 再加一个优先级模式,为每个上游节点做优先级标记,根据节点存活状态切换 |
|
@MejiroRina The model You can try again without specifying a model (just If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: |
|
@MejiroRina The model You can try again without specifying a model (just If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: |
1 similar comment
|
@MejiroRina The model You can try again without specifying a model (just If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: |
Co-authored-by: MejiroRina <70424266+MejiroRina@users.noreply.github.com> Agent-Logs-Url: https://github.com/Team-Haruki/http-proxy-lb/sessions/b98dfa76-d6b3-429d-bd68-504f22a80536
Co-authored-by: MejiroRina <70424266+MejiroRina@users.noreply.github.com> Agent-Logs-Url: https://github.com/Team-Haruki/http-proxy-lb/sessions/b98dfa76-d6b3-429d-bd68-504f22a80536
已实现 priority 模式并支持按上游节点优先级自动切换(节点离线时切到下一优先级在线节点,恢复后可自动回切)。对应提交:be4ff1e。
已实现 priority 模式并支持按上游节点优先级自动切换(节点离线时切到下一优先级在线节点,恢复后可自动回切)。对应提交:be4ff1e。
已实现 priority 模式并支持按上游节点优先级自动切换(节点离线时切到下一优先级在线节点,恢复后可自动回切)。对应提交:be4ff1e。 |
|
@copilot 连通性测试用类似gstatic generate 204之类的captive来检测代理是否存活 |
Co-authored-by: MejiroRina <70424266+MejiroRina@users.noreply.github.com> Agent-Logs-Url: https://github.com/Team-Haruki/http-proxy-lb/sessions/796359e3-233b-45ca-b09b-fd596935b478
已按建议改为 captive 风格连通性检测:对离线上游发起 |
|
@copilot 需要支持黑白名单,比如黑名单模式下特定域名直接连接不走代理,白名单模式下特定域名走代理不走直连 |
Co-authored-by: MejiroRina <70424266+MejiroRina@users.noreply.github.com> Agent-Logs-Url: https://github.com/Team-Haruki/http-proxy-lb/sessions/7142be7c-21ed-4f22-a713-fb8bfd12f8d5
已支持黑白名单路由策略:新增 |
|
@copilot 忘了说了,域名要支持domain和domain suffix之类的表达方法,并且最后为这个项目添加AGENTS.md和copilot-Instructions.md |
Co-authored-by: MejiroRina <70424266+MejiroRina@users.noreply.github.com> Agent-Logs-Url: https://github.com/Team-Haruki/http-proxy-lb/sessions/4c8ca4fb-6fd8-475f-b504-6d64f5f3361f
已补充域名表达方式支持: |
Greenfield implementation of an HTTP relay proxy that listens on a local port and forwards traffic through a configurable upstream proxy pool with high-availability guarantees.
Core architecture
src/config.rs— YAML config structs (yaml_serde); mtime-based hot-reload detection; domain routing policy configsrc/upstream.rs—UpstreamEntry(atomic state machine, latency EMA α=0.25, active-conn counter) +UpstreamPool(selection, reload)src/health.rs— Background task; probes offline upstreams using captive-style HTTPgenerate_204requests through the proxy, marks online on HTTP 204src/proxy.rs— HTTP/1.x handler:CONNECTtunnel + plain HTTP forwarding; Content-Length and chunked body; client keep-alive; domain-policy based direct/proxy routing with domain-expression matchingsrc/main.rs— Tokio accept loop; spawns health checker and hot-reload watcherLoad balancing
Three modes via
mode:in config:round_robinbestlatency_ema_ms + active_conns × 50prioritypriorityvalue (higher priority), and automatically falls back to the next online priority level when the current one is offlineEach upstream now supports a
priorityfield (default:100) forprioritymode.Domain routing policy (blacklist / whitelist)
Adds optional domain-based direct/proxy selection:
Behavior:
off(default): all domains use upstream proxyblacklist: listed domains connect directly (bypass upstream proxy); others use upstream proxywhitelist: listed domains use upstream proxy; others connect directlyThis policy is applied to both:
For direct HTTP routing, absolute-form proxy request targets are rewritten to origin-form before sending to origin servers.
Domain expression formats
domain_policy.domainssupports:domain:example.com— exact domain matchsuffix:example.com— domain suffix match*.example.com/.example.com— suffix shorthandexample.com— backward-compatible exact-or-suffix matchingHealth checking
Passive — any TCP connect failure immediately marks the upstream offline; the in-flight request is retried on the next available upstream (up to
min(pool_size, 3)attempts, then 502).Active — background task probes each offline upstream every
health_check.interval_secsseconds by sending a captive-style HTTP proxy request to:GET http://connectivitycheck.gstatic.com/generate_204Only an HTTP 204 response marks the upstream back online; non-204/timeout/error keeps it offline.
Hot reload
Config file mtime is polled every
reload_interval_secsseconds. On change, the upstream list is reconciled: existing entries (matched by URL) retain their online/offline state and stats; new entries start online; removed entries are dropped — no restart required.For existing URL-matched upstreams, hot reload now refreshes mutable config values (including
priority,weight, and auth settings) while preserving runtime state/statistics, so priority changes take effect without restart.Documentation additions
AGENTS.mdat repository rootcopilot-Instructions.mdat repository rootTests and validation
off/blacklist/whitelist)domain:,suffix:,*./.shorthand, legacy plain form, empty-expression guards)cargo test)cargo clippy -- -D warnings)Original prompt
📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.