diff --git a/PUBLICATION-AUDIT.json b/PUBLICATION-AUDIT.json index 51861c1..1adcc7a 100644 --- a/PUBLICATION-AUDIT.json +++ b/PUBLICATION-AUDIT.json @@ -761,5 +761,154 @@ ], "SourceOnly": true, "Version": "0.3.3" + }, + "Windows034ConnectionResilienceDelta": { + "CandidateSha256": "270c5c8d804fc1c2c930a4d86667b6fbf0f7bab9875f359a076342ee5a96cb78", + "ExampleEndpointChanges": [ + { + "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/release/RELEASE-NOTES-0.3.4.md" + }, + { + "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": 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": 1, + "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" + } + ], + "FrozenSha256": "63580db09d867fb14853c17a8d7f7be8c420b0eb389457adf5f910fe1ab5ce6c", + "Omitted": [ + "windows/assets/login-cloud-scene-v1.jpg" + ], + "OptionalUnlicensedSceneRemainsOmitted": true, + "OriginalAcceptanceTransferred": false, + "OriginalSourceManifestSha256": "343499b680a3f91e01349123a8d9ce449db2bb8184aaf7d4c7f15934cd02383f", + "OtherComponentsModified": false, + "PrivateHistoryIncluded": false, + "ProductionAccepted": false, + "PublicBaseCommit": "aff1a50d35c22507bf4e72d44827038d7f8454e9", + "PublicDownloadDomainsRetained": [ + "pro.ucvl.cn" + ], + "SourceOnly": true, + "Version": "0.3.4" } } diff --git a/README.md b/README.md index 3a5c0da..512c435 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # 纵横家开源源码 -此仓库是无私有 Git 历史的清洁源码快照:Windows 0.3.3、Django 后台及 iPhone/iPad 1.0.2。公司自有代码按 MIT 开源;第三方组件遵守原许可,公司商标及 Logo 不在 MIT 授权范围。Android 保留原 GPL-3.0 公开仓库,不重复拷贝或改换许可。 +此仓库是无私有 Git 历史的清洁源码快照:Windows 0.3.4、Django 后台及 iPhone/iPad 1.0.2。公司自有代码按 MIT 开源;第三方组件遵守原许可,公司商标及 Logo 不在 MIT 授权范围。Android 保留原 GPL-3.0 公开仓库,不重复拷贝或改换许可。 | 目录 | 内容与状态 | | --- | --- | diff --git a/SOURCE-PROVENANCE.json b/SOURCE-PROVENANCE.json index 1e7d733..9005440 100644 --- a/SOURCE-PROVENANCE.json +++ b/SOURCE-PROVENANCE.json @@ -4,7 +4,7 @@ "ExportDiffersFromOriginalCandidates": true, "FilesBeforeProvenanceAndAudit": { "LICENSE": "b7e94910b8dc377b0a05ccde3c6e5941838dfc15c9dd790078d11728205b524e", - "README.md": "a64ccb0297d56ab12f3859d8a4559ec1d8ad7ac564c5805cd141f38bbb7eab3f", + "README.md": "daaf98fb434c1565ed967a48fbf1494e5df8b2fef1377bf5dafb878a6a798679", "SECURITY.md": "34e56cd9b8f6aa5fee45921c6eb831a542e05e76e41850fc31c44e09de088b3c", "THIRD_PARTY_NOTICES.md": "8c862f2f6b71440616a887e6deb7444a1262cf7d9f144208cc04041c3f9a3371", "android/README.md": "bb4387da9a055e97f33bb29a883c543e0938fa858df3fd744abc80553a5ec65c", @@ -186,17 +186,19 @@ "windows/ClientShutdownScope.cs": "f5944b57ccb4616dbd32ee2952b56dd0c9feccb7c556d8954092c88354a78d41", "windows/ClientUpdater.cs": "b218513dc57b8513eb749aeab093e39911428a07f05363ae349555d22e53e4b8", "windows/ConnectionAcceptanceTrace.cs": "c9efd15e19672a5ac3b4b807c96a3de3db3ff2fd373e13494a548df51fecdd9a", - "windows/ConnectionHealthPolicy.cs": "c17cf49eab51b691163ee8105f32bcaec121707ead862a773dbc372bf01e2a11", - "windows/ConnectionHealthSelfTest.cs": "5a483194f754ad51366acd9df00554c8ceecaa5dadba73972c4922b72dc7e2fe", - "windows/ConnectionRecoveryPolicy.cs": "860bd4cedf393f157fc1dd68e407776e1fe0fa1cc6cef7e99cd5581b64c6f5f6", + "windows/ConnectionAuthorizationLease.cs": "3edbd5123c051c797c488b49bcd7204d8c1a0c5a0743bfec95ffa4ab0bdd9bfc", + "windows/ConnectionAuthorizationSelfTest.cs": "d747ac77ef353a991fd50ae3f2229e063d27ede7b6e588d2e17a41a06b7abe90", + "windows/ConnectionHealthPolicy.cs": "69f5dd230631f4b10a091f53a5000df46d19561b7c65c82a2b97eddfef7f82dd", + "windows/ConnectionHealthSelfTest.cs": "3715ea4ed2a6d44a41a3f8d5c4c4bfc65f8f20cf9dd5b3dda2a47e7503bf4813", + "windows/ConnectionRecoveryPolicy.cs": "814f4fa370f445c40ac4cc79d8e07663975f5ad20d9ef77df2affb342609ac17", "windows/ConnectionSelection.cs": "def94b338b9e1fd940c19b8991e4268a4e59bec741ea624f5a6e4fb7a7d3bbcc", "windows/ConnectionSelectionSelfTest.cs": "1ed673268d6e443ec84ef39dbf5e5562132e5ea31fc87977a54d9805b0fef3a8", "windows/ConnectionSelfTest.cs": "6ad3f227cec3e26514d833ec1cb996818597a0cb27901053362faa45e3c1c9b3", "windows/DailyTrafficChart.cs": "4af8d8a91559e6a3fc1dd56db11f3534606aeb486ff918b2b301db0b82e4c716", "windows/DashboardComboSelfTest.cs": "f1149225e373936f0e90f3f2a5b4fa29179398bba641051fceba1b1cda78b998", - "windows/DashboardControls.cs": "091ee2f42de1ecd56f5ffbe506a60af95c98ce917ee782d95b8ab7be3e064a6b", + "windows/DashboardControls.cs": "55af71aac386053d05a14cb3205083654aff4f00d49b2fa3427e0c81eb57a97b", "windows/DashboardInteractionSelfTest.cs": "401ca89225426627e10a8d0559daf7aa5f530fbb9e7485feda6affab64ddb255", - "windows/DashboardLayout.cs": "5625a220a49bff18f843aebe5e4540b4df8e7dc75ba9b8aaf464ea1fb5215c23", + "windows/DashboardLayout.cs": "37d24ed2c88d8e81b43d90372147c259ff64be18b962a73e713c84e539ac0fdc", "windows/DashboardTailnetLayoutSelfTest.cs": "bc4f51bae884e135a183caa7f389a0065d523a52078d7c69b33201996606bd43", "windows/DashboardWheelRouter.cs": "d903097a5febbff296febb65855dc10b4e056ea5bb54d2df71b5d1f0297dcc1f", "windows/GitReleasePolicySelfTest.cs": "9e49ba957ab15a5c23d889004b171856c3d523f98cecf10088df4fcd8b577c61", @@ -221,14 +223,14 @@ "windows/LearningSyncCoordinatorSelfTest.cs": "471ec344130fe74d892c1115637bd98c517084fc309e982d4d11d3f0ee19403c", "windows/LearningTransportSelfTest.cs": "05dcfd3fcfc6f25e20612c020583eb6c36934c1b251e50e70fcd29501ad0efe7", "windows/MainForm.Chrome.cs": "30dc6520a44a5120c78c472c9fb053e2e4dea8e254b5531d04a5342964969c7a", - "windows/MainForm.Compact.cs": "c4f4e4af89804bb8dc2c2d5d285f388c38e6382bdb79b28a38bd6cfb9a98c396", - "windows/MainForm.Dashboard.cs": "bc9593cfcf3564807e523c34c120d92502e54855de714b6162f434a5e47faa95", + "windows/MainForm.Compact.cs": "314157977adfe088c7452322045b718afc9caeb2913bdfa17af756842298027c", + "windows/MainForm.Dashboard.cs": "6b757b2187533fba1dfdc5c012e09d68757049175e026537ffc07ae596b78d3c", "windows/MainForm.Handover.cs": "4a914f4de335331f1f9d2397407328f17ae372e9119329e534af218555dc92e6", - "windows/MainForm.NextGeneration.cs": "2b34a4191e9a3c3b07507c4975f4dcbce04b0045af7a27d64190741d8639e678", + "windows/MainForm.NextGeneration.cs": "5a1c21e02e304a5135b66160855aba5961d5da7da68041ff1b79be9de4a41916", "windows/MainForm.Selection.cs": "71d3884eb6535b1c8095379585a7479c5d7dd35d00e59da4dabfa673557f17fa", "windows/MainForm.TailnetTraffic.cs": "432ea16a7f5fe66006530b5b90af6eab59362a2b02685ec2130dadfd43c1652b", "windows/MainForm.TransportSelection.cs": "7e7bf74f16cb902b71da5a13117db06e9cdf4ea6121511a5ebceaf017bd1f919", - "windows/MainForm.cs": "326a8dbabc89d58534c718ceb967a18ec7caf6809ad0c390ba8c40f66b19a321", + "windows/MainForm.cs": "ce95f896536ea84b2ccab09b8b16c2af0d19497cd27dae136183cd5e36b160b8", "windows/NOTICE.md": "8c862f2f6b71440616a887e6deb7444a1262cf7d9f144208cc04041c3f9a3371", "windows/NetworkHandover.cs": "b43548be0051cf92dfd332e537951e4b5083f2a123be8021994513bbc3748d46", "windows/NetworkHandoverSelfTest.cs": "681d0154dc0aa5f49d7ce1f3088b465eea3ed82571b464951df8d4c89cecdf73", @@ -239,8 +241,8 @@ "windows/NetworkRecoveryTool.cs": "2dec1406ca0719af3eacedf2d8f83659927c44bc4a1eaccc1babe84c0d3d99cc", "windows/NetworkRouteLease.cs": "0b57aa0e3499ec3f9f7f7a4c683cecca0f6d7f275734e126a5da4f7849cd7ae3", "windows/NextGenerationSelfTest.cs": "a92cbbf4c8ba0cde0ec12faf2e1cdbcd2c86f758d440d677471968569030f8f1", - "windows/NodeHealthProbe.cs": "5c501094402010d2f8ecdc4145f1084ef084b749c2b47794fca0c0f60c4441fb", - "windows/NodeHealthProbeSelfTest.cs": "85d645160ed53f2646b58ba29d2ec17d6ff8fa54b658dc15e15c9609514c16ea", + "windows/NodeHealthProbe.cs": "c9e5aded50d6091065258c2a882d914683ed95075e66650e177f29df36fe31f2", + "windows/NodeHealthProbeSelfTest.cs": "512dd9f91ef8c1d645908300b3f1a08c18905caaf7a1174b230b17e963603c62", "windows/NodeMatrixSelfTest.cs": "eed8e56036d300fdffd82b83cca87ea6b2806e8598b2c4fc916aded15197f20d", "windows/NodePresentation.cs": "c70a8be06cce937f309fd10531d97b02b675a72509fff2419e412fbdf84977c0", "windows/NodeTrafficMonitor.cs": "03bdbb748fee521a6e0d9b08edbf60c5699ae1ebf98ae719d9c45a5cf0962a5a", @@ -258,7 +260,7 @@ "windows/ProxyProbe.cs": "5d27b5a6c6b192a0c0f3ec4637c5a876a71130497af57f7cb4a04ab4735ca1ec", "windows/PublicTailnetSelection.cs": "68b6dd3d5c77c3253046f9b90e22742c1f2852e07d07157daa296512370fada7", "windows/PublicTailnetSelectionSelfTest.cs": "7b5e7352fe4529e01ce537d488a5cfcc8f5259f98bbe307846cb36a7144cacac", - "windows/README.md": "9bfa24ddb2f1d3af4845c3a25c275ec6efd1819552735c6178f8e07e3d29722f", + "windows/README.md": "d422c224a9138709bb5881afb195f2c74b4a288541ae986e19c010621f45be34", "windows/ReplacementContinuitySelfTest.cs": "107878ab2b367f1812377c0b209f6d620da390091c3882e4be53a48e517d86a1", "windows/RouteLeaseSelfTest.cs": "6189c66b9f66c58bed26de4441c58a9ec02b67257bfa04ed66d702acfcd054d9", "windows/RoutingRuleBatches.cs": "9997bfa766fffe7bed7352f307c1f6f118a9be9aa86653eaefae3b2bdaa26c1e", @@ -272,13 +274,15 @@ "windows/SystemPowerShell.cs": "1f9247d2e4f8c9bad1d71105886d2ab33d8958006dcff7fadc63f27502eda6fe", "windows/SystemProxy.cs": "beaf443f1e285e227e0c390d8e9114d5cf8464e0078a8bb842efa9eeb2b5e916", "windows/THIRD_PARTY_NOTICES.md": "c7141fe279b2c364c868888db37bd995feba1552025e2259dc4662a01e5122bb", - "windows/TailnetReadinessPolicy.cs": "50c21754e9ca700963de34ef1f4abf9107b4f29920403ea22c19c17e120a07dd", - "windows/TailnetReadinessSelfTest.cs": "80fc579bd477a03a4cc29d6a350f9b052afa719c1fffe1dba7488e30e35dc091", + "windows/TailnetPingConfirmation.cs": "19fad61844b5e3cb4a994b8f4558a332a9f5b39285ca8549b19cb76064bc805a", + "windows/TailnetPingConfirmationSelfTest.cs": "5fa8f0d932a1b3fba825aff0b8301a61723cbe9ad1ac140c00a936194393be14", + "windows/TailnetReadinessPolicy.cs": "32385fd2de8762f947c9cbf6d0fb3fc934b33a2a17c0e2375d60ceb619cbff71", + "windows/TailnetReadinessSelfTest.cs": "92ba7abec5fa3f98550dd9460fb2c87b58cbdc4a55efd9f4b58ca8c5c16f67e7", "windows/TailnetTransport.cs": "c93769b845090f244eeedef2b49afa4bea500af809a995ffdcaf8c314ffb84eb", "windows/TailnetTransportProbe.cs": "c71a0d946cbefb2713e0b564ea95ae99cbd70f0ec19c8cfc416a12e16589f99a", "windows/TailnetTransportSelfTest.cs": "8ace8cc2f443c1ce576bbb9471cb46f107ac28f999090baa30431412d8a263f3", "windows/TokenStore.cs": "e07cf7d1a4cf7a1bba871c19e50b9d6355cb8c1546657346b0256c8215fed8bb", - "windows/TrafficChart.cs": "3876ab1095a2b0d37542383ef580e69e716ce6b1f517955320b12143bd241bc4", + "windows/TrafficChart.cs": "0412f5d45d33ee95f0d0c80ea57a53e4708ff549e20373596035a47c7a0d1eb0", "windows/TransportPlan.cs": "f49b780fd5095cd494c040582d3cf1607548d1eb0572490bfe588dc55521a772", "windows/TransportPlanSelfTest.cs": "21ba43f220cf2d36d66c5ecab149ecefa5a1e9be62813582db6274897b25093e", "windows/TunConfigBuilder.cs": "35a17b9da204e338dde5ed6cd4f2e979d94ad73c4c01cc0001fc582e94b67194", @@ -288,11 +292,11 @@ "windows/UpdateSelfTest.cs": "453165bb611efb8db0d8a8c9ea13f3553e0047aa22b838c43096e3d83fe18771", "windows/UpdateStreamSelfTest.cs": "ad059016c0197f33582b1969ab3280c5b9589a28d659613b3e97ce4a357d38c1", "windows/UsageHistorySeries.cs": "9e7515ceede1899e06116352de79edd6252c921048bcae9958bf9358d93b3069", - "windows/VPNPlus.csproj": "5ac3d22f53cd3e6af8b700a69f7ead4c8cebad355e527a5418a3a82632aae058", + "windows/VPNPlus.csproj": "3680b9ce415be4e022ed4786f9f04b8173dbeda96ca1988b39a768dc915094db", "windows/VpnApiClient.cs": "187829698d9f26b896dbfef596bc71b12a9ed4e014261abde0497e6763e40ae3", "windows/WindowChrome.cs": "0eceea0879e792b8ae83a74eaf5658d4a7be6a798fbdb026ff8d19fa9aa6af2c", "windows/WindowChromeSelfTest.cs": "c17dd805a0102d12b71a3e32c77ceeb45e303e08612de5d3c5259c78327532be", - "windows/XrayManager.cs": "1d8fc21dad18faccb6e0d9c571164603f5b7e4916f24d22b31d527bbd6da585c", + "windows/XrayManager.cs": "8c87c1d84e42f00528da52ecbe9a0a4ecded445ac50e83442c187536af9555a5", "windows/XrayRoutingUpdater.cs": "91fd2b5db25477dbe4de7118faef79f9c51f9a8a3dd86e8b26c676092de3bca5", "windows/app.manifest": "4c9a2e8e2056c3bb0ae45a5f7b2e223298ee683a82b70ba4910e17f5728cf5b6", "windows/assets/company-logo-original.png": "04cf7f754a5353b96cddbed4a57a557154342c190a1785487e3bfb36cab04163", @@ -334,7 +338,8 @@ "windows/release/RELEASE-NOTES-0.3.0.md": "cc1e398354ffb562c0647dbe91ffd3f43e614f3923298005c76999c457b77bf2", "windows/release/RELEASE-NOTES-0.3.1.md": "e28a99d049842adc34f593e39bbc33484dd4dfc9e31568cbcb1aef1f3bcd4132", "windows/release/RELEASE-NOTES-0.3.2.md": "29f2030b0be583a541dc0289ee9916d42156cf3bbd823bd5cf7867f097fb2abd", - "windows/release/RELEASE-NOTES-0.3.3.md": "18e1f04a925b82668813cb7bde18d29790fa6218d6726887b0ad3cabec253dea" + "windows/release/RELEASE-NOTES-0.3.3.md": "18e1f04a925b82668813cb7bde18d29790fa6218d6726887b0ad3cabec253dea", + "windows/release/RELEASE-NOTES-0.3.4.md": "10f0a3edd111932ea92e25581208ac527990b515ee1c73bbd7bd4acba734936f" }, "IosSourceCommit": "b07d085413b1b6370245866fd82271b76590b6d6", "Kind": "clean-history-free-open-source-export", @@ -595,5 +600,18 @@ "SourceOnly": true, "Version": "0.3.3" }, + "Windows034ConnectionResilienceDelta": { + "CandidateSha256": "270c5c8d804fc1c2c930a4d86667b6fbf0f7bab9875f359a076342ee5a96cb78", + "FrozenSha256": "63580db09d867fb14853c17a8d7f7be8c420b0eb389457adf5f910fe1ab5ce6c", + "OptionalUnlicensedSceneRemainsOmitted": true, + "OriginalAcceptanceTransferred": false, + "OriginalSourceManifestSha256": "343499b680a3f91e01349123a8d9ce449db2bb8184aaf7d4c7f15934cd02383f", + "OtherComponentsModified": false, + "PrivateHistoryIncluded": false, + "ProductionAccepted": false, + "PublicBaseCommit": "aff1a50d35c22507bf4e72d44827038d7f8454e9", + "SourceOnly": true, + "Version": "0.3.4" + }, "WindowsSourceCommit": "0d463e6af91a3802c564b06dabb6bf86ebff5a38" } diff --git a/windows/ConnectionAuthorizationLease.cs b/windows/ConnectionAuthorizationLease.cs new file mode 100644 index 0000000..bf15b94 --- /dev/null +++ b/windows/ConnectionAuthorizationLease.cs @@ -0,0 +1,42 @@ +namespace UCVL.VPNPlus; + +// Memory-only bounds from authenticated responses. This permits retention of +// an already-running core; it never grants offline login or a new connection. +internal sealed class ConnectionAuthorizationLease +{ + private bool _known, _active; + private DateTimeOffset? _sessionExpiry, _profileExpiry; + private long? _sessionDeadline, _profileDeadline; + + internal void Reset(DateTimeOffset? sessionExpiry, DateTimeOffset now, long ticks) + { + _known = _active = false; + _sessionExpiry = sessionExpiry; + _sessionDeadline = Deadline(sessionExpiry, now, ticks); + _profileExpiry = null; _profileDeadline = null; + } + + internal void AcceptProfile(string status, DateTimeOffset? expiry, DateTimeOffset now, long ticks) + { + _known = !string.IsNullOrWhiteSpace(status); _active = status == "active"; + var deadline = Deadline(expiry, now, ticks); + if (_profileExpiry == expiry && _profileDeadline.HasValue && deadline.HasValue) + deadline = Math.Min(_profileDeadline.Value, deadline.Value); + _profileExpiry = expiry; + _profileDeadline = deadline; + } + + internal bool AccountIsValid(DateTimeOffset now, long ticks) => (!_known || _active) + && (_sessionExpiry is null || now < _sessionExpiry) && (_profileExpiry is null || now < _profileExpiry) + && (_sessionDeadline is null || ticks < _sessionDeadline) && (_profileDeadline is null || ticks < _profileDeadline); + + internal bool CanRetain(DateTimeOffset now, long ticks, bool privateAuxiliary, long privateDeadline) + => AccountIsValid(now, ticks) && (!privateAuxiliary || privateDeadline > ticks); + + private static long? Deadline(DateTimeOffset? expiry, DateTimeOffset now, long ticks) + { + if (expiry is null) return null; + var remaining = Math.Max(0, (expiry.Value - now).TotalMilliseconds); + return ticks + (long)Math.Min(remaining, long.MaxValue - Math.Max(0, ticks)); + } +} diff --git a/windows/ConnectionAuthorizationSelfTest.cs b/windows/ConnectionAuthorizationSelfTest.cs new file mode 100644 index 0000000..eff11d8 --- /dev/null +++ b/windows/ConnectionAuthorizationSelfTest.cs @@ -0,0 +1,44 @@ +namespace UCVL.VPNPlus; + +internal static class ConnectionAuthorizationSelfTest +{ + internal static Dictionary Check() + { + var checks = new Dictionary(); + var now = DateTimeOffset.Parse("2026-11-05T00:00:00Z"); + var lease = new ConnectionAuthorizationLease(); + lease.Reset(null, now, 1000); + checks["unknown_deadline_does_not_expire_existing_core"] = lease.AccountIsValid(now.AddDays(1), 86_401_000); + lease.AcceptProfile("active", null, now, 1000); + checks["explicit_long_term_profile_has_no_invented_expiry"] = lease.CanRetain(now.AddDays(100), 8_640_001_000, false, 0); + checks["valid_private_lease_can_be_retained_during_api_outage"] = lease.CanRetain(now, 1000, true, 2000); + checks["expired_private_lease_cannot_be_retained"] = !lease.CanRetain(now, 2000, true, 2000); + checks["private_expiry_does_not_mark_account_expired_or_shadow_renewal"] = lease.AccountIsValid(now, 2000); + lease.AcceptProfile("active", now.AddSeconds(10), now, 1000); + checks["known_subscription_expiry_is_enforced"] = lease.AccountIsValid(now.AddSeconds(9), 10_000) + && !lease.AccountIsValid(now.AddSeconds(10), 11_000); + checks["clock_rollback_cannot_extend_known_subscription"] = !lease.AccountIsValid(now.AddDays(-1), 11_000); + lease.AcceptProfile("active", now.AddSeconds(10), now.AddDays(-1), 11_000); + checks["same_profile_refresh_cannot_extend_deadline_after_clock_rollback"] = !lease.AccountIsValid(now.AddDays(-1), 11_000); + lease.AcceptProfile("active", now.AddDays(1), now.AddSeconds(10), 11_000); + checks["fresh_authenticated_profile_can_renew_subscription"] = lease.AccountIsValid(now.AddHours(1), 3_601_000); + lease.Reset(now.AddSeconds(5), now, 1000); + lease.AcceptProfile("active", now.AddDays(1), now, 1000); + checks["profile_cannot_extend_known_login_session_expiry"] = !lease.AccountIsValid(now.AddSeconds(5), 6000); + lease.Reset(null, now, 1000); + lease.AcceptProfile("suspended", null, now, 1000); + checks["explicit_inactive_status_is_not_retained"] = !lease.AccountIsValid(now, 1000); + lease.Reset(null, now, 1000); + lease.AcceptProfile("", null, now, 1000); + checks["legacy_fixture_without_status_or_deadline_is_not_expired"] = lease.AccountIsValid(now, 1000); + foreach (var failure in new Exception[] { new TimeoutException(), new HttpRequestException(), new ApiException(500, "fixture outage"), new ApiException(503, "fixture outage") }) + checks["fresh_grant_failure_keeps_running_authorized_core_" + failure.GetType().Name + checks.Count] + = ConnectionRecoveryPolicy.KeepExisting(true, false, true, failure, true); + checks["expiry_prevents_control_plane_retention"] = !ConnectionRecoveryPolicy.KeepExisting(true, false, true, new TimeoutException(), false); + checks["revocation_still_ends_existing_session"] = !ConnectionRecoveryPolicy.KeepExisting(true, false, true, new ApiException(401, "revoked"), true) + && !ConnectionRecoveryPolicy.KeepExisting(true, false, true, new ApiException(403, "revoked"), true); + checks["no_offline_new_login_or_connection_granted"] = !ConnectionRecoveryPolicy.KeepExisting(false, false, false, new TimeoutException(), true); + checks["already_replaced_core_is_not_falsely_retained"] = !ConnectionRecoveryPolicy.KeepExisting(true, true, true, new TimeoutException(), true); + return checks; + } +} diff --git a/windows/ConnectionHealthPolicy.cs b/windows/ConnectionHealthPolicy.cs index 6afd9b7..f3abb0d 100644 --- a/windows/ConnectionHealthPolicy.cs +++ b/windows/ConnectionHealthPolicy.cs @@ -4,7 +4,7 @@ namespace UCVL.VPNPlus; // A delayed probe must not undo a user's disconnect or judge a different core. internal sealed class ConnectionHealthPolicy { - internal enum Decision { Ignore, Keep, Repair, Switch } + internal enum Decision { Ignore, Keep, Repair, Degraded, Switch } internal long Revision { get; private set; } internal int Failures { get; private set; } internal bool HasBeenHealthy { get; private set; } @@ -18,7 +18,8 @@ internal sealed class ConnectionHealthPolicy internal void ResetFailures() => Failures = 0; internal bool IsDue(long now, bool running) => !running || now >= _nextProbe; internal Decision Observe(long revision, int? testedCore, int? currentCore, - bool wanted, bool busy, bool transitioning, bool exiting, bool healthy, long now, bool proxyHealthy = false) + bool wanted, bool busy, bool transitioning, bool exiting, bool healthy, long now, bool proxyHealthy = false, + bool activeTailnet = false, bool businessUnavailable = false) { if (revision != Revision || testedCore != currentCore || !wanted || busy || transitioning || exiting) return Decision.Ignore; @@ -26,6 +27,12 @@ internal sealed class ConnectionHealthPolicy HasBeenHealthy = true; Failures = 0; _nextProbe = now + 20_000; return Decision.Keep; } + if (currentCore is not null && (businessUnavailable && proxyHealthy || activeTailnet && !proxyHealthy)) { + // Third-party HTTP diagnostics cannot identify an active Tailnet + // transport failure. The bounded periodic ICMP policy owns fallback. + Failures = 0; _nextProbe = now + 20_000; + return Decision.Degraded; + } if (proxyHealthy && currentCore is not null) { // Do not punish/restart a working node for a local smart-rule fault. // The UI must show degraded routing, not declare the business path healthy. diff --git a/windows/ConnectionHealthSelfTest.cs b/windows/ConnectionHealthSelfTest.cs index 02c4d8f..7ac6a12 100644 --- a/windows/ConnectionHealthSelfTest.cs +++ b/windows/ConnectionHealthSelfTest.cs @@ -52,6 +52,19 @@ internal static class ConnectionHealthSelfTest == ConnectionHealthPolicy.Decision.Switch; checks["stale_proxy_proof_cannot_affect_new_core"] = policy.Observe(policy.Revision,10,11,true,false,false,false,false,500_000,true) == ConnectionHealthPolicy.Decision.Ignore; + policy.BeginCore(600_000); + checks["website_failures_do_not_rebuild_live_tailnet_core"] = Enumerable.Range(0, 12).All(i => + policy.Observe(policy.Revision, 10, 10, true, false, false, false, false, 605_000 + i * 20_000, + false, activeTailnet: true) == ConnectionHealthPolicy.Decision.Degraded) && policy.Failures == 0; + checks["transport_proof_with_site_outage_is_degraded_not_false_green"] = policy.Observe(policy.Revision, 10, 10, + true, false, false, false, false, 900_000, true, businessUnavailable: true) == ConnectionHealthPolicy.Decision.Degraded; + checks["dead_tailnet_core_still_requests_fast_recovery"] = policy.Observe(policy.Revision, null, null, + true, false, false, false, false, 920_000, false, activeTailnet: true) == ConnectionHealthPolicy.Decision.Switch; + revision = policy.Revision; + policy.Invalidate(); + checks["new_login_fence_blocks_old_probe_even_if_core_id_same"] = policy.Observe(revision, 10, 10, + true, false, false, false, true, 940_000, true, activeTailnet: true) == ConnectionHealthPolicy.Decision.Ignore; + foreach (var check in ConnectionAuthorizationSelfTest.Check()) checks.Add(check.Key, check.Value); var passed = checks.Values.All(v => v); File.WriteAllText(Path.Combine(AppContext.BaseDirectory,"connection-health-self-test.json"), JsonSerializer.Serialize(new { kind="advisory_connection_health_policy", network_modified=false, diff --git a/windows/ConnectionRecoveryPolicy.cs b/windows/ConnectionRecoveryPolicy.cs index e42faf0..0494207 100644 --- a/windows/ConnectionRecoveryPolicy.cs +++ b/windows/ConnectionRecoveryPolicy.cs @@ -4,8 +4,9 @@ internal static class ConnectionRecoveryPolicy { // A control-plane timeout is not evidence that the existing data-plane // process needs to be destroyed. Revoked authorization still stops service. - internal static bool KeepExisting(bool reconnect, bool replacementStarted, bool coreRunning, Exception failure) - => reconnect && !replacementStarted && coreRunning + internal static bool KeepExisting(bool reconnect, bool replacementStarted, bool coreRunning, Exception failure, + bool authorizationValid = true) + => reconnect && !replacementStarted && coreRunning && authorizationValid && failure is not ApiException { StatusCode: 401 or 403 }; internal static bool SelfTest() diff --git a/windows/DashboardControls.cs b/windows/DashboardControls.cs index d6aed35..f05688c 100644 --- a/windows/DashboardControls.cs +++ b/windows/DashboardControls.cs @@ -116,11 +116,14 @@ internal sealed class MetricCard : CardPanel if(Height (int)Math.Round(n * scale); var margin = S(8); var gap = S(4); var compact = preferCompact || viewport.Width < S(720) || viewport.Height < S(442); - var topOffset = compact ? -S(22) : 0; + var topOffset = compact ? 0 : S(22); var width = Math.Max(1, viewport.Width - margin * 2); var welcome = new Rectangle(margin, 0, S(120), S(18)); var account = new Rectangle(welcome.Right + gap, 0, Math.Min(S(160), width - S(252)), S(18)); var identity = new Rectangle(account.Right + gap, S(1), S(50), S(16)); var logout = new Rectangle(margin + width - S(64), 0, S(64), S(19)); - var status = new Rectangle(margin, S(22)+topOffset, width, S(32)); - var configuration = new Rectangle(margin, S(58)+topOffset, width, S(48)); + var status = new Rectangle(margin, margin+topOffset, width, S(30)); + var configuration = new Rectangle(margin, status.Bottom + gap, width, S(44)); // The right hand actual-state panel is embedded in the same surface. - var actualLeft = (int)Math.Round(width * .52); - var actual = new Rectangle(actualLeft, S(3), width - actualLeft - S(8), S(42)); - var traffic = new Rectangle(margin, S(110)+topOffset, width, S(24)); + var actualLeft = width / 2 + S(4); + var actual = new Rectangle(actualLeft, 0, width - actualLeft - S(8), configuration.Height); + var traffic = new Rectangle(margin, configuration.Bottom + gap, width, S(24)); var tailnet = showTailnet ? new Rectangle(margin, traffic.Bottom + gap, width, S(24)) : Rectangle.Empty; - var daily = new Rectangle(margin, (showTailnet ? tailnet.Bottom : traffic.Bottom) + gap, width, S(28)); - var footer = new Rectangle(margin, viewport.Height - S(22), width, S(18)); + var daily = new Rectangle(margin, (showTailnet ? tailnet.Bottom : traffic.Bottom) + gap, width, S(22)); + var footer = new Rectangle(margin, viewport.Height - margin - S(18), width, S(18)); var servers = showServerTraffic ? new Rectangle(margin, footer.Top - gap - S(38), width, S(38)) : Rectangle.Empty; var trendTop = daily.Bottom + gap; var trend = new Rectangle(margin, trendTop, width, Math.Max(S(28), (showServerTraffic ? servers.Top : footer.Top) - gap - trendTop)); - var headingWidth = S(112); - var speedWidth = (width - headingWidth - S(16)) / 2; + var headingWidth = S(120); + var speedWidth = (width - headingWidth - S(10)) / 2; Rectangle Speed(int column) => new(headingWidth + column * speedWidth, 0, speedWidth, traffic.Height - S(2)); - var totalWidth = (width - S(76)) / 2; - Rectangle Total(int column) => new(S(66) + column * totalWidth, 0, totalWidth, daily.Height - S(2)); + Rectangle Total(int column) => new(headingWidth + column * speedWidth, 0, speedWidth, daily.Height - S(2)); Rectangle[] metrics = [Total(0), Speed(0), Speed(1), Total(1)]; return new(welcome, account, identity, logout, status, configuration, actual, metrics, traffic, tailnet, trend, daily, servers, footer, viewport.Height, true, 1f); @@ -75,6 +74,8 @@ internal static class DashboardLayout if (p.Footer != baseline.Footer || p.ContentHeight != baseline.ContentHeight || p.TrafficCard != baseline.TrafficCard) return false; if (showTailnet && (p.TailnetTrafficCard.Top <= p.TrafficCard.Bottom || p.DailyCard.Top<=p.TailnetTrafficCard.Bottom)) return false; if(p.TrafficCard.Width!=p.SpeedTrendCard.Width || p.DailyCard.Height>Sized(40))return false; + if (p.Metrics[0].Left != p.Metrics[1].Left || p.Metrics[3].Left != p.Metrics[2].Left + || p.Metrics[0].Width != p.Metrics[1].Width || p.Metrics[3].Width != p.Metrics[2].Width) return false; if(p.SpeedTrendCard.Height= p.Footer.Top)) return false; int Sized(int n)=>(int)Math.Round(n*Math.Max(1f,dpi/96f)); diff --git a/windows/MainForm.Compact.cs b/windows/MainForm.Compact.cs index 7bb259b..bc05326 100644 --- a/windows/MainForm.Compact.cs +++ b/windows/MainForm.Compact.cs @@ -6,6 +6,7 @@ internal sealed partial class MainForm private bool CompactPresentation => ClientSize.Width < ScaleLogical(720) || ClientSize.Height < ScaleLogical(550); private readonly Font _compactStatusFont=Brand.Font(9.5f,FontStyle.Bold); private readonly Font _compactChartFont=Brand.Font(7.5f); + private readonly Font _compactRowFont=Brand.Font(8f,FontStyle.Bold); private readonly Dictionary _presentationFonts = new(); private bool _presentationFontsDisposed; protected override void Dispose(bool disposing) @@ -17,6 +18,7 @@ internal sealed partial class MainForm _presentationFonts.Clear(); _compactStatusFont.Dispose(); _compactChartFont.Dispose(); + _compactRowFont.Dispose(); } private void SetStatusTitleFont(float size) { @@ -54,9 +56,9 @@ internal sealed partial class MainForm foreach(Control control in _brandHeader.Controls) { if(control.Tag is not Rectangle)continue; - if(control is PictureBox)control.Bounds=new(S(10),S(5),S(34),S(37)); - else if(control is Label label && label.Text=="纵横家")control.Bounds=new(S(52),S(5),S(180),S(25)); - else control.Bounds=new(S(53),S(28),S(260),S(15)); + if(control is PictureBox)control.Bounds=new(S(8),S(6),S(34),S(36)); + else if(control is Label label && label.Text=="纵横家")control.Bounds=new(S(48),S(6),S(176),S(26)); + else control.Bounds=new(S(49),S(31),S(180),S(14)); } _headerPoem.Visible=false; LayoutWindowChrome(); @@ -103,8 +105,9 @@ internal sealed partial class MainForm { _welcomeLabel.Parent=_brandHeader; _logoutButton.Parent=_brandHeader; - _welcomeLabel.Bounds=new(_brandHeader.Width-S(226),S(5),S(172),S(20)); - _logoutButton.Bounds=new(_brandHeader.Width-S(128),S(28),S(72),S(19)); + var caption = _windowChrome!.MinimizeButton.Bounds; + _logoutButton.Bounds=new(caption.Left-S(72),caption.Top,S(64),caption.Height); + _welcomeLabel.Bounds=new(_logoutButton.Left-S(126),caption.Top,S(118),caption.Height); _welcomeLabel.Visible=_logoutButton.Visible=_dashboardView.Visible; _accountLabel.Visible=_identityBadge.Visible=false; } @@ -117,41 +120,44 @@ internal sealed partial class MainForm _welcomeLabel.Visible=_logoutButton.Visible=_accountLabel.Visible=_identityBadge.Visible=true; } _statusDot.Bounds=R(10,4,22,22); - _connectButton.Bounds=new(_statusCard.Width-S(80),S(4),S(70),S(24)); - _statusTitle.Bounds=new(S(40),S(1),_statusCard.Width-S(130),S(17)); - _statusDetail.Bounds=new(S(40),S(17),_statusCard.Width-S(130),S(14)); + _connectButton.Bounds=new(_statusCard.Width-S(80),S(3),S(70),S(24)); + _statusTitle.Bounds=new(S(40),0,_statusCard.Width-S(130),S(16)); + _statusDetail.Bounds=new(S(40),S(16),_statusCard.Width-S(130),S(13)); _nodeIcon.Visible=_modeIcon.Visible=false; _scheduleBadge.Visible=false; var leftWidth=_modeCard.Left-S(8); - _selectionHeading.Bounds=R(10,3,27,20); - _routeHeading.Bounds=R(10,25,27,20); + _selectionHeading.Bounds=R(10,1,27,20); + _routeHeading.Bounds=R(10,23,27,20); _routeHeading.Text="模式"; var fieldLeft=S(38); var fieldWidth=leftWidth-fieldLeft; var splitWidth=Math.Max(S(84),(fieldWidth-S(4))/2); - _connectionModeCombo.Bounds=new(fieldLeft,S(3),_manualNodeCombo.Visible?splitWidth:fieldWidth,S(20)); - _manualNodeCombo.Bounds=new(_connectionModeCombo.Right+S(4),S(3),Math.Max(S(60),fieldWidth-splitWidth-S(4)),S(20)); - _routeCombo.Bounds=new(fieldLeft,S(25),fieldWidth,S(20)); + _connectionModeCombo.Bounds=new(fieldLeft,S(1),_manualNodeCombo.Visible?splitWidth:fieldWidth,S(20)); + _manualNodeCombo.Bounds=new(_connectionModeCombo.Right+S(4),S(1),Math.Max(S(60),fieldWidth-splitWidth-S(4)),S(20)); + _routeCombo.Bounds=new(fieldLeft,S(23),fieldWidth,S(20)); _nodeHeading.Text="节点"; - _nodeHeading.Bounds=R(8,0,27,20); - _currentNodeLabel.Bounds=new(S(39),0,_modeCard.Width-S(41),S(20)); - _actualModeHeading.Bounds=R(8,22,27,20); - _routeReadOnly.Bounds=new(S(39),S(22),_modeCard.Width-S(41),S(20)); + _nodeHeading.Bounds=R(8,1,27,20); + _currentNodeLabel.Bounds=new(S(39),S(1),_modeCard.Width-S(41),S(20)); + _actualModeHeading.Bounds=R(8,23,27,20); + _routeReadOnly.Bounds=new(S(39),S(23),_modeCard.Width-S(41),S(20)); + foreach(var label in new[]{_selectionHeading,_routeHeading,_nodeHeading,_actualModeHeading,_currentNodeLabel}) + { label.TextAlign=ContentAlignment.MiddleLeft; label.Padding=Padding.Empty; } _trafficIcon.Visible=_dailyIcon.Visible=_tailnetTrafficIcon.Visible=false; - _trafficHeading.Bounds=new(S(10),0,S(96),_trafficCard.Height-S(2)); - _dailyHeading.Bounds=new(S(10),0,S(56),_dailyCard.Height-S(2)); + _trafficHeading.Bounds=new(S(10),0,S(106),_trafficCard.Height-S(2)); + _dailyHeading.Bounds=new(S(10),0,S(106),_dailyCard.Height-S(2)); _tailnetTrafficHeading.Text="Tailscale 速度"; - _tailnetTrafficHeading.Bounds=new(S(10),0,S(96),_tailnetTrafficCard.Height-S(2)); + _tailnetTrafficHeading.Bounds=new(S(10),0,S(106),_tailnetTrafficCard.Height-S(2)); + foreach(var heading in new[]{_trafficHeading,_tailnetTrafficHeading,_dailyHeading}) + { heading.Font=_compactRowFont; heading.TextAlign=ContentAlignment.MiddleLeft; } if(_tailnetTrafficVisible) { _tailnetUploadMetric.Bounds=_uploadMetric.Bounds; _tailnetDownloadMetric.Bounds=_downloadMetric.Bounds; } - var rail=CompactPresentation && _speedTrendCard.Heightlabel.TextAlign == ContentAlignment.MiddleLeft); + checks["fixed_grid_trend_title_range_share_header"] = form._trendHeading.Top == form._historyRangeCombo.Top + && form._trendHeading.Height == form._historyRangeCombo.Height && form._trendHeading.Right < form._historyRangeCombo.Left + && form._trafficChart.Top > form._historyRangeCombo.Bottom; + checks["fixed_grid_header_account_actions_share_centerline"] = form._welcomeLabel.Top == form._logoutButton.Top + && form._welcomeLabel.Height == form._logoutButton.Height && form._logoutButton.Top == form._windowChrome!.MinimizeButton.Top + && form._logoutButton.Height == form._windowChrome.MinimizeButton.Height && form._welcomeLabel.Right < form._logoutButton.Left + && form._logoutButton.Right < form._windowChrome.MinimizeButton.Left; + checks["fixed_grid_outer_eight_logical_margin"] = form._statusCard.Top == form.ScaleLogical(8) + && form._statusCard.Left == form.ScaleLogical(8) && form._statusCard.Right == form._dashboardBody.Width-form.ScaleLogical(8) + && form._footer.Bottom == form._dashboardBody.Height-form.ScaleLogical(8); checks["half_size_tailnet_servers_fit"] = form.DashboardControlsFit() && !form._dashboardScrollBar.Visible && form._nodeTrafficPanel.Bottom _connectionAuthorization.CanRetain(DateTimeOffset.UtcNow, + Environment.TickCount64, _currentNodeIsPrivateAuxiliary, _privateLeaseDeadlineTicks); + // The initial connection already tested this address. At ten-minute // intervals repeat only the authorized IP ping; failure on the active path // retries the same node's domain through the normal fresh-grant connector. @@ -51,9 +56,10 @@ internal sealed partial class MainForm try { if (_xray.TailnetProbeEndpoint is { } endpoint) - reachable = await TailnetTransport.ProbeEndpointAsync(endpoint.Address, endpoint.Port, _lifetime.Token); + reachable = await TailnetPingConfirmation.ProbeAsync( + pingToken => TailnetTransport.ProbeEndpointAsync(endpoint.Address, endpoint.Port, pingToken), _lifetime.Token); } - catch (OperationCanceledException) { } + catch (OperationCanceledException) when (_lifetime.IsCancellationRequested) { return; } catch (Exception) { /* Fixed diagnostics below contain no credentials. */ } var result = _tailnetReadiness.Observe(ticket, ReadTailnetReadinessContext(), Environment.TickCount64, reachable); if (_exiting || IsDisposed || Disposing) return; diff --git a/windows/MainForm.cs b/windows/MainForm.cs index 8594a32..182c7dc 100644 --- a/windows/MainForm.cs +++ b/windows/MainForm.cs @@ -15,6 +15,7 @@ internal sealed partial class MainForm : Form private readonly System.Windows.Forms.Timer _trafficTimer = new() { Interval = 5_000 }; private readonly System.Windows.Forms.Timer _healthTimer = new() { Interval = 5_000 }; private readonly ConnectionHealthPolicy _connectionHealth = new(); + private readonly ConnectionAuthorizationLease _connectionAuthorization = new(); private readonly Label _currentNodeLabel = new(); private readonly TrafficChart _trafficChart = new(); private readonly DailyTrafficChart _dailyChart = new(); @@ -439,7 +440,7 @@ internal sealed partial class MainForm : Form try { var response = await _api.LoginAsync(login, password, _lifetime.Token); - SetSessionToken(response.AccessToken); + SetSessionToken(response.AccessToken, response.ExpiresAt); TokenStore.Save(_accessToken); _passwordText.Clear(); ShowDashboard(response.Profile); @@ -515,6 +516,13 @@ internal sealed partial class MainForm : Form var replacementStarted = false; try { + if (!_connectionAuthorization.AccountIsValid(DateTimeOffset.UtcNow, Environment.TickCount64)) + { + var refreshed = await _api.GetProfileAsync(_accessToken, connectionToken); + UpdateProfile(refreshed, preserveSelections: true); + if (!_connectionAuthorization.AccountIsValid(DateTimeOffset.UtcNow, Environment.TickCount64)) + throw new ApiException(403, "账号或订阅授权已到期,请重新登录验证。"); + } var failures = new List(); ConfigResponse? response = null; var privateGrants = _privateAuxiliaryNodes.Where(n => n.ExpiresAt > DateTimeOffset.UtcNow).ToArray(); @@ -597,7 +605,7 @@ internal sealed partial class MainForm : Form } catch (ApiException exception) when (exception.StatusCode is not (401 or 403)) { - if (ConnectionRecoveryPolicy.KeepExisting(reconnect, replacementStarted, _xray.IsRunning, exception)) throw; + if (ConnectionRecoveryPolicy.KeepExisting(reconnect, replacementStarted, _xray.IsRunning, exception, CanRetainAuthorizedCore())) throw; failures.Add($"{candidate?.Name ?? "AI 调度"}: {exception.Message}"); await _xray.StopAsync(); if (candidate is null) break; @@ -606,7 +614,7 @@ internal sealed partial class MainForm : Form } catch (Exception exception) when (exception is not OperationCanceledException && exception is not ApiException { StatusCode: 401 or 403 }) { - if (ConnectionRecoveryPolicy.KeepExisting(reconnect, replacementStarted, _xray.IsRunning, exception)) throw; + if (ConnectionRecoveryPolicy.KeepExisting(reconnect, replacementStarted, _xray.IsRunning, exception, CanRetainAuthorizedCore())) throw; failures.Add($"{candidate?.Name ?? "AI 调度"}: {exception.Message}"); await _xray.StopAsync(); if (candidate is not null) _failedNodes[candidate.Slug] = DateTimeOffset.UtcNow.AddMinutes(5); @@ -642,7 +650,7 @@ internal sealed partial class MainForm : Form { if (!_exiting) await DisconnectAsync(); } - catch (Exception exception) when (ConnectionRecoveryPolicy.KeepExisting(reconnect, replacementStarted, _xray.IsRunning, exception)) + catch (Exception exception) when (ConnectionRecoveryPolicy.KeepExisting(reconnect, replacementStarted, _xray.IsRunning, exception, CanRetainAuthorizedCore())) { AppPaths.WriteLog("调度请求失败,尚未启动替换线路,保留原内核与路由;两分钟后重试。" + exception.GetType().Name); _wantConnected = true; @@ -761,6 +769,13 @@ internal sealed partial class MainForm : Form private async Task MaintainConnectionAsync() { + if (_wantConnected && !_connectionAuthorization.AccountIsValid(DateTimeOffset.UtcNow, Environment.TickCount64) + && !_busy && !_healthChecking && !_handoverOperating && !_exiting) + { + await DisconnectAsync(); + _statusDetail.Text = "已知账号或订阅授权已到期,请联网重新验证。"; + return; + } if (_currentNodeIsPrivateAuxiliary && _privateLeaseDeadlineTicks > 0 && Environment.TickCount64 >= _privateLeaseDeadlineTicks && !_busy && !_healthChecking && !_handoverOperating && !_exiting) { @@ -788,7 +803,8 @@ internal sealed partial class MainForm : Form var health = await _xray.CheckHealthWithRepairAsync(_lifetime.Token); var healthy = health.Healthy; var decision = _connectionHealth.Observe(revision, testedCore, _xray.CoreId, - _wantConnected, _busy, _xray.IsTransitioning, _exiting, healthy, Environment.TickCount64, health.ProxyHealthy); + _wantConnected, _busy, _xray.IsTransitioning, _exiting, healthy, Environment.TickCount64, health.ProxyHealthy, + _xray.UsesTailnet, health.BusinessUnavailable); if (decision == ConnectionHealthPolicy.Decision.Ignore) return; if (healthy && _xray.IsRunning) { if (_localRoutingFault) { @@ -800,6 +816,15 @@ internal sealed partial class MainForm : Form ConnectionAcceptanceTrace.Record("health_ok", _currentNodeSlug, true, _xray.CoreId); return; } + if (decision == ConnectionHealthPolicy.Decision.Degraded) { + _localRoutingFault = true; + SetConnectionState(true, "网站探测异常,连接保留", $"{_currentNodeName ?? _currentNodeSlug} · 目标网站可用性尚未确认,保留当前线路"); + _statusTitle.ForeColor = Color.FromArgb(155, 88, 12); + _statusDot.ForeColor = _statusTitle.ForeColor; + _notifyIcon.Text = "纵横家 · 网站探测异常"; + AppPaths.WriteLog("健康诊断:网站探测异常,保留当前内核和已授权线路;未将网站状态判为节点传输失败。"); + return; + } if (decision == ConnectionHealthPolicy.Decision.Repair) { _localRoutingFault = true; SetConnectionState(true, "分流异常,正在修复", $"{_currentNodeName ?? _currentNodeSlug} · 代理出口可达,保留现有连接并重试规则验证"); @@ -949,7 +974,9 @@ internal sealed partial class MainForm : Form var accepted = await _xray.RenewPrivateAuthorizationAsync(renewed.GetRuntimeConfigJson(), privateCore, _lifetime.Token); if (!IsCurrent() || _xray.CoreId != privateCore) return; if (accepted) + { _privateLeaseDeadlineTicks = Environment.TickCount64 + Math.Max(0, (long)(renewed.ConfigExpiresAt!.Value - DateTimeOffset.UtcNow).TotalMilliseconds); + } else { await DisconnectAsync(); @@ -1058,6 +1085,8 @@ internal sealed partial class MainForm : Form private void UpdateProfile(Profile profile, bool preserveSelections) { if (_exiting || IsDisposed || Disposing) return; + _connectionAuthorization.AcceptProfile(profile.Subscription.Status, profile.Subscription.ExpiresAt, + DateTimeOffset.UtcNow, Environment.TickCount64); _knownTailnetAllowed = true; SetNodeTrafficPermission(profile.CanViewNodeTraffic); var selectedRoute = preserveSelections ? (_routeCombo.SelectedItem as RouteModeInfo)?.Id : null; diff --git a/windows/NodeHealthProbe.cs b/windows/NodeHealthProbe.cs index 846d1d2..6f4e8f4 100644 --- a/windows/NodeHealthProbe.cs +++ b/windows/NodeHealthProbe.cs @@ -6,6 +6,8 @@ namespace UCVL.VPNPlus; // It is NOT part of 0.2.5's connection transaction and never changes routes. internal static class NodeHealthProbe { + internal readonly record struct Observation(bool BusinessHealthy, bool TransportReachable); + internal readonly record struct Report(bool BusinessHealthy, bool TransportReachable); internal static bool Accepts(int target, int status) => target == 0 ? status is 200 or 204 : status is >= 200 and < 500; @@ -13,6 +15,51 @@ internal static class NodeHealthProbe internal static bool OverallHealthy(IReadOnlyList results) => results.Count >= 3 && results[2] && (results[0] || results[1]); + internal static bool AcceptsTransportStatus(int status) => status is >= 100 and <= 599; + + private static async Task Observed(Task probe) + { + try { return await probe.ConfigureAwait(false); } + catch { return default; } + } + + internal static async Task AggregateTransportAsync(IReadOnlyList> probes, + CancellationToken token, Action cancelRemaining) + { + var pending = probes.Select(Observed).ToList(); + try + { + token.ThrowIfCancellationRequested(); + while (pending.Count > 0) + { + var finished = await Task.WhenAny(pending).WaitAsync(token).ConfigureAwait(false); + pending.Remove(finished); + var observation = await finished.ConfigureAwait(false); + token.ThrowIfCancellationRequested(); + if (observation.TransportReachable) return true; + } + return false; + } + finally { cancelRemaining(); } + } + + internal static async Task AggregateReportAsync(IReadOnlyList> probes, + CancellationToken token, Action cancelRemaining) + { + var observations = probes.Select(Observed).ToArray(); + async Task BusinessAsync(Task probe) => (await probe.ConfigureAwait(false)).BusinessHealthy; + try + { + token.ThrowIfCancellationRequested(); + var business = AggregateAsync(observations.Select(BusinessAsync).ToArray(), token, () => { }); + var transport = AggregateTransportAsync(observations, token, () => { }); + await Task.WhenAll(business, transport).ConfigureAwait(false); + token.ThrowIfCancellationRequested(); + return new(await business.ConfigureAwait(false), await transport.ConfigureAwait(false)); + } + finally { cancelRemaining(); } + } + internal static async Task AggregateAsync(IReadOnlyList> probes, CancellationToken token, Action cancelRemaining) { @@ -52,6 +99,12 @@ internal static class NodeHealthProbe } internal static async Task CheckAsync(CancellationToken token, int proxyPort = 0) + => (await CheckReportAsync(token, proxyPort).ConfigureAwait(false)).BusinessHealthy; + + internal static async Task CheckTransportAsync(CancellationToken token, int proxyPort) + => (await CheckReportAsync(token, proxyPort, transportOnly: true).ConfigureAwait(false)).TransportReachable; + + internal static async Task CheckReportAsync(CancellationToken token, int proxyPort = 0, bool transportOnly = false) { using var timeout = CancellationTokenSource.CreateLinkedTokenSource(token); timeout.CancelAfter(TimeSpan.FromSeconds(15)); @@ -64,14 +117,16 @@ internal static class NodeHealthProbe var probes = urls.Select(async (url, index) => { try { using var response = await client.GetAsync(url, HttpCompletionOption.ResponseHeadersRead, timeout.Token); - return Accepts(index, (int)response.StatusCode); + return new Observation(Accepts(index, (int)response.StatusCode), AcceptsTransportStatus((int)response.StatusCode)); } catch (OperationCanceledException) when (token.IsCancellationRequested) { throw; } - catch { return false; } + catch { return default(Observation); } }).ToArray(); - // This client exists primarily for ChatGPT/Codex. Google or the OpenAI - // REST API remaining reachable must not mask a broken Codex transport. - // Require the Codex endpoint plus one independent Internet target. - return await AggregateAsync(probes, token, timeout.Cancel); + // Retain the stricter business-site diagnostic separately. A valid + // TLS/HTTP response through the forced proxy, including 5xx, proves + // transport reachability without claiming the target service is healthy. + if (transportOnly) + return new(false, await AggregateTransportAsync(probes, token, timeout.Cancel).ConfigureAwait(false)); + return await AggregateReportAsync(probes, token, timeout.Cancel); } } diff --git a/windows/NodeHealthProbeSelfTest.cs b/windows/NodeHealthProbeSelfTest.cs index e4e8b24..d3d1c46 100644 --- a/windows/NodeHealthProbeSelfTest.cs +++ b/windows/NodeHealthProbeSelfTest.cs @@ -133,6 +133,43 @@ internal static class NodeHealthProbeSelfTest Require(await result, "Unused-probe cancellation changed the health verdict"); }); + await Check("http_5xx_response_proves_transport_but_not_business_health", () => { + Require(NodeHealthProbe.AcceptsTransportStatus(503) && !NodeHealthProbe.Accepts(2, 503), "HTTP outage confused with proxy transport"); + return Task.CompletedTask; + }); + await Check("single_codex_outage_keeps_independent_transport_proof", async () => { + var report = await NodeHealthProbe.AggregateReportAsync(new[] { + Task.FromResult(new NodeHealthProbe.Observation(true, true)), + Task.FromResult(new NodeHealthProbe.Observation(true, true)), + Task.FromResult(new NodeHealthProbe.Observation(false, false)) }, CancellationToken.None, () => { }); + Require(!report.BusinessHealthy && report.TransportReachable, "Site failure must remain distinct from transport failure"); + }); + await Check("all_sites_return_5xx_still_is_not_transport_death", async () => { + var report = await NodeHealthProbe.AggregateReportAsync(Enumerable.Range(0, 3) + .Select(_ => Task.FromResult(new NodeHealthProbe.Observation(false, true))).ToArray(), CancellationToken.None, () => { }); + Require(!report.BusinessHealthy && report.TransportReachable, "HTTP responses lost transport proof"); + }); + await Check("transport_proof_does_not_wait_for_failed_codex", async () => { + var pending = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); + var cancelled = false; + var reached = await NodeHealthProbe.AggregateTransportAsync(new[] { + Task.FromResult(new NodeHealthProbe.Observation(true, true)), pending.Task, pending.Task }, CancellationToken.None, () => cancelled = true) + .WaitAsync(TimeSpan.FromSeconds(1)); + Require(reached && cancelled, "Transport startup unnecessarily waited for a site diagnostic"); + pending.SetException(new IOException("late site fixture")); + }); + await Check("all_transport_failures_remain_unavailable", async () => { + var report = await NodeHealthProbe.AggregateReportAsync(Enumerable.Range(0, 3) + .Select(_ => Task.FromResult(default(NodeHealthProbe.Observation))).ToArray(), CancellationToken.None, () => { }); + Require(!report.BusinessHealthy && !report.TransportReachable, "Failed transport became false healthy"); + }); + await Check("transport_caller_cancellation_propagates", async () => { + using var caller = new CancellationTokenSource(); caller.Cancel(); + var cancelled = false; + try { await NodeHealthProbe.AggregateTransportAsync([], caller.Token, () => { }); } + catch (OperationCanceledException error) { cancelled = error.CancellationToken == caller.Token; } + Require(cancelled, "Transport cancellation was converted to false health"); + }); var passed = checks.Values.All(value => value); var report = JsonSerializer.Serialize(new { kind = "node_health_early_completion", network_used = false, checks, errors, passed }, new JsonSerializerOptions { WriteIndented = true }); diff --git a/windows/README.md b/windows/README.md index e218577..99d510f 100644 --- a/windows/README.md +++ b/windows/README.md @@ -1,6 +1,6 @@ -# 纵横家 Windows 0.3.3 开源源码 +# 纵横家 Windows 0.3.4 开源源码 -基于已冻结的 0.3.3 r22 第一方 Windows Forms / .NET 8 源码整理。此导出不是原安装包的逐字节副本:删除许可来源不明的可选登录插图及内部运维历史,保留原创山水缺图 fallback;端点为示例配置。原候选测试报告不能当作本导出的构建或生产验收证明。 +基于已冻结的 0.3.4 r22 第一方 Windows Forms / .NET 8 源码整理。此导出不是原安装包的逐字节副本:删除许可来源不明的可选登录插图及内部运维历史,保留原创山水缺图 fallback;端点为示例配置。原候选测试报告不能当作本导出的构建或生产验收证明。 ## 构建 @@ -17,6 +17,4 @@ dotnet publish VPNPlus.csproj -c Release -r win-x64 --self-contained true 公司自有代码适用 LICENSE;公司 Logo/商标保留来源识别用途、不授予品牌权利;第三方许可文本在 licenses/ 中,原 THIRD_PARTY_NOTICES.md 保持原文。 -0.3.3:重排紧凑主界面;左侧选择调度及代理模式,右侧显示实际工作状态;全宽代理速度与按实际传输显示的Tailscale速度行,紧凑累计数值与代理速度趋势。删除公网入口速度,速率最低为KB/s并保留一位小数;修复下拉重排选择、无障碍值及密集图表上限标注。此清洁源码保留原授权、连接与统计口径;离线和合成界面测试不代表生产网络或安装验收。 - -0.3.3追加:授权内网候选遵循后台新会话分配并确认节点预留;连接后每十分钟复测内网,不可达时先尝试同节点域名。服务器监控上入下出细柱沿用真实样本及过期失效。现有连接保持粘性,不拆分单个TCP流,不宣称启用跨节点带宽叠加。 +0.3.4:区分业务网站可用性与代理传输可达性,网站异常使用降级状态;有界多次内网Ping与确认轮次减少瞬时丢包误判。后台暂时不可用时只保留仍获明确授权的既有核心,401/403及已知到期仍终止,不新增离线登录。统一紧凑主界面的标题列、配置行、数值和单位槽及短图标签。清洁源码保留原MIT/GPL和第三方许可边界,不含用户提供的可选JPG;同包离线、合成界面与隔离文件事务验证不等于生产网络或覆盖安装验收。 diff --git a/windows/TailnetPingConfirmation.cs b/windows/TailnetPingConfirmation.cs new file mode 100644 index 0000000..e614c09 --- /dev/null +++ b/windows/TailnetPingConfirmation.cs @@ -0,0 +1,29 @@ +namespace UCVL.VPNPlus; + +// A bounded round tolerates isolated ICMP loss. This is address reachability, +// never a substitute for an authenticated proxy grant or a business-site test. +internal static class TailnetPingConfirmation +{ + internal const int Attempts = 3; + internal static async Task ProbeAsync(Func> ping, + CancellationToken token, TimeSpan? budget = null) + { + token.ThrowIfCancellationRequested(); + using var deadline = CancellationTokenSource.CreateLinkedTokenSource(token); + deadline.CancelAfter(budget ?? TimeSpan.FromSeconds(4)); + for (var attempt = 0; attempt < Attempts; attempt++) + { + try + { + var reachable = await ping(deadline.Token).WaitAsync(deadline.Token).ConfigureAwait(false); + token.ThrowIfCancellationRequested(); + if (reachable) return true; + } + catch (OperationCanceledException) when (!token.IsCancellationRequested && deadline.IsCancellationRequested) { return false; } + catch (OperationCanceledException) { throw; } + catch (Exception) { /* One failed ICMP attempt is inconclusive. */ } + token.ThrowIfCancellationRequested(); + } + return false; + } +} diff --git a/windows/TailnetPingConfirmationSelfTest.cs b/windows/TailnetPingConfirmationSelfTest.cs new file mode 100644 index 0000000..96df6d8 --- /dev/null +++ b/windows/TailnetPingConfirmationSelfTest.cs @@ -0,0 +1,36 @@ +namespace UCVL.VPNPlus; + +internal static class TailnetPingConfirmationSelfTest +{ + internal static async Task> CheckAsync() + { + var checks = new Dictionary(); + var calls = 0; + var reachable = await TailnetPingConfirmation.ProbeAsync(_ => Task.FromResult(++calls == 2), CancellationToken.None); + checks["single_lost_ping_followed_by_success_is_reachable"] = reachable && calls == 2; + calls = 0; + reachable = await TailnetPingConfirmation.ProbeAsync(_ => Task.FromResult(++calls == 3), CancellationToken.None); + checks["two_lost_pings_followed_by_success_do_not_switch"] = reachable && calls == 3; + calls = 0; + reachable = await TailnetPingConfirmation.ProbeAsync(_ => { calls++; return Task.FromResult(false); }, CancellationToken.None); + checks["three_failed_icmp_attempts_are_one_failed_round"] = !reachable && calls == 3; + calls = 0; + reachable = await TailnetPingConfirmation.ProbeAsync(_ => ++calls == 1 + ? Task.FromException(new IOException("fixture ping failure")) : Task.FromResult(true), CancellationToken.None); + checks["one_ping_exception_does_not_force_fallback"] = reachable && calls == 2; + var pending = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); + reachable = await TailnetPingConfirmation.ProbeAsync(_ => pending.Task, CancellationToken.None, TimeSpan.FromMilliseconds(30)); + checks["uncooperative_ping_callback_has_bounded_deadline"] = !reachable; + using var caller = new CancellationTokenSource(); caller.Cancel(); + var cancelled = false; + try { await TailnetPingConfirmation.ProbeAsync(_ => Task.FromResult(true), caller.Token); } + catch (OperationCanceledException error) { cancelled = error.CancellationToken == caller.Token; } + checks["caller_cancellation_is_not_a_failed_ping"] = cancelled; + using var race = new CancellationTokenSource(); + cancelled = false; + try { await TailnetPingConfirmation.ProbeAsync(_ => { race.Cancel(); return Task.FromResult(true); }, race.Token); } + catch (OperationCanceledException error) { cancelled = error.CancellationToken == race.Token; } + checks["cancelled_successful_ping_cannot_publish_old_result"] = cancelled; + return checks; + } +} diff --git a/windows/TailnetReadinessPolicy.cs b/windows/TailnetReadinessPolicy.cs index 72d4214..0d3b092 100644 --- a/windows/TailnetReadinessPolicy.cs +++ b/windows/TailnetReadinessPolicy.cs @@ -11,7 +11,9 @@ internal sealed class TailnetReadinessPolicy internal enum Result { Ignore, NotReady, Confirming, BecameReady, Ready, Fallback } internal const long IntervalMilliseconds = 10 * 60_000; + internal const long ConfirmationMilliseconds = 5_000; private bool _bound, _inFlight, _usesTailnet; + private int _failedRounds; private long _generation, _sequence, _epoch, _nextDue; private int? _core; internal bool IsReady { get; private set; } @@ -23,6 +25,7 @@ internal sealed class TailnetReadinessPolicy _bound = _inFlight = IsReady = false; _core = null; _nextDue = 0; + _failedRounds = 0; } private static bool Eligible(Context context) => context.Wanted && context.Running @@ -64,12 +67,19 @@ internal sealed class TailnetReadinessPolicy _nextDue = now + IntervalMilliseconds; // Do not publish a result obtained while connection/authorization state // is being changed. A new ticket can retry after the normal cadence. - if (context.Busy) return Result.Ignore; + if (context.Busy) { _failedRounds = 0; return Result.Ignore; } if (!reachable) { IsReady = false; - return context.UsesTailnet ? Result.Fallback : Result.NotReady; + if (!context.UsesTailnet) { _failedRounds = 0; return Result.NotReady; } + if (++_failedRounds < 2) + { + _nextDue = now + ConfirmationMilliseconds; + return Result.Confirming; + } + return Result.Fallback; } + _failedRounds = 0; if (context.UsesTailnet) return Result.Ready; if (IsReady) return Result.Ready; IsReady = true; diff --git a/windows/TailnetReadinessSelfTest.cs b/windows/TailnetReadinessSelfTest.cs index 3c84089..8d81638 100644 --- a/windows/TailnetReadinessSelfTest.cs +++ b/windows/TailnetReadinessSelfTest.cs @@ -25,7 +25,16 @@ internal static class TailnetReadinessSelfTest policy.Reset(); current = current with { UsesTailnet = true }; checks["active_tailnet_waits_ten_minutes"] = !Begin(4_000_000, out _) && policy.NextDue == 4_600_000; checks["active_tailnet_success_retains_transport"] = Begin(4_600_000, out first) && Complete(first, 4_600_100, true) == TailnetReadinessPolicy.Result.Ready && !policy.IsReady; - checks["active_tailnet_failure_requests_domain_fallback"] = Begin(5_200_100, out first) && Complete(first, 5_200_200, false).ToString() == "Fallback"; + checks["single_failed_round_does_not_switch_active_tailnet"] = Begin(5_200_100, out first) + && Complete(first, 5_200_200, false) == TailnetReadinessPolicy.Result.Confirming; + checks["confirmation_wait_is_bounded_five_seconds"] = !Begin(5_205_199, out _) + && Begin(5_205_200, out second); + checks["second_failed_round_confirms_domain_fallback"] = Complete(second, 5_205_300, false) == TailnetReadinessPolicy.Result.Fallback; + policy.Reset(); + checks["new_active_path_schedules_after_reset"] = !Begin(5_300_000, out _) && Begin(5_900_000, out first); + checks["loss_then_recovery_clears_confirmation"] = Complete(first, 5_900_100, false) == TailnetReadinessPolicy.Result.Confirming + && Begin(5_905_100, out second) && Complete(second, 5_905_200, true) == TailnetReadinessPolicy.Result.Ready + && policy.NextDue == 6_505_200; policy.Reset(); checks["reset_clears_schedule"] = !policy.IsReady && policy.NextDue == 0; checks["new_session_has_no_duplicate_immediate_probe"] = !Begin(6_000_000, out _) && Begin(6_600_000, out first); @@ -44,6 +53,7 @@ internal static class TailnetReadinessSelfTest checks["busy_completion_is_not_a_failure"] = Begin(10_600_000, out first) && policy.Observe(first, current with { Busy = true }, 10_600_100, false) == TailnetReadinessPolicy.Result.Ignore; foreach (var state in new[] { current with { Wanted = false }, current with { CoreId = null }, current with { Running = false }, current with { HasAuthorizedCandidate = false } }) checks["ineligible_state_" + checks.Count] = !policy.TryBegin(state, 12_000_000, out _); + foreach (var check in TailnetPingConfirmationSelfTest.CheckAsync().GetAwaiter().GetResult()) checks.Add(check.Key, check.Value); var passed = checks.Values.All(v => v); foreach (var check in checks.Where(c => !c.Value)) Console.WriteLine("FAIL " + check.Key); Console.WriteLine($"{(passed ? "PASS" : "FAIL")} ten-minute Tailnet recheck; {checks.Count} checks"); diff --git a/windows/TrafficChart.cs b/windows/TrafficChart.cs index 19b8ed2..4e39171 100644 --- a/windows/TrafficChart.cs +++ b/windows/TrafficChart.cs @@ -193,7 +193,11 @@ internal static class ChartAxis { var y = plot.Bottom - plot.Height * i / 2; g.DrawLine(grid, plot.Left, y, plot.Right, y); - if (denseSpeed ? i == 0 : !compactAxis || i == 0) TextRenderer.DrawText(g, axis.Tick(maximum * i / 2), font, new Rectangle(0, (int)y - fontHeight / 2, (int)left - 4, fontHeight), Brand.Muted, PaintFlags | TextFormatFlags.Right | TextFormatFlags.NoPadding); + // A fitted chart can be only a few text lines tall. Keep its + // explicit upper-limit metadata legible instead of drawing a + // redundant zero label across that second line in the gutter. + var drawTick = denseSpeed ? i == 0 && y - fontHeight / 2 >= fontHeight * 2 + 2 * scale : !compactAxis || i == 0; + if (drawTick) TextRenderer.DrawText(g, axis.Tick(maximum * i / 2), font, new Rectangle(0, (int)y - fontHeight / 2, (int)left - 4, fontHeight), Brand.Muted, PaintFlags | TextFormatFlags.Right | TextFormatFlags.NoPadding); } for (var i = 0; i <= 6; i++) { diff --git a/windows/VPNPlus.csproj b/windows/VPNPlus.csproj index c833536..6c7347e 100644 --- a/windows/VPNPlus.csproj +++ b/windows/VPNPlus.csproj @@ -10,10 +10,10 @@ assets\zonghengjia-app-v1.ico app.manifest PerMonitorV2 - 0.3.3 - 0.3.3.0 - 0.3.3.0 - 0.3.3 + 0.3.4 + 0.3.4.0 + 0.3.4.0 + 0.3.4 纵横家 优创未来(UCVL) 纵横家 Windows 智能网络客户端 diff --git a/windows/XrayManager.cs b/windows/XrayManager.cs index f318a31..8b23b46 100644 --- a/windows/XrayManager.cs +++ b/windows/XrayManager.cs @@ -140,14 +140,14 @@ internal sealed class XrayManager : IDisposable, IAsyncDisposable, IHandoverRunt internal Task CheckProxyHealthAsync(CancellationToken token) => !IsRunning || _learningProbePort == 0 ? Task.FromResult(false) - : NodeHealthProbe.CheckAsync(token, _learningProbePort); + : NodeHealthProbe.CheckTransportAsync(token, _learningProbePort); - internal sealed record HealthResult(bool Healthy, bool ProxyHealthy, bool RepairAttempted); + internal sealed record HealthResult(bool Healthy, bool ProxyHealthy, bool RepairAttempted, bool BusinessUnavailable = false); internal async Task CheckHealthWithRepairAsync(CancellationToken token) { var expectedCore = CoreId; if (await CheckHealthAsync(token)) return new(true, false, false); - if (_routeMode != "smart" || expectedCore is null || CoreId != expectedCore || _learningProbePort == 0) + if (expectedCore is null || CoreId != expectedCore || _learningProbePort == 0) return new(false, false, false); using var deadline = CancellationTokenSource.CreateLinkedTokenSource(token, _learningEpoch.Token); deadline.CancelAfter(TimeSpan.FromSeconds(45)); @@ -155,9 +155,14 @@ internal sealed class XrayManager : IDisposable, IAsyncDisposable, IHandoverRunt try { // A failing ordinary route is not proof that the proxy node is down. - if (!await NodeHealthProbe.CheckAsync(deadline.Token, _learningProbePort)) return new(false, false, false); + var proxy = await NodeHealthProbe.CheckReportAsync(deadline.Token, _learningProbePort); + if (!proxy.TransportReachable) return new(false, false, false); proxyHealthy = true; if (CoreId != expectedCore) return new(false, true, false); + // The forced proxy authenticated the same transport and received + // TLS/HTTP from at least one site. A site's outage is a business + // diagnostic, not evidence that this node needs to be replaced. + if (_routeMode != "smart" || !proxy.BusinessHealthy) return new(false, true, false, true); AppPaths.WriteLog("普通智能路径异常,代理比较路径正常;先重新验证并热修复规则,不重启内核。"); await Task.WhenAll(new[] { "chatgpt.com", "api.openai.com", "www.google.com" }.Select(target => ScheduleLearningAsync(new LearningObservation { Target = target, Port = 443, AccessKind = "http", diff --git a/windows/release/RELEASE-NOTES-0.3.4.md b/windows/release/RELEASE-NOTES-0.3.4.md new file mode 100644 index 0000000..9ceceec --- /dev/null +++ b/windows/release/RELEASE-NOTES-0.3.4.md @@ -0,0 +1,10 @@ +# 纵横家 Windows 0.3.4 · 连接容错与固定网格候选版 + +本版修复网站探测、内网丢包和后台暂时不可用引发的连接恢复问题,并统一紧凑主界面网格。实际验证结果以同一候选包的 evidence 报告为准,不能以本文代替验收。 + +- 将网站业务可用性与代理传输可达性区分。第三方网站异常时显示琥珀色“网站探测异常,连接保留”,不会将其假报为已恢复或据此拆掉运行中的 Tailscale 连接。核心进程退出仍触发正常恢复。 +- 首次连接沿用内网优先检测;连接后每十分钟复测。定期检查使用有界多次 ICMP,首轮失败先确认,约五秒后的确认仍失败才要求同节点域名回退。过期探测不能影响新会话或新核心。 +- 后台超时或服务端暂时故障时,保留尚在明确授权期限内的既有核心;新建连接仍需要后台新授权。401/403、已知账号或订阅到期仍终止;私有节点续租和到期回退沿用专属逻辑。不新增离线登录。 +- 默认 480 × 360 logical 的主界面使用统一外边距、行高、标题列及数值/单位槽。配置两行、当前工作状态、代理/Tailscale/累计数值和趋势表头对齐;Tailscale 及服务器区域显隐不加高窗口,不启用滚动。累计仍只显示数值,代理速度保留趋势,最小速度单位为 KB/s。 + +这是待部署候选版。中央后台 192.0.2.1 尚待云控制台诊断,本文不表示后台已恢复、真实连接提速、生产覆盖升级或实际网络验收通过。准备过程不修改当前安装、Tailscale 配置、手机或电视。安装包未做 Authenticode 签名,安装升级需要管理员权限。