feat: 国内流量直连分流(geoip-cn / geosite-cn)— #5
国内 IP/域名直连(不走隧道)→ 省流量 + 国内访问快;非国内走代理。
- clientconfig.go: BuildClientConfig 加 ClientConfigOpts{SplitCN,RulesBaseURL};
开启时 route 加 {rule_set:[geoip-cn,geosite-cn]→direct} + 定义 rule_set
(remote .srs,download_detour:direct 直连下载)
- rules.go: 控制面静态服务 /v1/rules/{name}.srs(白名单防穿越)——自托管避免
GitHub 在国内被墙的鸡生蛋;客户端反正连控制面,可达性有保证
- nodes.go ConnectNode: 读 ?split_cn → opts;NodeAPI 加 rulesBaseURL
(PANGOLIN_PUBLIC_URL);main.go 挂 /v1/rules 路由 + RulesHandler
- 客户端: connect_api splitCN→?split_cn=1;connection_provider 传 smartRoute 偏好
- deploy/single-node: 拉 geoip-cn/geosite-cn.srs 到 $DATA_DIR/rules +
设 PANGOLIN_PUBLIC_URL/PANGOLIN_RULES_DIR
验证:go test(splitCN 开/关渲染 + RulesHandler 白名单/404)+ flutter analyze +
shellcheck;不需要节点。订阅链接暂用默认 opts、DNS 分流为后续增强。
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -47,8 +47,13 @@ class ConnectApi {
|
||||
Future<String> fetchConfig({
|
||||
required String nodeId,
|
||||
required String deviceId,
|
||||
bool splitCN = false,
|
||||
}) async {
|
||||
final uri = Uri.parse('$baseUrl/v1/nodes/$nodeId/connect');
|
||||
// splitCN=true 时带 ?split_cn=1:控制面渲染国内 IP/域名直连(不走隧道,#5)。
|
||||
var uri = Uri.parse('$baseUrl/v1/nodes/$nodeId/connect');
|
||||
if (splitCN) {
|
||||
uri = uri.replace(queryParameters: {'split_cn': '1'});
|
||||
}
|
||||
final http.Response response;
|
||||
|
||||
try {
|
||||
|
||||
@@ -16,6 +16,7 @@ import '../services/connect_api.dart';
|
||||
import 'app_providers.dart';
|
||||
import 'auth_provider.dart';
|
||||
import 'nodes_provider.dart';
|
||||
import 'settings_provider.dart';
|
||||
|
||||
// ── 设备 ID(MVP 常量;后续由 device_info_plus 取真实 ID)──────────
|
||||
|
||||
@@ -123,6 +124,8 @@ class ConnectionController extends StateNotifier<ConnectionState> {
|
||||
final configJson = await _api!.fetchConfig(
|
||||
nodeId: node.uuid,
|
||||
deviceId: _kDeviceId,
|
||||
// smartRoute 偏好 → 国内分流(#5):国内 IP/域名直连,不走隧道。
|
||||
splitCN: _ref.read(settingsProvider).smartRoute,
|
||||
);
|
||||
// bridge.start() 不阻塞至连接建立;on 状态由 statusStream 回调驱动。
|
||||
await _bridge.start(configJson);
|
||||
|
||||
Reference in New Issue
Block a user