Compare commits

...

2 Commits

25 changed files with 1192 additions and 123 deletions
+328
View File
@@ -1055,5 +1055,333 @@
],
"SourceOnly": true,
"Version": "0.3.5"
},
"Windows036RuntimeRepairDelta": {
"CandidateSha256": "001e2c92793d8508eed0eb5bfa82cdb51a243ac8aa7d2925e265f90c6454966e",
"ExampleEndpointChanges": [
{
"Count": 2,
"Path": "windows/ClientRuntimeSelfTest.cs"
},
{
"Count": 4,
"Path": "windows/KnownTailnetEndpoints.cs"
},
{
"Count": 3,
"Path": "windows/LearningSelfTest.cs"
},
{
"Count": 1,
"Path": "windows/LearningTransportSelfTest.cs"
},
{
"Count": 1,
"Path": "windows/NetworkHandoverSelfTest.cs"
},
{
"Count": 1,
"Path": "windows/PlatformBootstrapTransport.cs"
},
{
"Count": 5,
"Path": "windows/PlatformBootstrapTransportSelfTest.cs"
},
{
"Count": 4,
"Path": "windows/PrivateAuxiliaryRouting.cs"
},
{
"Count": 25,
"Path": "windows/PrivateAuxiliaryRoutingSelfTest.cs"
},
{
"Count": 1,
"Path": "windows/PublicTailnetSelectionSelfTest.cs"
},
{
"Count": 65,
"Path": "windows/TailnetTransportSelfTest.cs"
},
{
"Count": 1,
"Path": "windows/TransportPlanSelfTest.cs"
},
{
"Count": 1,
"Path": "windows/ConnectionSelfTest.cs",
"RuleSet": "windows-monitor-20261027"
},
{
"Count": 1,
"Path": "windows/GitReleasePolicySelfTest.cs",
"RuleSet": "windows-monitor-20261027"
},
{
"Count": 1,
"Path": "windows/InstallationIntegration.cs",
"RuleSet": "windows-monitor-20261027"
},
{
"Count": 1,
"Path": "windows/KnownTailnetEndpoints.cs",
"RuleSet": "windows-monitor-20261027"
},
{
"Count": 2,
"Path": "windows/LearningSelfTest.cs",
"RuleSet": "windows-monitor-20261027"
},
{
"Count": 1,
"Path": "windows/MainForm.Dashboard.cs",
"RuleSet": "windows-monitor-20261027"
},
{
"Count": 2,
"Path": "windows/MainForm.cs",
"RuleSet": "windows-monitor-20261027"
},
{
"Count": 1,
"Path": "windows/PlatformBootstrapTransport.cs",
"RuleSet": "windows-monitor-20261027"
},
{
"Count": 6,
"Path": "windows/PlatformBootstrapTransportSelfTest.cs",
"RuleSet": "windows-monitor-20261027"
},
{
"Count": 1,
"Path": "windows/PrivateAuxiliaryRouting.cs",
"RuleSet": "windows-monitor-20261027"
},
{
"Count": 7,
"Path": "windows/PrivateAuxiliaryRoutingSelfTest.cs",
"RuleSet": "windows-monitor-20261027"
},
{
"Count": 2,
"Path": "windows/TailnetTransportProbe.cs",
"RuleSet": "windows-monitor-20261027"
},
{
"Count": 3,
"Path": "windows/TailnetTransportSelfTest.cs",
"RuleSet": "windows-monitor-20261027"
},
{
"Count": 2,
"Path": "windows/TunConfigBuilder.cs",
"RuleSet": "windows-monitor-20261027"
},
{
"Count": 1,
"Path": "windows/VpnApiClient.cs",
"RuleSet": "windows-monitor-20261027"
},
{
"Count": 1,
"Path": "windows/XrayManager.cs",
"RuleSet": "windows-monitor-20261027"
},
{
"Count": 1,
"Path": "windows/installer/VPNPlus.nsi",
"RuleSet": "windows-monitor-20261027"
},
{
"Count": 1,
"Path": "windows/KnownTailnetEndpoints.cs",
"RuleSet": "windows-runtime-repair-20261106"
},
{
"Count": 3,
"Path": "windows/TailnetTransportSelfTest.cs",
"RuleSet": "windows-runtime-repair-20261106"
}
],
"FrozenSha256": "521d3065e0d8a9e6417dd721d64b16c12032edec7fb2a6cf60e0a05314c961f2",
"Omitted": [
"windows/assets/login-cloud-scene-v1.jpg"
],
"OptionalUnlicensedSceneRemainsOmitted": true,
"OriginalAcceptanceTransferred": false,
"OriginalSourceManifestSha256": "11d72a8778a76f90597aafec569bdd6d3a3f8e549ef8d09c9e70411ce916d58e",
"OtherComponentsModified": false,
"PrivateHistoryIncluded": false,
"ProductionAccepted": false,
"PublicBaseCommit": "23a87387b87aa82ffdafaf5cf87b4495d51207df",
"PublicDownloadDomainsRetained": [
"pro.ucvl.cn"
],
"SourceOnly": true,
"Version": "0.3.6"
},
"Windows037ExitReliabilityDelta": {
"CandidateSha256": "ee3751c05cec1a2ac0b5f53e8c9cb9d644dc8d5aa1b28b9879f03bfd8e4af7a4",
"ExampleEndpointChanges": [
{
"Count": 2,
"Path": "windows/ClientRuntimeSelfTest.cs"
},
{
"Count": 4,
"Path": "windows/KnownTailnetEndpoints.cs"
},
{
"Count": 3,
"Path": "windows/LearningSelfTest.cs"
},
{
"Count": 1,
"Path": "windows/LearningTransportSelfTest.cs"
},
{
"Count": 1,
"Path": "windows/NetworkHandoverSelfTest.cs"
},
{
"Count": 1,
"Path": "windows/PlatformBootstrapTransport.cs"
},
{
"Count": 5,
"Path": "windows/PlatformBootstrapTransportSelfTest.cs"
},
{
"Count": 4,
"Path": "windows/PrivateAuxiliaryRouting.cs"
},
{
"Count": 25,
"Path": "windows/PrivateAuxiliaryRoutingSelfTest.cs"
},
{
"Count": 1,
"Path": "windows/PublicTailnetSelectionSelfTest.cs"
},
{
"Count": 65,
"Path": "windows/TailnetTransportSelfTest.cs"
},
{
"Count": 1,
"Path": "windows/TransportPlanSelfTest.cs"
},
{
"Count": 1,
"Path": "windows/ConnectionSelfTest.cs",
"RuleSet": "windows-monitor-20261027"
},
{
"Count": 1,
"Path": "windows/GitReleasePolicySelfTest.cs",
"RuleSet": "windows-monitor-20261027"
},
{
"Count": 1,
"Path": "windows/InstallationIntegration.cs",
"RuleSet": "windows-monitor-20261027"
},
{
"Count": 1,
"Path": "windows/KnownTailnetEndpoints.cs",
"RuleSet": "windows-monitor-20261027"
},
{
"Count": 2,
"Path": "windows/LearningSelfTest.cs",
"RuleSet": "windows-monitor-20261027"
},
{
"Count": 1,
"Path": "windows/MainForm.Dashboard.cs",
"RuleSet": "windows-monitor-20261027"
},
{
"Count": 2,
"Path": "windows/MainForm.cs",
"RuleSet": "windows-monitor-20261027"
},
{
"Count": 1,
"Path": "windows/PlatformBootstrapTransport.cs",
"RuleSet": "windows-monitor-20261027"
},
{
"Count": 6,
"Path": "windows/PlatformBootstrapTransportSelfTest.cs",
"RuleSet": "windows-monitor-20261027"
},
{
"Count": 1,
"Path": "windows/PrivateAuxiliaryRouting.cs",
"RuleSet": "windows-monitor-20261027"
},
{
"Count": 7,
"Path": "windows/PrivateAuxiliaryRoutingSelfTest.cs",
"RuleSet": "windows-monitor-20261027"
},
{
"Count": 2,
"Path": "windows/TailnetTransportProbe.cs",
"RuleSet": "windows-monitor-20261027"
},
{
"Count": 3,
"Path": "windows/TailnetTransportSelfTest.cs",
"RuleSet": "windows-monitor-20261027"
},
{
"Count": 2,
"Path": "windows/TunConfigBuilder.cs",
"RuleSet": "windows-monitor-20261027"
},
{
"Count": 1,
"Path": "windows/VpnApiClient.cs",
"RuleSet": "windows-monitor-20261027"
},
{
"Count": 1,
"Path": "windows/XrayManager.cs",
"RuleSet": "windows-monitor-20261027"
},
{
"Count": 1,
"Path": "windows/installer/VPNPlus.nsi",
"RuleSet": "windows-monitor-20261027"
},
{
"Count": 1,
"Path": "windows/KnownTailnetEndpoints.cs",
"RuleSet": "windows-runtime-repair-20261106"
},
{
"Count": 3,
"Path": "windows/TailnetTransportSelfTest.cs",
"RuleSet": "windows-runtime-repair-20261106"
}
],
"FrozenSha256": "d2c0af09f08657bcd365c342cfbad681d83be8a468ad086036830fae81c63a7b",
"Omitted": [
"windows/assets/login-cloud-scene-v1.jpg"
],
"OptionalUnlicensedSceneRemainsOmitted": true,
"OriginalAcceptanceTransferred": false,
"OriginalSourceManifestSha256": "fe0fa2a01f6e1eb541ff85fc96f5ef978cb6716846c27eea0a8e8eccbfa10288",
"OtherComponentsModified": false,
"PrivateHistoryIncluded": false,
"ProductionAccepted": false,
"PublicBaseCommit": "ac40dd3a6ceb1391596dd55265e299c03d7419ee",
"PublicDownloadDomainsRetained": [
"pro.ucvl.cn"
],
"SourceOnly": true,
"Version": "0.3.7"
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
# 纵横家开源源码
此仓库是无私有 Git 历史的清洁源码快照:Windows 0.3.5、Django 后台及 iPhone/iPad 1.0.2。公司自有代码按 MIT 开源;第三方组件遵守原许可,公司商标及 Logo 不在 MIT 授权范围。Android 保留原 GPL-3.0 公开仓库,不重复拷贝或改换许可。
此仓库是无私有 Git 历史的清洁源码快照:Windows 0.3.7、Django 后台及 iPhone/iPad 1.0.2。公司自有代码按 MIT 开源;第三方组件遵守原许可,公司商标及 Logo 不在 MIT 授权范围。Android 保留原 GPL-3.0 公开仓库,不重复拷贝或改换许可。
| 目录 | 内容与状态 |
| --- | --- |
+71 -15
View File
@@ -4,7 +4,7 @@
"ExportDiffersFromOriginalCandidates": true,
"FilesBeforeProvenanceAndAudit": {
"LICENSE": "b7e94910b8dc377b0a05ccde3c6e5941838dfc15c9dd790078d11728205b524e",
"README.md": "0a94bef78ae64402abf281075d68dcba5aafca466d284bb5dd88c492f9924834",
"README.md": "3b3602a1b7eabfe504125f6293b5bd27dcb42cb47f9516cdce5949fdd868ccfb",
"SECURITY.md": "34e56cd9b8f6aa5fee45921c6eb831a542e05e76e41850fc31c44e09de088b3c",
"THIRD_PARTY_NOTICES.md": "8c862f2f6b71440616a887e6deb7444a1262cf7d9f144208cc04041c3f9a3371",
"android/README.md": "bb4387da9a055e97f33bb29a883c543e0938fa858df3fd744abc80553a5ec65c",
@@ -99,6 +99,27 @@
"backend/control/views.py": "28f1cd84e29bfe7d311a7af52c4a87f23cffdee6a735e5b4ca7e185293c24a59",
"backend/control/vpn_ai.py": "091c1379a8780c4804a40fbc6d6e0d076b9009c5fe3eba752926c7e164f5b19b",
"backend/docker/entrypoint.sh": "1ccee7b022efc9f7ef99f0703a46e235a4a8ee085f113eaea74c63b3063ac33b",
"backend/host-traffic-sampler/LICENSE": "b7e94910b8dc377b0a05ccde3c6e5941838dfc15c9dd790078d11728205b524e",
"backend/host-traffic-sampler/README.md": "8103d07ab651832a1529669f65b12cecc0a5abaca9b95e948caed9ff3148dfcd",
"backend/host-traffic-sampler/deploy_host_traffic_sampler.sh": "910e7234b6913e22b7e4aeb4b7ac7e74831e5038af1700e33073f42c14b0fe88",
"backend/host-traffic-sampler/host-traffic-contract-fixture.json": "f873e3f62982783fc29cc4f3bc9d298f3420a9e67bae085aeb4e6eeafed58696",
"backend/host-traffic-sampler/host_traffic_sampler.py": "d4b7f02ec39092cfc141e8275019c7b3b7458b6bf7096fe511742df9113bcab3",
"backend/host-traffic-sampler/test_host_traffic_sampler.py": "0c1cb6cf306ed16976781b614ff27203a06bdb6eb20fa734c3681c9a4f5a3023",
"backend/host-traffic-sampler/toplc-vpn-host-traffic.service": "f2ba0a79822457511717c2514ac7988d93d01bf71a39c027fd8267ecf6f8da44",
"backend/host-traffic-standalone-20261106-r2/LICENSE": "b7e94910b8dc377b0a05ccde3c6e5941838dfc15c9dd790078d11728205b524e",
"backend/host-traffic-standalone-20261106-r2/README.md": "275932318caa6ef5c69bdaeb12ec84f8f0b9a06aa3ae472cf70c9727980bf175",
"backend/host-traffic-standalone-20261106-r2/SOURCE-PROVENANCE.json": "71fab3c4dfc25171f2503ed262184359b8cea38a5b8e6716f1ffc608d09a134f",
"backend/host-traffic-standalone-20261106-r2/candidate-manifest.json": "c7b252a860af93f35c6db44da15073dee50cbce5ea23be9cf29d9949e5fdfc62",
"backend/host-traffic-standalone-20261106-r2/control/host_traffic.py": "c66421de2fbb74ab3b20ca771f6e2463737163eb6e245d56cc3875053e696d03",
"backend/host-traffic-standalone-20261106-r2/docker-compose.host-traffic-auth-r2.yml": "59a410949dd7900906aa6d6693a40759a90ddd23d34a7686b00715010afa5379",
"backend/host-traffic-standalone-20261106-r2/tests/run_auth_regression.py": "4f2d8d0ea6be83fd177e3a0f2133cb3255653df2f43bc70af6b4e31b2894805f",
"backend/host-traffic-standalone-20261106/LICENSE": "b7e94910b8dc377b0a05ccde3c6e5941838dfc15c9dd790078d11728205b524e",
"backend/host-traffic-standalone-20261106/README.md": "ffe1a73fcffcbc9bc137f8215b035887bfa2de00dc05bde53b2a91e52684f393",
"backend/host-traffic-standalone-20261106/control/host_traffic.py": "a63b10ba3c6ca4b465cd77e11c868df2b9876ab2b10ec358e1d5ee37d99fee12",
"backend/host-traffic-standalone-20261106/control/host_traffic_store.py": "c5a6a986208879417ac51bb4b395794e1e0a235cac34f609a572804eb90091b8",
"backend/host-traffic-standalone-20261106/control/urls.py": "4f055b0de4d6a7593cbf00db0bc15c8f8e8644afa4618bebca79c738ac916002",
"backend/host-traffic-standalone-20261106/docker-compose.host-traffic.yml": "990656d4044c02106917479490e2619cccd1097dda65be8b75f1f84e570e60c6",
"backend/host-traffic-standalone-20261106/tests/run_tests.py": "715f80bfe11643d4b01b84c09d02b13eb5d371680a4ddd0cee23c463150d9bab",
"backend/manage.py": "21f021f4b8c848bb2df0b30af032945e47da34ebe0fb6beed4149356189d1a9d",
"backend/requirements.txt": "fb0d4a17abb80eb2abf467346b3245d3b8fd83a2c6bebc9a08784cdc0fa19667",
"backend/static/brand/README.md": "95d2193ccd5ce6e325eed8cc3e9763c9bf85ae545785504ab400ada705e7194e",
@@ -183,8 +204,15 @@
"windows/AppPaths.cs": "2bac68512acfb68b4f3dad0d30c9ee17eb6f576eeb73c6a453501d4ea184488e",
"windows/Brand.cs": "621a1c5b75880cbf4f88b482dc58bdd3c98e0f4d156bf816d23d63d48e199bca",
"windows/ChartFreshnessSelfTest.cs": "4af3f37b14296fc34097f5708f8f0f78fb1683c1b091459091c425a11c500a62",
"windows/ClientShutdownScope.cs": "f5944b57ccb4616dbd32ee2952b56dd0c9feccb7c556d8954092c88354a78d41",
"windows/ClientUpdater.cs": "b218513dc57b8513eb749aeab093e39911428a07f05363ae349555d22e53e4b8",
"windows/ClientExitRecoveryFixture.cs": "577b11849cd8ca52a6f5af8f21c2e79411dd6a84d9f0c972d4738610fd6e02dc",
"windows/ClientRuntime.cs": "6b1babd9cbe4cafe463205905d90a83ce9180b8e43e278b9b47fb9ec7eecd03b",
"windows/ClientRuntimeSelfTest.cs": "9677ffbb300f5b73b64290339d5a8abb29c2c0edfb586e3da6cea03f97ad713f",
"windows/ClientShutdownChildSelfTest.cs": "4cb5f65087a45bc5360e2a4d8a5a8d792b9c7f3628b55a2051a07b6e452a9a14",
"windows/ClientShutdownScope.cs": "7adef7ac0ebff04453433d6e460ca4590d9e5dc7be3e45567d14c0a6660973fe",
"windows/ClientShutdownSelfTest.cs": "8a7a670f4e7446f46143e69424c9d1ea95671c1a72d8e054493125339a3fca76",
"windows/ClientShutdownUiSelfTest.cs": "a99b00e14f4eae28f7da3b02ad3ed93544ad8d81f1b7d8e99b7011eec163076b",
"windows/ClientUpdateFlow.cs": "9f9b1490487171e67c3e78d18652808a0f6fbb64f38c8f2dbaa96c7d7476d69a",
"windows/ClientUpdater.cs": "6c6265bf7946e4d1323d6ff94596409b3281ed396376263aaff22cf223c53a42",
"windows/ConnectionAcceptanceTrace.cs": "c9efd15e19672a5ac3b4b807c96a3de3db3ff2fd373e13494a548df51fecdd9a",
"windows/ConnectionAuthorizationLease.cs": "3edbd5123c051c797c488b49bcd7204d8c1a0c5a0743bfec95ffa4ab0bdd9bfc",
"windows/ConnectionAuthorizationSelfTest.cs": "d747ac77ef353a991fd50ae3f2229e063d27ede7b6e588d2e17a41a06b7abe90",
@@ -211,7 +239,7 @@
"windows/InstallationSelfTest.cs": "03cb0d797c4eeb5a0d44548d844e46f53e8943928c1f118ed6b5fed948eaf298",
"windows/InstallationTransaction.cs": "319d379052bb8633c77b54012862afa8e2b9fabbb50bce647332298eb3915ac9",
"windows/InstallerGuardianGate.cs": "416c5560d1fb413f02f0b0a924fb4be922652a601269c056f31c93f155c0014f",
"windows/KnownTailnetEndpoints.cs": "f887bb90dd0e054dd295931d7f289f13067f50cbba89229fa5b4b36efb27fbcf",
"windows/KnownTailnetEndpoints.cs": "3ee3b26955bbd14443c2d63bb26adf7b41a94908e0e60f2f8007c4046b752b16",
"windows/LICENSE": "b7e94910b8dc377b0a05ccde3c6e5941838dfc15c9dd790078d11728205b524e",
"windows/LearningExpirySoakSelfTest.cs": "c27890114e6597236ce407afb67f48ddd4f83b10cec3219d64e228f10309d23a",
"windows/LearningMatrixSelfTest.cs": "edb37d73f3db2e2722d49f92cf141e1b13275c76bdfadf36ab65eacf1d83d8ec",
@@ -225,12 +253,12 @@
"windows/MainForm.Chrome.cs": "30dc6520a44a5120c78c472c9fb053e2e4dea8e254b5531d04a5342964969c7a",
"windows/MainForm.Compact.cs": "2e2835ce952be24fdbe711032aebfe7f046e7c0d1967204d2e9981d9e694d6e1",
"windows/MainForm.Dashboard.cs": "46edae6d3412cee5369287ce67e1951867f728ee0a8f469879287e4c5ebd064b",
"windows/MainForm.Handover.cs": "4a914f4de335331f1f9d2397407328f17ae372e9119329e534af218555dc92e6",
"windows/MainForm.NextGeneration.cs": "5a1c21e02e304a5135b66160855aba5961d5da7da68041ff1b79be9de4a41916",
"windows/MainForm.Handover.cs": "7c661ddc14e42d33c6659aefff127d1ec0d2e0f1110eeab8ac7d9b7b9e30e94b",
"windows/MainForm.NextGeneration.cs": "e2e74727e20f6054c2b592aa039224489f4458c7b8ae0b9f3d26194106cf70c1",
"windows/MainForm.Selection.cs": "71d3884eb6535b1c8095379585a7479c5d7dd35d00e59da4dabfa673557f17fa",
"windows/MainForm.TailnetTraffic.cs": "bc48728563f163cc8553b288bcccd71e7d756f8beb11c13cb486652024c4b8d4",
"windows/MainForm.TransportSelection.cs": "7e7bf74f16cb902b71da5a13117db06e9cdf4ea6121511a5ebceaf017bd1f919",
"windows/MainForm.cs": "d515ae6f05f992789b63132a91141dbb6ea50e3d794b86c8174da1396b746687",
"windows/MainForm.cs": "e781334e1c13c5513d589a94c02522c1a5601f06fd39f909811a1130b4ecee2d",
"windows/NOTICE.md": "8c862f2f6b71440616a887e6deb7444a1262cf7d9f144208cc04041c3f9a3371",
"windows/NetworkHandover.cs": "b43548be0051cf92dfd332e537951e4b5083f2a123be8021994513bbc3748d46",
"windows/NetworkHandoverSelfTest.cs": "681d0154dc0aa5f49d7ce1f3088b465eea3ed82571b464951df8d4c89cecdf73",
@@ -250,7 +278,7 @@
"windows/NodeTrafficOneSecondSelfTest.cs": "640dc4091dbd0ac3d0b900b49e44d2876b8b1250461a652f50dbfbe4e007f78d",
"windows/NodeTrafficRepaintSelfTest.cs": "06f359e55cc35c73cf53443ff452d57c585c7214ced8f84a9b9e385c2e699bf3",
"windows/NodeTrafficSelfTest.cs": "284086275fbb7f81dbcbff2c7267379402c84cb2e4325658946520cf9b9b518d",
"windows/NodeTransportConnector.cs": "91d53471f35470fc9a4578e2819863e56a790cda62a7dbfe891a71149d2386e1",
"windows/NodeTransportConnector.cs": "a45a720a9afbf9b25601f4b484cec67f8cf945176a035385379d767183968b5d",
"windows/PhysicalUplink.cs": "b0a0eca6b9f724972d0e445c2dc352326ea4d7357317b98639972d60dadc2e63",
"windows/PlatformBootstrapTransport.cs": "0eef4a4272449c0e2adfac2e4652bd9cff9c1b2bc11011ca2049dde2f97e4e2b",
"windows/PlatformBootstrapTransportSelfTest.cs": "59177ceb52391fb27f04599e138f49a1c461ad283bb930bffc4bcefa663ab23f",
@@ -258,12 +286,12 @@
"windows/PrivateAuxiliaryRoutingSelfTest.cs": "8b2e867f562017e680def8f74c7fba972404442816abae7bf54fcab5d47339df",
"windows/PrivateAuxiliaryRuntime.cs": "dcfb406508e3d7e9a9163163cfe5e2724a6955a18ae4604e2d9f890da61308cf",
"windows/PrivateTransportProbe.cs": "e29e9bd0180a37bdcecf7104fde5069be799aca92b747881d0485a62d382d9b3",
"windows/Program.cs": "921dbd445f0461cfa7910961577c2ba735bb4b8903011e75435392c5ef16473c",
"windows/Program.cs": "93ac54d0c1656d4eceb4c9e95372572e693af5933e7614e6e875acf0a5ab8e7f",
"windows/ProxyDnsPolicy.cs": "997e2e922ad43956932c1bd0a6da3457bc308ee723f4f77ff8e52aa23fa954c0",
"windows/ProxyProbe.cs": "5d27b5a6c6b192a0c0f3ec4637c5a876a71130497af57f7cb4a04ab4735ca1ec",
"windows/PublicTailnetSelection.cs": "68b6dd3d5c77c3253046f9b90e22742c1f2852e07d07157daa296512370fada7",
"windows/PublicTailnetSelectionSelfTest.cs": "7b5e7352fe4529e01ce537d488a5cfcc8f5259f98bbe307846cb36a7144cacac",
"windows/README.md": "336e690f3b013f36baaca67bcbb70e4eab1c72b38e6084941230e582d7c58be2",
"windows/README.md": "20cf8d77eee9f07e2cfaef393bfbb986af0eec7de45a5aaa915309bff8ea4baf",
"windows/ReplacementContinuitySelfTest.cs": "107878ab2b367f1812377c0b209f6d620da390091c3882e4be53a48e517d86a1",
"windows/RouteLeaseSelfTest.cs": "6189c66b9f66c58bed26de4441c58a9ec02b67257bfa04ed66d702acfcd054d9",
"windows/RoutingRuleBatches.cs": "9997bfa766fffe7bed7352f307c1f6f118a9be9aa86653eaefae3b2bdaa26c1e",
@@ -283,7 +311,7 @@
"windows/TailnetReadinessSelfTest.cs": "92ba7abec5fa3f98550dd9460fb2c87b58cbdc4a55efd9f4b58ca8c5c16f67e7",
"windows/TailnetTransport.cs": "c93769b845090f244eeedef2b49afa4bea500af809a995ffdcaf8c314ffb84eb",
"windows/TailnetTransportProbe.cs": "c71a0d946cbefb2713e0b564ea95ae99cbd70f0ec19c8cfc416a12e16589f99a",
"windows/TailnetTransportSelfTest.cs": "8ace8cc2f443c1ce576bbb9471cb46f107ac28f999090baa30431412d8a263f3",
"windows/TailnetTransportSelfTest.cs": "0a61716193d185c0b86819c29813625e6c5ab7d28df0c700b368e708c12607d7",
"windows/TokenStore.cs": "e07cf7d1a4cf7a1bba871c19e50b9d6355cb8c1546657346b0256c8215fed8bb",
"windows/TrafficChart.cs": "0412f5d45d33ee95f0d0c80ea57a53e4708ff549e20373596035a47c7a0d1eb0",
"windows/TransportPlan.cs": "f49b780fd5095cd494c040582d3cf1607548d1eb0572490bfe588dc55521a772",
@@ -292,14 +320,14 @@
"windows/TunConnectivitySelfTest.cs": "a7d7aff1d03e45dff921807cbfb8f83b5013c9df5c7e06b6662d84a8686b2f86",
"windows/TunRouting.cs": "c6b3e1070a0ba0a3c42dbd12becba55404e540d06aba03cb1cc1053fa426a4c1",
"windows/UpdateProgressForm.cs": "25286b76a235635704dbe8831367141939d063153d0828ee375f1c71d461f041",
"windows/UpdateSelfTest.cs": "453165bb611efb8db0d8a8c9ea13f3553e0047aa22b838c43096e3d83fe18771",
"windows/UpdateSelfTest.cs": "fcb73067484cad50618f0ce93e087fa36a1cc3b40a10173d26a2b0230b0b77e1",
"windows/UpdateStreamSelfTest.cs": "ad059016c0197f33582b1969ab3280c5b9589a28d659613b3e97ce4a357d38c1",
"windows/UsageHistorySeries.cs": "9e7515ceede1899e06116352de79edd6252c921048bcae9958bf9358d93b3069",
"windows/VPNPlus.csproj": "c81156e80e7d5ceac088c8e167ce3e3f33cc8cdf61a125b905a6761ef2e43221",
"windows/VPNPlus.csproj": "b1f1e3d2663e08b32feaaca50f5a5888a57eb49c73f05f7d9f59ea8bf34367a7",
"windows/VpnApiClient.cs": "5bb824cd89d4d8fa251f10a66f4c284c58118b773f877aa07c9700fe271216a8",
"windows/WindowChrome.cs": "0eceea0879e792b8ae83a74eaf5658d4a7be6a798fbdb026ff8d19fa9aa6af2c",
"windows/WindowChromeSelfTest.cs": "c17dd805a0102d12b71a3e32c77ceeb45e303e08612de5d3c5259c78327532be",
"windows/XrayManager.cs": "8c87c1d84e42f00528da52ecbe9a0a4ecded445ac50e83442c187536af9555a5",
"windows/XrayManager.cs": "8befd495ca283b529d3c0a44f243b4e6b07b1387ecf281e2fc82afaf2f6bbe9b",
"windows/XrayRoutingUpdater.cs": "91fd2b5db25477dbe4de7118faef79f9c51f9a8a3dd86e8b26c676092de3bca5",
"windows/app.manifest": "4c9a2e8e2056c3bb0ae45a5f7b2e223298ee683a82b70ba4910e17f5728cf5b6",
"windows/assets/company-logo-original.png": "04cf7f754a5353b96cddbed4a57a557154342c190a1785487e3bfb36cab04163",
@@ -343,7 +371,9 @@
"windows/release/RELEASE-NOTES-0.3.2.md": "29f2030b0be583a541dc0289ee9916d42156cf3bbd823bd5cf7867f097fb2abd",
"windows/release/RELEASE-NOTES-0.3.3.md": "18e1f04a925b82668813cb7bde18d29790fa6218d6726887b0ad3cabec253dea",
"windows/release/RELEASE-NOTES-0.3.4.md": "10f0a3edd111932ea92e25581208ac527990b515ee1c73bbd7bd4acba734936f",
"windows/release/RELEASE-NOTES-0.3.5.md": "4b92799fbd145660732a1748828d03f0defe179709bc77b7e13e9de693ccc304"
"windows/release/RELEASE-NOTES-0.3.5.md": "4b92799fbd145660732a1748828d03f0defe179709bc77b7e13e9de693ccc304",
"windows/release/RELEASE-NOTES-0.3.6.md": "b5ce5826c244a9159783fc408e09cfd923140dc4ac8c716d8dff2e4c268776b1",
"windows/release/RELEASE-NOTES-0.3.7.md": "74abb193dea9ff6ae076e3919947fee98590b57b97e96d89b55fab8e30e66da5"
},
"IosSourceCommit": "b07d085413b1b6370245866fd82271b76590b6d6",
"Kind": "clean-history-free-open-source-export",
@@ -630,5 +660,31 @@
"SourceOnly": true,
"Version": "0.3.5"
},
"Windows036RuntimeRepairDelta": {
"CandidateSha256": "001e2c92793d8508eed0eb5bfa82cdb51a243ac8aa7d2925e265f90c6454966e",
"FrozenSha256": "521d3065e0d8a9e6417dd721d64b16c12032edec7fb2a6cf60e0a05314c961f2",
"OptionalUnlicensedSceneRemainsOmitted": true,
"OriginalAcceptanceTransferred": false,
"OriginalSourceManifestSha256": "11d72a8778a76f90597aafec569bdd6d3a3f8e549ef8d09c9e70411ce916d58e",
"OtherComponentsModified": false,
"PrivateHistoryIncluded": false,
"ProductionAccepted": false,
"PublicBaseCommit": "23a87387b87aa82ffdafaf5cf87b4495d51207df",
"SourceOnly": true,
"Version": "0.3.6"
},
"Windows037ExitReliabilityDelta": {
"CandidateSha256": "ee3751c05cec1a2ac0b5f53e8c9cb9d644dc8d5aa1b28b9879f03bfd8e4af7a4",
"FrozenSha256": "d2c0af09f08657bcd365c342cfbad681d83be8a468ad086036830fae81c63a7b",
"OptionalUnlicensedSceneRemainsOmitted": true,
"OriginalAcceptanceTransferred": false,
"OriginalSourceManifestSha256": "fe0fa2a01f6e1eb541ff85fc96f5ef978cb6716846c27eea0a8e8eccbfa10288",
"OtherComponentsModified": false,
"PrivateHistoryIncluded": false,
"ProductionAccepted": false,
"PublicBaseCommit": "ac40dd3a6ceb1391596dd55265e299c03d7419ee",
"SourceOnly": true,
"Version": "0.3.7"
},
"WindowsSourceCommit": "0d463e6af91a3802c564b06dabb6bf86ebff5a38"
}
+5
View File
@@ -0,0 +1,5 @@
namespace UCVL.VPNPlus;
// Only uiOnly fixtures may substitute recovery. Production always uses Xray's
// ownership-checked route/DNS journals and exact child process handle.
internal sealed record ClientExitRecoveryFixture(Func<Task> Dispose, TimeSpan? Deadline = null);
+76
View File
@@ -0,0 +1,76 @@
using System.ComponentModel;
using System.Diagnostics;
using System.Security;
namespace UCVL.VPNPlus;
internal enum ClientRuntimeFault { Missing, Unreadable, Empty, CannotStart }
// An installation failure is local to every node. Never feed it into node or
// transport health/cooldown, or retry it by changing the user's network route.
internal sealed class ClientRuntimeException(string componentPath, ClientRuntimeFault fault, Exception? inner = null)
: IOException(MessageFor(componentPath, fault), inner)
{
internal string ComponentPath { get; } = Path.GetFullPath(componentPath);
internal ClientRuntimeFault Fault { get; } = fault;
private static string MessageFor(string path, ClientRuntimeFault fault)
{
var issue = fault switch
{
ClientRuntimeFault.Missing => "缺失",
ClientRuntimeFault.Empty => "为空或已损坏",
ClientRuntimeFault.CannotStart => "无法启动(程序文件或依赖异常)",
_ => "无法读取(权限或文件占用)",
};
return $"本机客户端组件{issue}:{Path.GetFileName(path)}\n位置:{Path.GetFullPath(path)}\n\n"
+ "请重新运行纵横家最新完整安装包,在原安装目录修复。账号和配置会保留。";
}
// Only local installation identity. No token, node config or credentials.
internal string Diagnostic => $"client_runtime fault={Fault} component={Clean(ComponentPath)}"
+ $" process={Clean(Environment.ProcessPath ?? "unknown")} version={Clean(Application.ProductVersion)}";
private static string Clean(string value) => value.Replace('\r', ' ').Replace('\n', ' ');
}
internal static class ClientRuntime
{
internal static readonly string[] Components = ["xray.exe", "geoip.dat", "geosite.dat", "wintun.dll"];
internal static void Validate(string installationDirectory)
{
// Resolve exclusively beside this application, never the current
// working directory, PATH, or an unrelated installed Xray binary.
var directory = Path.Combine(Path.GetFullPath(installationDirectory), "xray");
foreach (var name in Components)
{
var path = Path.Combine(directory, name);
try
{
using var stream = new FileStream(path, FileMode.Open, FileAccess.Read,
FileShare.ReadWrite | FileShare.Delete);
if (stream.Length == 0 || stream.ReadByte() < 0)
throw new ClientRuntimeException(path, ClientRuntimeFault.Empty);
}
catch (ClientRuntimeException) { throw; }
catch (Exception error) when (error is FileNotFoundException or DirectoryNotFoundException)
{ throw new ClientRuntimeException(path, ClientRuntimeFault.Missing, error); }
catch (Exception error) when (error is IOException or UnauthorizedAccessException or SecurityException)
{ throw new ClientRuntimeException(path, ClientRuntimeFault.Unreadable, error); }
}
}
internal static bool Start(Process process)
{
try { return process.Start(); }
// The executable can disappear or become blocked after preflight.
// Classify only known local CreateProcess failures, not socket errors,
// arbitrary IO, or remote Reality/TLS/configuration failures.
catch (Win32Exception error) when (error.NativeErrorCode is 2 or 3 or 5 or 32 or 33 or 126 or 193 or 216 or 225 or 740)
{
var fault = error.NativeErrorCode is 2 or 3 ? ClientRuntimeFault.Missing
: error.NativeErrorCode is 5 or 32 or 33 ? ClientRuntimeFault.Unreadable : ClientRuntimeFault.CannotStart;
throw new ClientRuntimeException(process.StartInfo.FileName, fault, error);
}
}
}
+127
View File
@@ -0,0 +1,127 @@
using System.Text.Json;
using System.Security.AccessControl;
using System.Security.Principal;
namespace UCVL.VPNPlus;
internal static class ClientRuntimeSelfTest
{
internal static async Task<Dictionary<string, bool>> CheckAsync()
{
var checks = new Dictionary<string, bool>();
var root = Path.Combine(Path.GetTempPath(), "ucvl-runtime-test-" + Guid.NewGuid().ToString("N"));
Directory.CreateDirectory(Path.Combine(root, "xray"));
// Tiny inert fixture files; none are executed or treated as real Xray.
void Seed() { foreach (var name in ClientRuntime.Components) File.WriteAllBytes(Path.Combine(root, "xray", name), [1, 2]); }
ClientRuntimeException? ReadFault()
{
try { ClientRuntime.Validate(root); return null; }
catch (ClientRuntimeException error) { return error; }
}
async Task<bool> RuntimeFailure(Func<Task> operation)
{
try { await operation(); return false; }
catch (ClientRuntimeException) { return true; }
}
try
{
Seed();
checks["four_readable_nonempty_components_accepted"] = ReadFault() is null;
foreach (var name in ClientRuntime.Components)
{
var path = Path.Combine(root, "xray", name);
File.Delete(path);
var missing = ReadFault();
checks["missing_" + name] = missing is { Fault: ClientRuntimeFault.Missing }
&& missing.ComponentPath == path && missing.Message.Contains("完整安装包") && missing.Message.Contains(path);
Seed();
File.WriteAllBytes(path, []);
checks["empty_" + name] = ReadFault() is { Fault: ClientRuntimeFault.Empty };
Seed();
using (var locked = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.None))
checks["locked_not_reported_missing_" + name] = ReadFault() is { Fault: ClientRuntimeFault.Unreadable };
}
var deniedPath = Path.Combine(root, "xray", "xray.exe");
var originalAcl = new FileInfo(deniedPath).GetAccessControl();
try
{
var deniedAcl = new FileInfo(deniedPath).GetAccessControl();
deniedAcl.AddAccessRule(new FileSystemAccessRule(WindowsIdentity.GetCurrent().User!, FileSystemRights.ReadData,
AccessControlType.Deny));
new FileInfo(deniedPath).SetAccessControl(deniedAcl);
checks["access_denied_not_reported_missing"] = ReadFault() is { Fault: ClientRuntimeFault.Unreadable };
}
finally { new FileInfo(deniedPath).SetAccessControl(originalAcl); }
var error = new ClientRuntimeException(Path.Combine(root, "xray", "xray.exe"), ClientRuntimeFault.Missing);
using (var absent = new System.Diagnostics.Process { StartInfo = new System.Diagnostics.ProcessStartInfo {
FileName=Path.Combine(root, "xray", "missing-fixture.exe"), UseShellExecute=false, CreateNoWindow=true,
} })
{
try { ClientRuntime.Start(absent); checks["disappeared_executable_is_local_failure"] = false; }
catch (ClientRuntimeException failure) { checks["disappeared_executable_is_local_failure"] = failure.Fault == ClientRuntimeFault.Missing; }
}
using (var invalid = new System.Diagnostics.Process { StartInfo = new System.Diagnostics.ProcessStartInfo {
FileName=Path.Combine(root, "xray", "xray.exe"), UseShellExecute=false, CreateNoWindow=true,
} })
{
try { ClientRuntime.Start(invalid); checks["invalid_executable_is_local_failure"] = false; }
catch (ClientRuntimeException failure) { checks["invalid_executable_is_local_failure"] = failure.Fault == ClientRuntimeFault.CannotStart; }
}
checks["diagnostic_contains_only_installation_identity"] = error.Diagnostic.Contains(error.ComponentPath)
&& error.Diagnostic.Contains(" process=") && error.Diagnostic.Contains(" version=")
&& !error.Diagnostic.Contains('\n') && !error.Diagnostic.Contains('\r');
var response = JsonSerializer.Deserialize<ConfigResponse>("""
{"config_contract":2,"connection_scope":"public","node":{"slug":"tokyo","name":"VPN002"},"route_mode":"smart",
"tailscale_endpoint":{"contract":1,"node_slug":"tokyo","address":"100.64.0.2","port":10803},
"config":{"inbounds":[],"outbounds":[
{"tag":"proxy","protocol":"vless","settings":{"vnext":[{"address":"vpn002.example.invalid","port":11082,"users":[{"id":"11111111-1111-1111-1111-111111111111","encryption":"none","flow":"xtls-rprx-vision"}]}]},
"streamSettings":{"network":"tcp","security":"reality","realitySettings":{"serverName":"one.one.one.one","publicKey":"fixture-key","shortId":"aabb"}}},
{"tag":"direct","protocol":"freedom"},{"tag":"block","protocol":"blackhole"}],"routing":{"rules":[]}}}
""")!;
foreach (var stage in new[] { "route", "ping", "tailnet_start", "public_start" })
{
var preference = new TailnetPreference();
var starts = 0; var stops = 0; var probes = 0;
Task Start(string _, CancellationToken token) { starts++; if (stage is "tailnet_start" or "public_start") throw error; return Task.CompletedTask; }
Task Stop() { stops++; return Task.CompletedTask; }
Task<bool> Health(CancellationToken _) { probes++; return Task.FromResult(true); }
void Route(string _) { if (stage == "route") throw error; }
Task<bool> Ping(string _, int port, CancellationToken token) { if (stage == "ping") throw error; return Task.FromResult(true); }
var selectedResponse = stage == "public_start" ? new ConfigResponse {
Config=response.Config, ConfigContract=response.ConfigContract, ConnectionScope=response.ConnectionScope,
Node=response.Node, RouteMode=response.RouteMode, TailscaleEndpoint=null,
} : response;
var rejected = await RuntimeFailure(() => NodeTransportConnector.ConnectAsync(selectedResponse, preference, Start, Stop,
Health, Route, _ => { }, () => 100, CancellationToken.None, endpointProbe: Ping));
checks[stage + "_local_failure_propagates"] = rejected;
checks[stage + "_no_domain_or_cooldown_state_change"] = !preference.DomainOnly && preference.MayTry("tokyo", 101);
checks[stage + "_no_cleanup_or_health_attempt"] = stops == 0 && probes == 0;
checks[stage + "_no_second_start"] = starts == (stage is "tailnet_start" or "public_start" ? 1 : 0);
}
var tailnet = TailnetTransport.TryPrepare(response)!;
var rebindStarts = 0; var rebindStops = 0;
checks["rebind_local_failure_propagates_without_fallback"] = await RuntimeFailure(() => NodeTransportConnector.RebindAsync(
tailnet, response.GetRuntimeConfigJson(), (_, _) => { rebindStarts++; throw error; },
() => { rebindStops++; return Task.CompletedTask; }, _ => Task.FromResult(true), CancellationToken.None))
&& rebindStarts == 1 && rebindStops == 0;
}
finally
{
// Only these four known inert files in the fresh GUID directory.
foreach (var name in ClientRuntime.Components) File.Delete(Path.Combine(root, "xray", name));
Directory.Delete(Path.Combine(root, "xray"));
Directory.Delete(root);
}
return checks;
}
internal static async Task<int> RunAsync()
{
var checks = await CheckAsync();
var passed = checks.Values.All(value => value);
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, "client-runtime-self-test.json"),
JsonSerializer.Serialize(new { passed, network_modified = false, installed_client_modified = false, installer_launched = false, checks },
new JsonSerializerOptions { WriteIndented=true }));
return passed ? 0 : 92;
}
}
+51
View File
@@ -0,0 +1,51 @@
using System.Diagnostics;
using System.Reflection;
using System.Text.Json;
namespace UCVL.VPNPlus;
internal static class ClientShutdownChildSelfTest
{
internal static int Run()
{
var checks = new Dictionary<string, bool>();
var children = new List<Process>();
string? error = null;
Process Start(int delay, int exitCode)
{
var info = new ProcessStartInfo(Environment.ProcessPath!) { UseShellExecute = false, CreateNoWindow = true };
if (Path.GetFileNameWithoutExtension(Environment.ProcessPath).Equals("dotnet", StringComparison.OrdinalIgnoreCase))
info.ArgumentList.Add(Assembly.GetExecutingAssembly().Location);
info.ArgumentList.Add("--client-shutdown-test-child"); info.ArgumentList.Add(delay.ToString()); info.ArgumentList.Add(exitCode.ToString());
var child = Process.Start(info)!;
_ = child.Handle; // Pin the exact owned child before waiting.
children.Add(child);
return child;
}
try
{
var delayed = Start(1200, 0);
checks["exact_owned_child_exits_cleanly_before_handoff"] = ClientShutdownScope.WaitForExit([delayed]) && delayed.HasExited;
var failed = Start(10, 7);
checks["nonzero_old_client_exit_blocks_replacement"] = !ClientShutdownScope.WaitForExit([failed]);
var slow = Start(1200, 0);
var timer = Stopwatch.StartNew();
checks["timeout_blocks_replacement_without_killing_client"] = !ClientShutdownScope.WaitForExit([slow], TimeSpan.FromMilliseconds(70)) && !slow.HasExited;
checks["wait_is_bounded"] = timer.ElapsedMilliseconds < 1000;
checks["timed_out_child_can_finish_gracefully"] = ClientShutdownScope.WaitForExit([slow]);
checks["all_exact_handles_reap_successfully"] = children.All(c => c.HasExited);
}
catch (Exception exception) { error = exception.ToString(); }
finally
{
foreach (var child in children)
{
try { if (!child.HasExited) { child.Kill(entireProcessTree: true); child.WaitForExit(2000); } } catch { }
child.Dispose();
}
}
var passed = error is null && checks.Values.All(v => v);
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, "client-exit-child-handoff-self-test.json"),
JsonSerializer.Serialize(new { Passed = passed, Checks = checks, Error = error, ProductionProcessQueried = false, NetworkingModified = false }, new JsonSerializerOptions { WriteIndented = true }));
return passed ? 0 : 87;
}
}
+15
View File
@@ -8,6 +8,21 @@ internal static class ClientShutdownScope
internal static bool IsUnambiguous(string expected, int session, IEnumerable<Instance> processes)
=> processes.Where(p => p.SessionId == session).All(p => !string.IsNullOrWhiteSpace(p.Executable)
&& string.Equals(Path.GetFullPath(p.Executable), Path.GetFullPath(expected), StringComparison.OrdinalIgnoreCase));
// Call only after path/session verification and pinning exact handles.
// All instances consume one shared budget; a timeout never kills a client.
internal static bool WaitForExit(IEnumerable<System.Diagnostics.Process> processes, TimeSpan? budget = null)
{
var watch = System.Diagnostics.Stopwatch.StartNew();
var limit = budget ?? TimeSpan.FromSeconds(90);
foreach (var process in processes)
{
var remaining = (int)Math.Clamp(limit.TotalMilliseconds - watch.ElapsedMilliseconds, 0, int.MaxValue);
if (!process.HasExited && (remaining == 0 || !process.WaitForExit(remaining))) return false;
if (process.ExitCode != 0) return false;
}
return true;
}
internal static bool SelfTest()
{
const string expected = @"C:\fixture\installed\VPNPlus.exe";
+72
View File
@@ -0,0 +1,72 @@
using System.Diagnostics;
using System.Text.Json;
namespace UCVL.VPNPlus;
internal static class ClientShutdownSelfTest
{
internal static int Run()
{
var flow = RunFlowAsync().GetAwaiter().GetResult();
var ui = flow == 0 ? ClientShutdownUiSelfTest.Run() : -1;
var handoff = flow == 0 && ui == 0 ? ClientShutdownChildSelfTest.Run() : -1;
var passed = flow == 0 && ui == 0 && handoff == 0;
var checks = new Dictionary<string, bool>();
foreach (var (prefix, file) in new[] { ("flow", "client-exit-self-test.json"),
("ui", "client-exit-ui-self-test.json"), ("handoff", "client-exit-child-handoff-self-test.json") })
{
var path = Path.Combine(AppContext.BaseDirectory, file);
if (!File.Exists(path)) { checks[prefix + ".report_exists"] = false; continue; }
using var document = JsonDocument.Parse(File.ReadAllText(path));
foreach (var assertion in document.RootElement.GetProperty("Checks").EnumerateObject())
checks[prefix + "." + assertion.Name] = assertion.Value.GetBoolean();
}
passed &= checks.Count > 0 && checks.Values.All(value => value);
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, "client-shutdown-self-test.json"),
JsonSerializer.Serialize(new { passed, checks, flow_exit_code = flow, ui_exit_code = ui, child_handoff_exit_code = handoff,
network_modified = false, installed_client_modified = false }, new JsonSerializerOptions { WriteIndented = true }));
return passed ? 0 : 85;
}
private static async Task<int> RunFlowAsync()
{
var checks = new Dictionary<string, bool>();
try
{
var current = false;
var confirms = 0; var downloads = 0; var launches = 0;
var accepted = await ClientUpdateFlow.RunAsync(() => current,
() => { confirms++; return true; },
() => { downloads++; return Task.FromResult("fixture.exe"); }, _ => launches++);
checks["closed_before_offer_has_no_side_effect"] = !accepted && confirms == 0 && downloads == 0 && launches == 0;
current = true; confirms = downloads = launches = 0;
accepted = await ClientUpdateFlow.RunAsync(() => current,
() => { confirms++; current = false; return true; },
() => { downloads++; return Task.FromResult("fixture.exe"); }, _ => launches++);
checks["shutdown_during_confirmation_never_opens_progress_or_installer"] = !accepted && confirms == 1 && downloads == 0 && launches == 0;
current = true; confirms = downloads = launches = 0;
var downloaded = new TaskCompletionSource<string>(TaskCreationOptions.RunContinuationsAsynchronously);
var pending = ClientUpdateFlow.RunAsync(() => current,
() => { confirms++; return true; },
() => { downloads++; return downloaded.Task; }, _ => launches++);
current = false;
downloaded.SetResult("fixture.exe");
accepted = await pending;
checks["shutdown_during_download_never_launches_installer"] = !accepted && confirms == 1 && downloads == 1 && launches == 0;
current = true; confirms = downloads = launches = 0;
accepted = await ClientUpdateFlow.RunAsync(() => current, () => false,
() => { downloads++; return Task.FromResult("fixture.exe"); }, _ => launches++);
checks["declined_offer_retains_client"] = !accepted && downloads == 0 && launches == 0;
accepted = await ClientUpdateFlow.RunAsync(() => current, () => true,
() => Task.FromResult("verified-fixture.exe"), path => { if (path == "verified-fixture.exe") launches++; });
checks["active_accepted_update_launches_exact_download_once"] = accepted && launches == 1;
}
catch (Exception error) { checks["unexpected_error"] = false; Console.Error.WriteLine(error); }
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, "client-exit-self-test.json"),
JsonSerializer.Serialize(new { Passed = checks.Values.All(x => x), Checks = checks }, new JsonSerializerOptions { WriteIndented = true }));
return checks.Values.All(x => x) ? 0 : 85;
}
}
+123
View File
@@ -0,0 +1,123 @@
using System.Reflection;
using System.Text.Json;
namespace UCVL.VPNPlus;
internal static class ClientShutdownUiSelfTest
{
internal static int Run()
{
var checks = new Dictionary<string, bool>();
string? error = null;
try
{
var uiThread = Environment.CurrentManagedThreadId;
var disposals = 0;
var background = false;
var release = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
using (var form = new MainForm(uiOnly: true, exitRecoveryFixture: new(
async () => { Interlocked.Increment(ref disposals); background = Environment.CurrentManagedThreadId != uiThread; await release.Task; })))
{
form.Show(); PumpUntil(() => form.LoginReadyForTest);
form.WindowChromeForTest!.SetLoginMode(false);
form.Close();
checks["ordinary_authenticated_close_is_blocked"] = form.Visible && !form.IsDisposed && disposals == 0;
form.RequestExitForUpdate();
PumpUntil(() => Volatile.Read(ref disposals) == 1);
form.RequestExitForUpdate();
checks["installer_exit_bypasses_tray_and_starts_cleanup_once"] = disposals == 1 && !form.IsDisposed && background;
release.SetResult();
checks["installer_closes_when_tracked_cleanup_finishes"] = PumpUntil(() => form.IsDisposed);
}
using (var failed = new MainForm(uiOnly: true, exitRecoveryFixture: new(
() => Task.FromException(new IOException("isolated recovery failure")))))
{
failed.Show(); PumpUntil(() => failed.LoginReadyForTest);
failed.RequestExitForUpdate();
checks["installer_recovery_error_closes_without_blocking_modal"] = PumpUntil(() => failed.IsDisposed)
&& failed.NetworkRecoveryFailed;
}
var timedOutRecovery = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
using (var timedOut = new MainForm(uiOnly: true, exitRecoveryFixture: new(
() => timedOutRecovery.Task, TimeSpan.FromMilliseconds(80))))
{
timedOut.Show(); PumpUntil(() => timedOut.LoginReadyForTest);
timedOut.RequestExitForUpdate();
checks["stalled_recovery_bounds_exit_and_blocks_install_success"] = PumpUntil(() => timedOut.IsDisposed)
&& timedOut.NetworkRecoveryFailed;
timedOutRecovery.SetResult();
}
disposals = 0;
using (var canceled = new MainForm(uiOnly: true, exitRecoveryFixture: new(
() => { Interlocked.Increment(ref disposals); return Task.CompletedTask; })))
{
canceled.Show(); PumpUntil(() => canceled.LoginReadyForTest);
Invoke(canceled, "SetBusy", true, null);
var watch = System.Diagnostics.Stopwatch.StartNew();
var query = Dispatch(canceled, 0x11, IntPtr.Zero);
var repeat = Dispatch(canceled, 0x11, IntPtr.Zero);
checks["repeated_session_query_returns_promptly_without_recovery"] = watch.ElapsedMilliseconds < 300
&& query == (IntPtr)1 && repeat == (IntPtr)1 && disposals == 0
&& !Lifetime(canceled).IsCancellationRequested && !canceled.IsDisposed;
// Query/canceled END must not reset an active operation or its UI.
canceled.Enabled = false; canceled.UseWaitCursor = true;
Dispatch(canceled, 0x16, IntPtr.Zero);
Dispatch(canceled, 0x16, IntPtr.Zero);
checks["canceled_session_query_preserves_active_ui_state"] = !canceled.Enabled && canceled.UseWaitCursor
&& !Lifetime(canceled).IsCancellationRequested && disposals == 0;
canceled.Enabled = true; Invoke(canceled, "SetBusy", false, null);
checks["operation_can_finish_after_canceled_shutdown"] = canceled.LoginReadyForTest;
canceled.RequestExitForUpdate();
checks["canceled_query_client_can_later_exit"] = PumpUntil(() => canceled.IsDisposed) && disposals == 1;
}
disposals = 0;
using (var queued = new MainForm(uiOnly: true, exitRecoveryFixture: new(
() => { Interlocked.Increment(ref disposals); return Task.CompletedTask; })))
{
queued.Show(); PumpUntil(() => queued.LoginReadyForTest);
Dispatch(queued, 0x11, IntPtr.Zero);
queued.RequestExitForUpdate();
checks["installer_exit_still_works_after_session_query"] = PumpUntil(() => queued.IsDisposed) && disposals == 1;
}
disposals = 0;
using (var confirmed = new MainForm(uiOnly: true, exitRecoveryFixture: new(
() => { Interlocked.Increment(ref disposals); return Task.CompletedTask; })))
{
confirmed.Show(); PumpUntil(() => confirmed.LoginReadyForTest);
Dispatch(confirmed, 0x11, IntPtr.Zero);
Invoke(confirmed, "CompleteSessionEnding");
Invoke(confirmed, "CompleteSessionEnding");
Dispatch(confirmed, 0x16, IntPtr.Zero);
checks["confirmed_session_finalizes_once_and_cannot_resume"] = disposals == 1
&& Lifetime(confirmed).IsCancellationRequested && !confirmed.NetworkRecoveryFailed;
}
}
catch (Exception exception) { error = exception.ToString(); }
var passed = error is null && checks.Values.All(v => v);
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, "client-exit-ui-self-test.json"),
JsonSerializer.Serialize(new { Passed = passed, Checks = checks, Error = error, ProductionNetworking = false, ActualWindowsShutdown = false }, new JsonSerializerOptions { WriteIndented = true }));
return passed ? 0 : 86;
}
private static object? Invoke(MainForm form, string method, params object?[] args) => typeof(MainForm)
.GetMethod(method, BindingFlags.Instance | BindingFlags.NonPublic)!.Invoke(form, args);
private static IntPtr Dispatch(MainForm form, int message, IntPtr wparam)
{
object?[] args = [Message.Create(form.Handle, message, wparam, IntPtr.Zero)];
typeof(MainForm).GetMethod("WndProc", BindingFlags.Instance | BindingFlags.NonPublic)!.Invoke(form, args);
return ((Message)args[0]!).Result;
}
private static CancellationTokenSource Lifetime(MainForm form) => (CancellationTokenSource)typeof(MainForm)
.GetField("_lifetime", BindingFlags.Instance | BindingFlags.NonPublic)!.GetValue(form)!;
private static bool PumpUntil(Func<bool> condition)
{
var watch = System.Diagnostics.Stopwatch.StartNew();
while (!condition() && watch.ElapsedMilliseconds < 2500) { Application.DoEvents(); Thread.Sleep(5); }
return condition();
}
}
+16
View File
@@ -0,0 +1,16 @@
namespace UCVL.VPNPlus;
// The confirmation dialog runs a nested message loop. Shutdown may win while
// it is open, or while the package is downloading; never launch afterwards.
internal static class ClientUpdateFlow
{
internal static async Task<bool> RunAsync(Func<bool> isCurrent, Func<bool> confirm,
Func<Task<string>> download, Action<string> launch)
{
if (!isCurrent() || !confirm() || !isCurrent()) return false;
var installer = await download();
if (!isCurrent()) return false;
launch(installer);
return true;
}
}
+4 -1
View File
@@ -6,6 +6,9 @@ namespace UCVL.VPNPlus;
internal static class ClientUpdater
{
private const long MaximumInstallerBytes = 200L * 1024 * 1024;
// A 200 MiB package takes 1024 seconds on a slow 200 KiB/s link.
// Keep a bounded transfer budget with headroom; idle reads still stop at 30s.
internal static readonly TimeSpan DefaultTotalTimeout = TimeSpan.FromMinutes(20);
internal static bool IsNewerVersion(string candidate, string? current = null)
{
@@ -88,7 +91,7 @@ internal static class ClientUpdater
// Bound the entire transfer and each body read independently; a stalled
// download must not leave the update UI disabled indefinitely.
using var deadline = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);
deadline.CancelAfter(totalTimeout ?? TimeSpan.FromMinutes(10));
deadline.CancelAfter(totalTimeout ?? DefaultTotalTimeout);
var idleLimit = idleTimeout ?? TimeSpan.FromSeconds(30);
try
{
+3 -2
View File
@@ -2,8 +2,8 @@ using System.Text.Json.Nodes;
namespace UCVL.VPNPlus;
// Compatibility addresses explicitly supplied by the operator and authenticated
// against these two existing nodes on 2026-09-26. Not new nodes or login grants.
// Operator-supplied compatibility addresses for already-authorized nodes.
// These are same-node transports, not new nodes or login grants.
// The authenticated API config remains the authority for credentials and identity.
internal static class KnownTailnetEndpoints
{
@@ -30,6 +30,7 @@ internal static class KnownTailnetEndpoints
{
"aliyun-tokyo-002" => (Host: "vpn002.example.invalid", PublicPort: 11082, Address: "100.64.0.2", Port: 10803),
"aliyun-siliconvalley-003" => (Host: "vpn003.example.invalid", PublicPort: 11083, Address: "100.64.0.3", Port: 11083),
"racknerd-newyork-004" => (Host: "004.vpn.example.invalid", PublicPort: 11084, Address: "100.64.0.44", Port: 11084),
_ => default
};
reason = "known_node_unmapped";
+6 -4
View File
@@ -38,14 +38,15 @@ internal sealed partial class MainForm
private async Task CheckUplinkAsync()
{
if (_preview || _uiOnly || _exiting || !_wantConnected || _busy || _uplinkChecking || _xray.IsTransitioning || !_xray.CanRebindNetwork) return;
if (_runtimeRepairRequired || _preview || _uiOnly || _exiting || !_wantConnected || _busy || _uplinkChecking || _xray.IsTransitioning || !_xray.CanRebindNetwork) return;
if (!PreflightClientRuntime(suppressDialogs: true)) return;
_uplinkChecking = true;
var refreshAuthorization = false;
var operating = false;
try
{
var reading = await Task.Run(() => PhysicalUplink.Read(_xray.BoundNetwork?.InterfaceIndex));
if (_exiting || !_wantConnected || _busy || _xray.IsTransitioning) return;
if (_runtimeRepairRequired || _exiting || !_wantConnected || _busy || _xray.IsTransitioning) return;
if (!reading.Success) return;
if (!_handover.Pending && PhysicalUplink.Fingerprint(reading.Network) == _xray.BoundNetworkFingerprint && reading.Network is not null)
{
@@ -61,7 +62,7 @@ internal sealed partial class MainForm
_connectButton.Enabled = true;
_connectButton.Text = "断开";
var result = await _handover.ObserveAsync(reading, Environment.TickCount64, _handoverCancellation.Token);
if (!_wantConnected || _exiting) return;
if (_runtimeRepairRequired || !_wantConnected || _exiting) return;
if (result == NetworkHandover.Result.Recovered)
{
if (_currentNodeUsesTailnet && !_xray.UsesTailnet)
@@ -89,10 +90,11 @@ internal sealed partial class MainForm
}
}
catch (OperationCanceledException) { }
catch (ClientRuntimeException error) { HandleClientRuntimeFailure(error, suppressDialogs: true); }
catch (Exception error)
{
AppPaths.WriteError(error);
if (_wantConnected && !_exiting)
if (!_runtimeRepairRequired && _wantConnected && !_exiting)
{
SetConnectionState(false, "等待网络恢复", "本地网络尚未就绪,将自动重试;可点击断开取消。");
DisplayTraffic(null, null, "等待网络恢复");
+10 -1
View File
@@ -11,6 +11,12 @@ internal sealed partial class MainForm
{
_connectionAttemptCancellation?.Cancel();
_accessToken = token;
if (token is null)
{
_runtimeRepairRequired = false;
_statusDetail.AccessibleDescription = null;
_runtimeRepairTip.SetToolTip(_statusDetail, null);
}
_connectionAuthorization.Reset(expiresAt, DateTimeOffset.UtcNow, Environment.TickCount64);
_connectionHealth.Invalidate();
_sessionRevision++;
@@ -46,7 +52,8 @@ internal sealed partial class MainForm
// retries the same node's domain through the normal fresh-grant connector.
private async Task CheckTailnetReadinessAsync()
{
if (_uiOnly || _preview) return;
if (_runtimeRepairRequired || !_wantConnected || _uiOnly || _preview) return;
if (!PreflightClientRuntime(suppressDialogs: true)) return;
if (!_tailnetReadiness.TryBegin(ReadTailnetReadinessContext(), Environment.TickCount64, out var ticket))
{
_tailnetReconnectItem.Enabled = _tailnetReadiness.IsReady && !_busy && !_exiting;
@@ -63,6 +70,7 @@ internal sealed partial class MainForm
catch (Exception) { /* Fixed diagnostics below contain no credentials. */ }
var result = _tailnetReadiness.Observe(ticket, ReadTailnetReadinessContext(), Environment.TickCount64, reachable);
if (_exiting || IsDisposed || Disposing) return;
if (_runtimeRepairRequired || !PreflightClientRuntime(suppressDialogs: true)) return;
_tailnetReconnectItem.Enabled = _tailnetReadiness.IsReady && !_busy;
if (result == TailnetReadinessPolicy.Result.Fallback && _currentNodeSlug is { } slug)
{
@@ -86,6 +94,7 @@ internal sealed partial class MainForm
{
if (_uiOnly || _preview || _exiting || _busy || !_wantConnected || !_xray.IsRunning
|| _xray.UsesTailnet || !_tailnetReadiness.IsReady) return;
if (!PreflightClientRuntime(suppressDialogs: false, clearRepair: true)) return;
_tailnetReadiness.Reset();
_tailnetReconnectItem.Enabled = false;
_tailnetPreference.ResetForUserConnect();
+131 -43
View File
@@ -74,17 +74,24 @@ internal sealed partial class MainForm : Form
private Task<Exception?>? _exitCleanupTask;
private bool _exitResourcesDisposed;
private bool _sessionEnding;
private bool _installerExitRequested;
private readonly ClientExitRecoveryFixture? _exitRecoveryFixture;
private bool _windowExitSelfTestConnected;
private bool _updateCheckRunning;
private DateTimeOffset _nextUpdateCheckAt = DateTimeOffset.MinValue;
private bool _installerLaunched;
private bool _runtimeRepairRequired;
private readonly ToolTip _runtimeRepairTip = new() { AutoPopDelay = 20_000 };
internal bool WindowExitSelfTestPassed { get; private set; }
internal bool NetworkRecoveryFailed { get; private set; }
internal MainForm(bool runWindowExitSelfTest = false, bool preview = false, bool uiOnly = false,
bool autoConnect = false, Func<CancellationToken, Task>? startupRecovery = null)
bool autoConnect = false, Func<CancellationToken, Task>? startupRecovery = null,
ClientExitRecoveryFixture? exitRecoveryFixture = null)
{
if (exitRecoveryFixture is not null && !uiOnly) throw new ArgumentException("Recovery fixtures require uiOnly isolation.");
_exitRecoveryFixture = exitRecoveryFixture;
_uiOnly = uiOnly;
_preview = preview;
_startupRecovery = startupRecovery;
@@ -190,33 +197,34 @@ internal sealed partial class MainForm : Form
return false;
}
var notes = string.IsNullOrWhiteSpace(update.Notes) ? "包含稳定性和网络恢复改进。" : update.Notes.Trim();
var choice = MessageBox.Show(
$"发现新版本 {update.Version}\n\n{notes}\n\n是否现在安全升级?\n升级将覆盖原安装目录,但会保留账号、设备标识和本机配置。",
"纵横家·发现更新",
update.Mandatory ? MessageBoxButtons.OKCancel : MessageBoxButtons.YesNo,
MessageBoxIcon.Information);
accepted = update.Mandatory ? choice == DialogResult.OK : choice == DialogResult.Yes;
if (!accepted)
{
_nextUpdateCheckAt = DateTimeOffset.UtcNow.AddHours(6);
return false;
}
UseWaitCursor = true;
Text = $"纵横家 · 正在下载 {update.Version}…";
using var progressWindow = new UpdateProgressForm(update.Version);
progressWindow.Show(this);
Enabled = false;
string installer;
try { installer = await ClientUpdater.DownloadAsync(update, _lifetime.Token, new Progress<int>(progressWindow.Report)); }
finally { Enabled = true; }
// Start and authorize the installer BEFORE stopping the working client.
// The installer stages and validates all files, then requests graceful shutdown.
// Cancelling UAC or failing to start must leave the current connection alive.
var installerProcess = ClientUpdater.LaunchInstaller(installer);
_installerLaunched = true;
_ = ObserveInstallerAsync(installerProcess);
return true;
return await ClientUpdateFlow.RunAsync(
() => !_exiting && !_sessionEnding && !IsDisposed && !Disposing && !_lifetime.IsCancellationRequested,
() => {
var choice = MessageBox.Show(this,
$"发现新版本 {update.Version}\n\n{notes}\n\n是否现在安全升级?\n升级将覆盖原安装目录,但会保留账号、设备标识和本机配置。",
"纵横家·发现更新",
update.Mandatory ? MessageBoxButtons.OKCancel : MessageBoxButtons.YesNo,
MessageBoxIcon.Information);
accepted = update.Mandatory ? choice == DialogResult.OK : choice == DialogResult.Yes;
if (!accepted) _nextUpdateCheckAt = DateTimeOffset.UtcNow.AddHours(6);
return accepted;
}, async () => {
UseWaitCursor = true;
Text = $"纵横家 · 正在下载 {update.Version}…";
using var progressWindow = new UpdateProgressForm(update.Version);
progressWindow.Show(this);
Enabled = false;
try { return await ClientUpdater.DownloadAsync(update, _lifetime.Token, new Progress<int>(progressWindow.Report)); }
finally { if (!_exiting && !IsDisposed && !Disposing) Enabled = true; }
}, installer => {
// Start and authorize the installer BEFORE stopping the working client.
// The installer stages and validates all files, then requests graceful shutdown.
// Cancelling UAC or failing to start must leave the current connection alive.
var installerProcess = ClientUpdater.LaunchInstaller(installer);
_installerLaunched = true;
_ = ObserveInstallerAsync(installerProcess);
AppPaths.WriteLog("update.install.started version=" + update.Version);
});
}
catch (OperationCanceledException) when (_lifetime.IsCancellationRequested)
{
@@ -226,7 +234,7 @@ internal sealed partial class MainForm : Form
{
_nextUpdateCheckAt = DateTimeOffset.UtcNow.AddMinutes(accepted ? 30 : 2);
AppPaths.WriteError(exception);
if (accepted)
if (accepted && !_exiting && !_sessionEnding && !IsDisposed && !Disposing)
{
MessageBox.Show(
$"更新未启动,已保留当前版本和当前连接。\n\n{exception.Message}",
@@ -239,8 +247,7 @@ internal sealed partial class MainForm : Form
finally
{
_updateCheckRunning = false;
UseWaitCursor = false;
Text = "纵横家";
if (!_exiting && !IsDisposed && !Disposing) { UseWaitCursor = false; Text = "纵横家"; }
}
}
@@ -489,6 +496,9 @@ internal sealed partial class MainForm : Form
return;
}
if (reconnect && _runtimeRepairRequired) return;
if (!PreflightClientRuntime(suppressDialogs, clearRepair: !reconnect)) return;
ConnectionSelection selection;
try
{
@@ -514,6 +524,7 @@ internal sealed partial class MainForm : Form
foreach (var slug in _failedNodes.Where(p => p.Value <= DateTimeOffset.UtcNow).Select(p => p.Key).ToList()) _failedNodes.Remove(slug);
SetConnectionState(false, "正在连接", selection.Manual ? "正在连接手动指定节点…" : "vpn-ai 正在分配工作节点…");
var replacementStarted = false;
var runtimeFailure = false;
try
{
if (!_connectionAuthorization.AccountIsValid(DateTimeOffset.UtcNow, Environment.TickCount64))
@@ -597,6 +608,7 @@ internal sealed partial class MainForm : Form
break;
}
catch (LocalNetworkException) { throw; }
catch (ClientRuntimeException) { throw; }
catch (TailnetUnavailableException)
{
// Connector cleans up only a core it actually attempted.
@@ -646,6 +658,11 @@ internal sealed partial class MainForm : Form
_notifyIcon.Text = "纵横家 · 已连接";
_notifyIcon.ShowBalloonTip(1800, "纵横家已连接", $"当前线路:{_currentNodeName}", ToolTipIcon.Info);
}
catch (ClientRuntimeException exception)
{
runtimeFailure = true;
HandleClientRuntimeFailure(exception, suppressDialogs);
}
catch (Exception) when (connectionToken.IsCancellationRequested)
{
if (!_exiting) await DisconnectAsync();
@@ -682,12 +699,52 @@ internal sealed partial class MainForm : Form
}
finally
{
if (!_xray.IsRunning && reconnect && !connectionToken.IsCancellationRequested && !string.IsNullOrWhiteSpace(_accessToken)) { _wantConnected = true; _nextReconnect = DateTimeOffset.UtcNow.AddMinutes(2); }
if (!runtimeFailure && !_xray.IsRunning && reconnect && !connectionToken.IsCancellationRequested && !string.IsNullOrWhiteSpace(_accessToken)) { _wantConnected = true; _nextReconnect = DateTimeOffset.UtcNow.AddMinutes(2); }
if (ReferenceEquals(_connectionAttemptCancellation, attemptCancellation)) _connectionAttemptCancellation = null;
SetBusy(false);
}
}
private void HandleClientRuntimeFailure(ClientRuntimeException exception, bool suppressDialogs)
{
var firstNotice = !_runtimeRepairRequired;
_runtimeRepairRequired = true;
AppPaths.WriteLog(exception.Diagnostic);
// Component repair requires the installer, not another node or route.
// A running core retains its existing configuration and network state.
var connected = _xray.IsRunning;
_wantConnected = connected;
_nextReconnect = DateTimeOffset.MaxValue;
_connectionHealth.Invalidate();
_connectionHealth.ResetFailures();
_tailnetReadiness.Reset();
_tailnetReconnectItem.Enabled = false;
_handover.Reset();
SetConnectionState(connected, connected ? "组件需修复 · 保留原连接" : "客户端组件需要修复",
exception.Message.Replace('\n', ' '));
_statusDetail.AccessibleDescription = exception.Message;
_runtimeRepairTip.SetToolTip(_statusDetail, exception.Message);
if (connected) _currentNodeLabel.Text = _currentNodeName ?? _currentNodeSlug ?? "原工作节点";
if (!suppressDialogs) MessageBox.Show(exception.Message, "客户端安装需要修复", MessageBoxButtons.OK, MessageBoxIcon.Warning);
else if (firstNotice) _notifyIcon.ShowBalloonTip(7000, "客户端安装需要修复", exception.Message, ToolTipIcon.Warning);
}
private bool PreflightClientRuntime(bool suppressDialogs, bool clearRepair = false)
{
try
{
_xray.ValidateRuntime();
if (clearRepair)
{
_runtimeRepairRequired = false;
_statusDetail.AccessibleDescription = null;
_runtimeRepairTip.SetToolTip(_statusDetail, null);
}
return true;
}
catch (ClientRuntimeException error) { HandleClientRuntimeFailure(error, suppressDialogs); return false; }
}
private async Task DisconnectAsync(bool cancelPending = true)
{
_wantConnected = false;
@@ -788,6 +845,8 @@ internal sealed partial class MainForm : Form
} finally { _healthChecking = false; }
return;
}
// Keep authorization expiry enforcement above this local repair gate.
if (_runtimeRepairRequired) return;
await CheckUplinkAsync();
if (_uplinkChecking || _handover.Pending || _handover.Settling) return;
if (!_wantConnected || _busy || _xray.IsTransitioning || _healthChecking || _exiting || DateTimeOffset.UtcNow < _nextReconnect) return;
@@ -801,6 +860,7 @@ internal sealed partial class MainForm : Form
var revision = _connectionHealth.Revision;
var testedCore = _xray.CoreId;
var health = await _xray.CheckHealthWithRepairAsync(_lifetime.Token);
if (_runtimeRepairRequired) return;
var healthy = health.Healthy;
var decision = _connectionHealth.Observe(revision, testedCore, _xray.CoreId,
_wantConnected, _busy, _xray.IsTransitioning, _exiting, healthy, Environment.TickCount64, health.ProxyHealthy,
@@ -836,6 +896,7 @@ internal sealed partial class MainForm : Form
}
ConnectionAcceptanceTrace.Record("health_failed", _currentNodeSlug, _xray.IsRunning, _xray.CoreId, _connectionHealth.Failures);
if (decision != ConnectionHealthPolicy.Decision.Switch) return;
if (!PreflightClientRuntime(suppressDialogs: true)) return;
if (_currentNodeSlug is not null)
{
if (_currentNodeUsesTailnet)
@@ -935,11 +996,11 @@ internal sealed partial class MainForm : Form
private void ShowAiStatus(string message)
{
if (_exiting || IsDisposed || Disposing) return;
if (_runtimeRepairRequired || _exiting || IsDisposed || Disposing) return;
var reportingCore = _xray.CoreId;
PostUi(() =>
{
if (_dashboardView.Visible && _wantConnected && _xray.CoreId == reportingCore)
if (!_runtimeRepairRequired && _dashboardView.Visible && _wantConnected && _xray.CoreId == reportingCore)
_statusDetail.Text = NodePresentation.LearningDetail(_selectionUiConnected, _currentNodeName, message);
});
}
@@ -1193,7 +1254,7 @@ internal sealed partial class MainForm : Form
eventArgs.Cancel = true;
return;
}
if (_uiOnly || _preview)
if ((_uiOnly || _preview) && _exitRecoveryFixture is null)
{
_ = BeginExitCleanup();
CompleteExitResources();
@@ -1213,13 +1274,21 @@ internal sealed partial class MainForm : Form
SetConnectionState(false, "正在恢复本地网络", "正在恢复系统代理并关闭内核,请稍候…");
}
var error = await cleanup;
Exception? error;
try { error = await cleanup.WaitAsync(_exitRecoveryFixture?.Deadline ?? TimeSpan.FromSeconds(85)); }
catch (TimeoutException timeout)
{
// Leave every still-owned recovery journal intact. The installer
// observes a nonzero client exit and must not replace its files.
error = timeout;
AppPaths.WriteLog("exit.recovery.timeout journals_retained=true");
}
if (_sessionEnding || IsDisposed || Disposing) return;
if (error is not null)
{
// Never install over a client whose network recovery failed.
NetworkRecoveryFailed = true;
MessageBox.Show("网络恢复未全部完成,恢复记录已保留;本次不继续自动安装。\n" + error.GetBaseException().Message,
if (!_installerExitRequested) MessageBox.Show("网络恢复未全部完成,恢复记录已保留;本次不继续自动安装。\n" + error.GetBaseException().Message,
"纵横家 · 网络恢复提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
CompleteExitResources();
@@ -1237,13 +1306,19 @@ internal sealed partial class MainForm : Form
_refreshTimer.Stop(); _updateTimer.Stop(); _trafficTimer.Stop(); _healthTimer.Stop();
_nodeTrafficTimer.Stop();
_lifetime.Cancel();
if (_uiOnly || _preview) return _exitCleanupTask = Task.FromResult<Exception?>(null);
if ((_uiOnly || _preview) && _exitRecoveryFixture is null) return _exitCleanupTask = Task.FromResult<Exception?>(null);
// The same tracked cleanup serves menu/installer exit and session end.
// Run it without a UI synchronization context so WM_ENDSESSION can
// wait within Windows' shutdown budget without blocking its continuations.
return _exitCleanupTask = Task.Run(async () =>
{
try { await _xray.DisposeAsync().ConfigureAwait(false); return (Exception?)null; }
try
{
if (_exitRecoveryFixture is { } fixture) await fixture.Dispose().ConfigureAwait(false);
else await _xray.DisposeAsync().ConfigureAwait(false);
return (Exception?)null;
}
catch (OperationCanceledException error) when (_sessionEnding) { return error; }
catch (Exception error) { AppPaths.WriteError(error); return error; }
});
}
@@ -1257,20 +1332,24 @@ internal sealed partial class MainForm : Form
_api.Dispose();
_notifyIcon.Visible = false;
_notifyIcon.Dispose();
_runtimeRepairTip.Dispose();
}
protected override void WndProc(ref Message message)
{
if (message.Msg == 0x11 /* WM_QUERYENDSESSION */)
{
// A query may be canceled by another application. Do not cancel
// our session or await network cleanup until Windows confirms it.
// A query can be canceled. Return promptly without disconnecting
// or launching any recovery helper before Windows confirms it.
message.Result = (IntPtr)1;
return;
}
if (message.Msg == 0x16 /* WM_ENDSESSION */)
{
if (message.WParam == IntPtr.Zero) { message.Result = IntPtr.Zero; return; }
if (message.WParam == IntPtr.Zero)
{
message.Result = IntPtr.Zero; return;
}
CompleteSessionEnding();
}
base.WndProc(ref message);
@@ -1280,6 +1359,7 @@ internal sealed partial class MainForm : Form
{
if (_sessionEnding) return;
_sessionEnding = true;
_xray.ConfirmSessionShutdown();
var cleanup = BeginExitCleanup();
// Windows can terminate us after its short shutdown allowance. Never
// remove recovery journals here or display a modal recovery error.
@@ -1379,11 +1459,19 @@ internal sealed partial class MainForm : Form
internal void RequestExit()
{
if (_exiting || IsDisposed || Disposing) return;
if (IsDisposed || Disposing) return;
_exitRequested = true;
if (_exiting) return;
Close();
}
internal void RequestExitForUpdate()
{
_installerExitRequested = true;
AppPaths.WriteLog("update.shutdown.requested");
RequestExit();
}
private static void OpenRegistrationPage()
{
try
+10 -7
View File
@@ -54,7 +54,7 @@ internal static class NodeTransportConnector
diagnostic?.Invoke(new("rebind_selected", tailnet ? "tailnet_verified" : "public_ingress", ""));
return selected;
}
catch (Exception e) when (tailnet && e is not LocalNetworkException && !token.IsCancellationRequested)
catch (Exception e) when (tailnet && e is not LocalNetworkException && e is not ClientRuntimeException && !token.IsCancellationRequested)
{
await stop(); // Full cleanup before same-node fallback; failure aborts.
token.ThrowIfCancellationRequested();
@@ -88,7 +88,7 @@ internal static class NodeTransportConnector
requireRoute(TailnetTransport.Address(tailnet)!);
token.ThrowIfCancellationRequested();
}
catch (Exception e) when (e is not OperationCanceledException)
catch (Exception e) when (e is not OperationCanceledException && e is not ClientRuntimeException)
{
preference.Failed(response.Node.Slug, ticks());
tailnet = null;
@@ -106,7 +106,7 @@ internal static class NodeTransportConnector
throw new IOException("代理内网 IP Ping 不通。");
token.ThrowIfCancellationRequested();
}
catch (Exception e) when (e is not OperationCanceledException)
catch (Exception e) when (e is not OperationCanceledException && e is not ClientRuntimeException)
{
preference.Failed(response.Node.Slug, ticks());
tailnet = null;
@@ -132,6 +132,7 @@ internal static class NodeTransportConnector
return true;
}
catch (LocalNetworkException) { throw; }
catch (ClientRuntimeException) { throw; }
catch (OperationCanceledException) when (token.IsCancellationRequested) { throw; }
catch (Exception)
{
@@ -147,11 +148,13 @@ internal static class NodeTransportConnector
// Automatic selection can test ALL authorized Tailnet nodes first. A
// failed alternate must not launch public ingress before that pass ends.
if (tailnetOnly) throw new TailnetUnavailableException(reason);
if (response.ConnectionScope != PrivateAuxiliaryRouting.Scope && response.RouteMode is "smart" or "global")
preference.CommitDomainFallback();
Report("selected", "public_ingress");
await start(response.GetRuntimeConfigJson(), token);
var commitDomain = response.ConnectionScope != PrivateAuxiliaryRouting.Scope && response.RouteMode is "smart" or "global";
try { await start(response.GetRuntimeConfigJson(), token); }
catch (ClientRuntimeException) { throw; }
catch { if (commitDomain) preference.CommitDomainFallback(); throw; }
if (commitDomain) preference.CommitDomainFallback();
token.ThrowIfCancellationRequested();
Report("selected", "public_ingress");
return false;
}
}
+22 -15
View File
@@ -11,12 +11,27 @@ internal static class Program
[STAThread]
private static int Main(string[] args)
{
if (args.Length == 1 && args[0] == "--client-shutdown-self-test")
{
ApplicationConfiguration.Initialize();
return ClientShutdownSelfTest.Run();
}
if (args.Length == 3 && args[0] == "--client-shutdown-test-child"
&& int.TryParse(args[1], out var childDelay) && childDelay is >= 10 and <= 2000
&& int.TryParse(args[2], out var childExit) && childExit is 0 or 7)
{
Thread.Sleep(childDelay);
return childExit;
}
if (args.Any(a => a.StartsWith("--client-shutdown-test-child", StringComparison.OrdinalIgnoreCase))) return 87;
if (args.Length == 5 && args[0] is "--installer-guardian-gate" or "--installer-guardian-apply")
return InstallerGuardianGate.Run(args[1], args[2], args[3], args[4], apply: args[0] == "--installer-guardian-apply");
// Malformed maintenance arguments must never fall through to the GUI.
if (args.Any(a => a.StartsWith("--installer-guardian-", StringComparison.OrdinalIgnoreCase))) return InstallerGuardianGate.Invalid;
if (args.Length == 1 && args[0] == "--platform-bootstrap-self-test")
return PlatformBootstrapTransportSelfTest.RunAsync().GetAwaiter().GetResult();
if (args.Length == 1 && args[0] == "--client-runtime-self-test")
return ClientRuntimeSelfTest.RunAsync().GetAwaiter().GetResult();
if (args.Length == 1 && args[0] == "--tailnet-transport-self-test")
return TailnetTransportSelfTest.RunAsync().GetAwaiter().GetResult();
if (args.Length == 1 && args[0] == "--public-tailnet-selection-self-test")
@@ -193,9 +208,12 @@ internal static class Program
shutdownEvent,
(_, _) =>
{
var form = Application.OpenForms.OfType<MainForm>().FirstOrDefault();
if (form is null || form.IsDisposed || !form.IsHandleCreated) return;
form.BeginInvoke(form.RequestExit);
try
{
if (!mainForm.IsDisposed && mainForm.IsHandleCreated)
mainForm.BeginInvoke(mainForm.RequestExitForUpdate);
}
catch (InvalidOperationException) { /* A concurrent close destroyed the HWND. */ }
},
null,
Timeout.Infinite,
@@ -333,18 +351,7 @@ internal static class Program
foreach (var process in processes) process.CloseMainWindow();
}
foreach (var process in processes)
{
using (process)
{
if (!process.WaitForExit(15_000))
{
return 2;
}
if (process.ExitCode != 0) return 2;
}
}
return 0;
return ClientShutdownScope.WaitForExit(processes) ? 0 : 2;
}
catch
{
+3 -3
View File
@@ -1,6 +1,6 @@
# 纵横家 Windows 0.3.5 开源源码
# 纵横家 Windows 0.3.7 开源源码
基于已冻结的 0.3.5 r22 第一方 Windows Forms / .NET 8 源码整理。此导出不是原安装包的逐字节副本:删除许可来源不明的可选登录插图及内部运维历史,保留原创山水缺图 fallback;端点为示例配置。原候选测试报告不能当作本导出的构建或生产验收证明。
基于已冻结的 0.3.7 r22 第一方 Windows Forms / .NET 8 源码整理。此导出不是原安装包的逐字节副本:删除许可来源不明的可选登录插图及内部运维历史,保留原创山水缺图 fallback;端点为示例配置。原候选测试报告不能当作本导出的构建或生产验收证明。
## 构建
@@ -17,4 +17,4 @@ dotnet publish VPNPlus.csproj -c Release -r win-x64 --self-contained true
公司自有代码适用 LICENSE;公司 Logo/商标保留来源识别用途、不授予品牌权利;第三方许可文本在 licenses/ 中,原 THIRD_PARTY_NOTICES.md 保持原文。
0.3.5:为本机代理及各服务器显示独立流量趋势,清晰区分上传、下载及累计数值,保持固定紧凑主界面。保留0.3.4连接容错与授权有效期处理;本次只更新界面,不改变调度、节点优先级或网络路由,不宣称网络提速。清洁源码保留原MIT/GPL和第三方许可边界,不含用户提供的可选JPG;同包离线、合成界面与隔离文件事务验证不等于生产网络或覆盖安装验收。
0.3.7:修复升级确认后窗口退出竞态、旧进程退出等待期限、安装器退出的阻塞提示,并改进Windows会话结束的限时清理和恢复记录保留。保留0.3.6连接与运行组件修复。已进行隔离回归,不代表实际关机验收。可选JPG保持从开源代码中省略,许可边界保持不变。
+46
View File
@@ -203,6 +203,52 @@ internal static class TailnetTransportSelfTest
r["config"]!["outbounds"]![0]!["settings"]!["vnext"]![0]!["port"] = 11083;
}), true)!;
checks["known_silicon_exact_mapping"] = Host(silicon) == "100.64.0.3" && TailnetTransport.Port(silicon) == 11083;
ConfigResponse NewYork(Action<JsonObject>? change = null) => Known(r => {
r["node"]!["slug"] = "racknerd-newyork-004"; r["node"]!["name"] = "VPN004";
r["config"]!["outbounds"]![0]!["settings"]!["vnext"]![0]!["address"] = "004.vpn.example.invalid";
r["config"]!["outbounds"]![0]!["settings"]!["vnext"]![0]!["port"] = 11084;
change?.Invoke(r);
});
var newYork = NewYork();
var newYorkOriginal = newYork.GetRuntimeConfigJson();
var newYorkPrepared = TailnetTransport.TryPrepare(newYork, true);
checks["known_newyork_exact_mapping"] = newYorkPrepared is not null
&& Host(newYorkPrepared) == "100.64.0.44" && TailnetTransport.Port(newYorkPrepared) == 11084;
checks["known_newyork_requires_mapping_permission"] = TailnetTransport.TryPrepare(newYork) is null;
checks["known_newyork_same_authorized_fallback"] = newYorkPrepared is not null
&& TailnetTransport.SameAuthorizedFallback(newYorkPrepared, newYorkOriginal);
var newYorkRestored = newYorkPrepared is null ? null : JsonNode.Parse(newYorkPrepared)!.AsObject();
if (newYorkRestored is not null)
{
newYorkRestored.Remove(TailnetTransport.Marker);
newYorkRestored["outbounds"]![0]!["settings"]!["vnext"]![0]!["address"] = "004.vpn.example.invalid";
newYorkRestored["outbounds"]![0]!["settings"]!["vnext"]![0]!["port"] = 11084;
}
checks["known_newyork_preserves_all_credentials_and_rules"] = newYorkRestored is not null
&& JsonNode.DeepEquals(newYorkRestored, JsonNode.Parse(newYorkOriginal))
&& newYork.GetRuntimeConfigJson() == newYorkOriginal;
checks["known_newyork_changed_host_rejected"] = TailnetTransport.TryPrepare(NewYork(r =>
r["config"]!["outbounds"]![0]!["settings"]!["vnext"]![0]!["address"] = "other.example.com"), true) is null;
checks["known_newyork_changed_port_rejected"] = TailnetTransport.TryPrepare(NewYork(r =>
r["config"]!["outbounds"]![0]!["settings"]!["vnext"]![0]!["port"] = 11083), true) is null;
checks["known_newyork_changed_slug_rejected"] = TailnetTransport.TryPrepare(NewYork(r =>
r["node"]!["slug"] = "unapproved-newyork"), true) is null;
checks["known_newyork_explicit_null_disables_mapping"] = TailnetTransport.TryPrepare(NewYork(r => r["tailscale_endpoint"] = null), true) is null;
checks["known_newyork_invalid_metadata_never_uses_mapping"] = TailnetTransport.TryPrepare(NewYork(r => r["tailscale_endpoint"] = new JsonObject()), true) is null;
var newYorkExplicit = TailnetTransport.TryPrepare(NewYork(r => r["tailscale_endpoint"] = new JsonObject {
["contract"] = 1, ["node_slug"] = "racknerd-newyork-004", ["address"] = "100.65.1.9", ["port"] = 2345
}), true);
checks["known_newyork_server_metadata_remains_authoritative"] = newYorkExplicit is not null
&& Host(newYorkExplicit) == "100.65.1.9" && TailnetTransport.Port(newYorkExplicit) == 2345;
var newYorkStarts = new List<string>(); var newYorkStops = 0; var newYorkProbes = 0;
var newYorkSelected = await NodeTransportConnector.ConnectAsync(newYork, new(),
(json, _) => { newYorkStarts.Add(json); return Task.CompletedTask; },
() => { newYorkStops++; return Task.CompletedTask; },
_ => { newYorkProbes++; return Task.FromResult(false); }, _ => { }, _ => { }, () => tick, CancellationToken.None,
allowKnownEndpoints: true, endpointProbe: (address, port, _) => Task.FromResult(address == "100.64.0.44" && port == 11084));
checks["known_newyork_failed_proxy_falls_back_only_same_authorized_node"] = !newYorkSelected
&& newYorkStarts.Count == 2 && Host(newYorkStarts[0]) == "100.64.0.44"
&& newYorkStarts[1] == newYorkOriginal && newYorkStops == 1 && newYorkProbes == 1;
var future = TailnetTransport.TryPrepare(Known(r => r["tailscale_endpoint"] = new JsonObject {
["contract"] = 1, ["node_slug"] = "aliyun-tokyo-002", ["address"] = "100.65.1.9", ["port"] = 2345
}), true)!;
+3
View File
@@ -68,6 +68,9 @@ internal static class UpdateSelfTest
};
try
{
report["largest_allowed_package_fits_slow_200kib_link_with_headroom"] = ClientUpdater.DefaultTotalTimeout
>= TimeSpan.FromSeconds(200.0 * 1024 * 1024 / (200 * 1024) + 60);
report["update_total_deadline_remains_bounded"] = ClientUpdater.DefaultTotalTimeout <= TimeSpan.FromMinutes(20);
var bytes = RandomNumberGenerator.GetBytes(300_000); // Test data, not an executable.
var hash = Convert.ToHexString(SHA256.HashData(bytes));
ClientUpdateInfo Info(string digest, bool available = true) => new() {
+4 -4
View File
@@ -10,10 +10,10 @@
<ApplicationIcon>assets\zonghengjia-app-v1.ico</ApplicationIcon>
<ApplicationManifest>app.manifest</ApplicationManifest>
<ApplicationHighDpiMode>PerMonitorV2</ApplicationHighDpiMode>
<Version>0.3.5</Version>
<AssemblyVersion>0.3.5.0</AssemblyVersion>
<FileVersion>0.3.5.0</FileVersion>
<InformationalVersion>0.3.5</InformationalVersion>
<Version>0.3.7</Version>
<AssemblyVersion>0.3.7.0</AssemblyVersion>
<FileVersion>0.3.7.0</FileVersion>
<InformationalVersion>0.3.7</InformationalVersion>
<Product>纵横家</Product>
<Company>优创未来(UCVL)</Company>
<Description>纵横家 Windows 智能网络客户端</Description>
+41 -27
View File
@@ -22,6 +22,8 @@ internal sealed class XrayManager : IDisposable, IAsyncDisposable, IHandoverRunt
private bool _disposed;
private NetworkOwnerLease? _ownerLease;
private bool _recoveryComplete;
private bool _stoppedCleanly;
private readonly CancellationTokenSource _systemShutdown = new();
private readonly SemaphoreSlim _lifecycle = new(1, 1);
private readonly string _xrayDirectory = Path.Combine(AppContext.BaseDirectory, "xray");
private string? _baseConfigJson;
@@ -66,6 +68,8 @@ internal sealed class XrayManager : IDisposable, IAsyncDisposable, IHandoverRunt
public bool CanRebindNetwork => !string.IsNullOrWhiteSpace(_baseConfigJson) && _boundNetwork is not null;
bool IHandoverRuntime.IsRunning => IsRunning;
internal void ConfirmSessionShutdown() => _systemShutdown.Cancel();
public async Task SuspendForNetworkChangeAsync(CancellationToken token)
{
await _lifecycle.WaitAsync(token);
@@ -75,10 +79,14 @@ internal sealed class XrayManager : IDisposable, IAsyncDisposable, IHandoverRunt
public async Task RebindNetworkAsync(CancellationToken token)
{
ValidateRuntime();
await _lifecycle.WaitAsync(token);
var replacementStarted = false;
try
{
ValidateRuntime();
if (!CanRebindNetwork) throw new InvalidOperationException("没有可恢复的已授权线路。");
replacementStarted = true;
await StopCoreAsync(); // Restore old routes/DNS BEFORE any DNS/network requests.
token.ThrowIfCancellationRequested();
_baseConfigJson = await NodeTransportConnector.RebindAsync(_baseConfigJson!, _tailnetFallbackConfigJson,
@@ -89,7 +97,7 @@ internal sealed class XrayManager : IDisposable, IAsyncDisposable, IHandoverRunt
endpointProbe: TailnetTransport.ProbeEndpointAsync,
diagnostic: entry => AppPaths.WriteLog((entry with { Node = _nodeSlug }).SafeMessage));
}
catch { await StopCoreAsync(); throw; }
catch { if (replacementStarted) await StopCoreAsync(); throw; }
finally { _lifecycle.Release(); }
}
@@ -202,6 +210,8 @@ internal sealed class XrayManager : IDisposable, IAsyncDisposable, IHandoverRunt
internal async Task StartAsync(string configJson, string routeMode, string nodeSlug, CancellationToken cancellationToken,
string? tailnetFallbackConfigJson = null, string? preferredTailnetConfigJson = null)
{
// Fail locally before ownership/recovery or stopping a healthy core.
ValidateRuntime();
if (TailnetTransport.Address(configJson) is not null
&& !TailnetTransport.SameAuthorizedFallback(configJson, tailnetFallbackConfigJson))
throw new InvalidOperationException("Tailscale 原入口与已授权线路不匹配。");
@@ -214,8 +224,12 @@ internal sealed class XrayManager : IDisposable, IAsyncDisposable, IHandoverRunt
await InitializeAsync(cancellationToken);
await StartupLearningWarmup.RunAsync(async beginLearning => {
await _lifecycle.WaitAsync(cancellationToken);
var replacementStarted = false;
try
{
// Recheck after waiting for the lifecycle; a file may change.
ValidateRuntime();
replacementStarted = true;
await StopCoreAsync();
_baseConfigJson = configJson;
_tailnetFallbackConfigJson = preferred is not null ? original : tailnetFallbackConfigJson;
@@ -226,7 +240,7 @@ internal sealed class XrayManager : IDisposable, IAsyncDisposable, IHandoverRunt
}
catch
{
await StopCoreAsync().ConfigureAwait(false);
if (replacementStarted) await StopCoreAsync().ConfigureAwait(false);
throw;
}
finally { _lifecycle.Release(); }
@@ -276,8 +290,9 @@ internal sealed class XrayManager : IDisposable, IAsyncDisposable, IHandoverRunt
private async Task StartCoreAsync(CancellationToken cancellationToken,
Action<CancellationToken>? beginStartupLearning = null)
{
EnsureRuntime();
ValidateRuntime();
if (string.IsNullOrWhiteSpace(_baseConfigJson)) throw new InvalidOperationException("线路配置为空。");
_stoppedCleanly = false;
PrivateAuxiliaryRuntime.ValidateLifetime(_baseConfigJson);
var privateAuxiliary = PrivateAuxiliaryRuntime.IsPrivate(_baseConfigJson);
var preservePrivateRoute = privateAuxiliary && PrivateAuxiliaryRuntime.Address(_baseConfigJson) != PrivateAuxiliaryRouting.PublicPhoneHost;
@@ -354,7 +369,7 @@ internal sealed class XrayManager : IDisposable, IAsyncDisposable, IHandoverRunt
_process.ErrorDataReceived += (_, eventArgs) => AppendXrayLog(eventArgs.Data);
var startedProcess = _process;
_process.Exited += (_, _) => _ = HandleCoreExitAsync(startedProcess);
if (!_process.Start()) throw new InvalidOperationException("Xray 内核无法启动。");
if (!ClientRuntime.Start(_process)) throw new ClientRuntimeException(XrayPath, ClientRuntimeFault.CannotStart);
_process.BeginOutputReadLine();
_process.BeginErrorReadLine();
File.WriteAllText(AppPaths.PidFile, _process.Id.ToString());
@@ -425,16 +440,18 @@ internal sealed class XrayManager : IDisposable, IAsyncDisposable, IHandoverRunt
{
// A rejected second instance must not delete the active owner's DNS,
// routes, PID journal or virtual adapter through its error/Dispose path.
if (_ownerLease is null || !_recoveryComplete) return;
if (_ownerLease is null || !_recoveryComplete || _stoppedCleanly) return;
_learningEpoch.Cancel();
var proxyRestored = SystemProxy.Restore();
Exception? restoreError = null;
using var recovery = new CancellationTokenSource(TimeSpan.FromSeconds(25));
var sessionToken = _systemShutdown.Token;
using var recovery = CancellationTokenSource.CreateLinkedTokenSource(sessionToken);
recovery.CancelAfter(TimeSpan.FromSeconds(25));
Exception? dnsRestoreError = null;
try { await ProxyDnsPolicy.RestoreAsync(recovery.Token).ConfigureAwait(false); }
catch (Exception error) { dnsRestoreError = error; AppPaths.WriteError(error); }
try { await TunRouting.RestoreAsync(recovery.Token).ConfigureAwait(false); }
catch (Exception error) { restoreError = error; AppPaths.WriteError(error); }
try { recovery.Token.ThrowIfCancellationRequested(); await ProxyDnsPolicy.RestoreAsync(recovery.Token).ConfigureAwait(false); }
catch (Exception error) { dnsRestoreError = error; if (!sessionToken.IsCancellationRequested) AppPaths.WriteError(error); }
try { recovery.Token.ThrowIfCancellationRequested(); await TunRouting.RestoreAsync(recovery.Token).ConfigureAwait(false); }
catch (Exception error) { restoreError = error; if (!sessionToken.IsCancellationRequested) AppPaths.WriteError(error); }
try
{
if (_process is { HasExited: false })
@@ -454,21 +471,30 @@ internal sealed class XrayManager : IDisposable, IAsyncDisposable, IHandoverRunt
SafeDelete(AppPaths.PidFile);
SafeDeleteConfig();
}
await TunRouting.CleanupOwnedAdapterAsync(CancellationToken.None).ConfigureAwait(false);
// Confirmed system shutdown forbids launching fresh helper processes.
// Kill the already-owned core above, retain failed journals, and let
// startup recovery finish after Windows is ready again.
sessionToken.ThrowIfCancellationRequested();
await TunRouting.CleanupOwnedAdapterAsync(sessionToken).ConfigureAwait(false);
if (restoreError is not null)
{
// Removal of a failed TUN device may have removed its routes too.
// Retry the retained journal; never erase it merely because exit was requested.
using var retry = new CancellationTokenSource(TimeSpan.FromSeconds(15));
using var retry = CancellationTokenSource.CreateLinkedTokenSource(sessionToken);
retry.CancelAfter(TimeSpan.FromSeconds(15));
retry.Token.ThrowIfCancellationRequested();
await TunRouting.RestoreAsync(retry.Token).ConfigureAwait(false);
}
if (!proxyRestored && !SystemProxy.Restore())
throw new IOException("系统代理恢复未完成,恢复记录已保留。请勿继续升级安装。");
if (dnsRestoreError is not null)
{
using var retry = new CancellationTokenSource(TimeSpan.FromSeconds(25));
using var retry = CancellationTokenSource.CreateLinkedTokenSource(sessionToken);
retry.CancelAfter(TimeSpan.FromSeconds(25));
retry.Token.ThrowIfCancellationRequested();
await ProxyDnsPolicy.RestoreAsync(retry.Token).ConfigureAwait(false);
}
_stoppedCleanly = true;
}
private async Task HandleCoreExitAsync(Process exited)
@@ -557,7 +583,7 @@ internal sealed class XrayManager : IDisposable, IAsyncDisposable, IHandoverRunt
StandardErrorEncoding = Encoding.UTF8,
}
};
process.Start();
ClientRuntime.Start(process);
var stdout = process.StandardOutput.ReadToEndAsync(cancellationToken);
var stderr = process.StandardError.ReadToEndAsync(cancellationToken);
await process.WaitForExitAsync(cancellationToken);
@@ -593,19 +619,7 @@ internal sealed class XrayManager : IDisposable, IAsyncDisposable, IHandoverRunt
return addresses;
}
private void EnsureRuntime()
{
foreach (var file in new[]
{
XrayPath,
Path.Combine(_xrayDirectory, "geoip.dat"),
Path.Combine(_xrayDirectory, "geosite.dat"),
Path.Combine(_xrayDirectory, "wintun.dll"),
})
{
if (!File.Exists(file)) throw new FileNotFoundException($"客户端组件缺失:{Path.GetFileName(file)}");
}
}
internal void ValidateRuntime() => ClientRuntime.Validate(AppContext.BaseDirectory);
private async Task RecoverStaleStateAsync(CancellationToken cancellationToken)
{
+13
View File
@@ -0,0 +1,13 @@
# 纵横家 Windows 0.3.6
本次维护修复本机运行组件故障被重复显示为多个节点连接失败的问题。
- 建立连接前检查程序目录中的运行组件,区分文件缺失、读取受限和空文件,显示具体位置及完整安装包修复方法。
- 本机组件故障直接进入安装修复提示,保留仍在运行的连接,避免重复重试节点和误记 Tailscale 故障。
- 自动升级的整包下载期限调整为 20 分钟,保留单次读取超时、取消、完整长度及 SHA-256 校验,适应低速网络。
- 补齐 VPN004 的 Tailscale 兼容入口识别,沿用已授权的同节点配置,内网可达时优先使用内网入口。
- 保留 0.3.5 的本机与服务器独立流量趋势图和紧凑累计数值。
完整安装包包含 Xray、Wintun 及路由数据文件。覆盖安装会保留账号、设备标识和用户配置。组件读取受限时应先排查该文件的访问权限,再运行完整安装包修复。
发布验证范围包括同包离线回归、缺件修复的隔离文件事务、运行组件故障的模拟连接及升级下载边界测试。离线和隔离结果不代表真实 TUN 切换、生产覆盖安装或多节点分流已经验收。
+11
View File
@@ -0,0 +1,11 @@
# 纵横家 Windows 0.3.7
修复自动升级确认后旧程序偶发无法退出,以及退出过程中后台升级检查继续操作已销毁窗口的问题。
- 升级确认和下载完成后重新检查窗口生命周期,退出时取消升级检查,避免关闭后再次弹窗。
- 安装器等待旧程序的期限与网络恢复流程对齐,后台升级退出不被恢复警告弹窗挡住。
- 关闭事件与窗口销毁发生竞争时安全结束回调。
- Windows 查询关机时立即响应,取消关机不会改变当前连接;确认结束时使用限时清理,不再启动新的外部恢复工具或交互提示,未完成的恢复记录保留供下次启动处理。
- 保留 0.3.6 的运行组件修复、内网优先和本机与服务器独立流量趋势。
验证包含同包离线回归和隔离退出/会话消息测试。没有重启当前电脑,不将模拟消息测试称为真实关机验收。安装包未签名,安装时仍需 Windows 授权。