mirror of
https://github.com/therealaleph/MasterHttpRelayVPN-RUST.git
synced 2026-05-18 06:44:35 +03:00
5101a06a5d
Three user-reported fixes / features in one release. === PR #9 — dynamic Google IP discovery (@v4g4b0nd-0x76) === Already merged in the previous commit. Opt-in via 'fetch_ips_from_api' in config. Pulls goog.json from www.gstatic.com, maps it against resolved IPs of well-known Google domains, samples from matching CIDRs, and validates each candidate with gws / x-google / alt-svc response-header checks. Graceful fallback to the static list if the fetch fails or nothing passes validation. Default is off so existing users are unaffected. Closes #10. === Issue #8 — OpenWRT: 'accept: No file descriptors available' === OpenWRT routers ship a very low RLIMIT_NOFILE (often 1024, sometimes 256 on constrained devices). A browser's burst of ~30 parallel sub- resource requests can fill the limit within seconds, after which accept(2) returns EMFILE and the proxy is effectively dead. Two-fold fix: 1. New assets/openwrt/mhrv-rs.init now sets procd limits nofile= "16384 16384" on the service. procd raises the per-process fd limit before the binary even starts. 2. New src/rlimit.rs best-effort-raises RLIMIT_NOFILE in the binary itself (Unix only, no new runtime deps — libc is already transitively present via tokio). Targets 16384 soft, capped to whatever hard limit the kernel already allows the user (so it doesn't need root). Both layers mean the fix applies whether the user runs via /etc/init.d/mhrv-rs start (procd limits kick in) or ./mhrv-rs --config ... (in-binary bump kicks in) or any other invocation path. Closes #8. === Issue #7 — Windows UI crashes silently === User report: on Win 11, run.bat prints 'Starting mhrv-rs UI...' and exits clean, but no UI window ever appears. Root cause: the old run.bat used 'start "" "mhrv-rs-ui.exe"' which returns immediately — if the UI binary dies at launch time (missing GPU driver, RDP without GL accel, AV blocking, …), the crash is invisible because start already disowned the child. Fix: run the UI in-place (not via 'start'), so its stderr and exit code land in the run.bat cmd window. On non-zero exit print a helpful checklist of common Windows launch failures and pause so the user can screenshot the output for an issue report. This doesn't fix the underlying crash for affected users, but it turns a ghost-crash bug into a self-diagnosing one so the next report includes actionable info. Closes-via-diag #7. === Fixes folded into the PR #9 merge === - src/scan_ips.rs: rand::thread_rng() held across an .await tripped the Send bound on the async fn. Scoped the rng in a block so it drops before the subsequent awaits. - src/scan_ips.rs: defend /0 and /32 CIDRs in cidr_to_ips and ip_in_cidr against 1u32 << 32 shift panic. All 36 unit tests pass.
39 lines
1.1 KiB
Bash
39 lines
1.1 KiB
Bash
#!/bin/sh /etc/rc.common
|
|
# OpenWRT procd init script for mhrv-rs.
|
|
# Install as /etc/init.d/mhrv-rs, then:
|
|
# /etc/init.d/mhrv-rs enable
|
|
# /etc/init.d/mhrv-rs start
|
|
#
|
|
# Expects:
|
|
# /usr/bin/mhrv-rs (the static musl binary from the release)
|
|
# /etc/mhrv-rs/config.json (your config)
|
|
|
|
START=99
|
|
USE_PROCD=1
|
|
|
|
BIN=/usr/bin/mhrv-rs
|
|
CONFIG=/etc/mhrv-rs/config.json
|
|
|
|
start_service() {
|
|
[ -x "$BIN" ] || return 1
|
|
[ -f "$CONFIG" ] || return 1
|
|
|
|
procd_open_instance
|
|
procd_set_param command "$BIN" --config "$CONFIG" --no-cert-check
|
|
procd_set_param respawn 3600 5 5
|
|
procd_set_param stdout 1
|
|
procd_set_param stderr 1
|
|
procd_set_param file "$CONFIG"
|
|
# Issue #8 — OpenWRT's default fd limit is tiny (often 1024 and sometimes
|
|
# as low as 256 on constrained devices). A browser's parallel sub-resource
|
|
# burst fills it in seconds and accept(2) starts returning EMFILE. 16k is
|
|
# plenty for a local proxy and costs virtually no kernel memory.
|
|
procd_set_param limits nofile="16384 16384"
|
|
procd_close_instance
|
|
}
|
|
|
|
reload_service() {
|
|
stop
|
|
start
|
|
}
|