SELECT 组的点名成员 AUTO 排第一,不再静默回退到直连
内核给没有选中记录的组默认用第一个成员,选中的线路被订阅刷新删掉时也 静默回退到第一个成员(selector.go:103-112)。之前第一位是 DIRECT,这两种 情况都会让一路入站在无人察觉时变成直连,对按端口定向出站的场景是泄露。 另加 sharedPeers():「共用」标记只在真有别的入站落在同一个组上时才该出现, 只有自己在用时它是噪音。
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* 一路入站配三个组,入站的 `proxy:` 指向其中的 SELECT,换线是换那个组的当前选中,
|
||||
* 不改配置文件(决策记录 0007):
|
||||
* SELECT 手动选。它的成员是 DIRECT、下面两个组,加上订阅里的线路
|
||||
* SELECT 手动选。成员是 AUTO、FALLBACK、DIRECT 加订阅里的线路,顺序见 applySetup
|
||||
* AUTO url-test,自动挑延迟最低的
|
||||
* FALLBACK fallback,按顺序挑第一个测得通的
|
||||
* 界面上这三个是并排的 tab。做成三个而不是让用户自己配,是因为它们就是所有 clash 配置
|
||||
@@ -15,7 +15,7 @@
|
||||
* 配置里的东西属于谁全靠三条线索还原,不靠解析名字:
|
||||
* 四个组 名字由入站名推出来
|
||||
* 订阅副本 override.dialer-proxy 指向哪一路的入口组
|
||||
* 副本的来源 url 和哪个用户订阅相同
|
||||
* 副本的来源 path 和哪个用户订阅相同(读同一个缓存文件)
|
||||
*/
|
||||
import type { ConfigObject } from '../vendor/config-editor/index.ts'
|
||||
import { resolveDestination } from './inbounds.ts'
|
||||
@@ -272,7 +272,7 @@ function makeChainProvider(source: ConfigObject, inbound: string, cachePath: str
|
||||
* 把一路入站的出站设置写回配置。
|
||||
*
|
||||
* 开了链式代理时,三个组的成员都改从订阅副本里取,因为只有副本挂着 `dialer-proxy`。
|
||||
* 用户选的来源订阅仍然可以从副本的 `url` 还原出来,所以配置文件之外不需要另存状态。
|
||||
* 用户选的来源订阅仍然可以从副本的 `path` 还原出来,所以配置文件之外不需要另存状态。
|
||||
*/
|
||||
export function applySetup(data: ConfigObject, inbound: string, setup: OutboundSetup): ConfigObject {
|
||||
const next = { ...data }
|
||||
@@ -305,12 +305,15 @@ export function applySetup(data: ConfigObject, inbound: string, setup: OutboundS
|
||||
|
||||
const { filter } = setup.proxy
|
||||
let groups = groupsOf(next)
|
||||
// AUTO 排第一位:内核给没有选中记录的组默认用第一个成员,选中的线路被订阅刷新删掉时
|
||||
// 也静默回退到第一个成员(内核源码 adapter/outboundgroup/selector.go:103-112)。这两种
|
||||
// 情况都该落到自动测速上;排 DIRECT 就是静默直连,对按端口定向出站的场景是泄露。
|
||||
groups = upsert(
|
||||
groups,
|
||||
makeGroup(proxyGroupName(inbound), 'select', use, filter, [
|
||||
'DIRECT',
|
||||
autoGroupName(inbound),
|
||||
fallbackGroupName(inbound),
|
||||
'DIRECT',
|
||||
]),
|
||||
)
|
||||
groups = upsert(groups, makeGroup(autoGroupName(inbound), 'url-test', use, filter))
|
||||
@@ -480,6 +483,30 @@ export function panelGroups(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 还有哪些入站和这一路落在同一个共用组上。
|
||||
*
|
||||
* 「共用」这个提醒只在真有人共用时才成立:几路没接管的入站顺着规则表落到同一个手动
|
||||
* 选择组时,在其中一路上换选中会连带改掉其它几路的去向。只有自己在用就没什么可提醒的。
|
||||
*/
|
||||
export function sharedPeers(
|
||||
data: ConfigObject,
|
||||
runtime: Record<string, RuntimeNode>,
|
||||
inbounds: Inbound[],
|
||||
inbound: Inbound,
|
||||
): string[] {
|
||||
const own = panelGroups(data, runtime, inbound)
|
||||
if (!own.shared) return []
|
||||
const group = own.groups[0]?.name
|
||||
return inbounds
|
||||
.filter((other) => other.id !== inbound.id)
|
||||
.filter((other) => {
|
||||
const panel = panelGroups(data, runtime, other)
|
||||
return panel.shared && panel.groups[0]?.name === group
|
||||
})
|
||||
.map((other) => other.name)
|
||||
}
|
||||
|
||||
/**
|
||||
* 筛选条件会留下哪些线路。界面上用来在保存前当场告诉用户「匹配到几条」。
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user