Compare commits

..

1 Commits

23 changed files with 4001 additions and 3092 deletions
+141
View File
@@ -475,5 +475,146 @@
], ],
"SourceOnly": true, "SourceOnly": true,
"Version": "0.3.1" "Version": "0.3.1"
},
"Windows032ConnectCompactDelta": {
"CandidateSha256": "85fac03989c71cbc61bdf756ac7e7194ac9cd003533c0aa6bc1c355eeb375813",
"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/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": "18d98d6e58c67ecf6d0293668eaeaa6946e2a2e7b879177f1410e7bf08503f7f",
"Omitted": [
"windows/assets/login-cloud-scene-v1.jpg"
],
"OptionalUnlicensedSceneRemainsOmitted": true,
"OriginalAcceptanceTransferred": false,
"OriginalSourceManifestSha256": "bf4a9f7360d2d44b11a8e94db881cc60d7234d2db7a3e89bffef0515ad244991",
"OtherComponentsModified": false,
"PrivateHistoryIncluded": false,
"ProductionAccepted": false,
"PublicBaseCommit": "1cf54a46e495d6f0f74b7b4b67e1786b2c51d5a2",
"PublicDownloadDomainsRetained": [
"pro.ucvl.cn"
],
"SourceOnly": true,
"Version": "0.3.2"
} }
} }
+1 -1
View File
@@ -1,6 +1,6 @@
# 纵横家开源源码 # 纵横家开源源码
此仓库是无私有 Git 历史的清洁源码快照:Windows 0.3.1、Django 后台及 iPhone/iPad 1.0.2。公司自有代码按 MIT 开源;第三方组件遵守原许可,公司商标及 Logo 不在 MIT 授权范围。Android 保留原 GPL-3.0 公开仓库,不重复拷贝或改换许可。 此仓库是无私有 Git 历史的清洁源码快照:Windows 0.3.2、Django 后台及 iPhone/iPad 1.0.2。公司自有代码按 MIT 开源;第三方组件遵守原许可,公司商标及 Logo 不在 MIT 授权范围。Android 保留原 GPL-3.0 公开仓库,不重复拷贝或改换许可。
| 目录 | 内容与状态 | | 目录 | 内容与状态 |
| --- | --- | | --- | --- |
+35 -16
View File
@@ -4,7 +4,7 @@
"ExportDiffersFromOriginalCandidates": true, "ExportDiffersFromOriginalCandidates": true,
"FilesBeforeProvenanceAndAudit": { "FilesBeforeProvenanceAndAudit": {
"LICENSE": "b7e94910b8dc377b0a05ccde3c6e5941838dfc15c9dd790078d11728205b524e", "LICENSE": "b7e94910b8dc377b0a05ccde3c6e5941838dfc15c9dd790078d11728205b524e",
"README.md": "c2c081754048ff7561f65eb5a471c08e7293acaddbbe48839ab302a3ec37b6d7", "README.md": "bdaeafc190ac7c8bde109937d37c9f0437b044c9be78dc9dabcb13a2cb56d13c",
"SECURITY.md": "34e56cd9b8f6aa5fee45921c6eb831a542e05e76e41850fc31c44e09de088b3c", "SECURITY.md": "34e56cd9b8f6aa5fee45921c6eb831a542e05e76e41850fc31c44e09de088b3c",
"THIRD_PARTY_NOTICES.md": "8c862f2f6b71440616a887e6deb7444a1262cf7d9f144208cc04041c3f9a3371", "THIRD_PARTY_NOTICES.md": "8c862f2f6b71440616a887e6deb7444a1262cf7d9f144208cc04041c3f9a3371",
"android/README.md": "bb4387da9a055e97f33bb29a883c543e0938fa858df3fd744abc80553a5ec65c", "android/README.md": "bb4387da9a055e97f33bb29a883c543e0938fa858df3fd744abc80553a5ec65c",
@@ -190,13 +190,13 @@
"windows/ConnectionHealthSelfTest.cs": "5a483194f754ad51366acd9df00554c8ceecaa5dadba73972c4922b72dc7e2fe", "windows/ConnectionHealthSelfTest.cs": "5a483194f754ad51366acd9df00554c8ceecaa5dadba73972c4922b72dc7e2fe",
"windows/ConnectionRecoveryPolicy.cs": "860bd4cedf393f157fc1dd68e407776e1fe0fa1cc6cef7e99cd5581b64c6f5f6", "windows/ConnectionRecoveryPolicy.cs": "860bd4cedf393f157fc1dd68e407776e1fe0fa1cc6cef7e99cd5581b64c6f5f6",
"windows/ConnectionSelection.cs": "def94b338b9e1fd940c19b8991e4268a4e59bec741ea624f5a6e4fb7a7d3bbcc", "windows/ConnectionSelection.cs": "def94b338b9e1fd940c19b8991e4268a4e59bec741ea624f5a6e4fb7a7d3bbcc",
"windows/ConnectionSelectionSelfTest.cs": "12bd82071989c5e539031f6e7921660edb4eb10a4136ac332cc84eca2e2d96de", "windows/ConnectionSelectionSelfTest.cs": "0d8f131cf461648aa91651a9790924b6da9cedd1801ef44cc79852164bc9f0d5",
"windows/ConnectionSelfTest.cs": "6ad3f227cec3e26514d833ec1cb996818597a0cb27901053362faa45e3c1c9b3", "windows/ConnectionSelfTest.cs": "6ad3f227cec3e26514d833ec1cb996818597a0cb27901053362faa45e3c1c9b3",
"windows/DailyTrafficChart.cs": "4af8d8a91559e6a3fc1dd56db11f3534606aeb486ff918b2b301db0b82e4c716", "windows/DailyTrafficChart.cs": "4af8d8a91559e6a3fc1dd56db11f3534606aeb486ff918b2b301db0b82e4c716",
"windows/DashboardControls.cs": "1be17efd73acec775aade94461e59c7255a988bd46d056ad8613fdc3e4bd126d", "windows/DashboardControls.cs": "d1ced56aa6e7b1a896fecaf23249adbd7c9c9ba7ba3f6ea20e171b9b96886d72",
"windows/DashboardInteractionSelfTest.cs": "ad4845d14b5b5db4d91a180f95536dd1093458fab86ec8767b74983891a456b4", "windows/DashboardInteractionSelfTest.cs": "ad4845d14b5b5db4d91a180f95536dd1093458fab86ec8767b74983891a456b4",
"windows/DashboardLayout.cs": "a07985d84c69ed68783068d847059452db889ee244a98d7ab4e02ace4a5528ba", "windows/DashboardLayout.cs": "e30bb9b0f3bc6038f482a4be7b3daab04f34a96a7d367a4ac47a29f692c981d7",
"windows/DashboardTailnetLayoutSelfTest.cs": "64ed480d434f673137c5edc5b2b1a5d51f8aa31f8440efb734c052a472bf81d6", "windows/DashboardTailnetLayoutSelfTest.cs": "ff632fc070ec04a4a47a350f2ba0d543c4895423f88db64f38b53519dc82cd47",
"windows/DashboardWheelRouter.cs": "d903097a5febbff296febb65855dc10b4e056ea5bb54d2df71b5d1f0297dcc1f", "windows/DashboardWheelRouter.cs": "d903097a5febbff296febb65855dc10b4e056ea5bb54d2df71b5d1f0297dcc1f",
"windows/GitReleasePolicySelfTest.cs": "9e49ba957ab15a5c23d889004b171856c3d523f98cecf10088df4fcd8b577c61", "windows/GitReleasePolicySelfTest.cs": "9e49ba957ab15a5c23d889004b171856c3d523f98cecf10088df4fcd8b577c61",
"windows/GitReleaseUpdater.cs": "dcd00a0feca6801aad4e346c7565d8bcd80b3fd24a4accbe5cd4643d04264b9b", "windows/GitReleaseUpdater.cs": "dcd00a0feca6801aad4e346c7565d8bcd80b3fd24a4accbe5cd4643d04264b9b",
@@ -220,13 +220,14 @@
"windows/LearningSyncCoordinatorSelfTest.cs": "471ec344130fe74d892c1115637bd98c517084fc309e982d4d11d3f0ee19403c", "windows/LearningSyncCoordinatorSelfTest.cs": "471ec344130fe74d892c1115637bd98c517084fc309e982d4d11d3f0ee19403c",
"windows/LearningTransportSelfTest.cs": "05dcfd3fcfc6f25e20612c020583eb6c36934c1b251e50e70fcd29501ad0efe7", "windows/LearningTransportSelfTest.cs": "05dcfd3fcfc6f25e20612c020583eb6c36934c1b251e50e70fcd29501ad0efe7",
"windows/MainForm.Chrome.cs": "30dc6520a44a5120c78c472c9fb053e2e4dea8e254b5531d04a5342964969c7a", "windows/MainForm.Chrome.cs": "30dc6520a44a5120c78c472c9fb053e2e4dea8e254b5531d04a5342964969c7a",
"windows/MainForm.Dashboard.cs": "1e081c6039eac155e87c057919d7381eecdc2388615b9d56f211de0e379386f4", "windows/MainForm.Compact.cs": "45599d3d795a14c031be051abff4b039480df5e6867aba57c3724488950d280d",
"windows/MainForm.Dashboard.cs": "0b8c2489483dd221d4b94f21f14058d8b4bda28a4326f89c8cc612c6dac05421",
"windows/MainForm.Handover.cs": "4a914f4de335331f1f9d2397407328f17ae372e9119329e534af218555dc92e6", "windows/MainForm.Handover.cs": "4a914f4de335331f1f9d2397407328f17ae372e9119329e534af218555dc92e6",
"windows/MainForm.NextGeneration.cs": "b560218aed601359310e9ee57f9628d28432be046342748931253c22dbc2d8b5", "windows/MainForm.NextGeneration.cs": "b560218aed601359310e9ee57f9628d28432be046342748931253c22dbc2d8b5",
"windows/MainForm.Selection.cs": "d872004a98fc634e40c5edebf85eac7f3dfbb62fad8cafaae66a5c8470cfdaf3", "windows/MainForm.Selection.cs": "d872004a98fc634e40c5edebf85eac7f3dfbb62fad8cafaae66a5c8470cfdaf3",
"windows/MainForm.TailnetTraffic.cs": "432ea16a7f5fe66006530b5b90af6eab59362a2b02685ec2130dadfd43c1652b", "windows/MainForm.TailnetTraffic.cs": "432ea16a7f5fe66006530b5b90af6eab59362a2b02685ec2130dadfd43c1652b",
"windows/MainForm.TransportSelection.cs": "92e1dd715f39cc40f217e65125d89747bb8c9bedf9a11f70bcd577926e75b995", "windows/MainForm.TransportSelection.cs": "92e1dd715f39cc40f217e65125d89747bb8c9bedf9a11f70bcd577926e75b995",
"windows/MainForm.cs": "0c202d8c136fc8ae5ed812582bff5d9177c14d009b27e47bd24f5ea518f8c9dd", "windows/MainForm.cs": "9bea6d7edfa294cb620398e0199379c91a2483fed5ddf882406292efe5f504e2",
"windows/NOTICE.md": "8c862f2f6b71440616a887e6deb7444a1262cf7d9f144208cc04041c3f9a3371", "windows/NOTICE.md": "8c862f2f6b71440616a887e6deb7444a1262cf7d9f144208cc04041c3f9a3371",
"windows/NetworkHandover.cs": "b43548be0051cf92dfd332e537951e4b5083f2a123be8021994513bbc3748d46", "windows/NetworkHandover.cs": "b43548be0051cf92dfd332e537951e4b5083f2a123be8021994513bbc3748d46",
"windows/NetworkHandoverSelfTest.cs": "681d0154dc0aa5f49d7ce1f3088b465eea3ed82571b464951df8d4c89cecdf73", "windows/NetworkHandoverSelfTest.cs": "681d0154dc0aa5f49d7ce1f3088b465eea3ed82571b464951df8d4c89cecdf73",
@@ -237,11 +238,12 @@
"windows/NetworkRecoveryTool.cs": "2dec1406ca0719af3eacedf2d8f83659927c44bc4a1eaccc1babe84c0d3d99cc", "windows/NetworkRecoveryTool.cs": "2dec1406ca0719af3eacedf2d8f83659927c44bc4a1eaccc1babe84c0d3d99cc",
"windows/NetworkRouteLease.cs": "0b57aa0e3499ec3f9f7f7a4c683cecca0f6d7f275734e126a5da4f7849cd7ae3", "windows/NetworkRouteLease.cs": "0b57aa0e3499ec3f9f7f7a4c683cecca0f6d7f275734e126a5da4f7849cd7ae3",
"windows/NextGenerationSelfTest.cs": "a92cbbf4c8ba0cde0ec12faf2e1cdbcd2c86f758d440d677471968569030f8f1", "windows/NextGenerationSelfTest.cs": "a92cbbf4c8ba0cde0ec12faf2e1cdbcd2c86f758d440d677471968569030f8f1",
"windows/NodeHealthProbe.cs": "c49e5cf6b3a62242ae0e486aa3fd267d50485269ec0bd769cf140e743850fec7", "windows/NodeHealthProbe.cs": "5c501094402010d2f8ecdc4145f1084ef084b749c2b47794fca0c0f60c4441fb",
"windows/NodeHealthProbeSelfTest.cs": "85d645160ed53f2646b58ba29d2ec17d6ff8fa54b658dc15e15c9609514c16ea",
"windows/NodeMatrixSelfTest.cs": "eed8e56036d300fdffd82b83cca87ea6b2806e8598b2c4fc916aded15197f20d", "windows/NodeMatrixSelfTest.cs": "eed8e56036d300fdffd82b83cca87ea6b2806e8598b2c4fc916aded15197f20d",
"windows/NodePresentation.cs": "c70a8be06cce937f309fd10531d97b02b675a72509fff2419e412fbdf84977c0", "windows/NodePresentation.cs": "c70a8be06cce937f309fd10531d97b02b675a72509fff2419e412fbdf84977c0",
"windows/NodeTrafficMonitor.cs": "365c821eb9fc08f33e9387369c9f985f31992470214a5a13758f51dc3c84f0b8", "windows/NodeTrafficMonitor.cs": "6e04288302ebe2cad0e15fd77ea22e13fa8f06998af079a303e66a7fe1ae4170",
"windows/NodeTrafficSelfTest.cs": "33d7c8e16d23d19396f60e36d3204196e9499546022c09b3a8aaca9b957e01f2", "windows/NodeTrafficSelfTest.cs": "0d11d2d1c4b04f50449487af5948960f282c9b58651c233a06def5d93ce34b48",
"windows/NodeTransportConnector.cs": "91d53471f35470fc9a4578e2819863e56a790cda62a7dbfe891a71149d2386e1", "windows/NodeTransportConnector.cs": "91d53471f35470fc9a4578e2819863e56a790cda62a7dbfe891a71149d2386e1",
"windows/PhysicalUplink.cs": "b0a0eca6b9f724972d0e445c2dc352326ea4d7357317b98639972d60dadc2e63", "windows/PhysicalUplink.cs": "b0a0eca6b9f724972d0e445c2dc352326ea4d7357317b98639972d60dadc2e63",
"windows/PlatformBootstrapTransport.cs": "0eef4a4272449c0e2adfac2e4652bd9cff9c1b2bc11011ca2049dde2f97e4e2b", "windows/PlatformBootstrapTransport.cs": "0eef4a4272449c0e2adfac2e4652bd9cff9c1b2bc11011ca2049dde2f97e4e2b",
@@ -250,18 +252,19 @@
"windows/PrivateAuxiliaryRoutingSelfTest.cs": "8b2e867f562017e680def8f74c7fba972404442816abae7bf54fcab5d47339df", "windows/PrivateAuxiliaryRoutingSelfTest.cs": "8b2e867f562017e680def8f74c7fba972404442816abae7bf54fcab5d47339df",
"windows/PrivateAuxiliaryRuntime.cs": "dcfb406508e3d7e9a9163163cfe5e2724a6955a18ae4604e2d9f890da61308cf", "windows/PrivateAuxiliaryRuntime.cs": "dcfb406508e3d7e9a9163163cfe5e2724a6955a18ae4604e2d9f890da61308cf",
"windows/PrivateTransportProbe.cs": "e29e9bd0180a37bdcecf7104fde5069be799aca92b747881d0485a62d382d9b3", "windows/PrivateTransportProbe.cs": "e29e9bd0180a37bdcecf7104fde5069be799aca92b747881d0485a62d382d9b3",
"windows/Program.cs": "632a984e5c971b016a5f15b2ff1804b99cfd279661bd637a45f40dcd42e68ecd", "windows/Program.cs": "c5fba480cc2f8864862205a8beaf99e4daae15b90ac966ca768528a60ff6474f",
"windows/ProxyDnsPolicy.cs": "997e2e922ad43956932c1bd0a6da3457bc308ee723f4f77ff8e52aa23fa954c0", "windows/ProxyDnsPolicy.cs": "997e2e922ad43956932c1bd0a6da3457bc308ee723f4f77ff8e52aa23fa954c0",
"windows/ProxyProbe.cs": "5d27b5a6c6b192a0c0f3ec4637c5a876a71130497af57f7cb4a04ab4735ca1ec", "windows/ProxyProbe.cs": "5d27b5a6c6b192a0c0f3ec4637c5a876a71130497af57f7cb4a04ab4735ca1ec",
"windows/PublicTailnetSelection.cs": "cdd6e9195e678bd29dcef96aa9d16ffac9bf42bfe1a10ef293aefd31a2c4a68a", "windows/PublicTailnetSelection.cs": "cdd6e9195e678bd29dcef96aa9d16ffac9bf42bfe1a10ef293aefd31a2c4a68a",
"windows/PublicTailnetSelectionSelfTest.cs": "aed90554aa88aa7701eaccc925307a48d4a79e244c40d0c456b88f1207b540c0", "windows/PublicTailnetSelectionSelfTest.cs": "aed90554aa88aa7701eaccc925307a48d4a79e244c40d0c456b88f1207b540c0",
"windows/README.md": "7296f084849469b2420a091cbee1ed381986d95956dd79d94338b4b924167671", "windows/README.md": "5e4cff115fd3a8e2270d026ae9e37b913479ee620baa8350126819b2365e04af",
"windows/ReplacementContinuitySelfTest.cs": "107878ab2b367f1812377c0b209f6d620da390091c3882e4be53a48e517d86a1", "windows/ReplacementContinuitySelfTest.cs": "107878ab2b367f1812377c0b209f6d620da390091c3882e4be53a48e517d86a1",
"windows/RouteLeaseSelfTest.cs": "6189c66b9f66c58bed26de4441c58a9ec02b67257bfa04ed66d702acfcd054d9", "windows/RouteLeaseSelfTest.cs": "6189c66b9f66c58bed26de4441c58a9ec02b67257bfa04ed66d702acfcd054d9",
"windows/RoutingRuleBatches.cs": "9997bfa766fffe7bed7352f307c1f6f118a9be9aa86653eaefae3b2bdaa26c1e", "windows/RoutingRuleBatches.cs": "9997bfa766fffe7bed7352f307c1f6f118a9be9aa86653eaefae3b2bdaa26c1e",
"windows/RoutingUpdateSelfTest.cs": "48c99fc7a01037aa0368c53ccdb7eec0fea1edfac3bb2532c0de89631343206d", "windows/RoutingUpdateSelfTest.cs": "48c99fc7a01037aa0368c53ccdb7eec0fea1edfac3bb2532c0de89631343206d",
"windows/ScenicTheme.cs": "da0ec888a65216b57f881cf5bbc2ed551a07363afae9f2b6a54f22c6502169c7", "windows/ScenicTheme.cs": "da0ec888a65216b57f881cf5bbc2ed551a07363afae9f2b6a54f22c6502169c7",
"windows/SessionOperationFence.cs": "86e8dff164dc7f6f45ba3a41126b8e2e36af9de098479a08a9007604ff112277", "windows/SessionOperationFence.cs": "86e8dff164dc7f6f45ba3a41126b8e2e36af9de098479a08a9007604ff112277",
"windows/StartupLearningWarmup.cs": "137041f1c1f83147ce50b824208470832c58db775a9b72197d1d106316466f8b",
"windows/StartupSelfTest.cs": "cb035bf5d22624ed5034b719f0c52a4c1527ace4c371e966f15f7c25c8126013", "windows/StartupSelfTest.cs": "cb035bf5d22624ed5034b719f0c52a4c1527ace4c371e966f15f7c25c8126013",
"windows/SystemPowerShell.cs": "1f9247d2e4f8c9bad1d71105886d2ab33d8958006dcff7fadc63f27502eda6fe", "windows/SystemPowerShell.cs": "1f9247d2e4f8c9bad1d71105886d2ab33d8958006dcff7fadc63f27502eda6fe",
"windows/SystemProxy.cs": "beaf443f1e285e227e0c390d8e9114d5cf8464e0078a8bb842efa9eeb2b5e916", "windows/SystemProxy.cs": "beaf443f1e285e227e0c390d8e9114d5cf8464e0078a8bb842efa9eeb2b5e916",
@@ -272,7 +275,7 @@
"windows/TailnetTransportProbe.cs": "c71a0d946cbefb2713e0b564ea95ae99cbd70f0ec19c8cfc416a12e16589f99a", "windows/TailnetTransportProbe.cs": "c71a0d946cbefb2713e0b564ea95ae99cbd70f0ec19c8cfc416a12e16589f99a",
"windows/TailnetTransportSelfTest.cs": "8ace8cc2f443c1ce576bbb9471cb46f107ac28f999090baa30431412d8a263f3", "windows/TailnetTransportSelfTest.cs": "8ace8cc2f443c1ce576bbb9471cb46f107ac28f999090baa30431412d8a263f3",
"windows/TokenStore.cs": "e07cf7d1a4cf7a1bba871c19e50b9d6355cb8c1546657346b0256c8215fed8bb", "windows/TokenStore.cs": "e07cf7d1a4cf7a1bba871c19e50b9d6355cb8c1546657346b0256c8215fed8bb",
"windows/TrafficChart.cs": "9b2b42761d9f636cd3be3d6015ce4eff73bf7c0645105c7679f1987b1f5571a0", "windows/TrafficChart.cs": "c7bd65735ffaaace1a8b5075e6e977d7449b481858f4130d42da70069c34c883",
"windows/TunConfigBuilder.cs": "35a17b9da204e338dde5ed6cd4f2e979d94ad73c4c01cc0001fc582e94b67194", "windows/TunConfigBuilder.cs": "35a17b9da204e338dde5ed6cd4f2e979d94ad73c4c01cc0001fc582e94b67194",
"windows/TunConnectivitySelfTest.cs": "a7d7aff1d03e45dff921807cbfb8f83b5013c9df5c7e06b6662d84a8686b2f86", "windows/TunConnectivitySelfTest.cs": "a7d7aff1d03e45dff921807cbfb8f83b5013c9df5c7e06b6662d84a8686b2f86",
"windows/TunRouting.cs": "c6b3e1070a0ba0a3c42dbd12becba55404e540d06aba03cb1cc1053fa426a4c1", "windows/TunRouting.cs": "c6b3e1070a0ba0a3c42dbd12becba55404e540d06aba03cb1cc1053fa426a4c1",
@@ -280,11 +283,11 @@
"windows/UpdateSelfTest.cs": "453165bb611efb8db0d8a8c9ea13f3553e0047aa22b838c43096e3d83fe18771", "windows/UpdateSelfTest.cs": "453165bb611efb8db0d8a8c9ea13f3553e0047aa22b838c43096e3d83fe18771",
"windows/UpdateStreamSelfTest.cs": "ad059016c0197f33582b1969ab3280c5b9589a28d659613b3e97ce4a357d38c1", "windows/UpdateStreamSelfTest.cs": "ad059016c0197f33582b1969ab3280c5b9589a28d659613b3e97ce4a357d38c1",
"windows/UsageHistorySeries.cs": "9e7515ceede1899e06116352de79edd6252c921048bcae9958bf9358d93b3069", "windows/UsageHistorySeries.cs": "9e7515ceede1899e06116352de79edd6252c921048bcae9958bf9358d93b3069",
"windows/VPNPlus.csproj": "cc59524a6a01f8a606bece97ae45ca6cf25f9fb5ec83b36372d68a0f02f76cab", "windows/VPNPlus.csproj": "6ace89a08e32b1527bcebf5d9406451ab4e00a8e0b2448a3dbf7290cfcbe9555",
"windows/VpnApiClient.cs": "187829698d9f26b896dbfef596bc71b12a9ed4e014261abde0497e6763e40ae3", "windows/VpnApiClient.cs": "187829698d9f26b896dbfef596bc71b12a9ed4e014261abde0497e6763e40ae3",
"windows/WindowChrome.cs": "0eceea0879e792b8ae83a74eaf5658d4a7be6a798fbdb026ff8d19fa9aa6af2c", "windows/WindowChrome.cs": "0eceea0879e792b8ae83a74eaf5658d4a7be6a798fbdb026ff8d19fa9aa6af2c",
"windows/WindowChromeSelfTest.cs": "c17dd805a0102d12b71a3e32c77ceeb45e303e08612de5d3c5259c78327532be", "windows/WindowChromeSelfTest.cs": "c17dd805a0102d12b71a3e32c77ceeb45e303e08612de5d3c5259c78327532be",
"windows/XrayManager.cs": "024178506c01a7fe6074c4a05973125338999862e3b52181a0a0ce7399209375", "windows/XrayManager.cs": "b6422093815b939b5a9c4cdbf7ba95fddeb6e32831e427aab074858606101146",
"windows/XrayRoutingUpdater.cs": "91fd2b5db25477dbe4de7118faef79f9c51f9a8a3dd86e8b26c676092de3bca5", "windows/XrayRoutingUpdater.cs": "91fd2b5db25477dbe4de7118faef79f9c51f9a8a3dd86e8b26c676092de3bca5",
"windows/app.manifest": "4c9a2e8e2056c3bb0ae45a5f7b2e223298ee683a82b70ba4910e17f5728cf5b6", "windows/app.manifest": "4c9a2e8e2056c3bb0ae45a5f7b2e223298ee683a82b70ba4910e17f5728cf5b6",
"windows/assets/company-logo-original.png": "04cf7f754a5353b96cddbed4a57a557154342c190a1785487e3bfb36cab04163", "windows/assets/company-logo-original.png": "04cf7f754a5353b96cddbed4a57a557154342c190a1785487e3bfb36cab04163",
@@ -304,6 +307,8 @@
"windows/build/OwnedProcessGroup.cs": "00fc73e00dbc25bdf5ff6557f0d81786ba1ef235822ea290bead9b8a5ac66618", "windows/build/OwnedProcessGroup.cs": "00fc73e00dbc25bdf5ff6557f0d81786ba1ef235822ea290bead9b8a5ac66618",
"windows/build/ProductionInstallationBaseline.ps1": "1079dcc459af2b217d7cbddb81d286888d1210f1069cada6272d3b79a531062a", "windows/build/ProductionInstallationBaseline.ps1": "1079dcc459af2b217d7cbddb81d286888d1210f1069cada6272d3b79a531062a",
"windows/build/ProductionNetworkBaseline.ps1": "aa3600f92ba19d3041b0c50696d1035efe68013dec7ae3f7973e75b5fc17f9b1", "windows/build/ProductionNetworkBaseline.ps1": "aa3600f92ba19d3041b0c50696d1035efe68013dec7ae3f7973e75b5fc17f9b1",
"windows/build/StartupLearningWarmupHarness.cs": "1d5266159f1e8426dafd2e035a85644d03a9ed15c9207e7cd629e0fc03a3e310",
"windows/build/StartupLearningWarmupHarness.csproj": "2fee8f47a9b6b3cffcee0689fae4960525a2beadad73c5c3a4146e292f30bee2",
"windows/build/Test-InstallerGuardianGate.ps1": "5289a4643cc41279eae8d32a7cfdabfdd528506b03cc9fadaf33880dea996694", "windows/build/Test-InstallerGuardianGate.ps1": "5289a4643cc41279eae8d32a7cfdabfdd528506b03cc9fadaf33880dea996694",
"windows/build/Test-ProductionInstallationBaseline.ps1": "7d5afbffd8e4ed595917fdc8054469cdf071cfe4c932955bb84840d867eec0f0", "windows/build/Test-ProductionInstallationBaseline.ps1": "7d5afbffd8e4ed595917fdc8054469cdf071cfe4c932955bb84840d867eec0f0",
"windows/build/Test-ProductionNetworkBaseline.ps1": "842d84027e8ec68e94ab860500a176b8d8f284b7ca0d4e55751d0e81818742ac", "windows/build/Test-ProductionNetworkBaseline.ps1": "842d84027e8ec68e94ab860500a176b8d8f284b7ca0d4e55751d0e81818742ac",
@@ -322,7 +327,8 @@
"windows/release/RELEASE-NOTES-0.2.22.md": "bf6c8b448481f59a05e8653fbaa1356d986d2d481c3cbaf02fe6402dcf55d499", "windows/release/RELEASE-NOTES-0.2.22.md": "bf6c8b448481f59a05e8653fbaa1356d986d2d481c3cbaf02fe6402dcf55d499",
"windows/release/RELEASE-NOTES-0.2.23.md": "2f8aea1ec4d4f1bcc9860d8945dc6266be6ea924ff9958c589a6e4eb0550dc76", "windows/release/RELEASE-NOTES-0.2.23.md": "2f8aea1ec4d4f1bcc9860d8945dc6266be6ea924ff9958c589a6e4eb0550dc76",
"windows/release/RELEASE-NOTES-0.3.0.md": "cc1e398354ffb562c0647dbe91ffd3f43e614f3923298005c76999c457b77bf2", "windows/release/RELEASE-NOTES-0.3.0.md": "cc1e398354ffb562c0647dbe91ffd3f43e614f3923298005c76999c457b77bf2",
"windows/release/RELEASE-NOTES-0.3.1.md": "e28a99d049842adc34f593e39bbc33484dd4dfc9e31568cbcb1aef1f3bcd4132" "windows/release/RELEASE-NOTES-0.3.1.md": "e28a99d049842adc34f593e39bbc33484dd4dfc9e31568cbcb1aef1f3bcd4132",
"windows/release/RELEASE-NOTES-0.3.2.md": "29f2030b0be583a541dc0289ee9916d42156cf3bbd823bd5cf7867f097fb2abd"
}, },
"IosSourceCommit": "b07d085413b1b6370245866fd82271b76590b6d6", "IosSourceCommit": "b07d085413b1b6370245866fd82271b76590b6d6",
"Kind": "clean-history-free-open-source-export", "Kind": "clean-history-free-open-source-export",
@@ -557,5 +563,18 @@
"SourceOnly": true, "SourceOnly": true,
"Version": "0.3.1" "Version": "0.3.1"
}, },
"Windows032ConnectCompactDelta": {
"CandidateSha256": "85fac03989c71cbc61bdf756ac7e7194ac9cd003533c0aa6bc1c355eeb375813",
"FrozenSha256": "18d98d6e58c67ecf6d0293668eaeaa6946e2a2e7b879177f1410e7bf08503f7f",
"OptionalUnlicensedSceneRemainsOmitted": true,
"OriginalAcceptanceTransferred": false,
"OriginalSourceManifestSha256": "bf4a9f7360d2d44b11a8e94db881cc60d7234d2db7a3e89bffef0515ad244991",
"OtherComponentsModified": false,
"PrivateHistoryIncluded": false,
"ProductionAccepted": false,
"PublicBaseCommit": "1cf54a46e495d6f0f74b7b4b67e1786b2c51d5a2",
"SourceOnly": true,
"Version": "0.3.2"
},
"WindowsSourceCommit": "0d463e6af91a3802c564b06dabb6bf86ebff5a38" "WindowsSourceCommit": "0d463e6af91a3802c564b06dabb6bf86ebff5a38"
} }
+17 -1
View File
@@ -106,7 +106,23 @@ internal sealed partial class MainForm
_currentNodeLabel.Text = _currentNodeName; _currentNodeLabel.Text = _currentNodeName;
SetConnectionState(true, "已安全连接", _currentNodeName); SetConnectionState(true, "已安全连接", _currentNodeName);
LayoutDashboard(); LayoutDashboard();
result["connected_node_gets_full_width"] = _currentNodeLabel.Right == _nodeCard.Width - ScaleLogical(14); var fullConnectedRow = true;
foreach (var (size, label) in new[] { (new Size(480, 360), "compact"), (new Size(960, 720), "wide") })
{
ClientSize = new Size(ScaleLogical(size.Width), ScaleLogical(size.Height));
PerformLayout(); LayoutDashboard(); Application.DoEvents();
var rightInset = _nodeCard.ClientSize.Width - _currentNodeLabel.Right;
// The node keeps the available row, with only a small edge inset.
// Exact decorative padding can differ between compact and wide UI.
var usesRow = _currentNodeLabel.Visible && _currentNodeLabel.Left >= 0
&& rightInset >= 0 && rightInset <= ScaleLogical(16)
&& _currentNodeLabel.Width >= _nodeCard.ClientSize.Width * .75;
result["connected_node_full_row_" + label] = usesRow;
result["connected_node_name_fits_" + label] = TextRenderer.MeasureText(_currentNodeName,
_currentNodeLabel.Font).Width <= _currentNodeLabel.Width;
fullConnectedRow &= usesRow;
}
result["connected_node_gets_full_width"] = fullConnectedRow;
result["connected_mode_badge_does_not_cover_name"] = !_scheduleBadge.Visible; result["connected_mode_badge_does_not_cover_name"] = !_scheduleBadge.Visible;
result["zero3_name_fits_connected_row"] = TextRenderer.MeasureText(_currentNodeName, _currentNodeLabel.Font).Width <= _currentNodeLabel.Width; result["zero3_name_fits_connected_row"] = TextRenderer.MeasureText(_currentNodeName, _currentNodeLabel.Font).Width <= _currentNodeLabel.Width;
Size = MinimumSize; Size = MinimumSize;
+10 -2
View File
@@ -105,12 +105,20 @@ internal sealed class MetricCard : CardPanel
var s = DeviceDpi / 96f; var s = DeviceDpi / 96f;
int S(int n) => (int)Math.Round(n * s); int S(int n) => (int)Math.Round(n * s);
var g = e.Graphics; var g = e.Graphics;
if(Height<S(30))
{
using var denseFont=Brand.Font(8,FontStyle.Bold);
var arrow=Glyph==DashboardIcon.Download?"↓":"↑";
TextRenderer.DrawText(g,$"{arrow} {ValueText} {UnitText}",denseFont,ClientRectangle,Brand.Navy,
ChartAxis.PaintFlags|TextFormatFlags.VerticalCenter|TextFormatFlags.HorizontalCenter|TextFormatFlags.SingleLine|TextFormatFlags.EndEllipsis);
return;
}
var narrow = Width < S(180); var narrow = Width < S(180);
var shortCard = Height < S(75); var shortCard = Height < S(75);
if (!narrow) DashboardDrawing.Icon(g, Glyph, new(S(10), S(18), S(22), S(22)), Glyph == DashboardIcon.Download ? Brand.Cyan : Brand.RoyalBlue); if (!narrow) DashboardDrawing.Icon(g, Glyph, new(S(10), S(18), S(22), S(22)), Glyph == DashboardIcon.Download ? Brand.Cyan : Brand.RoyalBlue);
var x = S(narrow ? 8 : 49); var right = Width - S(8); var available = Math.Max(1, right - x); var x = S(narrow ? 8 : 49); var right = Width - S(8); var available = Math.Max(1, right - x);
using var headingFont = Brand.Font(shortCard || narrow ? 8 : 9); using var headingFont = Brand.Font(Width<S(180)?6.8f:shortCard?8:9);
using var unitFont = Brand.Font(shortCard || narrow ? 8 : 9); using var unitFont = Brand.Font(Width<S(180)?6.8f:shortCard?8:9);
using var hintFont = Brand.Font(7.2f); using var hintFont = Brand.Font(7.2f);
var paintFlags = TextFormatFlags.PreserveGraphicsTranslateTransform | TextFormatFlags.PreserveGraphicsClipping; var paintFlags = TextFormatFlags.PreserveGraphicsTranslateTransform | TextFormatFlags.PreserveGraphicsClipping;
var headingHeight = Math.Min(S(22), Math.Max(S(14), Height / 3)); var headingHeight = Math.Min(S(22), Math.Max(S(14), Height / 3));
+59 -16
View File
@@ -3,14 +3,15 @@ namespace UCVL.VPNPlus;
internal readonly record struct DashboardGeometry( internal readonly record struct DashboardGeometry(
Rectangle WelcomeLabel, Rectangle AccountLabel, Rectangle IdentityBadge, Rectangle WelcomeLabel, Rectangle AccountLabel, Rectangle IdentityBadge,
Rectangle LogoutButton, Rectangle StatusCard, Rectangle NodeCard, Rectangle ModeCard, Rectangle LogoutButton, Rectangle StatusCard, Rectangle NodeCard, Rectangle ModeCard,
Rectangle[] Metrics, Rectangle TrafficCard, Rectangle TailnetTrafficCard, Rectangle DailyCard, Rectangle ServerTrafficCard, Rectangle Footer, Rectangle[] Metrics, Rectangle TrafficCard, Rectangle TailnetTrafficCard, Rectangle SpeedTrendCard, Rectangle DailyCard, Rectangle ServerTrafficCard, Rectangle Footer,
int ContentHeight, bool Compact, float VerticalScale); int ContentHeight, bool Compact, float VerticalScale);
// Logical pixels converted once, independent of WinForms autoscaling. // Logical pixels converted once, independent of WinForms autoscaling.
internal static class DashboardLayout internal static class DashboardLayout
{ {
internal static DashboardGeometry Calculate(Size viewport, int dpi, bool showTailnet = false, bool showServerTraffic = false) internal static DashboardGeometry Calculate(Size viewport, int dpi, bool showTailnet = false, bool showServerTraffic = false, bool preferCompact = false)
{ {
if (preferCompact || viewport.Width < 720f * dpi / 96f || viewport.Height < 442f * dpi / 96f) return CalculateCompact(viewport, dpi, showTailnet, showServerTraffic);
var scale = Math.Max(1f, dpi / 96f); var scale = Math.Max(1f, dpi / 96f);
int S(int n) => (int)Math.Round(n * scale); int S(int n) => (int)Math.Round(n * scale);
// Tailnet is a subdivision of the existing speed area, not another // Tailnet is a subdivision of the existing speed area, not another
@@ -32,9 +33,12 @@ internal static class DashboardLayout
var mode = new Rectangle(node.Right + columnGap, node.Top, width - half - columnGap, node.Height); var mode = new Rectangle(node.Right + columnGap, node.Top, width - half - columnGap, node.Height);
var analyticsTop = mode.Bottom + gap; var analyticsTop = mode.Bottom + gap;
var analyticsHeight = Y(276); var analyticsHeight = Y(276);
var leftHeight = showTailnet ? (analyticsHeight - gap) / 2 : analyticsHeight; var trendHeight = Y(120);
var figuresHeight = analyticsHeight - trendHeight - gap;
var leftHeight = showTailnet ? (figuresHeight - gap) / 2 : figuresHeight;
var traffic = new Rectangle(margin, analyticsTop, half, leftHeight); var traffic = new Rectangle(margin, analyticsTop, half, leftHeight);
var tailnet = showTailnet ? new Rectangle(traffic.Left, traffic.Bottom + gap, half, analyticsHeight - leftHeight - gap) : Rectangle.Empty; var tailnet = showTailnet ? new Rectangle(traffic.Left, traffic.Bottom + gap, half, figuresHeight - leftHeight - gap) : Rectangle.Empty;
var trend = new Rectangle(margin, analyticsTop + figuresHeight + gap, half, trendHeight);
var daily = new Rectangle(traffic.Right + columnGap, analyticsTop, width - half - columnGap, analyticsHeight); var daily = new Rectangle(traffic.Right + columnGap, analyticsTop, width - half - columnGap, analyticsHeight);
Rectangle Metric(Rectangle parent, int column, bool speed) => new( Rectangle Metric(Rectangle parent, int column, bool speed) => new(
S(10) + column * ((parent.Width - S(20)) / 2), S(10) + column * ((parent.Width - S(20)) / 2),
@@ -42,41 +46,80 @@ internal static class DashboardLayout
(parent.Width - S(20)) / 2 - S(1), (parent.Width - S(20)) / 2 - S(1),
speed ? Math.Min(Y(82), parent.Height - Y(44)) : Y(82)); speed ? Math.Min(Y(82), parent.Height - Y(44)) : Y(82));
// Relative to their matching chart card: totals together; speeds together. // Relative to their matching chart card: totals together; speeds together.
Rectangle[] metrics = [Metric(daily, 0, false), Metric(traffic, 0, true), Metric(traffic, 1, true), Metric(daily, 1, false)]; Rectangle Total(int row) => new(S(14), Y(40 + row * 112), daily.Width - S(28), Y(98));
Rectangle[] metrics = [Total(0), Metric(traffic, 0, true), Metric(traffic, 1, true), Total(1)];
var serverTraffic = showServerTraffic ? new Rectangle(margin, daily.Bottom + gap, width, Y(94)) : Rectangle.Empty; var serverTraffic = showServerTraffic ? new Rectangle(margin, daily.Bottom + gap, width, Y(94)) : Rectangle.Empty;
var footer = new Rectangle(margin, (showServerTraffic ? serverTraffic.Bottom : daily.Bottom) + gap, width, Y(76)); var footer = new Rectangle(margin, (showServerTraffic ? serverTraffic.Bottom : daily.Bottom) + gap, width, Y(76));
return new(welcome, account, identity, logout, status, node, mode, metrics, traffic, return new(welcome, account, identity, logout, status, node, mode, metrics, traffic,
tailnet, daily, serverTraffic, footer, Math.Min(viewport.Height, footer.Bottom + Y(12)), compact, verticalScale); tailnet, trend, daily, serverTraffic, footer, Math.Min(viewport.Height, footer.Bottom + Y(12)), compact, verticalScale);
}
private static DashboardGeometry CalculateCompact(Size viewport, int dpi, bool showTailnet, bool showServers)
{
var scale = Math.Max(1f, dpi / 96f);
int S(int n) => (int)Math.Round(n * scale);
var margin = S(8); var gap = S(4);
var width = Math.Max(S(400), viewport.Width - margin * 2);
var leftWidth = (int)Math.Round((width-gap)*.61);
var welcome = new Rectangle(margin, S(1), width-S(90), S(15));
var account = new Rectangle(margin, S(16), S(175), S(12));
var identity = new Rectangle(account.Right+gap, S(16), S(58), S(12));
var logout = new Rectangle(margin+width-S(70), S(3), S(70), S(23));
var status = new Rectangle(margin, S(30), width, S(40));
var node = new Rectangle(margin, S(74), leftWidth, S(42));
var mode = new Rectangle(node.Right+gap,node.Top,width-leftWidth-gap,node.Height);
var footer = new Rectangle(margin, viewport.Height-S(26), width, S(22));
var server = showServers ? new Rectangle(margin,footer.Top-gap-S(34),width,S(34)) : Rectangle.Empty;
var bottom = (showServers?server.Top:footer.Top)-gap;
var analyticsTop=S(120);
var height=Math.Max(S(112),bottom-analyticsTop);
var statsHeight=showTailnet?S(30):S(60);
var traffic=new Rectangle(margin,analyticsTop,leftWidth,statsHeight);
var tailnet=showTailnet?new Rectangle(margin,traffic.Bottom+gap,leftWidth,S(30)):Rectangle.Empty;
var trendTop=(showTailnet?tailnet.Bottom:traffic.Bottom)+gap;
var trend=new Rectangle(margin,trendTop,leftWidth,analyticsTop+height-trendTop);
var daily=new Rectangle(mode.Left,analyticsTop,mode.Width,height);
var totalHeight=(daily.Height-S(22))/2;
Rectangle Total(int row)=>new(S(5),S(20)+row*totalHeight,daily.Width-S(10),totalHeight-S(2));
var metricWidth=(traffic.Width-S(8))/2;
var metricTop=showTailnet?S(11):S(15);
var metricHeight=traffic.Height-metricTop-S(1);
Rectangle Speed(int col)=>new(S(4)+col*metricWidth,metricTop,metricWidth-S(1),metricHeight);
Rectangle[] metrics=[Total(0),Speed(0),Speed(1),Total(1)];
return new(welcome,account,identity,logout,status,node,mode,metrics,traffic,tailnet,trend,daily,server,footer,
viewport.Height,true,1f);
} }
internal static bool SelfTest() internal static bool SelfTest()
{ {
foreach (var dpi in new[] { 96, 120, 144, 168, 192, 240, 288, 336, 384 }) foreach (var dpi in new[] { 96, 120, 144, 168, 192, 240, 288, 336, 384 })
foreach (var width in new[] { 600, 620, 739, 760, 780, 900, 1100, 1600 }) foreach (var width in new[] { 480, 600, 620, 739, 760, 780, 900, 1100, 1600 })
foreach (var height in new[] { 350, 418, 560, 720 }) foreach (var height in new[] { 312, 350, 418, 560, 720 })
foreach (var showTailnet in new[] { false, true }) foreach (var showTailnet in new[] { false, true })
foreach (var showServers in new[] { false, true }) foreach (var showServers in new[] { false, true })
{ {
var viewport = new Size(width * dpi / 96, height * dpi / 96); var viewport = new Size(width * dpi / 96, height * dpi / 96);
var p = Calculate(viewport, dpi, showTailnet, showServers); var p = Calculate(viewport, dpi, showTailnet, showServers);
Rectangle[] cards = showTailnet Rectangle[] cards = [p.StatusCard,p.NodeCard,p.ModeCard,p.TrafficCard,p.SpeedTrendCard,p.DailyCard,p.Footer];
? [p.StatusCard, p.NodeCard, p.ModeCard, p.TrafficCard, p.TailnetTrafficCard, p.DailyCard, p.Footer] if(showTailnet)cards=[..cards,p.TailnetTrafficCard];
: [p.StatusCard, p.NodeCard, p.ModeCard, p.TrafficCard, p.DailyCard, p.Footer]; if(showServers)cards=[..cards,p.ServerTrafficCard];
if (showServers) cards = [..cards, p.ServerTrafficCard]; if (cards.Any(c => c.Left < 0 || c.Right > viewport.Width || c.Bottom > p.ContentHeight || c.Width <= 0 || c.Height<=0)) return false;
if (cards.Any(c => c.Left < 0 || c.Right > viewport.Width || c.Bottom > p.ContentHeight || c.Width <= 0)) return false;
for (var i = 0; i < cards.Length; i++) for (var i = 0; i < cards.Length; i++)
for (var j = i + 1; j < cards.Length; j++) for (var j = i + 1; j < cards.Length; j++)
if (cards[i].IntersectsWith(cards[j])) return false; if (cards[i].IntersectsWith(cards[j])) return false;
if (p.WelcomeLabel.IntersectsWith(p.LogoutButton) || p.AccountLabel.IntersectsWith(p.IdentityBadge)) return false; if (p.WelcomeLabel.IntersectsWith(p.LogoutButton) || p.AccountLabel.IntersectsWith(p.IdentityBadge)) return false;
if (p.Metrics[0].IntersectsWith(p.Metrics[3]) || p.Metrics[1].IntersectsWith(p.Metrics[2])) return false; if (p.Metrics[0].IntersectsWith(p.Metrics[3]) || p.Metrics[1].IntersectsWith(p.Metrics[2])) return false;
for (var i = 0; i < p.Metrics.Length; i++) for (var i = 0; i < p.Metrics.Length; i++)
if (p.Metrics[i].Right > (i == 0 || i == 3 ? p.DailyCard.Width : p.TrafficCard.Width)) return false; {
var parent=i==0||i==3?p.DailyCard:p.TrafficCard;
if(p.Metrics[i].Left<0||p.Metrics[i].Top<0||p.Metrics[i].Right>parent.Width||p.Metrics[i].Bottom>parent.Height)return false;
}
if (!showTailnet && p.TailnetTrafficCard != Rectangle.Empty) return false; if (!showTailnet && p.TailnetTrafficCard != Rectangle.Empty) return false;
if (p.ContentHeight > viewport.Height || p.Footer.Bottom > viewport.Height) return false; if (p.ContentHeight > viewport.Height || p.Footer.Bottom > viewport.Height) return false;
var baseline = Calculate(viewport, dpi, false, showServers); var baseline = Calculate(viewport, dpi, false, showServers);
if (p.DailyCard != baseline.DailyCard || p.Footer != baseline.Footer || p.ContentHeight != baseline.ContentHeight) return false; if (p.DailyCard != baseline.DailyCard || p.Footer != baseline.Footer || p.ContentHeight != baseline.ContentHeight) return false;
if (showTailnet && (p.TailnetTrafficCard.Top <= p.TrafficCard.Bottom if (showTailnet && (p.TailnetTrafficCard.Top <= p.TrafficCard.Bottom || p.SpeedTrendCard.Top<=p.TailnetTrafficCard.Bottom)) return false;
|| p.DailyCard.Top != p.TrafficCard.Top || p.DailyCard.Bottom != p.TailnetTrafficCard.Bottom)) return false; if(p.SpeedTrendCard.Bottom!=p.DailyCard.Bottom)return false;
if (showServers && (p.ServerTrafficCard.Top <= p.DailyCard.Bottom || p.ServerTrafficCard.Bottom >= p.Footer.Top)) return false; if (showServers && (p.ServerTrafficCard.Top <= p.DailyCard.Bottom || p.ServerTrafficCard.Bottom >= p.Footer.Top)) return false;
} }
return true; return true;
+14 -5
View File
@@ -7,17 +7,17 @@ internal sealed partial class MainForm
{ {
var checks = new Dictionary<string, bool>(); var checks = new Dictionary<string, bool>();
var originalSize = ClientSize; var originalSize = ClientSize;
foreach (var size in new[] { new Size(960, 720), new Size(620, 550), new Size(900, 640) }) foreach (var size in new[] { new Size(480, 360), new Size(900, 360), new Size(960, 720), new Size(620, 550), new Size(900, 640) })
{ {
ClientSize = new Size(ScaleLogical(size.Width), ScaleLogical(size.Height)); ClientSize = new Size(ScaleLogical(size.Width), ScaleLogical(size.Height));
SetTailnetTrafficVisibility(false); LayoutDashboard(); SetTailnetTrafficVisibility(false); LayoutDashboard();
var baseline = (_trafficCard.Bounds, _dailyCard.Bounds, _footer.Bounds, _dashboardBody.Size); var baseline = (_trafficCard.Bounds, _dailyCard.Bounds, _footer.Bounds, _dashboardBody.Size);
checks[$"no_tailnet_single_left_{size.Width}"] = !_tailnetTrafficCard.Visible checks[$"no_tailnet_single_left_{size.Width}"] = !_tailnetTrafficCard.Visible
&& _trafficCard.Top == _dailyCard.Top && _trafficCard.Bottom == _dailyCard.Bottom; && _trafficCard.Top == _dailyCard.Top && _speedTrendCard.Bottom == _dailyCard.Bottom;
SetTailnetTrafficVisibility(true); SetTailnetTrafficVisibility(true);
checks[$"tailnet_only_subdivides_left_{size.Width}"] = _tailnetTrafficCard.Left == _trafficCard.Left checks[$"tailnet_only_subdivides_left_{size.Width}"] = _tailnetTrafficCard.Left == _trafficCard.Left
&& _tailnetTrafficCard.Width == _trafficCard.Width && _tailnetTrafficCard.Top > _trafficCard.Bottom && _tailnetTrafficCard.Width == _trafficCard.Width && _tailnetTrafficCard.Top > _trafficCard.Bottom
&& _dailyCard.Top == _trafficCard.Top && _dailyCard.Bottom == _tailnetTrafficCard.Bottom; && _dailyCard.Top == _trafficCard.Top && _dailyCard.Bottom == _speedTrendCard.Bottom;
checks[$"tailnet_never_increases_page_{size.Width}"] = _dailyCard.Bounds == baseline.Item2 checks[$"tailnet_never_increases_page_{size.Width}"] = _dailyCard.Bounds == baseline.Item2
&& _footer.Bounds == baseline.Item3 && _dashboardBody.Size == baseline.Item4 && _footer.Bounds == baseline.Item3 && _dashboardBody.Size == baseline.Item4
&& !_dashboardScrollBar.Visible && _dashboardBody.Location == Point.Empty; && !_dashboardScrollBar.Visible && _dashboardBody.Location == Point.Empty;
@@ -26,6 +26,14 @@ internal sealed partial class MainForm
checks[$"tailnet_hide_restores_geometry_{size.Width}"] = _trafficCard.Bounds == baseline.Item1 checks[$"tailnet_hide_restores_geometry_{size.Width}"] = _trafficCard.Bounds == baseline.Item1
&& _dailyCard.Bounds == baseline.Item2 && _footer.Bounds == baseline.Item3; && _dailyCard.Bounds == baseline.Item2 && _footer.Bounds == baseline.Item3;
} }
ClientSize=new Size(ScaleLogical(480),ScaleLogical(360));
_connectionModeCombo.SelectedIndex=1;
if(_manualNodeCombo.Items.Count>0)_manualNodeCombo.SelectedIndex=0;
RefreshSelectionControls(); LayoutDashboard();
checks["half_size_manual_node_does_not_overlap_mode_selector"] = !_manualNodeCombo.Visible
|| (!_manualNodeCombo.Bounds.IntersectsWith(_connectionModeCombo.Bounds)
&& _manualNodeCombo.Bottom<=_nodeCard.Height);
_connectionModeCombo.SelectedIndex=0;
SetTailnetTrafficVisibility(true); SetTailnetTrafficVisibility(true);
var proxyValue = _uploadMetric.ValueText; var proxyValue = _uploadMetric.ValueText;
var session = (_sessionUp, _sessionDown); var session = (_sessionUp, _sessionDown);
@@ -44,9 +52,10 @@ internal sealed partial class MainForm
SetTailnetTrafficVisibility(false); SetTailnetTrafficVisibility(true); SetTailnetTrafficVisibility(false); SetTailnetTrafficVisibility(true);
checks["tailnet_hide_clears_previous_numbers"] = _tailnetUploadMetric.ValueText == "—" checks["tailnet_hide_clears_previous_numbers"] = _tailnetUploadMetric.ValueText == "—"
&& _tailnetDownloadMetric.ValueText == "—"; && _tailnetDownloadMetric.ValueText == "—";
checks["only_one_speed_curve_on_right"] = !_trafficCard.Controls.OfType<TrafficChart>().Any() checks["cumulative_is_numeric_only_proxy_has_speed_curve"] = !_dailyCard.Controls.OfType<TrafficChart>().Any()
&& !_trafficCard.Controls.OfType<TrafficChart>().Any()
&& !_tailnetTrafficCard.Controls.OfType<TrafficChart>().Any() && !_tailnetTrafficCard.Controls.OfType<TrafficChart>().Any()
&& _dailyCard.Controls.OfType<TrafficChart>().Single() == _trafficChart && _speedTrendCard.Controls.OfType<TrafficChart>().Single() == _trafficChart
&& _dailyChart.Parent is null && !_dailyChart.Visible; && _dailyChart.Parent is null && !_dailyChart.Visible;
UpdateConnectedTransportPresentation(true); UpdateConnectedTransportPresentation(true);
DisplayTraffic(1024, 2048, "互斥入口样本"); DisplayTraffic(1024, 2048, "互斥入口样本");
+135
View File
@@ -0,0 +1,135 @@
namespace UCVL.VPNPlus;
internal sealed partial class MainForm
{
// A compact logical canvas; native DPI scaling still happens exactly once.
private bool CompactPresentation => ClientSize.Width < ScaleLogical(720) || ClientSize.Height < ScaleLogical(550);
private readonly Font _compactStatusFont=Brand.Font(10,FontStyle.Bold);
private readonly Font _compactChartFont=Brand.Font(6.5f);
private readonly Dictionary<Control, (Font Original, Font? Compact)> _presentationFonts = new();
private bool _presentationFontsDisposed;
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if(!disposing || _presentationFontsDisposed)return;
_presentationFontsDisposed=true;
foreach(var fonts in _presentationFonts.Values)fonts.Compact?.Dispose();
_presentationFonts.Clear();
_compactStatusFont.Dispose();
_compactChartFont.Dispose();
}
private void SetStatusTitleFont(float size)
{
if(CompactPresentation && ReferenceEquals(_statusTitle.Font,_compactStatusFont))return;
if(!CompactPresentation && !ReferenceEquals(_statusTitle.Font,_compactStatusFont)
&& Math.Abs(_statusTitle.Font.SizeInPoints-size)<.1f)return;
var previous=_statusTitle.Font;
_statusTitle.Font=CompactPresentation?_compactStatusFont:Brand.Font(size,FontStyle.Bold);
if(!ReferenceEquals(previous,_compactStatusFont))previous.Dispose();
}
private void ApplyCompactTypography()
{
void Visit(Control parent)
{
foreach (Control control in parent.Controls)
{
if (control is CaptionButton || ReferenceEquals(control,_statusTitle)) continue;
if (!_presentationFonts.TryGetValue(control, out var fonts))
{
var original = control.Font;
fonts = (original, new Font(original.FontFamily, Math.Max(6.5f, original.SizeInPoints * .78f), original.Style));
_presentationFonts.Add(control, fonts);
}
control.Font = CompactPresentation ? fonts.Compact! : fonts.Original;
Visit(control);
}
}
Visit(this);
}
private void LayoutCompactHeader()
{
int S(int n) => ScaleLogical(n);
_brandHeader.Height=S(48);
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));
}
_headerPoem.Visible=false;
LayoutWindowChrome();
}
private void LayoutCompactLogin()
{
int S(int n)=>ScaleLogical(n);
_loginView.Size=new(S(400),S(280));
foreach(Control control in _loginView.Controls)
if(control.Tag is Rectangle r)
control.Bounds=new(S((int)Math.Round(r.X*400d/440)),S((int)Math.Round(r.Y*.72)),
S((int)Math.Round(r.Width*400d/440)),S(Math.Max(14,(int)Math.Round(r.Height*.72))));
// Text boxes and the primary action keep comfortable compact hit areas.
_loginText.Parent!.Bounds=new(S(25),S(65),S(350),S(29));
_passwordText.Parent!.Bounds=new(S(25),S(117),S(350),S(29));
_loginButton.Bounds=new(S(25),S(160),S(350),S(31));
var flags=TextFormatFlags.SingleLine;
var prompt=TextRenderer.MeasureText(_registerPrompt.Text,_registerPrompt.Font,Size.Empty,flags);
var link=TextRenderer.MeasureText(_registerLink.Text,_registerLink.Font,Size.Empty,flags);
var rowWidth=prompt.Width+link.Width+S(16);
var left=(_loginView.Width-rowWidth)/2;
_registerPrompt.Bounds=new(left,S(199),prompt.Width+S(4),S(20));
_registerLink.Bounds=new(_registerPrompt.Right+S(8),S(199),link.Width+S(4),S(20));
foreach(Control control in _loginView.Controls)
{
if(control is Label label && label.Text.StartsWith("浏览器完成注册"))control.Bounds=new(S(20),S(226),S(360),S(18));
}
_loginError.Bounds=new(S(20),S(248),S(360),S(24));
_loginView.Left=Math.Max(S(8),(_content.Width-_loginView.Width)/2);
_loginView.Top=Math.Max(S(8),(_content.Height-_loginView.Height)/2);
}
private void LayoutCompactDashboard(DashboardGeometry layout)
{
int S(int n)=>ScaleLogical(n);
Rectangle R(int x,int y,int w,int h)=>new(S(x),S(y),S(w),S(h));
_statusDot.Bounds=R(10,8,24,24);
_connectButton.Bounds=new(_statusCard.Width-S(68),S(7),S(60),S(26));
_statusTitle.Bounds=new(S(42),S(1),_statusCard.Width-S(116),S(21));
_statusDetail.Bounds=new(S(42),S(22),_statusCard.Width-S(116),S(15));
_nodeIcon.Visible=_modeIcon.Visible=false;
_nodeHeading.Bounds=R(8,0,122,15);
_nodeHeading.Text="工作节点";
_connectionModeCombo.Bounds=new(_nodeCard.Width-S(102),S(1),S(96),S(18));
_manualNodeCombo.Bounds=new(S(8),S(22),_nodeCard.Width-S(16),S(19));
_currentNodeLabel.Bounds=new(S(8),S(23),_nodeCard.Width-S(16),S(17));
_scheduleBadge.Visible=false;
_routeHeading.Bounds=new(S(8),0,_modeCard.Width-S(16),S(14));
_routeCombo.Bounds=new(S(8),S(14),_modeCard.Width-S(16),S(20));
_routeReadOnly.Bounds=_routeCombo.Bounds;
_trafficIcon.Visible=_dailyIcon.Visible=_tailnetTrafficIcon.Visible=false;
_trafficHeading.Bounds=new(S(6),0,_trafficCard.Width-S(12),S(13));
_dailyHeading.Bounds=new(S(7),S(2),_dailyCard.Width-S(14),S(17));
_tailnetTrafficHeading.Bounds=new(S(6),0,_tailnetTrafficCard.Width-S(12),S(13));
if(_tailnetTrafficVisible)
{
var width=(_tailnetTrafficCard.Width-S(8))/2;
_tailnetUploadMetric.Bounds=new(S(4),S(11),width-S(1),S(18));
_tailnetDownloadMetric.Bounds=new(S(4)+width,S(11),width-S(1),S(18));
}
_trendHeading.Bounds=new(S(6),0,_speedTrendCard.Width-S(88),S(15));
_historyRangeCombo.Bounds=new(_speedTrendCard.Width-S(82),0,S(77),S(19));
_trafficChart.Font=_compactChartFont;
_trafficChart.Bounds=new(S(1),S(18),_speedTrendCard.Width-S(3),Math.Max(S(30),_speedTrendCard.Height-S(19)));
_uploadLegend.Visible=_downloadLegend.Visible=_historyStatus.Visible=false;
_sampleLabel.Visible=false;
_planLabel.Bounds=new(0,0,_footer.Width-S(75),S(11));
_expiryLabel.Bounds=new(_footer.Width-S(72),0,S(72),S(11));
_footerCompanySite.Bounds=new(0,S(11),S(210),S(11));
_footerHint.Bounds=new(_footer.Width-S(205),S(11),S(205),S(11));
_footerPoem.Visible=false;
_dashboardBody.Size=_dashboardView.ClientSize;
_dashboardBody.Location=Point.Empty;
}
}
+47 -28
View File
@@ -26,7 +26,8 @@ internal sealed partial class MainForm
private readonly MetricCard _sessionMetric = new("本次代理流量", DashboardIcon.Document); private readonly MetricCard _sessionMetric = new("本次代理流量", DashboardIcon.Document);
private readonly DashboardGlyph _nodeIcon = new(DashboardIcon.Server), _modeIcon = new(DashboardIcon.Settings); private readonly DashboardGlyph _nodeIcon = new(DashboardIcon.Server), _modeIcon = new(DashboardIcon.Settings);
private readonly DashboardGlyph _trafficIcon = new(DashboardIcon.Chart), _dailyIcon = new(DashboardIcon.History); private readonly DashboardGlyph _trafficIcon = new(DashboardIcon.Chart), _dailyIcon = new(DashboardIcon.History);
private readonly Label _trafficHeading = new(), _dailyHeading = new(); private readonly Label _trafficHeading = new(), _dailyHeading = new(), _trendHeading = new();
private readonly CardPanel _speedTrendCard = new();
private bool _layingOutDashboard; private bool _layingOutDashboard;
private sealed record SpeedHistoryPeriod(int Minutes, string Label) private sealed record SpeedHistoryPeriod(int Minutes, string Label)
{ {
@@ -96,7 +97,7 @@ internal sealed partial class MainForm
ConfigureLabel(_trafficHeading, "公网入口速度", Brand.Font(9.5f, FontStyle.Bold), Brand.Text); ConfigureLabel(_trafficHeading, "公网入口速度", Brand.Font(9.5f, FontStyle.Bold), Brand.Text);
_trafficCard.AccessibleDescription = "仅当前纵横家使用域名或公网入口的代理速度;Tailscale 入口速度另列,非整机流量。"; _trafficCard.AccessibleDescription = "仅当前纵横家使用域名或公网入口的代理速度;Tailscale 入口速度另列,非整机流量。";
ConfigureLabel(_dailyHeading, "速度与累计", Brand.Font(9.5f, FontStyle.Bold), Brand.Text); ConfigureLabel(_dailyHeading, "累计流量", Brand.Font(9.5f, FontStyle.Bold), Brand.Text);
ConfigureLabel(_sampleLabel, "仅代理流量 · 近 5 分钟", Brand.Font(7.5f), Brand.Muted); ConfigureLabel(_sampleLabel, "仅代理流量 · 近 5 分钟", Brand.Font(7.5f), Brand.Muted);
_sampleLabel.TextAlign = ContentAlignment.MiddleRight; _sampleLabel.TextAlign = ContentAlignment.MiddleRight;
ConfigureLabel(_uploadLegend, "● 上传 —", Brand.Font(8), Brand.RoyalBlue); ConfigureLabel(_uploadLegend, "● 上传 —", Brand.Font(8), Brand.RoyalBlue);
@@ -104,9 +105,11 @@ internal sealed partial class MainForm
ConfigureLabel(_historyStatus, "仅本次运行采样 · B/s", Brand.Font(7), Brand.Muted); ConfigureLabel(_historyStatus, "仅本次运行采样 · B/s", Brand.Font(7), Brand.Muted);
_historyStatus.AutoEllipsis = true; _historyStatus.AutoEllipsis = true;
_historyStatus.TextAlign = ContentAlignment.MiddleRight; _historyStatus.TextAlign = ContentAlignment.MiddleRight;
_historyStatus.AccessibleDescription = "右侧曲线仅为当前客户端实际采集的代理速度。累计数值来自套餐和本次连接,不随速度时间范围改变。"; _historyStatus.AccessibleDescription = "代理速度曲线仅为当前客户端实际采集的代理速度;右侧累计区只显示统计数字。";
ConfigureLabel(_trendHeading, "代理速度趋势", Brand.Font(8, FontStyle.Bold), Brand.Text);
_trafficCard.Controls.AddRange([_trafficIcon, _trafficHeading]); _trafficCard.Controls.AddRange([_trafficIcon, _trafficHeading]);
_dailyCard.Controls.AddRange([_dailyIcon, _dailyHeading, _trafficChart, _uploadLegend, _downloadLegend]); _dailyCard.Controls.AddRange([_dailyIcon, _dailyHeading]);
_speedTrendCard.Controls.AddRange([_trendHeading, _trafficChart, _uploadLegend, _downloadLegend]);
// Keep backend accounting data available to UpdateProfile, but daily // Keep backend accounting data available to UpdateProfile, but daily
// byte totals are no longer drawn as a misleading speed history. // byte totals are no longer drawn as a misleading speed history.
_dailyChart.Visible = false; _dailyChart.Visible = false;
@@ -131,7 +134,7 @@ internal sealed partial class MainForm
{ {
if (_historyRangeCombo.SelectedItem is SpeedHistoryPeriod period) _trafficChart.SetPeriodMinutes(period.Minutes); if (_historyRangeCombo.SelectedItem is SpeedHistoryPeriod period) _trafficChart.SetPeriodMinutes(period.Minutes);
}; };
_dailyCard.Controls.AddRange([_historyRangeCombo, _historyStatus]); _speedTrendCard.Controls.AddRange([_historyRangeCombo, _historyStatus]);
ConfigureLabel(_planLabel, "", Brand.Font(8.5f), Brand.Muted); ConfigureLabel(_planLabel, "", Brand.Font(8.5f), Brand.Muted);
ConfigureLabel(_expiryLabel, "", Brand.Font(8.5f), Brand.Muted); ConfigureLabel(_expiryLabel, "", Brand.Font(8.5f), Brand.Muted);
ConfigureLabel(_footerHint, "仅限内部使用,不作商业使用。", Brand.Font(9, FontStyle.Bold), Brand.DeepBlue); ConfigureLabel(_footerHint, "仅限内部使用,不作商业使用。", Brand.Font(9, FontStyle.Bold), Brand.DeepBlue);
@@ -143,7 +146,7 @@ internal sealed partial class MainForm
ConfigureLabel(_footerCompanySite, "vpn.example.invalid", Brand.Font(8), Brand.Muted); ConfigureLabel(_footerCompanySite, "vpn.example.invalid", Brand.Font(8), Brand.Muted);
_footerCompanyLogo.BackColor = Color.Transparent; _footerCompanyLogo.BackColor = Color.Transparent;
_footer.Controls.AddRange([_planLabel, _expiryLabel, _footerHint, _footerPoem, _footerCompanyLogo, _footerCompanySite]); _footer.Controls.AddRange([_planLabel, _expiryLabel, _footerHint, _footerPoem, _footerCompanyLogo, _footerCompanySite]);
foreach (var card in new CardPanel[] { _statusCard, _nodeCard, _modeCard, _trafficCard, _dailyCard }) foreach (var card in new CardPanel[] { _statusCard, _nodeCard, _modeCard, _trafficCard, _speedTrendCard, _dailyCard })
{ {
card.BackColor = Color.White; card.BackColor = Color.White;
_dashboardBody.Controls.Add(card); _dashboardBody.Controls.Add(card);
@@ -185,19 +188,15 @@ internal sealed partial class MainForm
{ {
if (_layingOutDashboard || _dashboardView.ClientSize.Width <= 0) return; if (_layingOutDashboard || _dashboardView.ClientSize.Width <= 0) return;
_layingOutDashboard = true; _layingOutDashboard = true;
Control[] layoutContainers = [_dashboardView, _dashboardBody, _statusCard, _nodeCard, _modeCard, _trafficCard, _tailnetTrafficCard, _dailyCard, _nodeTrafficPanel, _footer]; Control[] layoutContainers = [_dashboardView, _dashboardBody, _statusCard, _nodeCard, _modeCard, _trafficCard, _tailnetTrafficCard, _speedTrendCard, _dailyCard, _nodeTrafficPanel, _footer];
foreach (var container in layoutContainers) container.SuspendLayout(); foreach (var container in layoutContainers) container.SuspendLayout();
try try
{ {
ApplyCompactTypography();
var viewport = _dashboardView.ClientSize; var viewport = _dashboardView.ClientSize;
var layout = DashboardLayout.Calculate(viewport, DeviceDpi, _tailnetTrafficVisible, _canViewNodeTraffic); var layout = DashboardLayout.Calculate(viewport, DeviceDpi, _tailnetTrafficVisible, _canViewNodeTraffic, CompactPresentation);
var titleSize = 17f * Math.Max(.7f, layout.VerticalScale); var titleSize = CompactPresentation ? 10f : 17f * Math.Max(.7f, layout.VerticalScale);
if (Math.Abs(_statusTitle.Font.Size - titleSize) > .1f) SetStatusTitleFont(titleSize);
{
var previousTitleFont = _statusTitle.Font;
_statusTitle.Font = Brand.Font(titleSize, FontStyle.Bold);
previousTitleFont.Dispose();
}
_dashboardScrollBar.Visible = false; _dashboardScrollBar.Visible = false;
_dashboardScrollBar.Value = 0; _dashboardScrollBar.Value = 0;
_dashboardScrollBar.Maximum = 0; _dashboardScrollBar.Maximum = 0;
@@ -209,10 +208,15 @@ internal sealed partial class MainForm
Place(_statusCard, layout.StatusCard); Place(_nodeCard, layout.NodeCard); Place(_modeCard, layout.ModeCard); Place(_statusCard, layout.StatusCard); Place(_nodeCard, layout.NodeCard); Place(_modeCard, layout.ModeCard);
var metrics = new[] { _usageMetric, _uploadMetric, _downloadMetric, _sessionMetric }; var metrics = new[] { _usageMetric, _uploadMetric, _downloadMetric, _sessionMetric };
for (var i = 0; i < 4; i++) Place(metrics[i], layout.Metrics[i]); for (var i = 0; i < 4; i++) Place(metrics[i], layout.Metrics[i]);
Place(_trafficCard, layout.TrafficCard); Place(_dailyCard, layout.DailyCard); Place(_footer, layout.Footer); Place(_trafficCard, layout.TrafficCard); Place(_speedTrendCard, layout.SpeedTrendCard); Place(_dailyCard, layout.DailyCard); Place(_footer, layout.Footer);
Place(_nodeTrafficPanel, layout.ServerTrafficCard); Place(_nodeTrafficPanel, layout.ServerTrafficCard);
LayoutTailnetTrafficCard(layout.TailnetTrafficCard, layout.VerticalScale); LayoutTailnetTrafficCard(layout.TailnetTrafficCard, layout.VerticalScale);
if (CompactPresentation) { LayoutCompactDashboard(layout); return; }
_nodeIcon.Visible=_modeIcon.Visible=_trafficIcon.Visible=_dailyIcon.Visible=true;
_uploadLegend.Visible=_downloadLegend.Visible=true;
_tailnetTrafficIcon.Visible=true;
_scheduleBadge.Visible=!_manualNodeCombo.Visible&&!_selectionUiConnected;
_statusDot.Bounds = R(24, 15, 42, 46); _statusDot.Bounds = R(24, 15, 42, 46);
_connectButton.Bounds = new(_statusCard.Width - ScaleLogical(148), Y(17), ScaleLogical(130), Y(42)); _connectButton.Bounds = new(_statusCard.Width - ScaleLogical(148), Y(17), ScaleLogical(130), Y(42));
var textWidth = _connectButton.Left - ScaleLogical(100); var textWidth = _connectButton.Left - ScaleLogical(100);
@@ -234,12 +238,13 @@ internal sealed partial class MainForm
_trafficIcon.Bounds = R(15, 10, 20, 20); _dailyIcon.Bounds = R(15, 10, 20, 20); _trafficIcon.Bounds = R(15, 10, 20, 20); _dailyIcon.Bounds = R(15, 10, 20, 20);
_trafficHeading.Bounds = R(42, 8, 150, 26); _trafficHeading.Bounds = R(42, 8, 150, 26);
_dailyHeading.Bounds = new(ScaleLogical(42), Y(8), Math.Max(1, _dailyCard.Width - ScaleLogical(166)), Y(26)); _dailyHeading.Bounds = new(ScaleLogical(42), Y(8), Math.Max(1, _dailyCard.Width - ScaleLogical(166)), Y(26));
_historyRangeCombo.Bounds = new(_dailyCard.Width - ScaleLogical(120), Y(8), ScaleLogical(106), Y(26)); _trendHeading.Bounds = new(ScaleLogical(10),Y(4),Math.Max(1,_speedTrendCard.Width-ScaleLogical(132)),Y(21));
_trafficChart.Bounds = new(ScaleLogical(10), Y(127), _dailyCard.Width - ScaleLogical(20), Y(105)); _historyRangeCombo.Bounds = new(_speedTrendCard.Width-ScaleLogical(110),Y(3),ScaleLogical(100),Y(24));
var legendWidth = (_dailyCard.Width - ScaleLogical(28)) / 2; _trafficChart.Bounds = new(ScaleLogical(5),Y(28),_speedTrendCard.Width-ScaleLogical(10),Math.Max(Y(38),_speedTrendCard.Height-Y(50)));
_uploadLegend.Bounds = new(ScaleLogical(14), Y(234), legendWidth, Y(19)); var legendWidth = (_speedTrendCard.Width-ScaleLogical(16))/2;
_downloadLegend.Bounds = new(ScaleLogical(14) + legendWidth, Y(234), legendWidth, Y(19)); _uploadLegend.Bounds = new(ScaleLogical(8),_speedTrendCard.Height-Y(20),legendWidth,Y(18));
_historyStatus.Bounds = new(ScaleLogical(14), Y(255), _dailyCard.Width - ScaleLogical(28), Y(17)); _downloadLegend.Bounds = new(ScaleLogical(8)+legendWidth,_speedTrendCard.Height-Y(20),legendWidth,Y(18));
_historyStatus.Visible=false;
_planLabel.Bounds = R(0, 4, 300, 26); _planLabel.Bounds = R(0, 4, 300, 26);
_expiryLabel.Bounds = R(306, 4, 132, 26); _expiryLabel.Bounds = R(306, 4, 132, 26);
_footerCompanyLogo.Bounds = R(0, 34, 32, 34); _footerCompanyLogo.Bounds = R(0, 34, 32, 34);
@@ -300,6 +305,12 @@ internal sealed partial class MainForm
image.Save(Path.Combine(AppContext.BaseDirectory, $"preview-{GetDisplayVersion()}-{suffix}.png")); image.Save(Path.Combine(AppContext.BaseDirectory, $"preview-{GetDisplayVersion()}-{suffix}.png"));
} }
Capture("dashboard"); Capture("dashboard");
checks["default_window_width_and_height_halved"] = form.ClientSize==new Size(form.ScaleLogical(480),form.ScaleLogical(360));
checks["cumulative_card_has_only_numeric_metrics"] = !form._dailyCard.Controls.OfType<TrafficChart>().Any()
&& form._usageMetric.Parent==form._dailyCard && form._sessionMetric.Parent==form._dailyCard;
checks["proxy_speed_has_independent_trend_card"] = form._trafficChart.Parent==form._speedTrendCard
&& form._speedTrendCard.Left==form._trafficCard.Left && form._speedTrendCard.Top>form._trafficCard.Bottom;
form._currentNodeName = NodePresentation.JinanName; form._currentNodeName = NodePresentation.JinanName;
form._currentNodeLabel.Text = form._currentNodeName; form._currentNodeLabel.Text = form._currentNodeName;
form.SetConnectionState(true, "已安全连接", form._currentNodeName + " · AI 智能代理"); form.SetConnectionState(true, "已安全连接", form._currentNodeName + " · AI 智能代理");
@@ -312,21 +323,21 @@ internal sealed partial class MainForm
&& !form._footerCompanySite.Text.Contains("vpn.", StringComparison.OrdinalIgnoreCase) && !form._footerCompanySite.Text.Contains("vpn.", StringComparison.OrdinalIgnoreCase)
&& !form._footerCompanySite.Text.Contains("://", StringComparison.OrdinalIgnoreCase); && !form._footerCompanySite.Text.Contains("://", StringComparison.OrdinalIgnoreCase);
checks["official_header_logo_preserved"] = form._brandHeader.Controls.OfType<PictureBox>().Any(logo => logo.Visible && logo.Image is not null checks["official_header_logo_preserved"] = form._brandHeader.Controls.OfType<PictureBox>().Any(logo => logo.Visible && logo.Image is not null
&& logo.SizeMode == PictureBoxSizeMode.Zoom && logo.Tag is Rectangle bounds && bounds == new Rectangle(20, 29, 62, 67) && logo.SizeMode == PictureBoxSizeMode.Zoom && form._brandHeader.ClientRectangle.Contains(logo.Bounds)
&& logo.Bounds == new Rectangle(form.ScaleLogical(20), form.ScaleLogical(29), form.ScaleLogical(62), form.ScaleLogical(67))); && logo.Width >= form.ScaleLogical(30) && logo.Right < form._windowChrome!.MinimizeButton.Left);
checks["product_header_named_zonghengjia"] = form.Text == "纵横家" && form._brandHeader.Controls.OfType<Label>().Any(label => label.Text == "纵横家"); checks["product_header_named_zonghengjia"] = form.Text == "纵横家" && form._brandHeader.Controls.OfType<Label>().Any(label => label.Text == "纵横家");
checks["powered_by_removed_from_login_and_footer"] = !form._footer.Controls.OfType<Label>().Concat(form._loginView.Controls.OfType<Label>()) checks["powered_by_removed_from_login_and_footer"] = !form._footer.Controls.OfType<Label>().Concat(form._loginView.Controls.OfType<Label>())
.Any(label => label.Text.Contains("Powered by", StringComparison.OrdinalIgnoreCase) || label.Text == "优创未来"); .Any(label => label.Text.Contains("Powered by", StringComparison.OrdinalIgnoreCase) || label.Text == "优创未来");
checks["content_uses_local_buffers_not_composited_subtree"] = !form._content.ComposeChildren; checks["content_uses_local_buffers_not_composited_subtree"] = !form._content.ComposeChildren;
checks["dashboard_reuses_login_backdrop"] = form._dashboardView.LoginArtwork && form._dashboardBody.ParentArtwork; checks["dashboard_reuses_login_backdrop"] = form._dashboardView.LoginArtwork && form._dashboardBody.ParentArtwork;
checks["header_only_has_minimize_button"] = form._brandHeader.Controls.OfType<CaptionButton>().Count() == 1; checks["header_only_has_minimize_button"] = form._brandHeader.Controls.OfType<CaptionButton>().Count() == 1;
checks["scenic_asset_is_decoration_only"] = form._brandHeader.BackgroundImage is null && form._trafficChart.Parent == form._dailyCard; checks["scenic_asset_is_decoration_only"] = form._brandHeader.BackgroundImage is null && form._trafficChart.Parent == form._speedTrendCard;
checks["scenic_artwork_packaged_in_exe"] = ScenicTheme.ArtworkAvailable; checks["scenic_artwork_packaged_in_exe"] = ScenicTheme.ArtworkAvailable;
checks["footer_poem_does_not_overlap_plan"] = !form._footerPoem.Visible || form._footerPoem.Left > form._expiryLabel.Right; checks["footer_poem_does_not_overlap_plan"] = !form._footerPoem.Visible || form._footerPoem.Left > form._expiryLabel.Right;
checks["internal_use_notice_visible"] = form._footerHint.Text == "仅限内部使用,不作商业使用。" && form._footerHint.Visible; checks["internal_use_notice_visible"] = form._footerHint.Text == "仅限内部使用,不作商业使用。" && form._footerHint.Visible;
checks["proxy_metrics_values"] = form._usageMetric.UnitText == "GB" && form._uploadMetric.UnitText == "KB/s" && form._sessionMetric.UnitText == "MB"; checks["proxy_metrics_values"] = form._usageMetric.UnitText == "GB" && form._uploadMetric.UnitText == "KB/s" && form._sessionMetric.UnitText == "MB";
checks["speed_figures_left_curve_and_totals_right"] = form._usageMetric.Parent == form._sessionMetric.Parent checks["speed_figures_left_curve_and_totals_right"] = form._usageMetric.Parent == form._sessionMetric.Parent
&& form._usageMetric.Parent == form._trafficChart.Parent && form._uploadMetric.Parent == form._trafficCard && form._usageMetric.Parent == form._dailyCard && form._trafficChart.Parent == form._speedTrendCard && form._uploadMetric.Parent == form._trafficCard
&& form._downloadMetric.Parent == form._trafficCard; && form._downloadMetric.Parent == form._trafficCard;
form._historyRangeCombo.SelectedIndex = 0; form._historyRangeCombo.SelectedIndex = 0;
Capture("history-legacy-unavailable"); Capture("history-legacy-unavailable");
@@ -396,14 +407,22 @@ internal sealed partial class MainForm
form.DisplayTailnetTraffic(23842, 89312, "演示样本 · 近 5 分钟"); form.DisplayTailnetTraffic(23842, 89312, "演示样本 · 近 5 分钟");
Capture("tailnet-dashboard"); Capture("tailnet-dashboard");
checks["tailnet_wide_preview_has_left_two_right_one"] = form._dailyCard.Top == form._trafficCard.Top checks["tailnet_wide_preview_has_left_two_right_one"] = form._dailyCard.Top == form._trafficCard.Top
&& form._dailyCard.Bottom == form._tailnetTrafficCard.Bottom; && form._dailyCard.Bottom == form._speedTrendCard.Bottom;
form.Size = form.MinimumSize; form.Size = form.MinimumSize;
Capture("tailnet-compact"); Capture("tailnet-compact");
form._dashboardScrollBar.Value = Math.Max(0, form._dashboardScrollBar.Maximum - form._dashboardScrollBar.LargeChange + 1); form._dashboardScrollBar.Value = Math.Max(0, form._dashboardScrollBar.Maximum - form._dashboardScrollBar.LargeChange + 1);
Capture("tailnet-compact-scrolled"); Capture("tailnet-compact-scrolled");
checks["tailnet_compact_preview_footer_reachable"] = form._footer.RectangleToScreen(form._footer.ClientRectangle).Bottom checks["tailnet_compact_preview_footer_reachable"] = form._footer.RectangleToScreen(form._footer.ClientRectangle).Bottom
<= form._dashboardView.RectangleToScreen(form._dashboardView.ClientRectangle).Bottom; <= form._dashboardView.RectangleToScreen(form._dashboardView.ClientRectangle).Bottom;
form.ClientSize=new Size(form.ScaleLogical(480),form.ScaleLogical(360));
form.SetNodeTrafficPermission(true);
form.LayoutDashboard(); Capture("half-size-tailnet-servers");
checks["half_size_tailnet_servers_fit"] = form.DashboardControlsFit() && !form._dashboardScrollBar.Visible
&& form._nodeTrafficPanel.Bottom<form._footer.Top;
form.SetNodeTrafficPermission(false);
form.SetTailnetTrafficVisibility(false); form.SetTailnetTrafficVisibility(false);
form.ShowLogin(); Capture("half-size-login");
checks["half_size_login_visible"] = form.LoginFieldsVisibleForTest && form.LoginRegistrationAlignedForTest;
form.ClientSize = new Size(form.ScaleLogical(900), form.ScaleLogical(640)); form.ClientSize = new Size(form.ScaleLogical(900), form.ScaleLogical(640));
form.ShowLogin(); Capture("login"); form.ShowLogin(); Capture("login");
checks["login_fields_visible"] = form.LoginFieldsVisibleForTest; checks["login_fields_visible"] = form.LoginFieldsVisibleForTest;
@@ -416,7 +435,7 @@ internal sealed partial class MainForm
if (checks.Values.Any(v => !v)) throw new InvalidOperationException("Dashboard UI self-test failed; inspect dashboard-ui-self-test.json"); if (checks.Values.Any(v => !v)) throw new InvalidOperationException("Dashboard UI self-test failed; inspect dashboard-ui-self-test.json");
} }
private bool DashboardControlsFit() => new Control[] { _statusCard, _nodeCard, _modeCard, _trafficCard, _tailnetTrafficCard, _dailyCard, _footer } private bool DashboardControlsFit() => new Control[] { _statusCard, _nodeCard, _modeCard, _trafficCard, _tailnetTrafficCard, _speedTrendCard, _dailyCard, _footer }
.Where(parent => parent.Visible) .Where(parent => parent.Visible)
.All(parent => parent.Controls.Cast<Control>().Where(c => c.Visible).All(c => c.Left >= 0 && c.Top >= 0 && c.Right <= parent.ClientSize.Width && c.Bottom <= parent.ClientSize.Height)); .All(parent => parent.Controls.Cast<Control>().Where(c => c.Visible).All(c => c.Left >= 0 && c.Top >= 0 && c.Right <= parent.ClientSize.Width && c.Bottom <= parent.ClientSize.Height));
} }
+7 -3
View File
@@ -93,8 +93,8 @@ internal sealed partial class MainForm : Form
Text = "纵横家"; Text = "纵横家";
StartPosition = FormStartPosition.CenterScreen; StartPosition = FormStartPosition.CenterScreen;
ShowInTaskbar = true; ShowInTaskbar = true;
MinimumSize = new Size(620, 550); MinimumSize = new Size(480, 360);
ClientSize = new Size(960, 720); ClientSize = new Size(480, 360);
BackColor = Brand.Surface; BackColor = Brand.Surface;
AutoScaleDimensions = new SizeF(96f, 96f); AutoScaleDimensions = new SizeF(96f, 96f);
AutoScaleMode = AutoScaleMode.Dpi; AutoScaleMode = AutoScaleMode.Dpi;
@@ -279,6 +279,8 @@ internal sealed partial class MainForm : Form
private void LayoutBrandHeader() private void LayoutBrandHeader()
{ {
ApplyCompactTypography();
if (CompactPresentation) { LayoutCompactHeader(); return; }
_brandHeader.Height = ScaleLogical(ScenicTheme.HeaderHeight); _brandHeader.Height = ScaleLogical(ScenicTheme.HeaderHeight);
for (var i = 0; i < _brandHeader.Controls.Count; i++) for (var i = 0; i < _brandHeader.Controls.Count; i++)
{ {
@@ -1127,6 +1129,8 @@ internal sealed partial class MainForm : Form
private void CenterCards() private void CenterCards()
{ {
ApplyCompactTypography();
if (CompactPresentation) { LayoutCompactLogin(); return; }
_loginView.Size = new Size(ScaleLogical(440), ScaleLogical(374)); _loginView.Size = new Size(ScaleLogical(440), ScaleLogical(374));
foreach (Control control in _loginView.Controls) foreach (Control control in _loginView.Controls)
if (control.Tag is Rectangle rect) if (control.Tag is Rectangle rect)
@@ -1337,7 +1341,7 @@ internal sealed partial class MainForm : Form
&& _loginView.ClientRectangle.Contains(_registerPrompt.Bounds) && _loginView.ClientRectangle.Contains(_registerPrompt.Bounds)
&& _loginView.ClientRectangle.Contains(_registerLink.Bounds) && _loginView.ClientRectangle.Contains(_registerLink.Bounds)
&& _registerPrompt.Top >= _loginButton.Bottom && _registerPrompt.Top >= _loginButton.Bottom
&& _registerPrompt.Bottom <= ScaleLogical(306) && _registerPrompt.Bottom <= (CompactPresentation ? _loginView.Height : ScaleLogical(306))
&& Math.Abs((_registerPrompt.Left + _registerLink.Right) / 2f - _loginView.Width / 2f) <= 1; && Math.Abs((_registerPrompt.Left + _registerLink.Right) / 2f - _loginView.Width / 2f) <= 1;
internal void RequestExit() internal void RequestExit()
+41 -3
View File
@@ -13,6 +13,44 @@ internal static class NodeHealthProbe
internal static bool OverallHealthy(IReadOnlyList<bool> results) => internal static bool OverallHealthy(IReadOnlyList<bool> results) =>
results.Count >= 3 && results[2] && (results[0] || results[1]); results.Count >= 3 && results[2] && (results[0] || results[1]);
internal static async Task<bool> AggregateAsync(IReadOnlyList<Task<bool>> probes,
CancellationToken token, Action cancelRemaining)
{
async Task<bool> ResultAsync(Task<bool> probe)
{
try { return await probe.ConfigureAwait(false); }
catch { return false; }
}
// Observe every probe even after an early verdict. Cancellation or a
// late HTTP exception from a losing probe must not escape unobserved.
var observations = probes.Select(ResultAsync).ToArray();
try
{
token.ThrowIfCancellationRequested();
if (observations.Length < 3) return false;
var results = new bool?[3];
var pending = Enumerable.Range(0, 3).ToList();
while (pending.Count > 0)
{
var completed = await Task.WhenAny(pending.Select(index => observations[index]))
.WaitAsync(token).ConfigureAwait(false);
var index = pending.First(index => observations[index] == completed);
results[index] = await completed.ConfigureAwait(false);
pending.Remove(index);
token.ThrowIfCancellationRequested();
// Codex is mandatory; either independent target is sufficient.
// Stop only once that same predicate is proved or impossible.
if (results[2] == false || results[0] == false && results[1] == false) return false;
if (results[2] == true && (results[0] == true || results[1] == true)) return true;
}
return false;
}
finally
{
cancelRemaining();
}
}
internal static async Task<bool> CheckAsync(CancellationToken token, int proxyPort = 0) internal static async Task<bool> CheckAsync(CancellationToken token, int proxyPort = 0)
{ {
using var timeout = CancellationTokenSource.CreateLinkedTokenSource(token); using var timeout = CancellationTokenSource.CreateLinkedTokenSource(token);
@@ -23,17 +61,17 @@ internal static class NodeHealthProbe
}) { Timeout = Timeout.InfiniteTimeSpan }; }) { Timeout = Timeout.InfiniteTimeSpan };
var urls = new[] { "https://www.google.com/generate_204", "https://api.openai.com/v1/models", var urls = new[] { "https://www.google.com/generate_204", "https://api.openai.com/v1/models",
"https://chatgpt.com/backend-api/codex/models" }; "https://chatgpt.com/backend-api/codex/models" };
var results = await Task.WhenAll(urls.Select(async (url, index) => { var probes = urls.Select(async (url, index) => {
try { try {
using var response = await client.GetAsync(url, HttpCompletionOption.ResponseHeadersRead, timeout.Token); using var response = await client.GetAsync(url, HttpCompletionOption.ResponseHeadersRead, timeout.Token);
return Accepts(index, (int)response.StatusCode); return Accepts(index, (int)response.StatusCode);
} }
catch (OperationCanceledException) when (token.IsCancellationRequested) { throw; } catch (OperationCanceledException) when (token.IsCancellationRequested) { throw; }
catch { return false; } catch { return false; }
})); }).ToArray();
// This client exists primarily for ChatGPT/Codex. Google or the OpenAI // This client exists primarily for ChatGPT/Codex. Google or the OpenAI
// REST API remaining reachable must not mask a broken Codex transport. // REST API remaining reachable must not mask a broken Codex transport.
// Require the Codex endpoint plus one independent Internet target. // Require the Codex endpoint plus one independent Internet target.
return OverallHealthy(results); return await AggregateAsync(probes, token, timeout.Cancel);
} }
} }
+185
View File
@@ -0,0 +1,185 @@
using System.Text.Json;
namespace UCVL.VPNPlus;
// Exercises the production aggregator without HTTP, proxies or network changes.
internal static class NodeHealthProbeSelfTest
{
internal static async Task<int> RunAsync()
{
var checks = new Dictionary<string, bool>();
var errors = new Dictionary<string, string>();
async Task Check(string name, Func<Task> test)
{
try { await test(); checks[name] = true; }
catch (Exception error) { checks[name] = false; errors[name] = error.Message; }
}
await Check("http_status_and_codex_requirement_preserved", () => {
Require(NodeHealthProbe.Accepts(0, 200) && NodeHealthProbe.Accepts(0, 204)
&& !NodeHealthProbe.Accepts(0, 201) && !NodeHealthProbe.Accepts(0, 401)
&& NodeHealthProbe.Accepts(1, 401) && !NodeHealthProbe.Accepts(1, 500)
&& NodeHealthProbe.Accepts(2, 499) && !NodeHealthProbe.Accepts(2, 500), "HTTP status policy changed");
Require(NodeHealthProbe.OverallHealthy(new[] { true, false, true })
&& NodeHealthProbe.OverallHealthy(new[] { false, true, true })
&& !NodeHealthProbe.OverallHealthy(new[] { true, true, false })
&& !NodeHealthProbe.OverallHealthy(new[] { false, false, true }), "Codex health predicate changed");
return Task.CompletedTask;
});
await Check("google_and_codex_do_not_wait_for_api", async () => {
using var fixture = new Probes();
var result = fixture.Start();
fixture.Google.SetResult(true); fixture.Codex.SetResult(true);
Require(await Finished(result), "Required successes did not prove health");
Require(fixture.Cancellation.IsCancellationRequested, "Unused HTTP probe was not cancelled");
});
await Check("api_and_codex_do_not_wait_for_google", async () => {
using var fixture = new Probes();
var result = fixture.Start();
fixture.Api.SetResult(true); fixture.Codex.SetResult(true);
Require(await Finished(result), "Required successes did not prove health");
Require(fixture.Cancellation.IsCancellationRequested, "Unused HTTP probe was not cancelled");
});
await Check("codex_failure_finishes_with_other_probes_pending", async () => {
using var fixture = new Probes();
var result = fixture.Start(); fixture.Codex.SetResult(false);
Require(!await Finished(result), "Codex failure must prove unhealthy");
Require(fixture.Cancellation.IsCancellationRequested, "Unneeded HTTP probes were not cancelled");
});
await Check("both_independent_failures_do_not_wait_for_codex", async () => {
using var fixture = new Probes();
var result = fixture.Start();
fixture.Google.SetResult(false); fixture.Api.SetResult(false);
Require(!await Finished(result), "No independent target can prove health");
});
await Check("google_and_api_success_still_waits_for_codex", async () => {
using var fixture = new Probes();
var result = fixture.Start();
fixture.Google.SetResult(true); fixture.Api.SetResult(true);
await StillPending(result);
Require(!fixture.Cancellation.IsCancellationRequested, "Codex was cancelled before its verdict");
fixture.Codex.SetResult(false);
Require(!await Finished(result), "Independent successes cannot mask Codex failure");
});
await Check("codex_success_still_waits_for_independent_proof", async () => {
using var fixture = new Probes();
var result = fixture.Start(); fixture.Codex.SetResult(true);
await StillPending(result);
fixture.Google.SetResult(false); await StillPending(result);
fixture.Api.SetResult(true);
Require(await Finished(result), "An eventual independent success must prove health");
});
await Check("critical_probe_exception_counts_as_failure", async () => {
using var fixture = new Probes();
var result = fixture.Start(); fixture.Codex.SetException(new HttpRequestException("test failure"));
Require(!await Finished(result), "Failed Codex probe must prove unhealthy");
});
await Check("independent_exception_allows_other_independent_success", async () => {
using var fixture = new Probes();
var result = fixture.Start();
fixture.Google.SetException(new HttpRequestException("test failure"));
fixture.Api.SetResult(true); fixture.Codex.SetResult(true);
Require(await Finished(result), "One failed independent probe must not hide valid health");
});
await Check("two_independent_exceptions_prove_failure", async () => {
using var fixture = new Probes();
var result = fixture.Start();
fixture.Google.SetException(new IOException("test failure"));
fixture.Api.SetException(new HttpRequestException("test failure"));
Require(!await Finished(result), "Two failed independent probes must prove unhealthy");
});
await Check("caller_precancellation_is_preserved", async () => {
using var caller = new CancellationTokenSource(); caller.Cancel();
using var fixture = new Probes();
await Cancelled(fixture.Start(caller.Token), caller.Token);
Require(fixture.Cancellation.IsCancellationRequested, "Probe cleanup did not run after cancellation");
});
await Check("caller_cancellation_interrupts_pending_probes", async () => {
using var caller = new CancellationTokenSource();
using var fixture = new Probes();
var result = fixture.Start(caller.Token); caller.Cancel();
await Cancelled(result, caller.Token);
Require(fixture.Cancellation.IsCancellationRequested, "Pending HTTP probes were not cancelled");
});
await Check("late_failure_cannot_change_success", async () => {
using var fixture = new Probes();
var result = fixture.Start();
fixture.Google.SetResult(true); fixture.Codex.SetResult(true);
Require(await Finished(result), "Health was not established");
fixture.Api.SetException(new HttpRequestException("late unused failure"));
Require(await result, "Late unused failure changed a completed health verdict");
});
await Check("late_success_cannot_change_failure", async () => {
using var fixture = new Probes();
var result = fixture.Start(); fixture.Codex.SetResult(false);
Require(!await Finished(result), "Failure was not established");
fixture.Google.SetResult(true); fixture.Api.SetResult(true);
Require(!await result, "Late successes changed a completed health verdict");
});
await Check("late_caller_cancellation_cannot_change_success", async () => {
using var caller = new CancellationTokenSource();
using var fixture = new Probes();
var result = fixture.Start(caller.Token);
fixture.Google.SetResult(true); fixture.Codex.SetResult(true);
Require(await Finished(result), "Health was not established"); caller.Cancel();
Require(await result, "Later cancellation changed a completed health verdict");
});
await Check("cancelled_unused_probe_cannot_change_success", async () => {
using var fixture = new Probes();
var result = fixture.Start();
fixture.Api.SetResult(true); fixture.Codex.SetResult(true);
Require(await Finished(result), "Health was not established");
fixture.Google.SetCanceled(fixture.Cancellation.Token);
Require(await result, "Unused-probe cancellation changed the health verdict");
});
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 });
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, "node-health-probe-self-test.json"), report);
Console.WriteLine(report);
return passed ? 0 : 1;
}
private static void Require(bool condition, string message)
{
if (!condition) throw new InvalidOperationException(message);
}
private static async Task<bool> Finished(Task<bool> result)
{
try { return await result.WaitAsync(TimeSpan.FromSeconds(1)); }
catch (TimeoutException) { throw new InvalidOperationException("Health verdict waited for an unnecessary pending probe"); }
}
private static async Task StillPending(Task<bool> result)
{
var winner = await Task.WhenAny(result, Task.Delay(40));
Require(winner != result, "Health completed without required evidence");
}
private static async Task Cancelled(Task<bool> result, CancellationToken caller)
{
try { await result.WaitAsync(TimeSpan.FromSeconds(1)); }
catch (OperationCanceledException error) when (caller.IsCancellationRequested && error.CancellationToken == caller) { return; }
throw new InvalidOperationException("Caller cancellation did not propagate with its token");
}
private sealed class Probes : IDisposable
{
private Task<bool>? _running;
internal TaskCompletionSource<bool> Google { get; } = new(TaskCreationOptions.RunContinuationsAsynchronously);
internal TaskCompletionSource<bool> Api { get; } = new(TaskCreationOptions.RunContinuationsAsynchronously);
internal TaskCompletionSource<bool> Codex { get; } = new(TaskCreationOptions.RunContinuationsAsynchronously);
internal CancellationTokenSource Cancellation { get; } = new();
internal Task<bool> Start(CancellationToken caller = default) => _running = NodeHealthProbe.AggregateAsync(
new[] { Google.Task, Api.Task, Codex.Task }, caller, Cancellation.Cancel);
public void Dispose()
{
Google.TrySetResult(false); Api.TrySetResult(false); Codex.TrySetResult(false);
if (_running is null) Cancellation.Dispose();
else _ = _running.ContinueWith(task => { _ = task.Exception; Cancellation.Dispose(); },
CancellationToken.None, TaskContinuationOptions.ExecuteSynchronously, TaskScheduler.Default);
}
}
}
+3 -1
View File
@@ -79,7 +79,8 @@ internal sealed class NodeTrafficPanel : CardPanel
{ {
base.OnPaint(e); base.OnPaint(e);
var now = DateTimeOffset.UtcNow; var now = DateTimeOffset.UtcNow;
using var font = Brand.Font(7.1f); var compact=Width<720*DeviceDpi/96;
using var font = Brand.Font(compact?6.5f:7.1f);
var layout = TextLayout(ClientSize, DeviceDpi, TextRenderer.MeasureText(e.Graphics, "VPN002 上传", font).Height); var layout = TextLayout(ClientSize, DeviceDpi, TextRenderer.MeasureText(e.Graphics, "VPN002 上传", font).Height);
var flags = ChartAxis.PaintFlags | TextFormatFlags.VerticalCenter | TextFormatFlags.SingleLine | TextFormatFlags.EndEllipsis; var flags = ChartAxis.PaintFlags | TextFormatFlags.VerticalCenter | TextFormatFlags.SingleLine | TextFormatFlags.EndEllipsis;
if (!layout.Title.IsEmpty) TextRenderer.DrawText(e.Graphics, "服务器整机流量 · 主 WAN 网卡 · 累计自网卡启动 / 重置", font, if (!layout.Title.IsEmpty) TextRenderer.DrawText(e.Graphics, "服务器整机流量 · 主 WAN 网卡 · 累计自网卡启动 / 重置", font,
@@ -97,6 +98,7 @@ internal sealed class NodeTrafficPanel : CardPanel
: row?.SampledAt is { } oldTime ? $"过期 {oldTime.LocalDateTime:HH:mm:ss}" : "等待上报"; : row?.SampledAt is { } oldTime ? $"过期 {oldTime.LocalDateTime:HH:mm:ss}" : "等待上报";
var text = $"{name} ↑ {NodeTrafficPresentation.Bytes(up, true)} ↓ {NodeTrafficPresentation.Bytes(down, true)}" var text = $"{name} ↑ {NodeTrafficPresentation.Bytes(up, true)} ↓ {NodeTrafficPresentation.Bytes(down, true)}"
+ $" 累计 ↑ {NodeTrafficPresentation.Bytes(row?.TotalUpload)} ↓ {NodeTrafficPresentation.Bytes(row?.TotalDownload)} {status}"; + $" 累计 ↑ {NodeTrafficPresentation.Bytes(row?.TotalUpload)} ↓ {NodeTrafficPresentation.Bytes(row?.TotalDownload)} {status}";
if(compact)text=$"{(i==0?"VPN002 东京":"VPN003 美国")} {(fresh?status:row?.SampledAt is { } age?$"过期{age.LocalDateTime:HH:mm}":"待上报")} ↑{NodeTrafficPresentation.Bytes(up,true)} ↓{NodeTrafficPresentation.Bytes(down,true)} 累计↑{NodeTrafficPresentation.Bytes(row?.TotalUpload)} ↓{NodeTrafficPresentation.Bytes(row?.TotalDownload)}";
TextRenderer.DrawText(e.Graphics, text, font, TextRenderer.DrawText(e.Graphics, text, font,
layout.Rows[i], Brand.Text, flags); layout.Rows[i], Brand.Text, flags);
} }
+12 -6
View File
@@ -46,16 +46,22 @@ internal static class NodeTrafficSelfTest
checks["rate_uses_bytes_not_bits"] = NodeTrafficPresentation.Bytes(204800, true) == "200 KB/s"; checks["rate_uses_bytes_not_bits"] = NodeTrafficPresentation.Bytes(204800, true) == "200 KB/s";
checks["cumulative_has_no_speed_suffix"] = NodeTrafficPresentation.Bytes(204800) == "200 KB"; checks["cumulative_has_no_speed_suffix"] = NodeTrafficPresentation.Bytes(204800) == "200 KB";
checks["all_geometry_monitor_tailnet_cases_fit"] = DashboardLayout.SelfTest(); checks["all_geometry_monitor_tailnet_cases_fit"] = DashboardLayout.SelfTest();
using (var font = Brand.Font(7.1f)) using (var font = Brand.Font(6.5f))
using (var graphics = Graphics.FromHwnd(IntPtr.Zero))
{ {
var measuredHeight = TextRenderer.MeasureText("VPN002 上传", font).Height; // Measure a real display context, then normalize once from its
// actual DPI. Default MeasureText may already be at 200% DPI.
var measuredHeight = TextRenderer.MeasureText(graphics, "VPN002 上传", font).Height;
var sourceDpi = graphics.DpiY;
foreach (var dpi in new[] { 96, 120, 144, 192, 336, 384 }) foreach (var dpi in new[] { 96, 120, 144, 192, 336, 384 })
foreach (var logicalView in new[] { new Size(480, 312), new Size(620, 350) })
{ {
var view = new Size(620 * dpi / 96, 350 * dpi / 96); var view = new Size(logicalView.Width * dpi / 96, logicalView.Height * dpi / 96);
var panel = DashboardLayout.Calculate(view, dpi, true, true).ServerTrafficCard; var panel = DashboardLayout.Calculate(view, dpi, true, true).ServerTrafficCard;
var text = NodeTrafficPanel.TextLayout(panel.Size, dpi, (int)Math.Ceiling(measuredHeight * dpi / 96d)); var targetFontHeight = (int)Math.Ceiling(measuredHeight * dpi / (double)sourceDpi);
checks["minimum_two_text_rows_fit_" + dpi] = text.Rows.Length == 2 var text = NodeTrafficPanel.TextLayout(panel.Size, dpi, targetFontHeight);
&& text.Rows.All(row => row.Height >= measuredHeight * dpi / 96d && row.Bottom <= panel.Height) checks[$"minimum_two_text_rows_fit_{logicalView.Width}x{logicalView.Height}_{dpi}"] = text.Rows.Length == 2
&& text.Rows.All(row => row.Height >= targetFontHeight && row.Bottom <= panel.Height)
&& !text.Rows[0].IntersectsWith(text.Rows[1]); && !text.Rows[0].IntersectsWith(text.Rows[1]);
} }
} }
+5
View File
@@ -28,7 +28,12 @@ internal static class Program
if (args.Length == 1 && args[0] == "--chart-freshness-self-test") if (args.Length == 1 && args[0] == "--chart-freshness-self-test")
return ChartFreshnessSelfTest.Run(); return ChartFreshnessSelfTest.Run();
if (args.Length == 1 && args[0] == "--node-traffic-self-test") if (args.Length == 1 && args[0] == "--node-traffic-self-test")
{
ApplicationConfiguration.Initialize();
return NodeTrafficSelfTest.Run(); return NodeTrafficSelfTest.Run();
}
if (args.Length == 1 && args[0] == "--node-health-probe-self-test")
return NodeHealthProbeSelfTest.RunAsync().GetAwaiter().GetResult();
if (args.Length == 1 && args[0] == "--nextgen-lifecycle-self-test") if (args.Length == 1 && args[0] == "--nextgen-lifecycle-self-test")
{ {
ApplicationConfiguration.Initialize(); ApplicationConfiguration.Initialize();
+6 -4
View File
@@ -1,6 +1,6 @@
# 纵横家 Windows 0.3.1 开源源码 # 纵横家 Windows 0.3.2 开源源码
基于已冻结的 0.3.1 r1 第一方 Windows Forms / .NET 8 源码整理。此导出不是原安装包的逐字节副本:删除许可来源不明的可选登录插图及内部运维历史,保留原创山水缺图 fallback;端点为示例配置。原候选测试报告不能当作本导出的构建或生产验收证明。 基于已冻结的 0.3.2 r1 第一方 Windows Forms / .NET 8 源码整理。此导出不是原安装包的逐字节副本:删除许可来源不明的可选登录插图及内部运维历史,保留原创山水缺图 fallback;端点为示例配置。原候选测试报告不能当作本导出的构建或生产验收证明。
## 构建 ## 构建
@@ -17,6 +17,8 @@ dotnet publish VPNPlus.csproj -c Release -r win-x64 --self-contained true
公司自有代码适用 LICENSE;公司 Logo/商标保留来源识别用途、不授予品牌权利;第三方许可文本在 licenses/ 中,原 THIRD_PARTY_NOTICES.md 保持原文。 公司自有代码适用 LICENSE;公司 Logo/商标保留来源识别用途、不授予品牌权利;第三方许可文本在 licenses/ 中,原 THIRD_PARTY_NOTICES.md 保持原文。
本次 0.3.1 同步连接排序与内网恢复提示、可取消连接、会话代际及学习同步退避、固定高度单页与实时速度显示。内网恢复不静默中断长连接;需要明确重连。此清洁源码以原创山水替代许可不明的可选人物插图,真实内部端点替换为示例。原安装包测试结论不自动转移为此导出的网络或安装验收。 本次 0.3.2 同步连接排序与内网恢复提示、可取消连接、会话代际及学习同步退避、固定高度单页与实时速度显示。内网恢复不静默中断长连接;需要明确重连。此清洁源码以原创山水替代许可不明的可选人物插图,真实内部端点替换为示例。原安装包测试结论不自动转移为此导出的网络或安装验收。
0.3.1:固定画布实时速率、主WAN采样显示、节点延迟和粘性连接维护。整机WAN监控与个人套餐分开;未部署的后台、账户限速、真实网络和实窗结论不转移到此清洁源码。 0.3.2:固定画布实时速率、主WAN采样显示、节点延迟和粘性连接维护。整机WAN监控与个人套餐分开;未部署的后台、账户限速、真实网络和实窗结论不转移到此清洁源码。
0.3.2:启动时重叠执行只读路径验证与本机DNS准备,健康判定取得必要证据后结束等待,并调整紧凑窗口布局。保留Codex必要健康条件、授权、路由提交锁与原有超时。离线和合成界面测试不代表实机启动提速、生产安装、持续业务会话或完整网络验收。
+38
View File
@@ -0,0 +1,38 @@
namespace UCVL.VPNPlus;
internal static class StartupLearningWarmup
{
// The readiness callback starts only transport proof. The setup owner keeps
// its lifecycle lock until DNS/network setup succeeds; rule commits wait on
// that existing lock. Setup time never spends the post-setup learning budget.
internal static async Task RunAsync(Func<Action<CancellationToken>, Task> setup,
Func<CancellationToken, Task> learn, CancellationToken token, TimeProvider? clock = null)
{
token.ThrowIfCancellationRequested();
using var budget = new CancellationTokenSource(Timeout.InfiniteTimeSpan, clock ?? TimeProvider.System);
CancellationTokenSource? learning = null;
Task? work = null;
try
{
await setup(epoch => {
if (learning is not null) throw new InvalidOperationException("Startup learning already began.");
learning = CancellationTokenSource.CreateLinkedTokenSource(token, epoch, budget.Token);
learning.Token.ThrowIfCancellationRequested();
work = learn(learning.Token);
});
token.ThrowIfCancellationRequested();
if (work is null) return;
budget.CancelAfter(TimeSpan.FromSeconds(15));
await work;
token.ThrowIfCancellationRequested();
}
finally
{
// A failed setup must leave no outstanding proof/commit task. Drain
// cancellation without replacing the original setup/learning error.
learning?.Cancel();
if (work is not null) try { await work; } catch { }
learning?.Dispose();
}
}
}
+3 -2
View File
@@ -153,13 +153,14 @@ internal static class ChartAxis
var left = Math.Max(31 * scale, TextRenderer.MeasureText(g, maximum.ToString("0.#"), font).Width + 5 * scale); var left = Math.Max(31 * scale, TextRenderer.MeasureText(g, maximum.ToString("0.#"), font).Width + 5 * scale);
var plot = new RectangleF(left, fontHeight + 1, Math.Max(1, bounds.Width - left - 9 * scale), Math.Max(1, bounds.Height - fontHeight * 2 - 7 * scale)); var plot = new RectangleF(left, fontHeight + 1, Math.Max(1, bounds.Width - left - 9 * scale), Math.Max(1, bounds.Height - fontHeight * 2 - 7 * scale));
g.SmoothingMode = SmoothingMode.AntiAlias; g.SmoothingMode = SmoothingMode.AntiAlias;
TextRenderer.DrawText(g, unitName + (speed ? "/s" : ""), font, new Rectangle(0, 0, bounds.Width, fontHeight), Brand.Muted, PaintFlags | TextFormatFlags.NoPadding); var compactAxis = plot.Height < fontHeight * 3;
TextRenderer.DrawText(g, unitName + (speed ? "/s" : "") + (compactAxis ? $" · {maximum:0.#}" : ""), font, new Rectangle(0, 0, bounds.Width, fontHeight), Brand.Muted, PaintFlags | TextFormatFlags.NoPadding);
using var grid = new Pen(Color.FromArgb(218, 230, 245), Math.Max(1, scale * .6f)) { DashStyle = DashStyle.Dash }; using var grid = new Pen(Color.FromArgb(218, 230, 245), Math.Max(1, scale * .6f)) { DashStyle = DashStyle.Dash };
for (var i = 0; i <= 2; i++) for (var i = 0; i <= 2; i++)
{ {
var y = plot.Bottom - plot.Height * i / 2; var y = plot.Bottom - plot.Height * i / 2;
g.DrawLine(grid, plot.Left, y, plot.Right, y); g.DrawLine(grid, plot.Left, y, plot.Right, y);
TextRenderer.DrawText(g, (maximum * i / 2).ToString("0.#"), font, new Rectangle(0, (int)y - fontHeight / 2, (int)left - 4, fontHeight), Brand.Muted, PaintFlags | TextFormatFlags.Right | TextFormatFlags.NoPadding); if (!compactAxis || i == 0) TextRenderer.DrawText(g, (maximum * i / 2).ToString("0.#"), 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++) for (var i = 0; i <= 6; i++)
{ {
+4 -4
View File
@@ -10,10 +10,10 @@
<ApplicationIcon>assets\zonghengjia-app-v1.ico</ApplicationIcon> <ApplicationIcon>assets\zonghengjia-app-v1.ico</ApplicationIcon>
<ApplicationManifest>app.manifest</ApplicationManifest> <ApplicationManifest>app.manifest</ApplicationManifest>
<ApplicationHighDpiMode>PerMonitorV2</ApplicationHighDpiMode> <ApplicationHighDpiMode>PerMonitorV2</ApplicationHighDpiMode>
<Version>0.3.1</Version> <Version>0.3.2</Version>
<AssemblyVersion>0.3.1.0</AssemblyVersion> <AssemblyVersion>0.3.2.0</AssemblyVersion>
<FileVersion>0.3.1.0</FileVersion> <FileVersion>0.3.2.0</FileVersion>
<InformationalVersion>0.3.1</InformationalVersion> <InformationalVersion>0.3.2</InformationalVersion>
<Product>纵横家</Product> <Product>纵横家</Product>
<Company>优创未来(UCVL)</Company> <Company>优创未来(UCVL)</Company>
<Description>纵横家 Windows 智能网络客户端</Description> <Description>纵横家 Windows 智能网络客户端</Description>
+28 -31
View File
@@ -196,37 +196,32 @@ internal sealed class XrayManager : IDisposable, IAsyncDisposable, IHandoverRunt
if (preferred is not null && !TailnetTransport.SameAuthorizedFallback(preferred, original)) if (preferred is not null && !TailnetTransport.SameAuthorizedFallback(preferred, original))
throw new InvalidOperationException("Tailscale 恢复入口与已授权线路不匹配。"); throw new InvalidOperationException("Tailscale 恢复入口与已授权线路不匹配。");
await InitializeAsync(cancellationToken); await InitializeAsync(cancellationToken);
await _lifecycle.WaitAsync(cancellationToken); await StartupLearningWarmup.RunAsync(async beginLearning => {
try await _lifecycle.WaitAsync(cancellationToken);
{ try
await StopCoreAsync(); {
_baseConfigJson = configJson; await StopCoreAsync();
_tailnetFallbackConfigJson = preferred is not null ? original : tailnetFallbackConfigJson; _baseConfigJson = configJson;
_preferredTailnetConfigJson = preferred; _tailnetFallbackConfigJson = preferred is not null ? original : tailnetFallbackConfigJson;
_routeMode = routeMode; _preferredTailnetConfigJson = preferred;
_nodeSlug = nodeSlug; _routeMode = routeMode;
await StartCoreAsync(cancellationToken); _nodeSlug = nodeSlug;
} await StartCoreAsync(cancellationToken, routeMode == "smart" ? beginLearning : null);
catch }
{ catch
await StopCoreAsync().ConfigureAwait(false); {
throw; await StopCoreAsync().ConfigureAwait(false);
} throw;
finally }
{ finally { _lifecycle.Release(); }
_lifecycle.Release(); if (_routeMode == "smart") StatusMessage?.Invoke("正在验证本地直连与代理路径…");
} }, warmupToken =>
if (_routeMode == "smart") // Keep the same targets, direct/proxy proof and lifecycle-gated
{ // commits. Only their read-only transport work overlaps DNS setup.
// The same three fixed health destinations, but first validate their real Task.WhenAll(new[] { "chatgpt.com", "api.openai.com", "www.google.com" }.Select(target =>
// physical direct path. Never mark all server candidate domains as proxy.
StatusMessage?.Invoke("正在验证本地直连与代理路径…");
using var warmup = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, _learningEpoch.Token);
warmup.CancelAfter(TimeSpan.FromSeconds(15));
await Task.WhenAll(new[] { "chatgpt.com", "api.openai.com", "www.google.com" }.Select(target =>
ScheduleLearningAsync(new LearningObservation { Target=target, Port=443, AccessKind="http", ScheduleLearningAsync(new LearningObservation { Target=target, Port=443, AccessKind="http",
Node=_nodeSlug, Scope=PrivateAuxiliaryRuntime.IsPrivate(_baseConfigJson ?? "{}") ? "private_auxiliary" : "public" }, warmup.Token))); Node=_nodeSlug, Scope=PrivateAuxiliaryRuntime.IsPrivate(_baseConfigJson ?? "{}") ? "private_auxiliary" : "public" }, warmupToken))),
} cancellationToken);
} }
internal async Task StopAsync() internal async Task StopAsync()
@@ -262,7 +257,8 @@ internal sealed class XrayManager : IDisposable, IAsyncDisposable, IHandoverRunt
finally { _lifecycle.Release(); } finally { _lifecycle.Release(); }
} }
private async Task StartCoreAsync(CancellationToken cancellationToken) private async Task StartCoreAsync(CancellationToken cancellationToken,
Action<CancellationToken>? beginStartupLearning = null)
{ {
EnsureRuntime(); EnsureRuntime();
if (string.IsNullOrWhiteSpace(_baseConfigJson)) throw new InvalidOperationException("线路配置为空。"); if (string.IsNullOrWhiteSpace(_baseConfigJson)) throw new InvalidOperationException("线路配置为空。");
@@ -365,6 +361,7 @@ internal sealed class XrayManager : IDisposable, IAsyncDisposable, IHandoverRunt
// Apply 0.2.5 routing first, then wait until Windows has completed // Apply 0.2.5 routing first, then wait until Windows has completed
// DAD before applications can use the tunnel's DNS/IPv4 path. // DAD before applications can use the tunnel's DNS/IPv4 path.
await TunRouting.WaitForAdapterAsync(cancellationToken, requireIpv4Ready: true); await TunRouting.WaitForAdapterAsync(cancellationToken, requireIpv4Ready: true);
beginStartupLearning?.Invoke(_learningEpoch.Token);
await ProxyDnsPolicy.EnableAsync(_baseConfigJson, cancellationToken); await ProxyDnsPolicy.EnableAsync(_baseConfigJson, cancellationToken);
StatusMessage?.Invoke("正在等待 Windows 网络与 DNS 就绪…"); StatusMessage?.Invoke("正在等待 Windows 网络与 DNS 就绪…");
await WaitForDnsReadyAsync(cancellationToken); await WaitForDnsReadyAsync(cancellationToken);
@@ -0,0 +1,209 @@
using System.Text.Json;
using UCVL.VPNPlus;
var checks = new Dictionary<string, bool>();
TaskCompletionSource Signal() => new(TaskCreationOptions.RunContinuationsAsynchronously);
// The real coordinator receives controlled external setup/probe phases. The
// semaphore is the same boundary used by XrayManager to defer rule commits.
using (var epoch = new CancellationTokenSource())
using (var lifecycle = new SemaphoreSlim(1, 1))
{
var tunReady = Signal(); var nrptStarted = Signal(); var finishNrpt = Signal();
var proofFinished = false; var committed = false; var setupFinished = false;
var clock = new ManualClock();
var run = StartupLearningWarmup.RunAsync(async begin => {
await lifecycle.WaitAsync();
try
{
await tunReady.Task;
begin(epoch.Token);
nrptStarted.SetResult();
await finishNrpt.Task;
setupFinished = true;
}
finally { lifecycle.Release(); }
}, async token => {
proofFinished = true;
await lifecycle.WaitAsync(token);
try { token.ThrowIfCancellationRequested(); committed = setupFinished; }
finally { lifecycle.Release(); }
}, CancellationToken.None, clock);
checks["learning_does_not_start_before_tun_ipv4_ready"] = !proofFinished;
tunReady.SetResult(); await nrptStarted.Task.WaitAsync(TimeSpan.FromSeconds(3));
checks["readonly_proof_overlaps_pending_nrpt"] = proofFinished;
checks["rule_commit_waits_for_setup_lifecycle_release"] = !committed;
finishNrpt.SetResult(); await run.WaitAsync(TimeSpan.FromSeconds(3));
checks["completed_proof_commits_after_setup"] = committed;
}
{
var clock = new ManualClock(); var setupEntered = Signal(); var finishSetup = Signal();
var learningStarted = Signal(); var cancelled = false;
var run = StartupLearningWarmup.RunAsync(async begin => {
begin(CancellationToken.None); setupEntered.SetResult(); await finishSetup.Task;
}, async token => {
learningStarted.SetResult();
try { await Task.Delay(Timeout.Infinite, token); }
catch (OperationCanceledException) { cancelled = true; }
}, CancellationToken.None, clock);
await setupEntered.Task.WaitAsync(TimeSpan.FromSeconds(3));
clock.Advance(TimeSpan.FromMinutes(1));
checks["setup_does_not_consume_post_setup_learning_budget"] = !cancelled;
finishSetup.SetResult(); await clock.Armed.Task.WaitAsync(TimeSpan.FromSeconds(3));
await learningStarted.Task.WaitAsync(TimeSpan.FromSeconds(3));
clock.Advance(TimeSpan.FromMilliseconds(14_999));
checks["learning_retains_fifteen_seconds_after_setup"] = !cancelled && !run.IsCompleted;
clock.Advance(TimeSpan.FromMilliseconds(1));
await run.WaitAsync(TimeSpan.FromSeconds(3));
checks["learning_stops_at_post_setup_budget"] = cancelled;
}
{
var learningCalls = 0;
await StartupLearningWarmup.RunAsync(_ => Task.CompletedTask,
_ => { learningCalls++; return Task.CompletedTask; }, CancellationToken.None, new ManualClock());
checks["setup_without_smart_readiness_never_starts_learning"] = learningCalls == 0;
}
foreach (var reason in new[] { "setup_failure", "caller_cancel", "epoch_cancel" })
{
using var caller = new CancellationTokenSource(); using var epoch = new CancellationTokenSource();
var setupEntered = Signal(); var finishSetup = Signal(); var stopped = false; var active = false;
var failure = new IOException("synthetic setup failure"); Exception? observed = null;
var run = StartupLearningWarmup.RunAsync(async begin => {
begin(epoch.Token); setupEntered.SetResult();
await finishSetup.Task.WaitAsync(caller.Token);
if (reason == "setup_failure") throw failure;
}, async token => {
active = true;
try { await Task.Delay(Timeout.Infinite, token); }
finally { active = false; stopped = true; }
}, caller.Token, new ManualClock());
await setupEntered.Task.WaitAsync(TimeSpan.FromSeconds(3));
if (reason == "caller_cancel") caller.Cancel();
if (reason == "epoch_cancel") epoch.Cancel();
finishSetup.TrySetResult();
try { await run.WaitAsync(TimeSpan.FromSeconds(3)); } catch (Exception error) { observed = error; }
checks[reason + "_drains_learning_without_late_work"] = stopped && !active;
checks[reason + "_preserves_original_failure"] = reason == "setup_failure"
? ReferenceEquals(observed, failure) : observed is OperationCanceledException;
}
// Failed NRPT setup cancels the same epoch while still holding the lifecycle
// lock. A proof already waiting to commit must not escape cleanup or apply late.
using (var epoch = new CancellationTokenSource())
using (var lifecycle = new SemaphoreSlim(1, 1))
{
var proofFinished = false; var committed = false; var drained = false;
var failure = new IOException("synthetic NRPT failure"); Exception? observed = null;
try
{
await StartupLearningWarmup.RunAsync(async begin => {
await lifecycle.WaitAsync();
try
{
begin(epoch.Token);
epoch.Cancel();
throw failure;
}
finally { lifecycle.Release(); }
}, async token => {
proofFinished = true;
try
{
await lifecycle.WaitAsync(token);
try { token.ThrowIfCancellationRequested(); committed = true; }
finally { lifecycle.Release(); }
}
finally { drained = true; }
}, CancellationToken.None, new ManualClock());
}
catch (Exception error) { observed = error; }
checks["failed_nrpt_cancels_pending_rule_commit"] = proofFinished && drained && !committed;
checks["pending_commit_cancellation_preserves_setup_error"] = ReferenceEquals(observed, failure);
}
{
var clock = new ManualClock();
using var caller = new CancellationTokenSource(TimeSpan.FromSeconds(45), clock);
var learningStopped = false; var setupStarted = Signal();
var run = StartupLearningWarmup.RunAsync(async begin => {
begin(CancellationToken.None); setupStarted.SetResult();
await Task.Delay(Timeout.Infinite, caller.Token);
}, async token => {
try { await Task.Delay(Timeout.Infinite, token); }
finally { learningStopped = true; }
}, caller.Token, clock);
await setupStarted.Task.WaitAsync(TimeSpan.FromSeconds(3));
clock.Advance(TimeSpan.FromSeconds(45));
var cancelled = false;
try { await run.WaitAsync(TimeSpan.FromSeconds(3)); } catch (OperationCanceledException) { cancelled = true; }
checks["caller_forty_five_second_bound_remains_active_during_setup"] = cancelled && learningStopped;
}
{
using var caller = new CancellationTokenSource(); caller.Cancel(); var setupCalled = false;
try { await StartupLearningWarmup.RunAsync(_ => { setupCalled = true; return Task.CompletedTask; },
_ => Task.CompletedTask, caller.Token, new ManualClock()); }
catch (OperationCanceledException) { }
checks["cancelled_caller_does_not_start_setup"] = !setupCalled;
}
// Production learning handlers absorb cancellation after cleaning up their own
// probes. The startup owner must still propagate the user's cancelled connect.
{
using var caller = new CancellationTokenSource();
var clock = new ManualClock(); var learnerFinishedNormally = false;
var run = StartupLearningWarmup.RunAsync(begin => {
begin(CancellationToken.None); return Task.CompletedTask;
}, async token => {
try { await Task.Delay(Timeout.Infinite, token); }
catch (OperationCanceledException) { learnerFinishedNormally = true; }
}, caller.Token, clock);
await clock.Armed.Task.WaitAsync(TimeSpan.FromSeconds(3));
caller.Cancel();
var cancelled = false;
try { await run.WaitAsync(TimeSpan.FromSeconds(3)); } catch (OperationCanceledException) { cancelled = true; }
checks["caller_cancellation_propagates_when_learning_swallows_it"] = cancelled && learnerFinishedNormally;
}
var report = new { passed = checks.Values.All(v => v), checks, production_coordinator = true,
simulated_external_phases = true, network_modified = false, production_client_started = false };
Console.WriteLine(JsonSerializer.Serialize(report, new JsonSerializerOptions { WriteIndented = true }));
return report.passed ? 0 : 91;
sealed class ManualClock : TimeProvider
{
private readonly List<ManualTimer> timers = [];
internal long ElapsedTicks { get; private set; }
internal TaskCompletionSource Armed { get; } = new(TaskCreationOptions.RunContinuationsAsynchronously);
public override ITimer CreateTimer(TimerCallback callback, object? state, TimeSpan dueTime, TimeSpan period)
{
var timer = new ManualTimer(this, callback, state); lock (timers) timers.Add(timer);
timer.Change(dueTime, period); return timer;
}
internal void Advance(TimeSpan elapsed)
{
ManualTimer[] snapshot; lock (timers) { ElapsedTicks += elapsed.Ticks; snapshot = timers.ToArray(); }
foreach (var timer in snapshot) timer.FireIfDue();
}
private sealed class ManualTimer(ManualClock clock, TimerCallback callback, object? state) : ITimer
{
private long? due; private bool disposed;
public bool Change(TimeSpan dueTime, TimeSpan period)
{
if (disposed) return false;
due = dueTime == Timeout.InfiniteTimeSpan ? null : clock.ElapsedTicks + dueTime.Ticks;
if (dueTime == TimeSpan.FromSeconds(15)) clock.Armed.TrySetResult();
return true;
}
internal void FireIfDue()
{
if (!disposed && due is { } value && value <= clock.ElapsedTicks)
{ due = null; callback(state); }
}
public void Dispose() { disposed = true; due = null; }
public ValueTask DisposeAsync() { Dispose(); return ValueTask.CompletedTask; }
}
}
@@ -0,0 +1,19 @@
<Project>
<PropertyGroup>
<BaseIntermediateOutputPath>obj/startup-learning-warmup/</BaseIntermediateOutputPath>
</PropertyGroup>
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<OutputPath>bin/startup-learning-warmup/</OutputPath>
</PropertyGroup>
<ItemGroup>
<Compile Include="StartupLearningWarmupHarness.cs" />
<Compile Include="../StartupLearningWarmup.cs" />
</ItemGroup>
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
</Project>
+13
View File
@@ -0,0 +1,13 @@
# 纵横家 Windows 0.3.2
正式、非强制更新,保留现有账号、授权和连接选择策略。
- 缩短连接启动的串行等待:TUN/IPv4 就绪后,将只读直连验证与隧道 DNS 设置并行;规则仍在设置成功后提交。
- 连接健康检查满足原有条件后立即完成,不再等待无关的第三个探测;仍要求 Codex 与另一独立目标通过验证。
- 主窗口默认宽、高各为原来的一半;累计流量仅显示统计数字,代理速度保留趋势图。公网、Tailscale 入口速度和服务器监控继续区分。
- 沿用内网 IP 优先、不可达后回退域名且本次连接保持回退入口的策略。不会启停、登录或修改 Tailscale。
验证包含同包离线回归、合成界面及隔离文件升级/恢复;保持当前运行连接,没有执行生产覆盖安装或真实 TUN 重连。因此本版不承诺固定连接秒数,也不将隔离验证写成生产联网验收。
安装包未进行 Authenticode 签名,更新需要 Windows 管理员授权。
既有共享账户限速执行层仍未启用,本版不宣称已启用跨服务器共享限速。