From 6fd29fa5b282707c8713af34efc5058e85e2b4dc Mon Sep 17 00:00:00 2001 From: kevin Date: Fri, 10 Jul 2026 15:01:36 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=85=A8=E9=9A=A7=E9=81=93=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E8=B7=B3=E8=BF=87=E6=97=A0=E6=84=8F=E4=B9=89=E7=9A=84?= =?UTF-8?q?CIDR=20URL=E4=B8=8B=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 全隧道模式下before-proxy、after-proxy和手动刷新三处仍会从URL 下载CIDR表,但下载结果永远不会被使用。添加ModeFull短路返回, 消除无意义的网络请求和连接延迟。 bump version to 0.6.9 --- Makefile | 2 +- internal/vpn/session.go | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index bc44e74..520f1b4 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ GO = go CGO_ENABLED = 1 WINDRES ?= x86_64-w64-mingw32-windres MINGW_CC ?= x86_64-w64-mingw32-gcc -SEMVER ?= 0.6.8 +SEMVER ?= 0.6.9 GIT_HASH = $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown) VERSION = $(SEMVER)-$(GIT_HASH) LDFLAGS = -s -w -X lmvpn/internal/version.Version=$(VERSION) diff --git a/internal/vpn/session.go b/internal/vpn/session.go index abddfa6..f7cb363 100644 --- a/internal/vpn/session.go +++ b/internal/vpn/session.go @@ -197,7 +197,7 @@ func (sm *SessionManager) run(ctx context.Context, cfg SessionConfig) { // to avoid consuming the server's 30s ReadyTimeout budget. var beforeCIDRs []string allURLSources := append(append([]model.CIDRURLSource{}, cfg.CIDRV4URLs...), cfg.CIDRV6URLs...) - if len(allURLSources) > 0 { + if len(allURLSources) > 0 && cfg.RoutingMode != route.ModeFull { sm.stats.SetConnectStep("fetch_cidrs") sm.setState(stats.StateConnecting) log.L().Info("fetching before-proxy CIDR lists", "url_count", len(allURLSources)) @@ -588,6 +588,9 @@ func (sm *SessionManager) setupTUN(init protocol.InitMessage, cfg SessionConfig, // (via the tunnel) and dynamically adds their routes to the route // manager. This is called in a goroutine after the data plane is up. func (sm *SessionManager) fetchAfterProxyCIDRs(ctx context.Context, cfg SessionConfig) { + if cfg.RoutingMode == route.ModeFull { + return + } allURLSources := append(append([]model.CIDRURLSource{}, cfg.CIDRV4URLs...), cfg.CIDRV6URLs...) // Count only "after" sources for logging. afterCount := 0 @@ -659,6 +662,10 @@ func (sm *SessionManager) RefreshCIDRs() { return } + if cfg.RoutingMode == route.ModeFull { + return + } + // Use a background context with 30s timeout so the refresh works // even if the session context is in a weird state. refreshCtx, cancel := context.WithTimeout(context.Background(), 30*time.Second)