页面层(用户真机截图发现前两轮漏裁): - 设置: 摘除 Telegram机器人/邮件菜单与页面, 及页内残留入口(通知页/外部流量/LDAP/2FA设置页) - Xray配置: 摘除负载均衡/DNS/高级配置菜单与页面; 基础配置(出站+路由)完好 - 总览: 摘除 Xray更新弹窗(VersionModal+GeodataSection)全部入口, 版本号改为静态展示 - 13个locale同步摘除461个已删功能专属翻译键(逐键核查前后端引用为零; i18n-dead-keys测试全绿) Xray更新后端(经调查确认仅服务本机bin/xray, 与agent下发/订阅无关): - 删除 getXrayVersion/installXray/updateGeofile 路由与handler(访问返回404) - 删除 ServerService 对应实现与校验和函数; 同步api-docs/monitor白名单/openapi 本机核心监管下线(设计: 主控永不运行本机xray, 入站全在agent): - XrayService.RestartXray 降级为no-op(一次性Warning说明日志); StopXray无进程时幂等返回 - web.go 摘除启动拉起本机核心/CheckXrayRunning看门狗(1s)/ApplyPendingRestart cron(30s)/XrayTrafficJob/CheckClientIpJob 注册 - ApplyPendingRestart 降级为消费即清, 其测试更新为新语义 - XrayMetricsService.Sample 短路: 不再每2s探本机/debug/vars, 状态优雅置为不可用 - 配置生成(纯JSON)/agent链路/订阅/入站CRUD未动; 状态读数优雅归零(stop/Unknown) 注: TestGetXrayConfig_EnabledClientsStillEmitted 在基线945b3a5同样失败(既有问题, 非本轮引入)
41 lines
1.1 KiB
Go
41 lines
1.1 KiB
Go
package service
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestRestartXrayRespectsManualStop(t *testing.T) {
|
|
setupSettingTestDB(t)
|
|
if err := (&SettingService{}).saveSetting("xrayTemplateConfig", "{ not valid json"); err != nil {
|
|
t.Fatalf("seed template: %v", err)
|
|
}
|
|
t.Cleanup(func() { isManuallyStopped.Store(false) })
|
|
|
|
isManuallyStopped.Store(true)
|
|
_ = (&XrayService{}).RestartXray(false)
|
|
|
|
if !isManuallyStopped.Load() {
|
|
t.Fatal("a non-forced restart cleared a deliberate manual stop and would revive xray")
|
|
}
|
|
}
|
|
|
|
// The local core never runs in this build, so ApplyPendingRestart no
|
|
// longer restarts anything and must not re-arm the flag for a retry loop:
|
|
// it consumes the pending flag and drops it.
|
|
func TestApplyPendingRestartDropsFlagWithoutLocalCore(t *testing.T) {
|
|
setupSettingTestDB(t)
|
|
t.Cleanup(func() {
|
|
isManuallyStopped.Store(false)
|
|
isNeedXrayRestart.Store(false)
|
|
})
|
|
isManuallyStopped.Store(false)
|
|
|
|
svc := &XrayService{}
|
|
svc.SetToNeedRestart()
|
|
svc.ApplyPendingRestart()
|
|
|
|
if isNeedXrayRestart.Load() {
|
|
t.Fatal("pending restart must be consumed and dropped; there is no local core to retry against")
|
|
}
|
|
}
|