mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-12-03 04:00:23 +08:00
Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9bdd2c0623 | ||
|
|
39fd5e968b | ||
|
|
c9223b204b | ||
|
|
9c3a433979 | ||
|
|
2943b58ef7 | ||
|
|
186ec116fa | ||
|
|
87de9bd5bf |
@@ -5,10 +5,10 @@
|
|||||||
"version": "v9.0.0",
|
"version": "v9.0.0",
|
||||||
"sha": "3a2844b7e9c422d3c10d287c895573f7108da1b3"
|
"sha": "3a2844b7e9c422d3c10d287c895573f7108da1b3"
|
||||||
},
|
},
|
||||||
"github/gh-aw-actions/setup@v1.4.2": {
|
"github/gh-aw-actions/setup@v1.4.5": {
|
||||||
"repo": "github/gh-aw-actions/setup",
|
"repo": "github/gh-aw-actions/setup",
|
||||||
"version": "v1.4.2",
|
"version": "v1.4.5",
|
||||||
"sha": "d7852d91d5d1d13e7848771edab8bd1792a08651"
|
"sha": "a83eaf07e756a15e65f669eb32d00787cf5a2569"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"containers": {
|
"containers": {
|
||||||
@@ -199,13 +199,13 @@
|
|||||||
},
|
},
|
||||||
"ghcr.io/github/gh-aw-node": {
|
"ghcr.io/github/gh-aw-node": {
|
||||||
"image": "ghcr.io/github/gh-aw-node",
|
"image": "ghcr.io/github/gh-aw-node",
|
||||||
"digest": "sha256:8735428c2d4e602f90781ba0c571c400e8ff93c7ee1508a75d71f87e34e415cc",
|
"digest": "sha256:1ee08ba84b321ff231ca905b73e6e7da8f5fd177bcc6433a56631fce2b5a0f2f",
|
||||||
"pinned_image": "ghcr.io/github/gh-aw-node@sha256:8735428c2d4e602f90781ba0c571c400e8ff93c7ee1508a75d71f87e34e415cc"
|
"pinned_image": "ghcr.io/github/gh-aw-node@sha256:1ee08ba84b321ff231ca905b73e6e7da8f5fd177bcc6433a56631fce2b5a0f2f"
|
||||||
},
|
},
|
||||||
"ghcr.io/github/github-mcp-server:v2.2.0": {
|
"ghcr.io/github/github-mcp-server:v2.3.0": {
|
||||||
"image": "ghcr.io/github/github-mcp-server:v2.2.0",
|
"image": "ghcr.io/github/github-mcp-server:v2.3.0",
|
||||||
"digest": "sha256:040c4e99810076035eb1d9beb4b4a96fcf589c43cefed6ff51a46a553eb4e174",
|
"digest": "sha256:f8ee4dedc7d5c8cb32854ab91cc92a31c55a8a5510708cf8742e9f9427588ca6",
|
||||||
"pinned_image": "ghcr.io/github/github-mcp-server:v2.2.0@sha256:040c4e99810076035eb1d9beb4b4a96fcf589c43cefed6ff51a46a553eb4e174"
|
"pinned_image": "ghcr.io/github/github-mcp-server:v2.3.0@sha256:f8ee4dedc7d5c8cb32854ab91cc92a31c55a8a5510708cf8742e9f9427588ca6"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,9 +31,9 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
- name: Install gh-aw extension
|
- name: Install gh-aw extension
|
||||||
uses: github/gh-aw-actions/setup-cli@d7852d91d5d1d13e7848771edab8bd1792a08651 # v1.4.2
|
uses: github/gh-aw-actions/setup-cli@a83eaf07e756a15e65f669eb32d00787cf5a2569 # v1.4.5
|
||||||
with:
|
with:
|
||||||
version: v1.4.2
|
version: v1.4.5
|
||||||
- name: Install Rust Stable
|
- name: Install Rust Stable
|
||||||
uses: dtolnay/rust-toolchain@stable
|
uses: dtolnay/rust-toolchain@stable
|
||||||
with:
|
with:
|
||||||
|
|||||||
+38
-33
@@ -1,6 +1,6 @@
|
|||||||
# gh-aw-metadata: {"schema_version":"v4","frontmatter_hash":"4ca5835c0c9cd01f3432b873f5a177ca6d3d1dbd6a35939e2058dcb37aa224b4","body_hash":"ca82fafbe18061d7c8bd708dc18e91b9116faf0c921a7fa35be1538d47a2b005","compiler_version":"v1.4.2","strict":true,"agent_id":"copilot","engine_versions":{"copilot":"1.0.103"}}
|
# gh-aw-metadata: {"schema_version":"v4","frontmatter_hash":"4ca5835c0c9cd01f3432b873f5a177ca6d3d1dbd6a35939e2058dcb37aa224b4","body_hash":"ca82fafbe18061d7c8bd708dc18e91b9116faf0c921a7fa35be1538d47a2b005","compiler_version":"v1.4.5","strict":true,"agent_id":"copilot","engine_versions":{"copilot":"1.0.103"}}
|
||||||
# gh-aw-manifest: {"version":1,"secrets":["COPILOT_GITHUB_TOKEN","GH_AW_DEFAULT_OTLP_ENDPOINT","GH_AW_DEFAULT_OTLP_HEADERS","GH_AW_GITHUB_MCP_SERVER_TOKEN","GH_AW_GITHUB_TOKEN","GITHUB_TOKEN"],"actions":[{"repo":"actions/checkout","sha":"3d3c42e5aac5ba805825da76410c181273ba90b1","version":"v7.0.1"},{"repo":"actions/download-artifact","sha":"9000827ccba6bdab643e8b6fd33ac0654aef8333","version":"v8.0.2"},{"repo":"actions/github-script","sha":"3a2844b7e9c422d3c10d287c895573f7108da1b3","version":"v9.0.0"},{"repo":"actions/setup-node","sha":"949feb2413d6458794dcd2491c4babbbce0c15c1","version":"v7.1.0"},{"repo":"actions/upload-artifact","sha":"cf430e030ddbb5b0abf93d22962f4752f3646cd9","version":"v7.0.2"},{"repo":"github/gh-aw-actions/setup","sha":"d7852d91d5d1d13e7848771edab8bd1792a08651","version":"v1.4.2"}],"containers":[{"image":"ghcr.io/github/gh-aw-firewall/agent:0.29.22@sha256:f5829ed92ec390e9c88c9d393556a16f0442c124c0d6b9c713e7544cb0efa5ad"},{"image":"ghcr.io/github/gh-aw-firewall/api-proxy:0.29.22@sha256:02149f4ed8b9c0bae954932745f2d16e8c5bd2b37adec5f788344806cd063dca"},{"image":"ghcr.io/github/gh-aw-firewall/cli-proxy:0.29.22@sha256:7b8ef50c5221824a425fbfabafb50767c5a4e6b0197a0fce6085fd9f7e97b5b7"},{"image":"ghcr.io/github/gh-aw-firewall/router:0.29.22@sha256:b4253735af3ab47c17bcdfaf86e91b541581e1338d3d9ead512a12ebd3f146fb"},{"image":"ghcr.io/github/gh-aw-firewall/squid:0.29.22@sha256:cf4dd8944eb5b389adcf49f42de0e884f46e07d63afc5824543e7c9ab8ddb882"},{"image":"ghcr.io/github/gh-aw-mcpg:v0.5.16","digest":"sha256:cd50cfae3acce5985985aee3964902c9358dcc809f1b68b8168cfe29b761b059","pinned_image":"ghcr.io/github/gh-aw-mcpg:v0.5.16@sha256:cd50cfae3acce5985985aee3964902c9358dcc809f1b68b8168cfe29b761b059"},{"image":"ghcr.io/github/gh-aw-node","digest":"sha256:8735428c2d4e602f90781ba0c571c400e8ff93c7ee1508a75d71f87e34e415cc","pinned_image":"ghcr.io/github/gh-aw-node@sha256:8735428c2d4e602f90781ba0c571c400e8ff93c7ee1508a75d71f87e34e415cc"},{"image":"ghcr.io/github/github-mcp-server:v2.2.0","digest":"sha256:040c4e99810076035eb1d9beb4b4a96fcf589c43cefed6ff51a46a553eb4e174","pinned_image":"ghcr.io/github/github-mcp-server:v2.2.0@sha256:040c4e99810076035eb1d9beb4b4a96fcf589c43cefed6ff51a46a553eb4e174"}],"mcp_servers":[{"name":"safeoutputs","tools":["add_comment","add_labels","noop","remove_labels","report_incomplete","report_missing_data","report_missing_tool"]}],"threat_detection":{"mode":"enabled"},"admission":false,"agent_metadata":{"14ba41178a91b10b7de6":{"name":"Agentic Workflows"}}}
|
# gh-aw-manifest: {"version":1,"secrets":["COPILOT_GITHUB_TOKEN","GH_AW_DEFAULT_OTLP_ENDPOINT","GH_AW_DEFAULT_OTLP_HEADERS","GH_AW_GITHUB_MCP_SERVER_TOKEN","GH_AW_GITHUB_TOKEN","GITHUB_TOKEN"],"actions":[{"repo":"actions/checkout","sha":"3d3c42e5aac5ba805825da76410c181273ba90b1","version":"v7.0.1"},{"repo":"actions/download-artifact","sha":"9000827ccba6bdab643e8b6fd33ac0654aef8333","version":"v8.0.2"},{"repo":"actions/github-script","sha":"3a2844b7e9c422d3c10d287c895573f7108da1b3","version":"v9.0.0"},{"repo":"actions/setup-node","sha":"949feb2413d6458794dcd2491c4babbbce0c15c1","version":"v7.1.0"},{"repo":"actions/upload-artifact","sha":"cf430e030ddbb5b0abf93d22962f4752f3646cd9","version":"v7.0.2"},{"repo":"github/gh-aw-actions/setup","sha":"a83eaf07e756a15e65f669eb32d00787cf5a2569","version":"v1.4.5"}],"containers":[{"image":"ghcr.io/github/gh-aw-firewall/agent:0.29.22@sha256:f5829ed92ec390e9c88c9d393556a16f0442c124c0d6b9c713e7544cb0efa5ad"},{"image":"ghcr.io/github/gh-aw-firewall/api-proxy:0.29.22@sha256:02149f4ed8b9c0bae954932745f2d16e8c5bd2b37adec5f788344806cd063dca"},{"image":"ghcr.io/github/gh-aw-firewall/cli-proxy:0.29.22@sha256:7b8ef50c5221824a425fbfabafb50767c5a4e6b0197a0fce6085fd9f7e97b5b7"},{"image":"ghcr.io/github/gh-aw-firewall/router:0.29.22@sha256:b4253735af3ab47c17bcdfaf86e91b541581e1338d3d9ead512a12ebd3f146fb"},{"image":"ghcr.io/github/gh-aw-firewall/squid:0.29.22@sha256:cf4dd8944eb5b389adcf49f42de0e884f46e07d63afc5824543e7c9ab8ddb882"},{"image":"ghcr.io/github/gh-aw-mcpg:v0.5.16","digest":"sha256:cd50cfae3acce5985985aee3964902c9358dcc809f1b68b8168cfe29b761b059","pinned_image":"ghcr.io/github/gh-aw-mcpg:v0.5.16@sha256:cd50cfae3acce5985985aee3964902c9358dcc809f1b68b8168cfe29b761b059"},{"image":"ghcr.io/github/gh-aw-node","digest":"sha256:1ee08ba84b321ff231ca905b73e6e7da8f5fd177bcc6433a56631fce2b5a0f2f","pinned_image":"ghcr.io/github/gh-aw-node@sha256:1ee08ba84b321ff231ca905b73e6e7da8f5fd177bcc6433a56631fce2b5a0f2f"},{"image":"ghcr.io/github/github-mcp-server:v2.3.0","digest":"sha256:f8ee4dedc7d5c8cb32854ab91cc92a31c55a8a5510708cf8742e9f9427588ca6","pinned_image":"ghcr.io/github/github-mcp-server:v2.3.0@sha256:f8ee4dedc7d5c8cb32854ab91cc92a31c55a8a5510708cf8742e9f9427588ca6"}],"mcp_servers":[{"name":"safeoutputs","tools":["add_comment","add_labels","noop","remove_labels","report_incomplete","report_missing_data","report_missing_tool"]}],"threat_detection":{"mode":"enabled"},"admission":false,"agent_metadata":{"14ba41178a91b10b7de6":{"name":"Agentic Workflows"}}}
|
||||||
# This file was automatically generated by gh-aw (v1.4.2). DO NOT EDIT. To debug this workflow, load the skill at https://github.com/github/gh-aw/blob/main/debug.md
|
# This file was automatically generated by gh-aw (v1.4.5). DO NOT EDIT. To debug this workflow, load the skill at https://github.com/github/gh-aw/blob/main/debug.md
|
||||||
#
|
#
|
||||||
# ___ _ _
|
# ___ _ _
|
||||||
# / _ \ | | (_)
|
# / _ \ | | (_)
|
||||||
@@ -44,12 +44,12 @@
|
|||||||
# - actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
# - actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||||
# - actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
# - actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
||||||
# - actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
# - actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
||||||
# - github/gh-aw-actions/setup@d7852d91d5d1d13e7848771edab8bd1792a08651 # v1.4.2
|
# - github/gh-aw-actions/setup@a83eaf07e756a15e65f669eb32d00787cf5a2569 # v1.4.5
|
||||||
#
|
#
|
||||||
# Container images used:
|
# Container images used:
|
||||||
# - ghcr.io/github/gh-aw-mcpg:v0.5.16@sha256:cd50cfae3acce5985985aee3964902c9358dcc809f1b68b8168cfe29b761b059
|
# - ghcr.io/github/gh-aw-mcpg:v0.5.16@sha256:cd50cfae3acce5985985aee3964902c9358dcc809f1b68b8168cfe29b761b059
|
||||||
# - ghcr.io/github/gh-aw-node@sha256:8735428c2d4e602f90781ba0c571c400e8ff93c7ee1508a75d71f87e34e415cc
|
# - ghcr.io/github/gh-aw-node@sha256:1ee08ba84b321ff231ca905b73e6e7da8f5fd177bcc6433a56631fce2b5a0f2f
|
||||||
# - ghcr.io/github/github-mcp-server:v2.2.0@sha256:040c4e99810076035eb1d9beb4b4a96fcf589c43cefed6ff51a46a553eb4e174
|
# - ghcr.io/github/github-mcp-server:v2.3.0@sha256:f8ee4dedc7d5c8cb32854ab91cc92a31c55a8a5510708cf8742e9f9427588ca6
|
||||||
# - ghcr.io/github/gh-aw-firewall/agent:0.29.22@sha256:f5829ed92ec390e9c88c9d393556a16f0442c124c0d6b9c713e7544cb0efa5ad
|
# - ghcr.io/github/gh-aw-firewall/agent:0.29.22@sha256:f5829ed92ec390e9c88c9d393556a16f0442c124c0d6b9c713e7544cb0efa5ad
|
||||||
# - ghcr.io/github/gh-aw-firewall/api-proxy:0.29.22@sha256:02149f4ed8b9c0bae954932745f2d16e8c5bd2b37adec5f788344806cd063dca
|
# - ghcr.io/github/gh-aw-firewall/api-proxy:0.29.22@sha256:02149f4ed8b9c0bae954932745f2d16e8c5bd2b37adec5f788344806cd063dca
|
||||||
# - ghcr.io/github/gh-aw-firewall/cli-proxy:0.29.22@sha256:7b8ef50c5221824a425fbfabafb50767c5a4e6b0197a0fce6085fd9f7e97b5b7
|
# - ghcr.io/github/gh-aw-firewall/cli-proxy:0.29.22@sha256:7b8ef50c5221824a425fbfabafb50767c5a4e6b0197a0fce6085fd9f7e97b5b7
|
||||||
@@ -130,7 +130,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Setup Scripts
|
- name: Setup Scripts
|
||||||
id: setup
|
id: setup
|
||||||
uses: github/gh-aw-actions/setup@d7852d91d5d1d13e7848771edab8bd1792a08651 # v1.4.2
|
uses: github/gh-aw-actions/setup@a83eaf07e756a15e65f669eb32d00787cf5a2569 # v1.4.5
|
||||||
with:
|
with:
|
||||||
destination: ${{ runner.temp }}/gh-aw/actions
|
destination: ${{ runner.temp }}/gh-aw/actions
|
||||||
job-name: ${{ github.job }}
|
job-name: ${{ github.job }}
|
||||||
@@ -152,7 +152,7 @@ jobs:
|
|||||||
GH_AW_INFO_MODEL: ${{ vars.GH_AW_MODEL_AGENT_COPILOT || vars.GH_AW_DEFAULT_MODEL_COPILOT || 'auto' }}
|
GH_AW_INFO_MODEL: ${{ vars.GH_AW_MODEL_AGENT_COPILOT || vars.GH_AW_DEFAULT_MODEL_COPILOT || 'auto' }}
|
||||||
GH_AW_INFO_VERSION: "1.0.103"
|
GH_AW_INFO_VERSION: "1.0.103"
|
||||||
GH_AW_INFO_AGENT_VERSION: "1.0.103"
|
GH_AW_INFO_AGENT_VERSION: "1.0.103"
|
||||||
GH_AW_INFO_CLI_VERSION: "v1.4.2"
|
GH_AW_INFO_CLI_VERSION: "v1.4.5"
|
||||||
GH_AW_INFO_WORKFLOW_NAME: "PR AI Slop Review"
|
GH_AW_INFO_WORKFLOW_NAME: "PR AI Slop Review"
|
||||||
GH_AW_INFO_WORKFLOW_ID: ${{ job.workflow_ref }}
|
GH_AW_INFO_WORKFLOW_ID: ${{ job.workflow_ref }}
|
||||||
GH_AW_INFO_WORKFLOW_SHA: ${{ job.workflow_sha }}
|
GH_AW_INFO_WORKFLOW_SHA: ${{ job.workflow_sha }}
|
||||||
@@ -271,7 +271,7 @@ jobs:
|
|||||||
if: steps.daily-ai-credits-workflow-guardrail.outputs.daily_ai_credits_guardrail_status != 'quota_blocked'
|
if: steps.daily-ai-credits-workflow-guardrail.outputs.daily_ai_credits_guardrail_status != 'quota_blocked'
|
||||||
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||||
env:
|
env:
|
||||||
GH_AW_COMPILED_VERSION: "v1.4.2"
|
GH_AW_COMPILED_VERSION: "v1.4.5"
|
||||||
GH_AW_HAS_SAFE_OUTPUTS: "true"
|
GH_AW_HAS_SAFE_OUTPUTS: "true"
|
||||||
GH_AW_BLOCKED_VERSION_REPORT_AS_ISSUE: "false"
|
GH_AW_BLOCKED_VERSION_REPORT_AS_ISSUE: "false"
|
||||||
GH_AW_WORKFLOW_NAME: "PR AI Slop Review"
|
GH_AW_WORKFLOW_NAME: "PR AI Slop Review"
|
||||||
@@ -558,7 +558,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Setup Scripts
|
- name: Setup Scripts
|
||||||
id: setup
|
id: setup
|
||||||
uses: github/gh-aw-actions/setup@d7852d91d5d1d13e7848771edab8bd1792a08651 # v1.4.2
|
uses: github/gh-aw-actions/setup@a83eaf07e756a15e65f669eb32d00787cf5a2569 # v1.4.5
|
||||||
with:
|
with:
|
||||||
destination: ${{ runner.temp }}/gh-aw/actions
|
destination: ${{ runner.temp }}/gh-aw/actions
|
||||||
job-name: ${{ github.job }}
|
job-name: ${{ github.job }}
|
||||||
@@ -654,7 +654,7 @@ jobs:
|
|||||||
run: "node <<'NODE'\nconst fs = require('fs');\nconst harnessPath = `${process.env.RUNNER_TEMP}/gh-aw/actions/copilot_harness.cjs`;\nconst harness = fs.readFileSync(harnessPath, 'utf8');\nconst quotaBranch = [\n ' if (isQuotaExceeded && (result.retryAfterMs == null || /\\\\bquota exceeded\\\\b/i.test(result.output))) {',\n ' log(`attempt ${attempt + 1}: Copilot quota exceeded — not retrying`);',\n ' return { action: \"stop\" };',\n ' }',\n].join('\\n');\nconst nonBlockingQuotaBranch = [\n ' let quotaErrorMsg = null;',\n ' if (isQuotaExceeded && (result.retryAfterMs == null || /\\\\bquota exceeded\\\\b/i.test(result.output))) {',\n ' log(`attempt ${attempt + 1}: Copilot quota exceeded — not retrying`);',\n ' quotaErrorMsg = { action: \"stop\" };',\n ' }',\n ' if (/\\\\b429\\\\b|Too Many Requests/i.test(result.output)) {',\n ' log(`attempt ${attempt + 1}: Copilot quota unavailable — exiting 0`);',\n ' quotaErrorMsg = { action: \"stop\", exitCode: 0 };',\n ' }',\n ' if (quotaErrorMsg) {',\n ' return quotaErrorMsg;',\n ' }',\n].join('\\n');\n\nif (harness.split(quotaBranch).length !== 2) {\n throw new Error('Unexpected Copilot quota branch; re-audit the gh-aw upgrade');\n}\nfs.writeFileSync(harnessPath, harness.replace(quotaBranch, nonBlockingQuotaBranch));\nNODE"
|
run: "node <<'NODE'\nconst fs = require('fs');\nconst harnessPath = `${process.env.RUNNER_TEMP}/gh-aw/actions/copilot_harness.cjs`;\nconst harness = fs.readFileSync(harnessPath, 'utf8');\nconst quotaBranch = [\n ' if (isQuotaExceeded && (result.retryAfterMs == null || /\\\\bquota exceeded\\\\b/i.test(result.output))) {',\n ' log(`attempt ${attempt + 1}: Copilot quota exceeded — not retrying`);',\n ' return { action: \"stop\" };',\n ' }',\n].join('\\n');\nconst nonBlockingQuotaBranch = [\n ' let quotaErrorMsg = null;',\n ' if (isQuotaExceeded && (result.retryAfterMs == null || /\\\\bquota exceeded\\\\b/i.test(result.output))) {',\n ' log(`attempt ${attempt + 1}: Copilot quota exceeded — not retrying`);',\n ' quotaErrorMsg = { action: \"stop\" };',\n ' }',\n ' if (/\\\\b429\\\\b|Too Many Requests/i.test(result.output)) {',\n ' log(`attempt ${attempt + 1}: Copilot quota unavailable — exiting 0`);',\n ' quotaErrorMsg = { action: \"stop\", exitCode: 0 };',\n ' }',\n ' if (quotaErrorMsg) {',\n ' return quotaErrorMsg;',\n ' }',\n].join('\\n');\n\nif (harness.split(quotaBranch).length !== 2) {\n throw new Error('Unexpected Copilot quota branch; re-audit the gh-aw upgrade');\n}\nfs.writeFileSync(harnessPath, harness.replace(quotaBranch, nonBlockingQuotaBranch));\nNODE"
|
||||||
|
|
||||||
- name: Download container images
|
- name: Download container images
|
||||||
run: bash "${RUNNER_TEMP}/gh-aw/actions/download_docker_images.sh" ghcr.io/github/gh-aw-mcpg:v0.5.16@sha256:cd50cfae3acce5985985aee3964902c9358dcc809f1b68b8168cfe29b761b059 ghcr.io/github/gh-aw-node@sha256:8735428c2d4e602f90781ba0c571c400e8ff93c7ee1508a75d71f87e34e415cc ghcr.io/github/github-mcp-server:v2.2.0@sha256:040c4e99810076035eb1d9beb4b4a96fcf589c43cefed6ff51a46a553eb4e174 ghcr.io/github/gh-aw-firewall/agent:0.29.22@sha256:f5829ed92ec390e9c88c9d393556a16f0442c124c0d6b9c713e7544cb0efa5ad ghcr.io/github/gh-aw-firewall/api-proxy:0.29.22@sha256:02149f4ed8b9c0bae954932745f2d16e8c5bd2b37adec5f788344806cd063dca ghcr.io/github/gh-aw-firewall/cli-proxy:0.29.22@sha256:7b8ef50c5221824a425fbfabafb50767c5a4e6b0197a0fce6085fd9f7e97b5b7 ghcr.io/github/gh-aw-firewall/router:0.29.22@sha256:b4253735af3ab47c17bcdfaf86e91b541581e1338d3d9ead512a12ebd3f146fb ghcr.io/github/gh-aw-firewall/squid:0.29.22@sha256:cf4dd8944eb5b389adcf49f42de0e884f46e07d63afc5824543e7c9ab8ddb882
|
run: bash "${RUNNER_TEMP}/gh-aw/actions/download_docker_images.sh" ghcr.io/github/gh-aw-mcpg:v0.5.16@sha256:cd50cfae3acce5985985aee3964902c9358dcc809f1b68b8168cfe29b761b059 ghcr.io/github/gh-aw-node@sha256:1ee08ba84b321ff231ca905b73e6e7da8f5fd177bcc6433a56631fce2b5a0f2f ghcr.io/github/github-mcp-server:v2.3.0@sha256:f8ee4dedc7d5c8cb32854ab91cc92a31c55a8a5510708cf8742e9f9427588ca6 ghcr.io/github/gh-aw-firewall/agent:0.29.22@sha256:f5829ed92ec390e9c88c9d393556a16f0442c124c0d6b9c713e7544cb0efa5ad ghcr.io/github/gh-aw-firewall/api-proxy:0.29.22@sha256:02149f4ed8b9c0bae954932745f2d16e8c5bd2b37adec5f788344806cd063dca ghcr.io/github/gh-aw-firewall/cli-proxy:0.29.22@sha256:7b8ef50c5221824a425fbfabafb50767c5a4e6b0197a0fce6085fd9f7e97b5b7 ghcr.io/github/gh-aw-firewall/router:0.29.22@sha256:b4253735af3ab47c17bcdfaf86e91b541581e1338d3d9ead512a12ebd3f146fb ghcr.io/github/gh-aw-firewall/squid:0.29.22@sha256:cf4dd8944eb5b389adcf49f42de0e884f46e07d63afc5824543e7c9ab8ddb882
|
||||||
- name: Prepare Safe Outputs Directories
|
- name: Prepare Safe Outputs Directories
|
||||||
run: |
|
run: |
|
||||||
mkdir -p "${RUNNER_TEMP}/gh-aw/safeoutputs"
|
mkdir -p "${RUNNER_TEMP}/gh-aw/safeoutputs"
|
||||||
@@ -899,12 +899,12 @@ jobs:
|
|||||||
|
|
||||||
mkdir -p "$HOME/.copilot"
|
mkdir -p "$HOME/.copilot"
|
||||||
GH_AW_NODE=$(which node 2>/dev/null || command -v node 2>/dev/null || echo node)
|
GH_AW_NODE=$(which node 2>/dev/null || command -v node 2>/dev/null || echo node)
|
||||||
cat << GH_AW_MCP_CONFIG_d448207cb151e2cb_EOF | "$GH_AW_NODE" "${RUNNER_TEMP}/gh-aw/actions/start_mcp_gateway.cjs"
|
cat << GH_AW_MCP_CONFIG_36d6009112b7e687_EOF | "$GH_AW_NODE" "${RUNNER_TEMP}/gh-aw/actions/start_mcp_gateway.cjs"
|
||||||
{
|
{
|
||||||
"mcpServers": {
|
"mcpServers": {
|
||||||
"safeoutputs": {
|
"safeoutputs": {
|
||||||
"type": "stdio",
|
"type": "stdio",
|
||||||
"container": "ghcr.io/github/gh-aw-node@sha256:8735428c2d4e602f90781ba0c571c400e8ff93c7ee1508a75d71f87e34e415cc",
|
"container": "ghcr.io/github/gh-aw-node@sha256:1ee08ba84b321ff231ca905b73e6e7da8f5fd177bcc6433a56631fce2b5a0f2f",
|
||||||
"mounts": ["\${GITHUB_WORKSPACE}:\${GITHUB_WORKSPACE}:rw", "${RUNNER_TEMP}/gh-aw/safeoutputs:${RUNNER_TEMP}/gh-aw/safeoutputs:rw", "/tmp/gh-aw:/tmp/gh-aw:rw"],
|
"mounts": ["\${GITHUB_WORKSPACE}:\${GITHUB_WORKSPACE}:rw", "${RUNNER_TEMP}/gh-aw/safeoutputs:${RUNNER_TEMP}/gh-aw/safeoutputs:rw", "/tmp/gh-aw:/tmp/gh-aw:rw"],
|
||||||
"args": ["-w", "\${GITHUB_WORKSPACE}"],
|
"args": ["-w", "\${GITHUB_WORKSPACE}"],
|
||||||
"entrypoint": "sh",
|
"entrypoint": "sh",
|
||||||
@@ -963,7 +963,7 @@ jobs:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GH_AW_MCP_CONFIG_d448207cb151e2cb_EOF
|
GH_AW_MCP_CONFIG_36d6009112b7e687_EOF
|
||||||
- name: Mount MCP servers as CLIs
|
- name: Mount MCP servers as CLIs
|
||||||
id: mount-mcp-clis
|
id: mount-mcp-clis
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
@@ -1104,7 +1104,7 @@ jobs:
|
|||||||
GH_AW_PROMPT: /tmp/gh-aw/aw-prompts/prompt.txt
|
GH_AW_PROMPT: /tmp/gh-aw/aw-prompts/prompt.txt
|
||||||
GH_AW_SAFE_OUTPUTS: ${{ steps.set-runtime-paths.outputs.GH_AW_SAFE_OUTPUTS }}
|
GH_AW_SAFE_OUTPUTS: ${{ steps.set-runtime-paths.outputs.GH_AW_SAFE_OUTPUTS }}
|
||||||
GH_AW_TIMEOUT_MINUTES: ${{ fromJSON(vars.GH_AW_DEFAULT_TIMEOUT_MINUTES || '20') }}
|
GH_AW_TIMEOUT_MINUTES: ${{ fromJSON(vars.GH_AW_DEFAULT_TIMEOUT_MINUTES || '20') }}
|
||||||
GH_AW_VERSION: v1.4.2
|
GH_AW_VERSION: v1.4.5
|
||||||
GH_TOKEN: ${{ secrets.GH_AW_GITHUB_TOKEN || github.token }}
|
GH_TOKEN: ${{ secrets.GH_AW_GITHUB_TOKEN || github.token }}
|
||||||
GITHUB_API_URL: ${{ github.api_url }}
|
GITHUB_API_URL: ${{ github.api_url }}
|
||||||
GITHUB_AW: true
|
GITHUB_AW: true
|
||||||
@@ -1197,8 +1197,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GH_AW_SAFE_OUTPUTS: ${{ steps.set-runtime-paths.outputs.GH_AW_SAFE_OUTPUTS }}
|
GH_AW_SAFE_OUTPUTS: ${{ steps.set-runtime-paths.outputs.GH_AW_SAFE_OUTPUTS }}
|
||||||
run: |
|
run: |
|
||||||
mkdir -p /tmp/gh-aw
|
bash "${RUNNER_TEMP}/gh-aw/actions/safe_copy.sh" file "$GH_AW_SAFE_OUTPUTS" /tmp/gh-aw/safeoutputs.jsonl || true
|
||||||
cp "$GH_AW_SAFE_OUTPUTS" /tmp/gh-aw/safeoutputs.jsonl 2>/dev/null || true
|
|
||||||
- name: Ingest agent output
|
- name: Ingest agent output
|
||||||
id: collect_output
|
id: collect_output
|
||||||
if: always()
|
if: always()
|
||||||
@@ -1417,7 +1416,7 @@ jobs:
|
|||||||
permissions:
|
permissions:
|
||||||
actions: read # Read workflow runs and artifacts for workflow context.
|
actions: read # Read workflow runs and artifacts for workflow context.
|
||||||
id-token: write # Request an OIDC token for authenticated services.
|
id-token: write # Request an OIDC token for authenticated services.
|
||||||
issues: write # Create or update issues and comments.
|
issues: write # Enabled by issue reporting, safe outputs, steering, work queues, reaction cleanup, or explicit job permissions.
|
||||||
pull-requests: write # Create or update pull requests and review comments.
|
pull-requests: write # Create or update pull requests and review comments.
|
||||||
concurrency:
|
concurrency:
|
||||||
group: "gh-aw-conclusion-pr-ai-slop-review-${{ inputs.pr_number }}"
|
group: "gh-aw-conclusion-pr-ai-slop-review-${{ inputs.pr_number }}"
|
||||||
@@ -1437,7 +1436,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Setup Scripts
|
- name: Setup Scripts
|
||||||
id: setup
|
id: setup
|
||||||
uses: github/gh-aw-actions/setup@d7852d91d5d1d13e7848771edab8bd1792a08651 # v1.4.2
|
uses: github/gh-aw-actions/setup@a83eaf07e756a15e65f669eb32d00787cf5a2569 # v1.4.5
|
||||||
with:
|
with:
|
||||||
destination: ${{ runner.temp }}/gh-aw/actions
|
destination: ${{ runner.temp }}/gh-aw/actions
|
||||||
job-name: ${{ github.job }}
|
job-name: ${{ github.job }}
|
||||||
@@ -1816,7 +1815,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Setup Scripts
|
- name: Setup Scripts
|
||||||
id: setup
|
id: setup
|
||||||
uses: github/gh-aw-actions/setup@d7852d91d5d1d13e7848771edab8bd1792a08651 # v1.4.2
|
uses: github/gh-aw-actions/setup@a83eaf07e756a15e65f669eb32d00787cf5a2569 # v1.4.5
|
||||||
with:
|
with:
|
||||||
destination: ${{ runner.temp }}/gh-aw/actions
|
destination: ${{ runner.temp }}/gh-aw/actions
|
||||||
job-name: ${{ github.job }}
|
job-name: ${{ github.job }}
|
||||||
@@ -1830,11 +1829,12 @@ jobs:
|
|||||||
GH_AW_INFO_ENGINE_ID: "copilot"
|
GH_AW_INFO_ENGINE_ID: "copilot"
|
||||||
GH_AW_SETUP_AW_CONTEXT: ${{ inputs.aw_context }}
|
GH_AW_SETUP_AW_CONTEXT: ${{ inputs.aw_context }}
|
||||||
- name: Download activation artifact
|
- name: Download activation artifact
|
||||||
|
id: download-detection-activation
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
||||||
with:
|
with:
|
||||||
name: activation
|
name: activation
|
||||||
path: /tmp/gh-aw
|
path: ${{ runner.temp }}/gh-aw-detection-activation
|
||||||
- name: Download agent output artifact
|
- name: Download agent output artifact
|
||||||
id: download-agent-output
|
id: download-agent-output
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
@@ -1855,6 +1855,10 @@ jobs:
|
|||||||
- name: Clear agent token usage
|
- name: Clear agent token usage
|
||||||
if: always()
|
if: always()
|
||||||
run: rm -f /tmp/gh-aw/agent_usage.json
|
run: rm -f /tmp/gh-aw/agent_usage.json
|
||||||
|
- name: Restore activation metadata
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
bash "${RUNNER_TEMP}/gh-aw/actions/restore_detection_activation_metadata.sh" "${RUNNER_TEMP}/gh-aw-detection-activation" "/tmp/gh-aw"
|
||||||
- name: Checkout repository for patch context
|
- name: Checkout repository for patch context
|
||||||
if: needs.agent.outputs.has_patch == 'true'
|
if: needs.agent.outputs.has_patch == 'true'
|
||||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
@@ -1903,8 +1907,10 @@ jobs:
|
|||||||
- name: Prepare threat detection files
|
- name: Prepare threat detection files
|
||||||
id: detection_prepare
|
id: detection_prepare
|
||||||
if: always() && steps.detection_guard.outputs.run_detection == 'true'
|
if: always() && steps.detection_guard.outputs.run_detection == 'true'
|
||||||
|
env:
|
||||||
|
ACTIVATION_DOWNLOAD_OUTCOME: ${{ steps.download-detection-activation.outcome }}
|
||||||
run: |
|
run: |
|
||||||
bash "${RUNNER_TEMP}/gh-aw/actions/prepare_threat_detection_files.sh"
|
bash "${RUNNER_TEMP}/gh-aw/actions/prepare_detection_inputs.sh" "${RUNNER_TEMP}/gh-aw-detection-activation" "/tmp/gh-aw"
|
||||||
- name: Install AWF binary
|
- name: Install AWF binary
|
||||||
id: detection_awf_install
|
id: detection_awf_install
|
||||||
run: bash "${RUNNER_TEMP}/gh-aw/actions/install_awf_binary.sh" v0.29.22 --rootless
|
run: bash "${RUNNER_TEMP}/gh-aw/actions/install_awf_binary.sh" v0.29.22 --rootless
|
||||||
@@ -1921,7 +1927,7 @@ jobs:
|
|||||||
GH_AW_COPILOT_MIN_VERSION: 1.0.35
|
GH_AW_COPILOT_MIN_VERSION: 1.0.35
|
||||||
- name: Execute threat detection with AWF
|
- name: Execute threat detection with AWF
|
||||||
id: detection_agentic_execution
|
id: detection_agentic_execution
|
||||||
if: always() && steps.detection_guard.outputs.run_detection == 'true' && steps.detection_staging_reset.outcome == 'success' && steps.detection_prepare.outcome == 'success' && steps.detection_awf_install.outcome == 'success'
|
if: always() && steps.detection_guard.outputs.run_detection == 'true' && steps.detection_prepare.outcome == 'success' && steps.detection_staging_reset.outcome == 'success' && steps.detection_awf_install.outcome == 'success'
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
timeout-minutes: 10
|
timeout-minutes: 10
|
||||||
env:
|
env:
|
||||||
@@ -1934,11 +1940,11 @@ jobs:
|
|||||||
GH_AW_LLM_PROVIDER: github
|
GH_AW_LLM_PROVIDER: github
|
||||||
GH_AW_MAX_AI_CREDITS: ${{ vars.GH_AW_DEFAULT_DETECTION_MAX_AI_CREDITS || '400' }}
|
GH_AW_MAX_AI_CREDITS: ${{ vars.GH_AW_DEFAULT_DETECTION_MAX_AI_CREDITS || '400' }}
|
||||||
GH_AW_MAX_TURNS: ${{ vars.GH_AW_DEFAULT_MAX_TURNS || '' }}
|
GH_AW_MAX_TURNS: ${{ vars.GH_AW_DEFAULT_MAX_TURNS || '' }}
|
||||||
GH_AW_MODEL_FALLBACK: ${{ vars.GH_AW_MODEL_DETECTION_COPILOT || vars.GH_AW_DEFAULT_MODEL_COPILOT || 'auto' }}
|
GH_AW_MODEL_FALLBACK: ${{ vars.GH_AW_MODEL_DETECTION_COPILOT || vars.GH_AW_DEFAULT_MODEL_COPILOT || 'detection' }}
|
||||||
GH_AW_PHASE: detection
|
GH_AW_PHASE: detection
|
||||||
GH_AW_PROMPT: /tmp/gh-aw/aw-prompts/prompt.txt
|
GH_AW_PROMPT: /tmp/gh-aw/aw-prompts/prompt.txt
|
||||||
GH_AW_TIMEOUT_MINUTES: 10
|
GH_AW_TIMEOUT_MINUTES: 10
|
||||||
GH_AW_VERSION: v1.4.2
|
GH_AW_VERSION: v1.4.5
|
||||||
GITHUB_API_URL: ${{ github.api_url }}
|
GITHUB_API_URL: ${{ github.api_url }}
|
||||||
GITHUB_AW: true
|
GITHUB_AW: true
|
||||||
GITHUB_COPILOT_INTEGRATION_ID: agentic-workflows
|
GITHUB_COPILOT_INTEGRATION_ID: agentic-workflows
|
||||||
@@ -2023,9 +2029,8 @@ jobs:
|
|||||||
if: always() && steps.detection_guard.outputs.run_detection == 'true'
|
if: always() && steps.detection_guard.outputs.run_detection == 'true'
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
run: |
|
run: |
|
||||||
mkdir -p /tmp/gh-aw/threat-detection/sandbox/firewall
|
bash "${RUNNER_TEMP}/gh-aw/actions/safe_copy.sh" tree /tmp/gh-aw/sandbox/firewall/logs /tmp/gh-aw/threat-detection/sandbox/firewall/logs
|
||||||
if [ -d /tmp/gh-aw/sandbox/firewall/logs ]; then mkdir -p /tmp/gh-aw/threat-detection/sandbox/firewall/logs && cp -r /tmp/gh-aw/sandbox/firewall/logs/. /tmp/gh-aw/threat-detection/sandbox/firewall/logs/; fi
|
bash "${RUNNER_TEMP}/gh-aw/actions/safe_copy.sh" tree /tmp/gh-aw/sandbox/firewall/audit /tmp/gh-aw/threat-detection/sandbox/firewall/audit
|
||||||
if [ -d /tmp/gh-aw/sandbox/firewall/audit ]; then mkdir -p /tmp/gh-aw/threat-detection/sandbox/firewall/audit && cp -r /tmp/gh-aw/sandbox/firewall/audit/. /tmp/gh-aw/threat-detection/sandbox/firewall/audit/; fi
|
|
||||||
- name: Redact secrets in detection logs
|
- name: Redact secrets in detection logs
|
||||||
id: redact_detection_logs
|
id: redact_detection_logs
|
||||||
if: always() && steps.detection_guard.outputs.run_detection == 'true'
|
if: always() && steps.detection_guard.outputs.run_detection == 'true'
|
||||||
@@ -2046,7 +2051,7 @@ jobs:
|
|||||||
await main({ additionalDirectories: ["/tmp/gh-aw/threat-detection/sandbox/firewall"], persistDetectionMasks });
|
await main({ additionalDirectories: ["/tmp/gh-aw/threat-detection/sandbox/firewall"], persistDetectionMasks });
|
||||||
- name: Parse threat detection token usage for step summary
|
- name: Parse threat detection token usage for step summary
|
||||||
id: parse_detection_token_usage
|
id: parse_detection_token_usage
|
||||||
if: always() && steps.detection_guard.outputs.run_detection == 'true' && steps.redact_detection_logs.outcome == 'success'
|
if: always() && steps.detection_guard.outputs.run_detection == 'true' && steps.detection_prepare.outcome == 'success' && steps.redact_detection_logs.outcome == 'success'
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||||
env:
|
env:
|
||||||
@@ -2082,7 +2087,7 @@ jobs:
|
|||||||
const { persistDetectionMasks } = require(path.join(actionsDir, 'detection_mask_state.cjs'));
|
const { persistDetectionMasks } = require(path.join(actionsDir, 'detection_mask_state.cjs'));
|
||||||
await main({ additionalDirectories: ["/tmp/gh-aw/threat-detection/sandbox/firewall"], persistDetectionMasks });
|
await main({ additionalDirectories: ["/tmp/gh-aw/threat-detection/sandbox/firewall"], persistDetectionMasks });
|
||||||
- name: Render detection log
|
- name: Render detection log
|
||||||
if: always() && steps.detection_guard.outputs.run_detection == 'true' && steps.redact_detection_logs.outcome == 'success' && steps.redact_detection_artifacts.outcome == 'success'
|
if: always() && steps.detection_guard.outputs.run_detection == 'true' && steps.detection_prepare.outcome == 'success' && steps.redact_detection_logs.outcome == 'success' && steps.redact_detection_artifacts.outcome == 'success'
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||||
with:
|
with:
|
||||||
@@ -2094,7 +2099,7 @@ jobs:
|
|||||||
const { main } = require(path.join(actionsDir, 'render_detection_log.cjs'));
|
const { main } = require(path.join(actionsDir, 'render_detection_log.cjs'));
|
||||||
await main();
|
await main();
|
||||||
- name: Upload threat detection artifact
|
- name: Upload threat detection artifact
|
||||||
if: always() && steps.detection_guard.outputs.run_detection == 'true' && steps.redact_detection_logs.outcome == 'success' && steps.redact_detection_artifacts.outcome == 'success' && steps.detection_staging_reset.outcome == 'success'
|
if: always() && steps.detection_guard.outputs.run_detection == 'true' && steps.detection_prepare.outcome == 'success' && steps.redact_detection_logs.outcome == 'success' && steps.redact_detection_artifacts.outcome == 'success' && steps.detection_staging_reset.outcome == 'success'
|
||||||
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
||||||
with:
|
with:
|
||||||
name: detection
|
name: detection
|
||||||
@@ -2110,7 +2115,7 @@ jobs:
|
|||||||
retention-days: ${{ vars.GH_AW_DEFAULT_ARTIFACT_RETENTION_DAYS || '0' }}
|
retention-days: ${{ vars.GH_AW_DEFAULT_ARTIFACT_RETENTION_DAYS || '0' }}
|
||||||
- name: Conclude threat detection
|
- name: Conclude threat detection
|
||||||
id: detection_conclusion
|
id: detection_conclusion
|
||||||
if: always() && steps.detection_guard.outputs.run_detection == 'false' || (always() && steps.detection_guard.outputs.run_detection == 'true' && steps.redact_detection_logs.outcome == 'success' && steps.redact_detection_artifacts.outcome == 'success')
|
if: always() && steps.detection_guard.outputs.run_detection == 'false' || (always() && steps.detection_guard.outputs.run_detection == 'true' && steps.detection_prepare.outcome == 'success' && steps.redact_detection_logs.outcome == 'success' && steps.redact_detection_artifacts.outcome == 'success')
|
||||||
env:
|
env:
|
||||||
RUN_DETECTION: ${{ steps.detection_guard.outputs.run_detection }}
|
RUN_DETECTION: ${{ steps.detection_guard.outputs.run_detection }}
|
||||||
DETECTION_AGENTIC_EXECUTION_OUTCOME: ${{ steps.detection_agentic_execution.outcome }}
|
DETECTION_AGENTIC_EXECUTION_OUTCOME: ${{ steps.detection_agentic_execution.outcome }}
|
||||||
@@ -2182,7 +2187,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Setup Scripts
|
- name: Setup Scripts
|
||||||
id: setup
|
id: setup
|
||||||
uses: github/gh-aw-actions/setup@d7852d91d5d1d13e7848771edab8bd1792a08651 # v1.4.2
|
uses: github/gh-aw-actions/setup@a83eaf07e756a15e65f669eb32d00787cf5a2569 # v1.4.5
|
||||||
with:
|
with:
|
||||||
destination: ${{ runner.temp }}/gh-aw/actions
|
destination: ${{ runner.temp }}/gh-aw/actions
|
||||||
job-name: ${{ github.job }}
|
job-name: ${{ github.job }}
|
||||||
|
|||||||
Generated
+39
-34
@@ -1,6 +1,6 @@
|
|||||||
# gh-aw-metadata: {"schema_version":"v4","frontmatter_hash":"d6b72464a3766dd7d74aefe4c7dd982ae7ae2db951f8040f978feca9166adb39","body_hash":"deddd98c5fa425a91487fb5f50dc59ac61ae395bdcd4dff6543f1e8e563a7d73","compiler_version":"v1.4.2","strict":true,"agent_id":"copilot","engine_versions":{"copilot":"1.0.103"}}
|
# gh-aw-metadata: {"schema_version":"v4","frontmatter_hash":"d6b72464a3766dd7d74aefe4c7dd982ae7ae2db951f8040f978feca9166adb39","body_hash":"deddd98c5fa425a91487fb5f50dc59ac61ae395bdcd4dff6543f1e8e563a7d73","compiler_version":"v1.4.5","strict":true,"agent_id":"copilot","engine_versions":{"copilot":"1.0.103"}}
|
||||||
# gh-aw-manifest: {"version":1,"secrets":["COPILOT_GITHUB_TOKEN","GH_AW_DEFAULT_OTLP_ENDPOINT","GH_AW_DEFAULT_OTLP_HEADERS","GH_AW_GITHUB_MCP_SERVER_TOKEN","GH_AW_GITHUB_TOKEN","GITHUB_TOKEN"],"actions":[{"repo":"actions/checkout","sha":"3d3c42e5aac5ba805825da76410c181273ba90b1","version":"v7.0.1"},{"repo":"actions/download-artifact","sha":"9000827ccba6bdab643e8b6fd33ac0654aef8333","version":"v8.0.2"},{"repo":"actions/github-script","sha":"3a2844b7e9c422d3c10d287c895573f7108da1b3","version":"v9.0.0"},{"repo":"actions/setup-node","sha":"949feb2413d6458794dcd2491c4babbbce0c15c1","version":"v7.1.0"},{"repo":"actions/upload-artifact","sha":"cf430e030ddbb5b0abf93d22962f4752f3646cd9","version":"v7.0.2"},{"repo":"github/gh-aw-actions/setup","sha":"d7852d91d5d1d13e7848771edab8bd1792a08651","version":"v1.4.2"}],"containers":[{"image":"ghcr.io/github/gh-aw-firewall/agent:0.29.22@sha256:f5829ed92ec390e9c88c9d393556a16f0442c124c0d6b9c713e7544cb0efa5ad"},{"image":"ghcr.io/github/gh-aw-firewall/api-proxy:0.29.22@sha256:02149f4ed8b9c0bae954932745f2d16e8c5bd2b37adec5f788344806cd063dca"},{"image":"ghcr.io/github/gh-aw-firewall/cli-proxy:0.29.22@sha256:7b8ef50c5221824a425fbfabafb50767c5a4e6b0197a0fce6085fd9f7e97b5b7"},{"image":"ghcr.io/github/gh-aw-firewall/router:0.29.22@sha256:b4253735af3ab47c17bcdfaf86e91b541581e1338d3d9ead512a12ebd3f146fb"},{"image":"ghcr.io/github/gh-aw-firewall/squid:0.29.22@sha256:cf4dd8944eb5b389adcf49f42de0e884f46e07d63afc5824543e7c9ab8ddb882"},{"image":"ghcr.io/github/gh-aw-mcpg:v0.5.16","digest":"sha256:cd50cfae3acce5985985aee3964902c9358dcc809f1b68b8168cfe29b761b059","pinned_image":"ghcr.io/github/gh-aw-mcpg:v0.5.16@sha256:cd50cfae3acce5985985aee3964902c9358dcc809f1b68b8168cfe29b761b059"},{"image":"ghcr.io/github/gh-aw-node","digest":"sha256:8735428c2d4e602f90781ba0c571c400e8ff93c7ee1508a75d71f87e34e415cc","pinned_image":"ghcr.io/github/gh-aw-node@sha256:8735428c2d4e602f90781ba0c571c400e8ff93c7ee1508a75d71f87e34e415cc"},{"image":"ghcr.io/github/github-mcp-server:v2.2.0","digest":"sha256:040c4e99810076035eb1d9beb4b4a96fcf589c43cefed6ff51a46a553eb4e174","pinned_image":"ghcr.io/github/github-mcp-server:v2.2.0@sha256:040c4e99810076035eb1d9beb4b4a96fcf589c43cefed6ff51a46a553eb4e174"}],"mcp_servers":[{"name":"safeoutputs","tools":["add_comment","noop","report_incomplete","report_missing_data","report_missing_tool"]}],"threat_detection":{"mode":"enabled"},"admission":false,"agent_metadata":{"14ba41178a91b10b7de6":{"name":"Agentic Workflows"}}}
|
# gh-aw-manifest: {"version":1,"secrets":["COPILOT_GITHUB_TOKEN","GH_AW_DEFAULT_OTLP_ENDPOINT","GH_AW_DEFAULT_OTLP_HEADERS","GH_AW_GITHUB_MCP_SERVER_TOKEN","GH_AW_GITHUB_TOKEN","GITHUB_TOKEN"],"actions":[{"repo":"actions/checkout","sha":"3d3c42e5aac5ba805825da76410c181273ba90b1","version":"v7.0.1"},{"repo":"actions/download-artifact","sha":"9000827ccba6bdab643e8b6fd33ac0654aef8333","version":"v8.0.2"},{"repo":"actions/github-script","sha":"3a2844b7e9c422d3c10d287c895573f7108da1b3","version":"v9.0.0"},{"repo":"actions/setup-node","sha":"949feb2413d6458794dcd2491c4babbbce0c15c1","version":"v7.1.0"},{"repo":"actions/upload-artifact","sha":"cf430e030ddbb5b0abf93d22962f4752f3646cd9","version":"v7.0.2"},{"repo":"github/gh-aw-actions/setup","sha":"a83eaf07e756a15e65f669eb32d00787cf5a2569","version":"v1.4.5"}],"containers":[{"image":"ghcr.io/github/gh-aw-firewall/agent:0.29.22@sha256:f5829ed92ec390e9c88c9d393556a16f0442c124c0d6b9c713e7544cb0efa5ad"},{"image":"ghcr.io/github/gh-aw-firewall/api-proxy:0.29.22@sha256:02149f4ed8b9c0bae954932745f2d16e8c5bd2b37adec5f788344806cd063dca"},{"image":"ghcr.io/github/gh-aw-firewall/cli-proxy:0.29.22@sha256:7b8ef50c5221824a425fbfabafb50767c5a4e6b0197a0fce6085fd9f7e97b5b7"},{"image":"ghcr.io/github/gh-aw-firewall/router:0.29.22@sha256:b4253735af3ab47c17bcdfaf86e91b541581e1338d3d9ead512a12ebd3f146fb"},{"image":"ghcr.io/github/gh-aw-firewall/squid:0.29.22@sha256:cf4dd8944eb5b389adcf49f42de0e884f46e07d63afc5824543e7c9ab8ddb882"},{"image":"ghcr.io/github/gh-aw-mcpg:v0.5.16","digest":"sha256:cd50cfae3acce5985985aee3964902c9358dcc809f1b68b8168cfe29b761b059","pinned_image":"ghcr.io/github/gh-aw-mcpg:v0.5.16@sha256:cd50cfae3acce5985985aee3964902c9358dcc809f1b68b8168cfe29b761b059"},{"image":"ghcr.io/github/gh-aw-node","digest":"sha256:1ee08ba84b321ff231ca905b73e6e7da8f5fd177bcc6433a56631fce2b5a0f2f","pinned_image":"ghcr.io/github/gh-aw-node@sha256:1ee08ba84b321ff231ca905b73e6e7da8f5fd177bcc6433a56631fce2b5a0f2f"},{"image":"ghcr.io/github/github-mcp-server:v2.3.0","digest":"sha256:f8ee4dedc7d5c8cb32854ab91cc92a31c55a8a5510708cf8742e9f9427588ca6","pinned_image":"ghcr.io/github/github-mcp-server:v2.3.0@sha256:f8ee4dedc7d5c8cb32854ab91cc92a31c55a8a5510708cf8742e9f9427588ca6"}],"mcp_servers":[{"name":"safeoutputs","tools":["add_comment","noop","report_incomplete","report_missing_data","report_missing_tool"]}],"threat_detection":{"mode":"enabled"},"admission":false,"agent_metadata":{"14ba41178a91b10b7de6":{"name":"Agentic Workflows"}}}
|
||||||
# This file was automatically generated by gh-aw (v1.4.2). DO NOT EDIT. To debug this workflow, load the skill at https://github.com/github/gh-aw/blob/main/debug.md
|
# This file was automatically generated by gh-aw (v1.4.5). DO NOT EDIT. To debug this workflow, load the skill at https://github.com/github/gh-aw/blob/main/debug.md
|
||||||
#
|
#
|
||||||
# ___ _ _
|
# ___ _ _
|
||||||
# / _ \ | | (_)
|
# / _ \ | | (_)
|
||||||
@@ -43,12 +43,12 @@
|
|||||||
# - actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
# - actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||||
# - actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
# - actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
||||||
# - actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
# - actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
||||||
# - github/gh-aw-actions/setup@d7852d91d5d1d13e7848771edab8bd1792a08651 # v1.4.2
|
# - github/gh-aw-actions/setup@a83eaf07e756a15e65f669eb32d00787cf5a2569 # v1.4.5
|
||||||
#
|
#
|
||||||
# Container images used:
|
# Container images used:
|
||||||
# - ghcr.io/github/gh-aw-mcpg:v0.5.16@sha256:cd50cfae3acce5985985aee3964902c9358dcc809f1b68b8168cfe29b761b059
|
# - ghcr.io/github/gh-aw-mcpg:v0.5.16@sha256:cd50cfae3acce5985985aee3964902c9358dcc809f1b68b8168cfe29b761b059
|
||||||
# - ghcr.io/github/gh-aw-node@sha256:8735428c2d4e602f90781ba0c571c400e8ff93c7ee1508a75d71f87e34e415cc
|
# - ghcr.io/github/gh-aw-node@sha256:1ee08ba84b321ff231ca905b73e6e7da8f5fd177bcc6433a56631fce2b5a0f2f
|
||||||
# - ghcr.io/github/github-mcp-server:v2.2.0@sha256:040c4e99810076035eb1d9beb4b4a96fcf589c43cefed6ff51a46a553eb4e174
|
# - ghcr.io/github/github-mcp-server:v2.3.0@sha256:f8ee4dedc7d5c8cb32854ab91cc92a31c55a8a5510708cf8742e9f9427588ca6
|
||||||
# - ghcr.io/github/gh-aw-firewall/agent:0.29.22@sha256:f5829ed92ec390e9c88c9d393556a16f0442c124c0d6b9c713e7544cb0efa5ad
|
# - ghcr.io/github/gh-aw-firewall/agent:0.29.22@sha256:f5829ed92ec390e9c88c9d393556a16f0442c124c0d6b9c713e7544cb0efa5ad
|
||||||
# - ghcr.io/github/gh-aw-firewall/api-proxy:0.29.22@sha256:02149f4ed8b9c0bae954932745f2d16e8c5bd2b37adec5f788344806cd063dca
|
# - ghcr.io/github/gh-aw-firewall/api-proxy:0.29.22@sha256:02149f4ed8b9c0bae954932745f2d16e8c5bd2b37adec5f788344806cd063dca
|
||||||
# - ghcr.io/github/gh-aw-firewall/cli-proxy:0.29.22@sha256:7b8ef50c5221824a425fbfabafb50767c5a4e6b0197a0fce6085fd9f7e97b5b7
|
# - ghcr.io/github/gh-aw-firewall/cli-proxy:0.29.22@sha256:7b8ef50c5221824a425fbfabafb50767c5a4e6b0197a0fce6085fd9f7e97b5b7
|
||||||
@@ -141,7 +141,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Setup Scripts
|
- name: Setup Scripts
|
||||||
id: setup
|
id: setup
|
||||||
uses: github/gh-aw-actions/setup@d7852d91d5d1d13e7848771edab8bd1792a08651 # v1.4.2
|
uses: github/gh-aw-actions/setup@a83eaf07e756a15e65f669eb32d00787cf5a2569 # v1.4.5
|
||||||
with:
|
with:
|
||||||
destination: ${{ runner.temp }}/gh-aw/actions
|
destination: ${{ runner.temp }}/gh-aw/actions
|
||||||
job-name: ${{ github.job }}
|
job-name: ${{ github.job }}
|
||||||
@@ -165,7 +165,7 @@ jobs:
|
|||||||
GH_AW_INFO_MODEL: ${{ vars.GH_AW_MODEL_AGENT_COPILOT || vars.GH_AW_DEFAULT_MODEL_COPILOT || 'auto' }}
|
GH_AW_INFO_MODEL: ${{ vars.GH_AW_MODEL_AGENT_COPILOT || vars.GH_AW_DEFAULT_MODEL_COPILOT || 'auto' }}
|
||||||
GH_AW_INFO_VERSION: "1.0.103"
|
GH_AW_INFO_VERSION: "1.0.103"
|
||||||
GH_AW_INFO_AGENT_VERSION: "1.0.103"
|
GH_AW_INFO_AGENT_VERSION: "1.0.103"
|
||||||
GH_AW_INFO_CLI_VERSION: "v1.4.2"
|
GH_AW_INFO_CLI_VERSION: "v1.4.5"
|
||||||
GH_AW_INFO_WORKFLOW_NAME: "Verify Review Fixes"
|
GH_AW_INFO_WORKFLOW_NAME: "Verify Review Fixes"
|
||||||
GH_AW_INFO_WORKFLOW_ID: ${{ job.workflow_ref }}
|
GH_AW_INFO_WORKFLOW_ID: ${{ job.workflow_ref }}
|
||||||
GH_AW_INFO_WORKFLOW_SHA: ${{ job.workflow_sha }}
|
GH_AW_INFO_WORKFLOW_SHA: ${{ job.workflow_sha }}
|
||||||
@@ -284,7 +284,7 @@ jobs:
|
|||||||
if: steps.daily-ai-credits-workflow-guardrail.outputs.daily_ai_credits_guardrail_status != 'quota_blocked'
|
if: steps.daily-ai-credits-workflow-guardrail.outputs.daily_ai_credits_guardrail_status != 'quota_blocked'
|
||||||
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||||
env:
|
env:
|
||||||
GH_AW_COMPILED_VERSION: "v1.4.2"
|
GH_AW_COMPILED_VERSION: "v1.4.5"
|
||||||
GH_AW_HAS_SAFE_OUTPUTS: "true"
|
GH_AW_HAS_SAFE_OUTPUTS: "true"
|
||||||
GH_AW_BLOCKED_VERSION_REPORT_AS_ISSUE: "false"
|
GH_AW_BLOCKED_VERSION_REPORT_AS_ISSUE: "false"
|
||||||
GH_AW_WORKFLOW_NAME: "Verify Review Fixes"
|
GH_AW_WORKFLOW_NAME: "Verify Review Fixes"
|
||||||
@@ -596,7 +596,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Setup Scripts
|
- name: Setup Scripts
|
||||||
id: setup
|
id: setup
|
||||||
uses: github/gh-aw-actions/setup@d7852d91d5d1d13e7848771edab8bd1792a08651 # v1.4.2
|
uses: github/gh-aw-actions/setup@a83eaf07e756a15e65f669eb32d00787cf5a2569 # v1.4.5
|
||||||
with:
|
with:
|
||||||
destination: ${{ runner.temp }}/gh-aw/actions
|
destination: ${{ runner.temp }}/gh-aw/actions
|
||||||
job-name: ${{ github.job }}
|
job-name: ${{ github.job }}
|
||||||
@@ -693,7 +693,7 @@ jobs:
|
|||||||
GH_AW_SKILL_DIR: ".github/skills"
|
GH_AW_SKILL_DIR: ".github/skills"
|
||||||
run: bash "${RUNNER_TEMP}/gh-aw/actions/restore_inline_skills.sh"
|
run: bash "${RUNNER_TEMP}/gh-aw/actions/restore_inline_skills.sh"
|
||||||
- name: Download container images
|
- name: Download container images
|
||||||
run: bash "${RUNNER_TEMP}/gh-aw/actions/download_docker_images.sh" ghcr.io/github/gh-aw-mcpg:v0.5.16@sha256:cd50cfae3acce5985985aee3964902c9358dcc809f1b68b8168cfe29b761b059 ghcr.io/github/gh-aw-node@sha256:8735428c2d4e602f90781ba0c571c400e8ff93c7ee1508a75d71f87e34e415cc ghcr.io/github/github-mcp-server:v2.2.0@sha256:040c4e99810076035eb1d9beb4b4a96fcf589c43cefed6ff51a46a553eb4e174 ghcr.io/github/gh-aw-firewall/agent:0.29.22@sha256:f5829ed92ec390e9c88c9d393556a16f0442c124c0d6b9c713e7544cb0efa5ad ghcr.io/github/gh-aw-firewall/api-proxy:0.29.22@sha256:02149f4ed8b9c0bae954932745f2d16e8c5bd2b37adec5f788344806cd063dca ghcr.io/github/gh-aw-firewall/cli-proxy:0.29.22@sha256:7b8ef50c5221824a425fbfabafb50767c5a4e6b0197a0fce6085fd9f7e97b5b7 ghcr.io/github/gh-aw-firewall/router:0.29.22@sha256:b4253735af3ab47c17bcdfaf86e91b541581e1338d3d9ead512a12ebd3f146fb ghcr.io/github/gh-aw-firewall/squid:0.29.22@sha256:cf4dd8944eb5b389adcf49f42de0e884f46e07d63afc5824543e7c9ab8ddb882
|
run: bash "${RUNNER_TEMP}/gh-aw/actions/download_docker_images.sh" ghcr.io/github/gh-aw-mcpg:v0.5.16@sha256:cd50cfae3acce5985985aee3964902c9358dcc809f1b68b8168cfe29b761b059 ghcr.io/github/gh-aw-node@sha256:1ee08ba84b321ff231ca905b73e6e7da8f5fd177bcc6433a56631fce2b5a0f2f ghcr.io/github/github-mcp-server:v2.3.0@sha256:f8ee4dedc7d5c8cb32854ab91cc92a31c55a8a5510708cf8742e9f9427588ca6 ghcr.io/github/gh-aw-firewall/agent:0.29.22@sha256:f5829ed92ec390e9c88c9d393556a16f0442c124c0d6b9c713e7544cb0efa5ad ghcr.io/github/gh-aw-firewall/api-proxy:0.29.22@sha256:02149f4ed8b9c0bae954932745f2d16e8c5bd2b37adec5f788344806cd063dca ghcr.io/github/gh-aw-firewall/cli-proxy:0.29.22@sha256:7b8ef50c5221824a425fbfabafb50767c5a4e6b0197a0fce6085fd9f7e97b5b7 ghcr.io/github/gh-aw-firewall/router:0.29.22@sha256:b4253735af3ab47c17bcdfaf86e91b541581e1338d3d9ead512a12ebd3f146fb ghcr.io/github/gh-aw-firewall/squid:0.29.22@sha256:cf4dd8944eb5b389adcf49f42de0e884f46e07d63afc5824543e7c9ab8ddb882
|
||||||
- name: Prepare Safe Outputs Directories
|
- name: Prepare Safe Outputs Directories
|
||||||
run: |
|
run: |
|
||||||
mkdir -p "${RUNNER_TEMP}/gh-aw/safeoutputs"
|
mkdir -p "${RUNNER_TEMP}/gh-aw/safeoutputs"
|
||||||
@@ -902,12 +902,12 @@ jobs:
|
|||||||
|
|
||||||
mkdir -p "$HOME/.copilot"
|
mkdir -p "$HOME/.copilot"
|
||||||
GH_AW_NODE=$(which node 2>/dev/null || command -v node 2>/dev/null || echo node)
|
GH_AW_NODE=$(which node 2>/dev/null || command -v node 2>/dev/null || echo node)
|
||||||
cat << GH_AW_MCP_CONFIG_e9f853f8279889ed_EOF | "$GH_AW_NODE" "${RUNNER_TEMP}/gh-aw/actions/start_mcp_gateway.cjs"
|
cat << GH_AW_MCP_CONFIG_060492a5ed2a5139_EOF | "$GH_AW_NODE" "${RUNNER_TEMP}/gh-aw/actions/start_mcp_gateway.cjs"
|
||||||
{
|
{
|
||||||
"mcpServers": {
|
"mcpServers": {
|
||||||
"safeoutputs": {
|
"safeoutputs": {
|
||||||
"type": "stdio",
|
"type": "stdio",
|
||||||
"container": "ghcr.io/github/gh-aw-node@sha256:8735428c2d4e602f90781ba0c571c400e8ff93c7ee1508a75d71f87e34e415cc",
|
"container": "ghcr.io/github/gh-aw-node@sha256:1ee08ba84b321ff231ca905b73e6e7da8f5fd177bcc6433a56631fce2b5a0f2f",
|
||||||
"mounts": ["\${GITHUB_WORKSPACE}:\${GITHUB_WORKSPACE}:rw", "${RUNNER_TEMP}/gh-aw/safeoutputs:${RUNNER_TEMP}/gh-aw/safeoutputs:rw", "/tmp/gh-aw:/tmp/gh-aw:rw"],
|
"mounts": ["\${GITHUB_WORKSPACE}:\${GITHUB_WORKSPACE}:rw", "${RUNNER_TEMP}/gh-aw/safeoutputs:${RUNNER_TEMP}/gh-aw/safeoutputs:rw", "/tmp/gh-aw:/tmp/gh-aw:rw"],
|
||||||
"args": ["-w", "\${GITHUB_WORKSPACE}"],
|
"args": ["-w", "\${GITHUB_WORKSPACE}"],
|
||||||
"entrypoint": "sh",
|
"entrypoint": "sh",
|
||||||
@@ -965,7 +965,7 @@ jobs:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GH_AW_MCP_CONFIG_e9f853f8279889ed_EOF
|
GH_AW_MCP_CONFIG_060492a5ed2a5139_EOF
|
||||||
- name: Mount MCP servers as CLIs
|
- name: Mount MCP servers as CLIs
|
||||||
id: mount-mcp-clis
|
id: mount-mcp-clis
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
@@ -1105,7 +1105,7 @@ jobs:
|
|||||||
GH_AW_PROMPT: /tmp/gh-aw/aw-prompts/prompt.txt
|
GH_AW_PROMPT: /tmp/gh-aw/aw-prompts/prompt.txt
|
||||||
GH_AW_SAFE_OUTPUTS: ${{ steps.set-runtime-paths.outputs.GH_AW_SAFE_OUTPUTS }}
|
GH_AW_SAFE_OUTPUTS: ${{ steps.set-runtime-paths.outputs.GH_AW_SAFE_OUTPUTS }}
|
||||||
GH_AW_TIMEOUT_MINUTES: ${{ fromJSON(vars.GH_AW_DEFAULT_TIMEOUT_MINUTES || '20') }}
|
GH_AW_TIMEOUT_MINUTES: ${{ fromJSON(vars.GH_AW_DEFAULT_TIMEOUT_MINUTES || '20') }}
|
||||||
GH_AW_VERSION: v1.4.2
|
GH_AW_VERSION: v1.4.5
|
||||||
GH_TOKEN: ${{ secrets.GH_AW_GITHUB_TOKEN || github.token }}
|
GH_TOKEN: ${{ secrets.GH_AW_GITHUB_TOKEN || github.token }}
|
||||||
GITHUB_API_URL: ${{ github.api_url }}
|
GITHUB_API_URL: ${{ github.api_url }}
|
||||||
GITHUB_AW: true
|
GITHUB_AW: true
|
||||||
@@ -1198,8 +1198,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GH_AW_SAFE_OUTPUTS: ${{ steps.set-runtime-paths.outputs.GH_AW_SAFE_OUTPUTS }}
|
GH_AW_SAFE_OUTPUTS: ${{ steps.set-runtime-paths.outputs.GH_AW_SAFE_OUTPUTS }}
|
||||||
run: |
|
run: |
|
||||||
mkdir -p /tmp/gh-aw
|
bash "${RUNNER_TEMP}/gh-aw/actions/safe_copy.sh" file "$GH_AW_SAFE_OUTPUTS" /tmp/gh-aw/safeoutputs.jsonl || true
|
||||||
cp "$GH_AW_SAFE_OUTPUTS" /tmp/gh-aw/safeoutputs.jsonl 2>/dev/null || true
|
|
||||||
- name: Ingest agent output
|
- name: Ingest agent output
|
||||||
id: collect_output
|
id: collect_output
|
||||||
if: always()
|
if: always()
|
||||||
@@ -1419,7 +1418,7 @@ jobs:
|
|||||||
permissions:
|
permissions:
|
||||||
actions: read # Read workflow runs and artifacts for workflow context.
|
actions: read # Read workflow runs and artifacts for workflow context.
|
||||||
id-token: write # Request an OIDC token for authenticated services.
|
id-token: write # Request an OIDC token for authenticated services.
|
||||||
issues: write # Create or update issues and comments.
|
issues: write # Enabled by issue reporting, safe outputs, steering, work queues, reaction cleanup, or explicit job permissions.
|
||||||
pull-requests: write # Create or update pull requests and review comments.
|
pull-requests: write # Create or update pull requests and review comments.
|
||||||
concurrency:
|
concurrency:
|
||||||
group: "gh-aw-conclusion-pr-verify-fix-${{ github.event.issue.number || inputs.pr_number || github.run_id }}"
|
group: "gh-aw-conclusion-pr-verify-fix-${{ github.event.issue.number || inputs.pr_number || github.run_id }}"
|
||||||
@@ -1439,7 +1438,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Setup Scripts
|
- name: Setup Scripts
|
||||||
id: setup
|
id: setup
|
||||||
uses: github/gh-aw-actions/setup@d7852d91d5d1d13e7848771edab8bd1792a08651 # v1.4.2
|
uses: github/gh-aw-actions/setup@a83eaf07e756a15e65f669eb32d00787cf5a2569 # v1.4.5
|
||||||
with:
|
with:
|
||||||
destination: ${{ runner.temp }}/gh-aw/actions
|
destination: ${{ runner.temp }}/gh-aw/actions
|
||||||
job-name: ${{ github.job }}
|
job-name: ${{ github.job }}
|
||||||
@@ -1818,7 +1817,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Setup Scripts
|
- name: Setup Scripts
|
||||||
id: setup
|
id: setup
|
||||||
uses: github/gh-aw-actions/setup@d7852d91d5d1d13e7848771edab8bd1792a08651 # v1.4.2
|
uses: github/gh-aw-actions/setup@a83eaf07e756a15e65f669eb32d00787cf5a2569 # v1.4.5
|
||||||
with:
|
with:
|
||||||
destination: ${{ runner.temp }}/gh-aw/actions
|
destination: ${{ runner.temp }}/gh-aw/actions
|
||||||
job-name: ${{ github.job }}
|
job-name: ${{ github.job }}
|
||||||
@@ -1832,11 +1831,12 @@ jobs:
|
|||||||
GH_AW_INFO_ENGINE_ID: "copilot"
|
GH_AW_INFO_ENGINE_ID: "copilot"
|
||||||
GH_AW_SETUP_AW_CONTEXT: ${{ inputs.aw_context }}
|
GH_AW_SETUP_AW_CONTEXT: ${{ inputs.aw_context }}
|
||||||
- name: Download activation artifact
|
- name: Download activation artifact
|
||||||
|
id: download-detection-activation
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
||||||
with:
|
with:
|
||||||
name: activation
|
name: activation
|
||||||
path: /tmp/gh-aw
|
path: ${{ runner.temp }}/gh-aw-detection-activation
|
||||||
- name: Download agent output artifact
|
- name: Download agent output artifact
|
||||||
id: download-agent-output
|
id: download-agent-output
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
@@ -1857,6 +1857,10 @@ jobs:
|
|||||||
- name: Clear agent token usage
|
- name: Clear agent token usage
|
||||||
if: always()
|
if: always()
|
||||||
run: rm -f /tmp/gh-aw/agent_usage.json
|
run: rm -f /tmp/gh-aw/agent_usage.json
|
||||||
|
- name: Restore activation metadata
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
bash "${RUNNER_TEMP}/gh-aw/actions/restore_detection_activation_metadata.sh" "${RUNNER_TEMP}/gh-aw-detection-activation" "/tmp/gh-aw"
|
||||||
- name: Checkout repository for patch context
|
- name: Checkout repository for patch context
|
||||||
if: needs.agent.outputs.has_patch == 'true'
|
if: needs.agent.outputs.has_patch == 'true'
|
||||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
@@ -1905,8 +1909,10 @@ jobs:
|
|||||||
- name: Prepare threat detection files
|
- name: Prepare threat detection files
|
||||||
id: detection_prepare
|
id: detection_prepare
|
||||||
if: always() && steps.detection_guard.outputs.run_detection == 'true'
|
if: always() && steps.detection_guard.outputs.run_detection == 'true'
|
||||||
|
env:
|
||||||
|
ACTIVATION_DOWNLOAD_OUTCOME: ${{ steps.download-detection-activation.outcome }}
|
||||||
run: |
|
run: |
|
||||||
bash "${RUNNER_TEMP}/gh-aw/actions/prepare_threat_detection_files.sh"
|
bash "${RUNNER_TEMP}/gh-aw/actions/prepare_detection_inputs.sh" "${RUNNER_TEMP}/gh-aw-detection-activation" "/tmp/gh-aw"
|
||||||
- name: Install AWF binary
|
- name: Install AWF binary
|
||||||
id: detection_awf_install
|
id: detection_awf_install
|
||||||
run: bash "${RUNNER_TEMP}/gh-aw/actions/install_awf_binary.sh" v0.29.22 --rootless
|
run: bash "${RUNNER_TEMP}/gh-aw/actions/install_awf_binary.sh" v0.29.22 --rootless
|
||||||
@@ -1923,7 +1929,7 @@ jobs:
|
|||||||
GH_AW_COPILOT_MIN_VERSION: 1.0.35
|
GH_AW_COPILOT_MIN_VERSION: 1.0.35
|
||||||
- name: Execute threat detection with AWF
|
- name: Execute threat detection with AWF
|
||||||
id: detection_agentic_execution
|
id: detection_agentic_execution
|
||||||
if: always() && steps.detection_guard.outputs.run_detection == 'true' && steps.detection_staging_reset.outcome == 'success' && steps.detection_prepare.outcome == 'success' && steps.detection_awf_install.outcome == 'success'
|
if: always() && steps.detection_guard.outputs.run_detection == 'true' && steps.detection_prepare.outcome == 'success' && steps.detection_staging_reset.outcome == 'success' && steps.detection_awf_install.outcome == 'success'
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
timeout-minutes: 10
|
timeout-minutes: 10
|
||||||
env:
|
env:
|
||||||
@@ -1936,11 +1942,11 @@ jobs:
|
|||||||
GH_AW_LLM_PROVIDER: github
|
GH_AW_LLM_PROVIDER: github
|
||||||
GH_AW_MAX_AI_CREDITS: ${{ vars.GH_AW_DEFAULT_DETECTION_MAX_AI_CREDITS || '400' }}
|
GH_AW_MAX_AI_CREDITS: ${{ vars.GH_AW_DEFAULT_DETECTION_MAX_AI_CREDITS || '400' }}
|
||||||
GH_AW_MAX_TURNS: ${{ vars.GH_AW_DEFAULT_MAX_TURNS || '' }}
|
GH_AW_MAX_TURNS: ${{ vars.GH_AW_DEFAULT_MAX_TURNS || '' }}
|
||||||
GH_AW_MODEL_FALLBACK: ${{ vars.GH_AW_MODEL_DETECTION_COPILOT || vars.GH_AW_DEFAULT_MODEL_COPILOT || 'auto' }}
|
GH_AW_MODEL_FALLBACK: ${{ vars.GH_AW_MODEL_DETECTION_COPILOT || vars.GH_AW_DEFAULT_MODEL_COPILOT || 'detection' }}
|
||||||
GH_AW_PHASE: detection
|
GH_AW_PHASE: detection
|
||||||
GH_AW_PROMPT: /tmp/gh-aw/aw-prompts/prompt.txt
|
GH_AW_PROMPT: /tmp/gh-aw/aw-prompts/prompt.txt
|
||||||
GH_AW_TIMEOUT_MINUTES: 10
|
GH_AW_TIMEOUT_MINUTES: 10
|
||||||
GH_AW_VERSION: v1.4.2
|
GH_AW_VERSION: v1.4.5
|
||||||
GITHUB_API_URL: ${{ github.api_url }}
|
GITHUB_API_URL: ${{ github.api_url }}
|
||||||
GITHUB_AW: true
|
GITHUB_AW: true
|
||||||
GITHUB_COPILOT_INTEGRATION_ID: agentic-workflows
|
GITHUB_COPILOT_INTEGRATION_ID: agentic-workflows
|
||||||
@@ -2025,9 +2031,8 @@ jobs:
|
|||||||
if: always() && steps.detection_guard.outputs.run_detection == 'true'
|
if: always() && steps.detection_guard.outputs.run_detection == 'true'
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
run: |
|
run: |
|
||||||
mkdir -p /tmp/gh-aw/threat-detection/sandbox/firewall
|
bash "${RUNNER_TEMP}/gh-aw/actions/safe_copy.sh" tree /tmp/gh-aw/sandbox/firewall/logs /tmp/gh-aw/threat-detection/sandbox/firewall/logs
|
||||||
if [ -d /tmp/gh-aw/sandbox/firewall/logs ]; then mkdir -p /tmp/gh-aw/threat-detection/sandbox/firewall/logs && cp -r /tmp/gh-aw/sandbox/firewall/logs/. /tmp/gh-aw/threat-detection/sandbox/firewall/logs/; fi
|
bash "${RUNNER_TEMP}/gh-aw/actions/safe_copy.sh" tree /tmp/gh-aw/sandbox/firewall/audit /tmp/gh-aw/threat-detection/sandbox/firewall/audit
|
||||||
if [ -d /tmp/gh-aw/sandbox/firewall/audit ]; then mkdir -p /tmp/gh-aw/threat-detection/sandbox/firewall/audit && cp -r /tmp/gh-aw/sandbox/firewall/audit/. /tmp/gh-aw/threat-detection/sandbox/firewall/audit/; fi
|
|
||||||
- name: Redact secrets in detection logs
|
- name: Redact secrets in detection logs
|
||||||
id: redact_detection_logs
|
id: redact_detection_logs
|
||||||
if: always() && steps.detection_guard.outputs.run_detection == 'true'
|
if: always() && steps.detection_guard.outputs.run_detection == 'true'
|
||||||
@@ -2048,7 +2053,7 @@ jobs:
|
|||||||
await main({ additionalDirectories: ["/tmp/gh-aw/threat-detection/sandbox/firewall"], persistDetectionMasks });
|
await main({ additionalDirectories: ["/tmp/gh-aw/threat-detection/sandbox/firewall"], persistDetectionMasks });
|
||||||
- name: Parse threat detection token usage for step summary
|
- name: Parse threat detection token usage for step summary
|
||||||
id: parse_detection_token_usage
|
id: parse_detection_token_usage
|
||||||
if: always() && steps.detection_guard.outputs.run_detection == 'true' && steps.redact_detection_logs.outcome == 'success'
|
if: always() && steps.detection_guard.outputs.run_detection == 'true' && steps.detection_prepare.outcome == 'success' && steps.redact_detection_logs.outcome == 'success'
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||||
env:
|
env:
|
||||||
@@ -2084,7 +2089,7 @@ jobs:
|
|||||||
const { persistDetectionMasks } = require(path.join(actionsDir, 'detection_mask_state.cjs'));
|
const { persistDetectionMasks } = require(path.join(actionsDir, 'detection_mask_state.cjs'));
|
||||||
await main({ additionalDirectories: ["/tmp/gh-aw/threat-detection/sandbox/firewall"], persistDetectionMasks });
|
await main({ additionalDirectories: ["/tmp/gh-aw/threat-detection/sandbox/firewall"], persistDetectionMasks });
|
||||||
- name: Render detection log
|
- name: Render detection log
|
||||||
if: always() && steps.detection_guard.outputs.run_detection == 'true' && steps.redact_detection_logs.outcome == 'success' && steps.redact_detection_artifacts.outcome == 'success'
|
if: always() && steps.detection_guard.outputs.run_detection == 'true' && steps.detection_prepare.outcome == 'success' && steps.redact_detection_logs.outcome == 'success' && steps.redact_detection_artifacts.outcome == 'success'
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||||
with:
|
with:
|
||||||
@@ -2096,7 +2101,7 @@ jobs:
|
|||||||
const { main } = require(path.join(actionsDir, 'render_detection_log.cjs'));
|
const { main } = require(path.join(actionsDir, 'render_detection_log.cjs'));
|
||||||
await main();
|
await main();
|
||||||
- name: Upload threat detection artifact
|
- name: Upload threat detection artifact
|
||||||
if: always() && steps.detection_guard.outputs.run_detection == 'true' && steps.redact_detection_logs.outcome == 'success' && steps.redact_detection_artifacts.outcome == 'success' && steps.detection_staging_reset.outcome == 'success'
|
if: always() && steps.detection_guard.outputs.run_detection == 'true' && steps.detection_prepare.outcome == 'success' && steps.redact_detection_logs.outcome == 'success' && steps.redact_detection_artifacts.outcome == 'success' && steps.detection_staging_reset.outcome == 'success'
|
||||||
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
||||||
with:
|
with:
|
||||||
name: detection
|
name: detection
|
||||||
@@ -2112,7 +2117,7 @@ jobs:
|
|||||||
retention-days: ${{ vars.GH_AW_DEFAULT_ARTIFACT_RETENTION_DAYS || '0' }}
|
retention-days: ${{ vars.GH_AW_DEFAULT_ARTIFACT_RETENTION_DAYS || '0' }}
|
||||||
- name: Conclude threat detection
|
- name: Conclude threat detection
|
||||||
id: detection_conclusion
|
id: detection_conclusion
|
||||||
if: always() && steps.detection_guard.outputs.run_detection == 'false' || (always() && steps.detection_guard.outputs.run_detection == 'true' && steps.redact_detection_logs.outcome == 'success' && steps.redact_detection_artifacts.outcome == 'success')
|
if: always() && steps.detection_guard.outputs.run_detection == 'false' || (always() && steps.detection_guard.outputs.run_detection == 'true' && steps.detection_prepare.outcome == 'success' && steps.redact_detection_logs.outcome == 'success' && steps.redact_detection_artifacts.outcome == 'success')
|
||||||
env:
|
env:
|
||||||
RUN_DETECTION: ${{ steps.detection_guard.outputs.run_detection }}
|
RUN_DETECTION: ${{ steps.detection_guard.outputs.run_detection }}
|
||||||
DETECTION_AGENTIC_EXECUTION_OUTCOME: ${{ steps.detection_agentic_execution.outcome }}
|
DETECTION_AGENTIC_EXECUTION_OUTCOME: ${{ steps.detection_agentic_execution.outcome }}
|
||||||
@@ -2145,7 +2150,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Setup Scripts
|
- name: Setup Scripts
|
||||||
id: setup
|
id: setup
|
||||||
uses: github/gh-aw-actions/setup@d7852d91d5d1d13e7848771edab8bd1792a08651 # v1.4.2
|
uses: github/gh-aw-actions/setup@a83eaf07e756a15e65f669eb32d00787cf5a2569 # v1.4.5
|
||||||
with:
|
with:
|
||||||
destination: ${{ runner.temp }}/gh-aw/actions
|
destination: ${{ runner.temp }}/gh-aw/actions
|
||||||
job-name: ${{ github.job }}
|
job-name: ${{ github.job }}
|
||||||
@@ -2240,7 +2245,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Setup Scripts
|
- name: Setup Scripts
|
||||||
id: setup
|
id: setup
|
||||||
uses: github/gh-aw-actions/setup@d7852d91d5d1d13e7848771edab8bd1792a08651 # v1.4.2
|
uses: github/gh-aw-actions/setup@a83eaf07e756a15e65f669eb32d00787cf5a2569 # v1.4.5
|
||||||
with:
|
with:
|
||||||
destination: ${{ runner.temp }}/gh-aw/actions
|
destination: ${{ runner.temp }}/gh-aw/actions
|
||||||
job-name: ${{ github.job }}
|
job-name: ${{ github.job }}
|
||||||
|
|||||||
+38
-33
@@ -1,6 +1,6 @@
|
|||||||
# gh-aw-metadata: {"schema_version":"v4","frontmatter_hash":"e44852fbf56eab99e67b3f6a306f75195603ece6ed130e55652a2467efed1415","body_hash":"7835f25016082d56592b67f4d2bf5b839eb02a6fa8f03d65699ed6bae979c5ad","compiler_version":"v1.4.2","strict":true,"agent_id":"copilot","engine_versions":{"copilot":"1.0.103"}}
|
# gh-aw-metadata: {"schema_version":"v4","frontmatter_hash":"e44852fbf56eab99e67b3f6a306f75195603ece6ed130e55652a2467efed1415","body_hash":"7835f25016082d56592b67f4d2bf5b839eb02a6fa8f03d65699ed6bae979c5ad","compiler_version":"v1.4.5","strict":true,"agent_id":"copilot","engine_versions":{"copilot":"1.0.103"}}
|
||||||
# gh-aw-manifest: {"version":1,"secrets":["COPILOT_GITHUB_TOKEN","GH_AW_DEFAULT_OTLP_ENDPOINT","GH_AW_DEFAULT_OTLP_HEADERS","GH_AW_GITHUB_MCP_SERVER_TOKEN","GH_AW_GITHUB_TOKEN","GITHUB_TOKEN"],"actions":[{"repo":"actions/checkout","sha":"3d3c42e5aac5ba805825da76410c181273ba90b1","version":"v7.0.1"},{"repo":"actions/download-artifact","sha":"9000827ccba6bdab643e8b6fd33ac0654aef8333","version":"v8.0.2"},{"repo":"actions/github-script","sha":"3a2844b7e9c422d3c10d287c895573f7108da1b3","version":"v9.0.0"},{"repo":"actions/setup-node","sha":"949feb2413d6458794dcd2491c4babbbce0c15c1","version":"v7.1.0"},{"repo":"actions/upload-artifact","sha":"cf430e030ddbb5b0abf93d22962f4752f3646cd9","version":"v7.0.2"},{"repo":"github/gh-aw-actions/setup","sha":"d7852d91d5d1d13e7848771edab8bd1792a08651","version":"v1.4.2"}],"containers":[{"image":"ghcr.io/github/gh-aw-firewall/agent:0.29.22@sha256:f5829ed92ec390e9c88c9d393556a16f0442c124c0d6b9c713e7544cb0efa5ad"},{"image":"ghcr.io/github/gh-aw-firewall/api-proxy:0.29.22@sha256:02149f4ed8b9c0bae954932745f2d16e8c5bd2b37adec5f788344806cd063dca"},{"image":"ghcr.io/github/gh-aw-firewall/cli-proxy:0.29.22@sha256:7b8ef50c5221824a425fbfabafb50767c5a4e6b0197a0fce6085fd9f7e97b5b7"},{"image":"ghcr.io/github/gh-aw-firewall/router:0.29.22@sha256:b4253735af3ab47c17bcdfaf86e91b541581e1338d3d9ead512a12ebd3f146fb"},{"image":"ghcr.io/github/gh-aw-firewall/squid:0.29.22@sha256:cf4dd8944eb5b389adcf49f42de0e884f46e07d63afc5824543e7c9ab8ddb882"},{"image":"ghcr.io/github/gh-aw-mcpg:v0.5.16","digest":"sha256:cd50cfae3acce5985985aee3964902c9358dcc809f1b68b8168cfe29b761b059","pinned_image":"ghcr.io/github/gh-aw-mcpg:v0.5.16@sha256:cd50cfae3acce5985985aee3964902c9358dcc809f1b68b8168cfe29b761b059"},{"image":"ghcr.io/github/gh-aw-node","digest":"sha256:8735428c2d4e602f90781ba0c571c400e8ff93c7ee1508a75d71f87e34e415cc","pinned_image":"ghcr.io/github/gh-aw-node@sha256:8735428c2d4e602f90781ba0c571c400e8ff93c7ee1508a75d71f87e34e415cc"},{"image":"ghcr.io/github/github-mcp-server:v2.2.0","digest":"sha256:040c4e99810076035eb1d9beb4b4a96fcf589c43cefed6ff51a46a553eb4e174","pinned_image":"ghcr.io/github/github-mcp-server:v2.2.0@sha256:040c4e99810076035eb1d9beb4b4a96fcf589c43cefed6ff51a46a553eb4e174"}],"mcp_servers":[{"name":"safeoutputs","tools":["add_comment","noop","report_incomplete","report_missing_data","report_missing_tool"]}],"threat_detection":{"mode":"enabled"},"admission":false,"agent_metadata":{"14ba41178a91b10b7de6":{"name":"Agentic Workflows"}}}
|
# gh-aw-manifest: {"version":1,"secrets":["COPILOT_GITHUB_TOKEN","GH_AW_DEFAULT_OTLP_ENDPOINT","GH_AW_DEFAULT_OTLP_HEADERS","GH_AW_GITHUB_MCP_SERVER_TOKEN","GH_AW_GITHUB_TOKEN","GITHUB_TOKEN"],"actions":[{"repo":"actions/checkout","sha":"3d3c42e5aac5ba805825da76410c181273ba90b1","version":"v7.0.1"},{"repo":"actions/download-artifact","sha":"9000827ccba6bdab643e8b6fd33ac0654aef8333","version":"v8.0.2"},{"repo":"actions/github-script","sha":"3a2844b7e9c422d3c10d287c895573f7108da1b3","version":"v9.0.0"},{"repo":"actions/setup-node","sha":"949feb2413d6458794dcd2491c4babbbce0c15c1","version":"v7.1.0"},{"repo":"actions/upload-artifact","sha":"cf430e030ddbb5b0abf93d22962f4752f3646cd9","version":"v7.0.2"},{"repo":"github/gh-aw-actions/setup","sha":"a83eaf07e756a15e65f669eb32d00787cf5a2569","version":"v1.4.5"}],"containers":[{"image":"ghcr.io/github/gh-aw-firewall/agent:0.29.22@sha256:f5829ed92ec390e9c88c9d393556a16f0442c124c0d6b9c713e7544cb0efa5ad"},{"image":"ghcr.io/github/gh-aw-firewall/api-proxy:0.29.22@sha256:02149f4ed8b9c0bae954932745f2d16e8c5bd2b37adec5f788344806cd063dca"},{"image":"ghcr.io/github/gh-aw-firewall/cli-proxy:0.29.22@sha256:7b8ef50c5221824a425fbfabafb50767c5a4e6b0197a0fce6085fd9f7e97b5b7"},{"image":"ghcr.io/github/gh-aw-firewall/router:0.29.22@sha256:b4253735af3ab47c17bcdfaf86e91b541581e1338d3d9ead512a12ebd3f146fb"},{"image":"ghcr.io/github/gh-aw-firewall/squid:0.29.22@sha256:cf4dd8944eb5b389adcf49f42de0e884f46e07d63afc5824543e7c9ab8ddb882"},{"image":"ghcr.io/github/gh-aw-mcpg:v0.5.16","digest":"sha256:cd50cfae3acce5985985aee3964902c9358dcc809f1b68b8168cfe29b761b059","pinned_image":"ghcr.io/github/gh-aw-mcpg:v0.5.16@sha256:cd50cfae3acce5985985aee3964902c9358dcc809f1b68b8168cfe29b761b059"},{"image":"ghcr.io/github/gh-aw-node","digest":"sha256:1ee08ba84b321ff231ca905b73e6e7da8f5fd177bcc6433a56631fce2b5a0f2f","pinned_image":"ghcr.io/github/gh-aw-node@sha256:1ee08ba84b321ff231ca905b73e6e7da8f5fd177bcc6433a56631fce2b5a0f2f"},{"image":"ghcr.io/github/github-mcp-server:v2.3.0","digest":"sha256:f8ee4dedc7d5c8cb32854ab91cc92a31c55a8a5510708cf8742e9f9427588ca6","pinned_image":"ghcr.io/github/github-mcp-server:v2.3.0@sha256:f8ee4dedc7d5c8cb32854ab91cc92a31c55a8a5510708cf8742e9f9427588ca6"}],"mcp_servers":[{"name":"safeoutputs","tools":["add_comment","noop","report_incomplete","report_missing_data","report_missing_tool"]}],"threat_detection":{"mode":"enabled"},"admission":false,"agent_metadata":{"14ba41178a91b10b7de6":{"name":"Agentic Workflows"}}}
|
||||||
# This file was automatically generated by gh-aw (v1.4.2). DO NOT EDIT. To debug this workflow, load the skill at https://github.com/github/gh-aw/blob/main/debug.md
|
# This file was automatically generated by gh-aw (v1.4.5). DO NOT EDIT. To debug this workflow, load the skill at https://github.com/github/gh-aw/blob/main/debug.md
|
||||||
#
|
#
|
||||||
# ___ _ _
|
# ___ _ _
|
||||||
# / _ \ | | (_)
|
# / _ \ | | (_)
|
||||||
@@ -43,12 +43,12 @@
|
|||||||
# - actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
# - actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||||
# - actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
# - actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
||||||
# - actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
# - actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
||||||
# - github/gh-aw-actions/setup@d7852d91d5d1d13e7848771edab8bd1792a08651 # v1.4.2
|
# - github/gh-aw-actions/setup@a83eaf07e756a15e65f669eb32d00787cf5a2569 # v1.4.5
|
||||||
#
|
#
|
||||||
# Container images used:
|
# Container images used:
|
||||||
# - ghcr.io/github/gh-aw-mcpg:v0.5.16@sha256:cd50cfae3acce5985985aee3964902c9358dcc809f1b68b8168cfe29b761b059
|
# - ghcr.io/github/gh-aw-mcpg:v0.5.16@sha256:cd50cfae3acce5985985aee3964902c9358dcc809f1b68b8168cfe29b761b059
|
||||||
# - ghcr.io/github/gh-aw-node@sha256:8735428c2d4e602f90781ba0c571c400e8ff93c7ee1508a75d71f87e34e415cc
|
# - ghcr.io/github/gh-aw-node@sha256:1ee08ba84b321ff231ca905b73e6e7da8f5fd177bcc6433a56631fce2b5a0f2f
|
||||||
# - ghcr.io/github/github-mcp-server:v2.2.0@sha256:040c4e99810076035eb1d9beb4b4a96fcf589c43cefed6ff51a46a553eb4e174
|
# - ghcr.io/github/github-mcp-server:v2.3.0@sha256:f8ee4dedc7d5c8cb32854ab91cc92a31c55a8a5510708cf8742e9f9427588ca6
|
||||||
# - ghcr.io/github/gh-aw-firewall/agent:0.29.22@sha256:f5829ed92ec390e9c88c9d393556a16f0442c124c0d6b9c713e7544cb0efa5ad
|
# - ghcr.io/github/gh-aw-firewall/agent:0.29.22@sha256:f5829ed92ec390e9c88c9d393556a16f0442c124c0d6b9c713e7544cb0efa5ad
|
||||||
# - ghcr.io/github/gh-aw-firewall/api-proxy:0.29.22@sha256:02149f4ed8b9c0bae954932745f2d16e8c5bd2b37adec5f788344806cd063dca
|
# - ghcr.io/github/gh-aw-firewall/api-proxy:0.29.22@sha256:02149f4ed8b9c0bae954932745f2d16e8c5bd2b37adec5f788344806cd063dca
|
||||||
# - ghcr.io/github/gh-aw-firewall/cli-proxy:0.29.22@sha256:7b8ef50c5221824a425fbfabafb50767c5a4e6b0197a0fce6085fd9f7e97b5b7
|
# - ghcr.io/github/gh-aw-firewall/cli-proxy:0.29.22@sha256:7b8ef50c5221824a425fbfabafb50767c5a4e6b0197a0fce6085fd9f7e97b5b7
|
||||||
@@ -133,7 +133,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Setup Scripts
|
- name: Setup Scripts
|
||||||
id: setup
|
id: setup
|
||||||
uses: github/gh-aw-actions/setup@d7852d91d5d1d13e7848771edab8bd1792a08651 # v1.4.2
|
uses: github/gh-aw-actions/setup@a83eaf07e756a15e65f669eb32d00787cf5a2569 # v1.4.5
|
||||||
with:
|
with:
|
||||||
destination: ${{ runner.temp }}/gh-aw/actions
|
destination: ${{ runner.temp }}/gh-aw/actions
|
||||||
job-name: ${{ github.job }}
|
job-name: ${{ github.job }}
|
||||||
@@ -155,7 +155,7 @@ jobs:
|
|||||||
GH_AW_INFO_MODEL: ${{ vars.GH_AW_MODEL_AGENT_COPILOT || vars.GH_AW_DEFAULT_MODEL_COPILOT || 'auto' }}
|
GH_AW_INFO_MODEL: ${{ vars.GH_AW_MODEL_AGENT_COPILOT || vars.GH_AW_DEFAULT_MODEL_COPILOT || 'auto' }}
|
||||||
GH_AW_INFO_VERSION: "1.0.103"
|
GH_AW_INFO_VERSION: "1.0.103"
|
||||||
GH_AW_INFO_AGENT_VERSION: "1.0.103"
|
GH_AW_INFO_AGENT_VERSION: "1.0.103"
|
||||||
GH_AW_INFO_CLI_VERSION: "v1.4.2"
|
GH_AW_INFO_CLI_VERSION: "v1.4.5"
|
||||||
GH_AW_INFO_WORKFLOW_NAME: "Renovate Minor Upgrade Analysis"
|
GH_AW_INFO_WORKFLOW_NAME: "Renovate Minor Upgrade Analysis"
|
||||||
GH_AW_INFO_WORKFLOW_ID: ${{ job.workflow_ref }}
|
GH_AW_INFO_WORKFLOW_ID: ${{ job.workflow_ref }}
|
||||||
GH_AW_INFO_WORKFLOW_SHA: ${{ job.workflow_sha }}
|
GH_AW_INFO_WORKFLOW_SHA: ${{ job.workflow_sha }}
|
||||||
@@ -274,7 +274,7 @@ jobs:
|
|||||||
if: steps.daily-ai-credits-workflow-guardrail.outputs.daily_ai_credits_guardrail_status != 'quota_blocked'
|
if: steps.daily-ai-credits-workflow-guardrail.outputs.daily_ai_credits_guardrail_status != 'quota_blocked'
|
||||||
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||||
env:
|
env:
|
||||||
GH_AW_COMPILED_VERSION: "v1.4.2"
|
GH_AW_COMPILED_VERSION: "v1.4.5"
|
||||||
GH_AW_HAS_SAFE_OUTPUTS: "true"
|
GH_AW_HAS_SAFE_OUTPUTS: "true"
|
||||||
GH_AW_BLOCKED_VERSION_REPORT_AS_ISSUE: "false"
|
GH_AW_BLOCKED_VERSION_REPORT_AS_ISSUE: "false"
|
||||||
GH_AW_WORKFLOW_NAME: "Renovate Minor Upgrade Analysis"
|
GH_AW_WORKFLOW_NAME: "Renovate Minor Upgrade Analysis"
|
||||||
@@ -562,7 +562,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Setup Scripts
|
- name: Setup Scripts
|
||||||
id: setup
|
id: setup
|
||||||
uses: github/gh-aw-actions/setup@d7852d91d5d1d13e7848771edab8bd1792a08651 # v1.4.2
|
uses: github/gh-aw-actions/setup@a83eaf07e756a15e65f669eb32d00787cf5a2569 # v1.4.5
|
||||||
with:
|
with:
|
||||||
destination: ${{ runner.temp }}/gh-aw/actions
|
destination: ${{ runner.temp }}/gh-aw/actions
|
||||||
job-name: ${{ github.job }}
|
job-name: ${{ github.job }}
|
||||||
@@ -674,7 +674,7 @@ jobs:
|
|||||||
GH_AW_SKILL_DIR: ".github/skills"
|
GH_AW_SKILL_DIR: ".github/skills"
|
||||||
run: bash "${RUNNER_TEMP}/gh-aw/actions/restore_inline_skills.sh"
|
run: bash "${RUNNER_TEMP}/gh-aw/actions/restore_inline_skills.sh"
|
||||||
- name: Download container images
|
- name: Download container images
|
||||||
run: bash "${RUNNER_TEMP}/gh-aw/actions/download_docker_images.sh" ghcr.io/github/gh-aw-mcpg:v0.5.16@sha256:cd50cfae3acce5985985aee3964902c9358dcc809f1b68b8168cfe29b761b059 ghcr.io/github/gh-aw-node@sha256:8735428c2d4e602f90781ba0c571c400e8ff93c7ee1508a75d71f87e34e415cc ghcr.io/github/github-mcp-server:v2.2.0@sha256:040c4e99810076035eb1d9beb4b4a96fcf589c43cefed6ff51a46a553eb4e174 ghcr.io/github/gh-aw-firewall/agent:0.29.22@sha256:f5829ed92ec390e9c88c9d393556a16f0442c124c0d6b9c713e7544cb0efa5ad ghcr.io/github/gh-aw-firewall/api-proxy:0.29.22@sha256:02149f4ed8b9c0bae954932745f2d16e8c5bd2b37adec5f788344806cd063dca ghcr.io/github/gh-aw-firewall/cli-proxy:0.29.22@sha256:7b8ef50c5221824a425fbfabafb50767c5a4e6b0197a0fce6085fd9f7e97b5b7 ghcr.io/github/gh-aw-firewall/router:0.29.22@sha256:b4253735af3ab47c17bcdfaf86e91b541581e1338d3d9ead512a12ebd3f146fb ghcr.io/github/gh-aw-firewall/squid:0.29.22@sha256:cf4dd8944eb5b389adcf49f42de0e884f46e07d63afc5824543e7c9ab8ddb882
|
run: bash "${RUNNER_TEMP}/gh-aw/actions/download_docker_images.sh" ghcr.io/github/gh-aw-mcpg:v0.5.16@sha256:cd50cfae3acce5985985aee3964902c9358dcc809f1b68b8168cfe29b761b059 ghcr.io/github/gh-aw-node@sha256:1ee08ba84b321ff231ca905b73e6e7da8f5fd177bcc6433a56631fce2b5a0f2f ghcr.io/github/github-mcp-server:v2.3.0@sha256:f8ee4dedc7d5c8cb32854ab91cc92a31c55a8a5510708cf8742e9f9427588ca6 ghcr.io/github/gh-aw-firewall/agent:0.29.22@sha256:f5829ed92ec390e9c88c9d393556a16f0442c124c0d6b9c713e7544cb0efa5ad ghcr.io/github/gh-aw-firewall/api-proxy:0.29.22@sha256:02149f4ed8b9c0bae954932745f2d16e8c5bd2b37adec5f788344806cd063dca ghcr.io/github/gh-aw-firewall/cli-proxy:0.29.22@sha256:7b8ef50c5221824a425fbfabafb50767c5a4e6b0197a0fce6085fd9f7e97b5b7 ghcr.io/github/gh-aw-firewall/router:0.29.22@sha256:b4253735af3ab47c17bcdfaf86e91b541581e1338d3d9ead512a12ebd3f146fb ghcr.io/github/gh-aw-firewall/squid:0.29.22@sha256:cf4dd8944eb5b389adcf49f42de0e884f46e07d63afc5824543e7c9ab8ddb882
|
||||||
- name: Prepare Safe Outputs Directories
|
- name: Prepare Safe Outputs Directories
|
||||||
run: |
|
run: |
|
||||||
mkdir -p "${RUNNER_TEMP}/gh-aw/safeoutputs"
|
mkdir -p "${RUNNER_TEMP}/gh-aw/safeoutputs"
|
||||||
@@ -885,12 +885,12 @@ jobs:
|
|||||||
|
|
||||||
mkdir -p "$HOME/.copilot"
|
mkdir -p "$HOME/.copilot"
|
||||||
GH_AW_NODE=$(which node 2>/dev/null || command -v node 2>/dev/null || echo node)
|
GH_AW_NODE=$(which node 2>/dev/null || command -v node 2>/dev/null || echo node)
|
||||||
cat << GH_AW_MCP_CONFIG_d448207cb151e2cb_EOF | "$GH_AW_NODE" "${RUNNER_TEMP}/gh-aw/actions/start_mcp_gateway.cjs"
|
cat << GH_AW_MCP_CONFIG_36d6009112b7e687_EOF | "$GH_AW_NODE" "${RUNNER_TEMP}/gh-aw/actions/start_mcp_gateway.cjs"
|
||||||
{
|
{
|
||||||
"mcpServers": {
|
"mcpServers": {
|
||||||
"safeoutputs": {
|
"safeoutputs": {
|
||||||
"type": "stdio",
|
"type": "stdio",
|
||||||
"container": "ghcr.io/github/gh-aw-node@sha256:8735428c2d4e602f90781ba0c571c400e8ff93c7ee1508a75d71f87e34e415cc",
|
"container": "ghcr.io/github/gh-aw-node@sha256:1ee08ba84b321ff231ca905b73e6e7da8f5fd177bcc6433a56631fce2b5a0f2f",
|
||||||
"mounts": ["\${GITHUB_WORKSPACE}:\${GITHUB_WORKSPACE}:rw", "${RUNNER_TEMP}/gh-aw/safeoutputs:${RUNNER_TEMP}/gh-aw/safeoutputs:rw", "/tmp/gh-aw:/tmp/gh-aw:rw"],
|
"mounts": ["\${GITHUB_WORKSPACE}:\${GITHUB_WORKSPACE}:rw", "${RUNNER_TEMP}/gh-aw/safeoutputs:${RUNNER_TEMP}/gh-aw/safeoutputs:rw", "/tmp/gh-aw:/tmp/gh-aw:rw"],
|
||||||
"args": ["-w", "\${GITHUB_WORKSPACE}"],
|
"args": ["-w", "\${GITHUB_WORKSPACE}"],
|
||||||
"entrypoint": "sh",
|
"entrypoint": "sh",
|
||||||
@@ -949,7 +949,7 @@ jobs:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GH_AW_MCP_CONFIG_d448207cb151e2cb_EOF
|
GH_AW_MCP_CONFIG_36d6009112b7e687_EOF
|
||||||
- name: Mount MCP servers as CLIs
|
- name: Mount MCP servers as CLIs
|
||||||
id: mount-mcp-clis
|
id: mount-mcp-clis
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
@@ -1094,7 +1094,7 @@ jobs:
|
|||||||
GH_AW_PROMPT: /tmp/gh-aw/aw-prompts/prompt.txt
|
GH_AW_PROMPT: /tmp/gh-aw/aw-prompts/prompt.txt
|
||||||
GH_AW_SAFE_OUTPUTS: ${{ steps.set-runtime-paths.outputs.GH_AW_SAFE_OUTPUTS }}
|
GH_AW_SAFE_OUTPUTS: ${{ steps.set-runtime-paths.outputs.GH_AW_SAFE_OUTPUTS }}
|
||||||
GH_AW_TIMEOUT_MINUTES: ${{ fromJSON(vars.GH_AW_DEFAULT_TIMEOUT_MINUTES || '20') }}
|
GH_AW_TIMEOUT_MINUTES: ${{ fromJSON(vars.GH_AW_DEFAULT_TIMEOUT_MINUTES || '20') }}
|
||||||
GH_AW_VERSION: v1.4.2
|
GH_AW_VERSION: v1.4.5
|
||||||
GH_TOKEN: ${{ secrets.GH_AW_GITHUB_TOKEN || github.token }}
|
GH_TOKEN: ${{ secrets.GH_AW_GITHUB_TOKEN || github.token }}
|
||||||
GITHUB_API_URL: ${{ github.api_url }}
|
GITHUB_API_URL: ${{ github.api_url }}
|
||||||
GITHUB_AW: true
|
GITHUB_AW: true
|
||||||
@@ -1193,8 +1193,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GH_AW_SAFE_OUTPUTS: ${{ steps.set-runtime-paths.outputs.GH_AW_SAFE_OUTPUTS }}
|
GH_AW_SAFE_OUTPUTS: ${{ steps.set-runtime-paths.outputs.GH_AW_SAFE_OUTPUTS }}
|
||||||
run: |
|
run: |
|
||||||
mkdir -p /tmp/gh-aw
|
bash "${RUNNER_TEMP}/gh-aw/actions/safe_copy.sh" file "$GH_AW_SAFE_OUTPUTS" /tmp/gh-aw/safeoutputs.jsonl || true
|
||||||
cp "$GH_AW_SAFE_OUTPUTS" /tmp/gh-aw/safeoutputs.jsonl 2>/dev/null || true
|
|
||||||
- name: Ingest agent output
|
- name: Ingest agent output
|
||||||
id: collect_output
|
id: collect_output
|
||||||
if: always()
|
if: always()
|
||||||
@@ -1413,7 +1412,7 @@ jobs:
|
|||||||
permissions:
|
permissions:
|
||||||
actions: read # Read workflow runs and artifacts for workflow context.
|
actions: read # Read workflow runs and artifacts for workflow context.
|
||||||
id-token: write # Request an OIDC token for authenticated services.
|
id-token: write # Request an OIDC token for authenticated services.
|
||||||
issues: write # Create or update issues and comments.
|
issues: write # Enabled by issue reporting, safe outputs, steering, work queues, reaction cleanup, or explicit job permissions.
|
||||||
pull-requests: write # Create or update pull requests and review comments.
|
pull-requests: write # Create or update pull requests and review comments.
|
||||||
concurrency:
|
concurrency:
|
||||||
group: "gh-aw-conclusion-renovate-minor-review-${{ inputs.pr_number }}"
|
group: "gh-aw-conclusion-renovate-minor-review-${{ inputs.pr_number }}"
|
||||||
@@ -1433,7 +1432,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Setup Scripts
|
- name: Setup Scripts
|
||||||
id: setup
|
id: setup
|
||||||
uses: github/gh-aw-actions/setup@d7852d91d5d1d13e7848771edab8bd1792a08651 # v1.4.2
|
uses: github/gh-aw-actions/setup@a83eaf07e756a15e65f669eb32d00787cf5a2569 # v1.4.5
|
||||||
with:
|
with:
|
||||||
destination: ${{ runner.temp }}/gh-aw/actions
|
destination: ${{ runner.temp }}/gh-aw/actions
|
||||||
job-name: ${{ github.job }}
|
job-name: ${{ github.job }}
|
||||||
@@ -1812,7 +1811,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Setup Scripts
|
- name: Setup Scripts
|
||||||
id: setup
|
id: setup
|
||||||
uses: github/gh-aw-actions/setup@d7852d91d5d1d13e7848771edab8bd1792a08651 # v1.4.2
|
uses: github/gh-aw-actions/setup@a83eaf07e756a15e65f669eb32d00787cf5a2569 # v1.4.5
|
||||||
with:
|
with:
|
||||||
destination: ${{ runner.temp }}/gh-aw/actions
|
destination: ${{ runner.temp }}/gh-aw/actions
|
||||||
job-name: ${{ github.job }}
|
job-name: ${{ github.job }}
|
||||||
@@ -1826,11 +1825,12 @@ jobs:
|
|||||||
GH_AW_INFO_ENGINE_ID: "copilot"
|
GH_AW_INFO_ENGINE_ID: "copilot"
|
||||||
GH_AW_SETUP_AW_CONTEXT: ${{ inputs.aw_context }}
|
GH_AW_SETUP_AW_CONTEXT: ${{ inputs.aw_context }}
|
||||||
- name: Download activation artifact
|
- name: Download activation artifact
|
||||||
|
id: download-detection-activation
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
||||||
with:
|
with:
|
||||||
name: activation
|
name: activation
|
||||||
path: /tmp/gh-aw
|
path: ${{ runner.temp }}/gh-aw-detection-activation
|
||||||
- name: Download agent output artifact
|
- name: Download agent output artifact
|
||||||
id: download-agent-output
|
id: download-agent-output
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
@@ -1851,6 +1851,10 @@ jobs:
|
|||||||
- name: Clear agent token usage
|
- name: Clear agent token usage
|
||||||
if: always()
|
if: always()
|
||||||
run: rm -f /tmp/gh-aw/agent_usage.json
|
run: rm -f /tmp/gh-aw/agent_usage.json
|
||||||
|
- name: Restore activation metadata
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
bash "${RUNNER_TEMP}/gh-aw/actions/restore_detection_activation_metadata.sh" "${RUNNER_TEMP}/gh-aw-detection-activation" "/tmp/gh-aw"
|
||||||
- name: Checkout repository for patch context
|
- name: Checkout repository for patch context
|
||||||
if: needs.agent.outputs.has_patch == 'true'
|
if: needs.agent.outputs.has_patch == 'true'
|
||||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
@@ -1899,8 +1903,10 @@ jobs:
|
|||||||
- name: Prepare threat detection files
|
- name: Prepare threat detection files
|
||||||
id: detection_prepare
|
id: detection_prepare
|
||||||
if: always() && steps.detection_guard.outputs.run_detection == 'true'
|
if: always() && steps.detection_guard.outputs.run_detection == 'true'
|
||||||
|
env:
|
||||||
|
ACTIVATION_DOWNLOAD_OUTCOME: ${{ steps.download-detection-activation.outcome }}
|
||||||
run: |
|
run: |
|
||||||
bash "${RUNNER_TEMP}/gh-aw/actions/prepare_threat_detection_files.sh"
|
bash "${RUNNER_TEMP}/gh-aw/actions/prepare_detection_inputs.sh" "${RUNNER_TEMP}/gh-aw-detection-activation" "/tmp/gh-aw"
|
||||||
- name: Install AWF binary
|
- name: Install AWF binary
|
||||||
id: detection_awf_install
|
id: detection_awf_install
|
||||||
run: bash "${RUNNER_TEMP}/gh-aw/actions/install_awf_binary.sh" v0.29.22 --rootless
|
run: bash "${RUNNER_TEMP}/gh-aw/actions/install_awf_binary.sh" v0.29.22 --rootless
|
||||||
@@ -1917,7 +1923,7 @@ jobs:
|
|||||||
GH_AW_COPILOT_MIN_VERSION: 1.0.35
|
GH_AW_COPILOT_MIN_VERSION: 1.0.35
|
||||||
- name: Execute threat detection with AWF
|
- name: Execute threat detection with AWF
|
||||||
id: detection_agentic_execution
|
id: detection_agentic_execution
|
||||||
if: always() && steps.detection_guard.outputs.run_detection == 'true' && steps.detection_staging_reset.outcome == 'success' && steps.detection_prepare.outcome == 'success' && steps.detection_awf_install.outcome == 'success'
|
if: always() && steps.detection_guard.outputs.run_detection == 'true' && steps.detection_prepare.outcome == 'success' && steps.detection_staging_reset.outcome == 'success' && steps.detection_awf_install.outcome == 'success'
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
timeout-minutes: 10
|
timeout-minutes: 10
|
||||||
env:
|
env:
|
||||||
@@ -1930,11 +1936,11 @@ jobs:
|
|||||||
GH_AW_LLM_PROVIDER: github
|
GH_AW_LLM_PROVIDER: github
|
||||||
GH_AW_MAX_AI_CREDITS: ${{ vars.GH_AW_DEFAULT_DETECTION_MAX_AI_CREDITS || '400' }}
|
GH_AW_MAX_AI_CREDITS: ${{ vars.GH_AW_DEFAULT_DETECTION_MAX_AI_CREDITS || '400' }}
|
||||||
GH_AW_MAX_TURNS: ${{ vars.GH_AW_DEFAULT_MAX_TURNS || '' }}
|
GH_AW_MAX_TURNS: ${{ vars.GH_AW_DEFAULT_MAX_TURNS || '' }}
|
||||||
GH_AW_MODEL_FALLBACK: ${{ vars.GH_AW_MODEL_DETECTION_COPILOT || vars.GH_AW_DEFAULT_MODEL_COPILOT || 'auto' }}
|
GH_AW_MODEL_FALLBACK: ${{ vars.GH_AW_MODEL_DETECTION_COPILOT || vars.GH_AW_DEFAULT_MODEL_COPILOT || 'detection' }}
|
||||||
GH_AW_PHASE: detection
|
GH_AW_PHASE: detection
|
||||||
GH_AW_PROMPT: /tmp/gh-aw/aw-prompts/prompt.txt
|
GH_AW_PROMPT: /tmp/gh-aw/aw-prompts/prompt.txt
|
||||||
GH_AW_TIMEOUT_MINUTES: 10
|
GH_AW_TIMEOUT_MINUTES: 10
|
||||||
GH_AW_VERSION: v1.4.2
|
GH_AW_VERSION: v1.4.5
|
||||||
GITHUB_API_URL: ${{ github.api_url }}
|
GITHUB_API_URL: ${{ github.api_url }}
|
||||||
GITHUB_AW: true
|
GITHUB_AW: true
|
||||||
GITHUB_COPILOT_INTEGRATION_ID: agentic-workflows
|
GITHUB_COPILOT_INTEGRATION_ID: agentic-workflows
|
||||||
@@ -2019,9 +2025,8 @@ jobs:
|
|||||||
if: always() && steps.detection_guard.outputs.run_detection == 'true'
|
if: always() && steps.detection_guard.outputs.run_detection == 'true'
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
run: |
|
run: |
|
||||||
mkdir -p /tmp/gh-aw/threat-detection/sandbox/firewall
|
bash "${RUNNER_TEMP}/gh-aw/actions/safe_copy.sh" tree /tmp/gh-aw/sandbox/firewall/logs /tmp/gh-aw/threat-detection/sandbox/firewall/logs
|
||||||
if [ -d /tmp/gh-aw/sandbox/firewall/logs ]; then mkdir -p /tmp/gh-aw/threat-detection/sandbox/firewall/logs && cp -r /tmp/gh-aw/sandbox/firewall/logs/. /tmp/gh-aw/threat-detection/sandbox/firewall/logs/; fi
|
bash "${RUNNER_TEMP}/gh-aw/actions/safe_copy.sh" tree /tmp/gh-aw/sandbox/firewall/audit /tmp/gh-aw/threat-detection/sandbox/firewall/audit
|
||||||
if [ -d /tmp/gh-aw/sandbox/firewall/audit ]; then mkdir -p /tmp/gh-aw/threat-detection/sandbox/firewall/audit && cp -r /tmp/gh-aw/sandbox/firewall/audit/. /tmp/gh-aw/threat-detection/sandbox/firewall/audit/; fi
|
|
||||||
- name: Redact secrets in detection logs
|
- name: Redact secrets in detection logs
|
||||||
id: redact_detection_logs
|
id: redact_detection_logs
|
||||||
if: always() && steps.detection_guard.outputs.run_detection == 'true'
|
if: always() && steps.detection_guard.outputs.run_detection == 'true'
|
||||||
@@ -2042,7 +2047,7 @@ jobs:
|
|||||||
await main({ additionalDirectories: ["/tmp/gh-aw/threat-detection/sandbox/firewall"], persistDetectionMasks });
|
await main({ additionalDirectories: ["/tmp/gh-aw/threat-detection/sandbox/firewall"], persistDetectionMasks });
|
||||||
- name: Parse threat detection token usage for step summary
|
- name: Parse threat detection token usage for step summary
|
||||||
id: parse_detection_token_usage
|
id: parse_detection_token_usage
|
||||||
if: always() && steps.detection_guard.outputs.run_detection == 'true' && steps.redact_detection_logs.outcome == 'success'
|
if: always() && steps.detection_guard.outputs.run_detection == 'true' && steps.detection_prepare.outcome == 'success' && steps.redact_detection_logs.outcome == 'success'
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||||
env:
|
env:
|
||||||
@@ -2078,7 +2083,7 @@ jobs:
|
|||||||
const { persistDetectionMasks } = require(path.join(actionsDir, 'detection_mask_state.cjs'));
|
const { persistDetectionMasks } = require(path.join(actionsDir, 'detection_mask_state.cjs'));
|
||||||
await main({ additionalDirectories: ["/tmp/gh-aw/threat-detection/sandbox/firewall"], persistDetectionMasks });
|
await main({ additionalDirectories: ["/tmp/gh-aw/threat-detection/sandbox/firewall"], persistDetectionMasks });
|
||||||
- name: Render detection log
|
- name: Render detection log
|
||||||
if: always() && steps.detection_guard.outputs.run_detection == 'true' && steps.redact_detection_logs.outcome == 'success' && steps.redact_detection_artifacts.outcome == 'success'
|
if: always() && steps.detection_guard.outputs.run_detection == 'true' && steps.detection_prepare.outcome == 'success' && steps.redact_detection_logs.outcome == 'success' && steps.redact_detection_artifacts.outcome == 'success'
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||||
with:
|
with:
|
||||||
@@ -2090,7 +2095,7 @@ jobs:
|
|||||||
const { main } = require(path.join(actionsDir, 'render_detection_log.cjs'));
|
const { main } = require(path.join(actionsDir, 'render_detection_log.cjs'));
|
||||||
await main();
|
await main();
|
||||||
- name: Upload threat detection artifact
|
- name: Upload threat detection artifact
|
||||||
if: always() && steps.detection_guard.outputs.run_detection == 'true' && steps.redact_detection_logs.outcome == 'success' && steps.redact_detection_artifacts.outcome == 'success' && steps.detection_staging_reset.outcome == 'success'
|
if: always() && steps.detection_guard.outputs.run_detection == 'true' && steps.detection_prepare.outcome == 'success' && steps.redact_detection_logs.outcome == 'success' && steps.redact_detection_artifacts.outcome == 'success' && steps.detection_staging_reset.outcome == 'success'
|
||||||
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
||||||
with:
|
with:
|
||||||
name: detection
|
name: detection
|
||||||
@@ -2106,7 +2111,7 @@ jobs:
|
|||||||
retention-days: ${{ vars.GH_AW_DEFAULT_ARTIFACT_RETENTION_DAYS || '0' }}
|
retention-days: ${{ vars.GH_AW_DEFAULT_ARTIFACT_RETENTION_DAYS || '0' }}
|
||||||
- name: Conclude threat detection
|
- name: Conclude threat detection
|
||||||
id: detection_conclusion
|
id: detection_conclusion
|
||||||
if: always() && steps.detection_guard.outputs.run_detection == 'false' || (always() && steps.detection_guard.outputs.run_detection == 'true' && steps.redact_detection_logs.outcome == 'success' && steps.redact_detection_artifacts.outcome == 'success')
|
if: always() && steps.detection_guard.outputs.run_detection == 'false' || (always() && steps.detection_guard.outputs.run_detection == 'true' && steps.detection_prepare.outcome == 'success' && steps.redact_detection_logs.outcome == 'success' && steps.redact_detection_artifacts.outcome == 'success')
|
||||||
env:
|
env:
|
||||||
RUN_DETECTION: ${{ steps.detection_guard.outputs.run_detection }}
|
RUN_DETECTION: ${{ steps.detection_guard.outputs.run_detection }}
|
||||||
DETECTION_AGENTIC_EXECUTION_OUTCOME: ${{ steps.detection_agentic_execution.outcome }}
|
DETECTION_AGENTIC_EXECUTION_OUTCOME: ${{ steps.detection_agentic_execution.outcome }}
|
||||||
@@ -2178,7 +2183,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Setup Scripts
|
- name: Setup Scripts
|
||||||
id: setup
|
id: setup
|
||||||
uses: github/gh-aw-actions/setup@d7852d91d5d1d13e7848771edab8bd1792a08651 # v1.4.2
|
uses: github/gh-aw-actions/setup@a83eaf07e756a15e65f669eb32d00787cf5a2569 # v1.4.5
|
||||||
with:
|
with:
|
||||||
destination: ${{ runner.temp }}/gh-aw/actions
|
destination: ${{ runner.temp }}/gh-aw/actions
|
||||||
job-name: ${{ github.job }}
|
job-name: ${{ github.job }}
|
||||||
|
|||||||
@@ -60,10 +60,6 @@ the ownership evidence the AI-slop review evaluates (see
|
|||||||
|
|
||||||
- For development and bug fixes, follow the
|
- For development and bug fixes, follow the
|
||||||
[development workflow](CONTRIBUTING.md#development-workflow).
|
[development workflow](CONTRIBUTING.md#development-workflow).
|
||||||
- For Rust backend changes that affect capability ownership or dependency
|
|
||||||
boundaries, follow [Workspace Crate Architecture](crates/AGENTS.md).
|
|
||||||
For Tauri commands and desktop integration, also follow
|
|
||||||
[Backend Architecture Guardrails](src-tauri/AGENTS.md).
|
|
||||||
- For code review and verification of review fixes, follow [REVIEW.md](REVIEW.md).
|
- For code review and verification of review fixes, follow [REVIEW.md](REVIEW.md).
|
||||||
Review is read-only unless changes are authorized; findings do not expand
|
Review is read-only unless changes are authorized; findings do not expand
|
||||||
that authorization to unrelated fixes, commits, pushes, or GitHub updates.
|
that authorization to unrelated fixes, commits, pushes, or GitHub updates.
|
||||||
|
|||||||
Generated
+359
-55
@@ -469,9 +469,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "backon"
|
name = "backon"
|
||||||
version = "1.6.0"
|
version = "1.7.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cffb0e931875b666fc4fcb20fee52e9bbd1ef836fd9e9e04ec21555f9f85f7ef"
|
checksum = "aa51bf3329e243b4ceebb25fddaa797b3e2d225c733b215548ffd1fa99294d5d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"fastrand",
|
"fastrand",
|
||||||
"gloo-timers",
|
"gloo-timers",
|
||||||
@@ -514,7 +514,16 @@ version = "0.8.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "08807e080ed7f9d5433fa9b275196cfc35414f66a0c79d864dc51a0d825231a3"
|
checksum = "08807e080ed7f9d5433fa9b275196cfc35414f66a0c79d864dc51a0d825231a3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bit-vec",
|
"bit-vec 0.8.0",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bit-set"
|
||||||
|
version = "0.11.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "56d87354e4229f54a44f7bf2435906a4656dba36026ab6eaca629a2c436a691c"
|
||||||
|
dependencies = [
|
||||||
|
"bit-vec 0.10.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -523,6 +532,16 @@ version = "0.8.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5e764a1d40d510daf35e07be9eb06e75770908c27d411ee6c92109c9840eaaf7"
|
checksum = "5e764a1d40d510daf35e07be9eb06e75770908c27d411ee6c92109c9840eaaf7"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bit-vec"
|
||||||
|
version = "0.10.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "72503af1e72be411d74ca45cd6b309878fcb35354e252fc2a3a8bda3a97082a0"
|
||||||
|
dependencies = [
|
||||||
|
"borsh",
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bitflags"
|
name = "bitflags"
|
||||||
version = "1.3.2"
|
version = "1.3.2"
|
||||||
@@ -741,6 +760,30 @@ dependencies = [
|
|||||||
"static_assertions",
|
"static_assertions",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "borsh"
|
||||||
|
version = "1.8.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "553c5d846a6ba5150c65e3b1b8ec073bcf1abc20f9b7220de384a4443ea4e20a"
|
||||||
|
dependencies = [
|
||||||
|
"borsh-derive",
|
||||||
|
"bytes",
|
||||||
|
"cfg_aliases",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "borsh-derive"
|
||||||
|
version = "1.8.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "12cdfe656708a01f89b451a7d36466e6fe6c414de0aa18fc54f864f6f9ca9f56"
|
||||||
|
dependencies = [
|
||||||
|
"once_cell",
|
||||||
|
"proc-macro-crate 3.5.0",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 3.0.5",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "brotli"
|
name = "brotli"
|
||||||
version = "9.0.0"
|
version = "9.0.0"
|
||||||
@@ -1092,15 +1135,12 @@ dependencies = [
|
|||||||
"boa_engine",
|
"boa_engine",
|
||||||
"bytes",
|
"bytes",
|
||||||
"chrono",
|
"chrono",
|
||||||
"clash-verge-backup-archive",
|
|
||||||
"clash-verge-draft",
|
"clash-verge-draft",
|
||||||
"clash-verge-i18n",
|
"clash-verge-i18n",
|
||||||
"clash-verge-limiter",
|
"clash-verge-limiter",
|
||||||
"clash-verge-logging",
|
"clash-verge-logging",
|
||||||
"clash-verge-media-unlock",
|
"clash-verge-media-unlock",
|
||||||
"clash-verge-profile",
|
|
||||||
"clash-verge-signal",
|
"clash-verge-signal",
|
||||||
"clash-verge-subscription",
|
|
||||||
"clash-verge-task",
|
"clash-verge-task",
|
||||||
"clash_verge_service_ipc",
|
"clash_verge_service_ipc",
|
||||||
"dark-light",
|
"dark-light",
|
||||||
@@ -1162,28 +1202,20 @@ dependencies = [
|
|||||||
"tristr",
|
"tristr",
|
||||||
"warp",
|
"warp",
|
||||||
"webpki-roots",
|
"webpki-roots",
|
||||||
"windows 0.62.2",
|
"windows 0.101.0",
|
||||||
"windows-service",
|
"windows-service",
|
||||||
"windows-sys 0.61.2",
|
"windows-sys 0.101.0",
|
||||||
"winreg 0.56.0",
|
"winreg 0.56.0",
|
||||||
"zip",
|
"zip",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "clash-verge-backup-archive"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"thiserror 2.0.20",
|
|
||||||
"zip",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clash-verge-draft"
|
name = "clash-verge-draft"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
"criterion",
|
"criterion",
|
||||||
"parking_lot 0.13.0",
|
"parking_lot 0.13.0",
|
||||||
"thiserror 2.0.20",
|
|
||||||
"tokio",
|
"tokio",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -1198,15 +1230,19 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "clash-verge-limiter"
|
name = "clash-verge-limiter"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"loom",
|
||||||
|
"proptest",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clash-verge-logging"
|
name = "clash-verge-logging"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
"flexi_logger",
|
"flexi_logger",
|
||||||
"log",
|
"log",
|
||||||
"parking_lot 0.13.0",
|
"parking_lot 0.13.0",
|
||||||
"thiserror 2.0.20",
|
|
||||||
"tracing-estuary",
|
"tracing-estuary",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -1225,18 +1261,6 @@ dependencies = [
|
|||||||
"tokio",
|
"tokio",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "clash-verge-profile"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"serde",
|
|
||||||
"serde_json",
|
|
||||||
"serde_yaml_ng",
|
|
||||||
"specta",
|
|
||||||
"thiserror 2.0.20",
|
|
||||||
"tristr",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clash-verge-signal"
|
name = "clash-verge-signal"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
@@ -1246,17 +1270,6 @@ dependencies = [
|
|||||||
"tokio",
|
"tokio",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "clash-verge-subscription"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"http",
|
|
||||||
"percent-encoding",
|
|
||||||
"serde_yaml_ng",
|
|
||||||
"thiserror 2.0.20",
|
|
||||||
"url",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clash-verge-task"
|
name = "clash-verge-task"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
@@ -1502,9 +1515,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cookie"
|
name = "cookie"
|
||||||
version = "0.18.1"
|
version = "0.18.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4ddef33a339a91ea89fb53151bd0a4689cfce27055c291dfa69945475d22c747"
|
checksum = "d55f2d6c30eeec7d5c6f98bd4395d4abb1895629eab97ee6522d340623615f8a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
"time",
|
"time",
|
||||||
@@ -1592,6 +1605,12 @@ dependencies = [
|
|||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "core_detect"
|
||||||
|
version = "1.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7f8f80099a98041a3d1622845c271458a2d73e688351bf3cb999266764b81d48"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "core_maths"
|
name = "core_maths"
|
||||||
version = "0.1.1"
|
version = "0.1.1"
|
||||||
@@ -2161,7 +2180,7 @@ version = "0.28.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fac5fca71e65e94cc718a6e2af65d6e0f9c6027751c2aa562fbb5087fda639bc"
|
checksum = "fac5fca71e65e94cc718a6e2af65d6e0f9c6027751c2aa562fbb5087fda639bc"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bit-set",
|
"bit-set 0.8.0",
|
||||||
"cssparser",
|
"cssparser",
|
||||||
"foldhash 0.2.0",
|
"foldhash 0.2.0",
|
||||||
"html5ever",
|
"html5ever",
|
||||||
@@ -2753,6 +2772,18 @@ dependencies = [
|
|||||||
"x11",
|
"x11",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "generator"
|
||||||
|
version = "0.8.13"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "66831419d9074e766421508dff218bf79d99616bc5e56e34599d3b433714a4a4"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
"log",
|
||||||
|
"windows-core 0.100.0",
|
||||||
|
"windows-sys 0.61.2",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "generic-array"
|
name = "generic-array"
|
||||||
version = "0.14.7"
|
version = "0.14.7"
|
||||||
@@ -3007,9 +3038,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gloo-timers"
|
name = "gloo-timers"
|
||||||
version = "0.3.0"
|
version = "0.4.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "bbb143cf96099802033e0d4f4963b19fd2e0b728bcf076cd9cf7f6634f092994"
|
checksum = "a4460540da666acdb5722b2a62ac47d18f627fcfc0c728d04dc7226b3f6d40a7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"futures-channel",
|
"futures-channel",
|
||||||
"futures-core",
|
"futures-core",
|
||||||
@@ -4158,6 +4189,19 @@ version = "0.4.35"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5d15f86d12da44cd8d4ec3c73984537eb7f4cadcb9776a575a0a8a05ca11005c"
|
checksum = "5d15f86d12da44cd8d4ec3c73984537eb7f4cadcb9776a575a0a8a05ca11005c"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "loom"
|
||||||
|
version = "0.7.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f1611ddbf89dc6ae42cfbd51fc207836140130257646eab8d6d2fb16577db2d2"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"generator",
|
||||||
|
"scoped-tls",
|
||||||
|
"tracing",
|
||||||
|
"tracing-subscriber",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lru-slab"
|
name = "lru-slab"
|
||||||
version = "0.1.2"
|
version = "0.1.2"
|
||||||
@@ -5562,6 +5606,26 @@ dependencies = [
|
|||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "proptest"
|
||||||
|
version = "1.12.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b8530004ccb15eae51c7e40009fbe317f341f804db54dc033eec1c50be28cfa0"
|
||||||
|
dependencies = [
|
||||||
|
"bit-set 0.11.1",
|
||||||
|
"bit-vec 0.10.2",
|
||||||
|
"bitflags 2.13.2",
|
||||||
|
"chacha20",
|
||||||
|
"core_detect",
|
||||||
|
"num-traits",
|
||||||
|
"rand 0.10.2",
|
||||||
|
"rand_xorshift",
|
||||||
|
"regex-syntax",
|
||||||
|
"rusty-fork",
|
||||||
|
"tempfile",
|
||||||
|
"unarray",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "prost"
|
name = "prost"
|
||||||
version = "0.14.4"
|
version = "0.14.4"
|
||||||
@@ -5616,6 +5680,12 @@ version = "0.1.30"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d55d956fa96f5ec02be2e13af0e20391a5aa83d6a074e3ad368959d0fab299ea"
|
checksum = "d55d956fa96f5ec02be2e13af0e20391a5aa83d6a074e3ad368959d0fab299ea"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "quick-error"
|
||||||
|
version = "1.2.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "quick-error"
|
name = "quick-error"
|
||||||
version = "2.0.1"
|
version = "2.0.1"
|
||||||
@@ -5803,6 +5873,15 @@ dependencies = [
|
|||||||
"rand_core 0.10.1",
|
"rand_core 0.10.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rand_xorshift"
|
||||||
|
version = "0.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "60aa6af80be32871323012e02e6e65f8a7cc7890931ae421d217ad8fe0df2ccf"
|
||||||
|
dependencies = [
|
||||||
|
"rand_core 0.10.1",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "raw-window-handle"
|
name = "raw-window-handle"
|
||||||
version = "0.6.2"
|
version = "0.6.2"
|
||||||
@@ -6253,9 +6332,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustls"
|
name = "rustls"
|
||||||
version = "0.23.46"
|
version = "0.23.47"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "48e13bd8c0e9365c43cfa5c9e8f9ad49d3c8444926c9aac819e0e4dc503c8fdf"
|
checksum = "4ac0e747c10d93d873fd4c50b26ef47ad92d1bfb48f6922003bb514070f6e88c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aws-lc-rs",
|
"aws-lc-rs",
|
||||||
"log",
|
"log",
|
||||||
@@ -6334,6 +6413,18 @@ version = "1.0.23"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f"
|
checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rusty-fork"
|
||||||
|
version = "0.3.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cc6bf79ff24e648f6da1f8d1f011e9cac26491b619e6b9280f2b47f1774e6ee2"
|
||||||
|
dependencies = [
|
||||||
|
"fnv",
|
||||||
|
"quick-error 1.2.3",
|
||||||
|
"tempfile",
|
||||||
|
"wait-timeout",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ryu"
|
name = "ryu"
|
||||||
version = "1.0.23"
|
version = "1.0.23"
|
||||||
@@ -7179,9 +7270,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "sysinfo"
|
name = "sysinfo"
|
||||||
version = "0.40.4"
|
version = "0.40.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3e80749408e2d8bec0ffa303012cf4e1b3b355f4a09087b4fdf7473680f6a2de"
|
checksum = "0ebe31c61260d7bc4bfc204a2d096c428a4c9ef59ca48bfa693d17fec4f129ad"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"memchr",
|
"memchr",
|
||||||
@@ -8131,7 +8222,7 @@ dependencies = [
|
|||||||
"fax",
|
"fax",
|
||||||
"flate2",
|
"flate2",
|
||||||
"half",
|
"half",
|
||||||
"quick-error",
|
"quick-error 2.0.1",
|
||||||
"weezl",
|
"weezl",
|
||||||
"zune-jpeg",
|
"zune-jpeg",
|
||||||
]
|
]
|
||||||
@@ -8762,6 +8853,12 @@ dependencies = [
|
|||||||
"windows-sys 0.61.2",
|
"windows-sys 0.61.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unarray"
|
||||||
|
version = "0.1.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicase"
|
name = "unicase"
|
||||||
version = "2.9.0"
|
version = "2.9.0"
|
||||||
@@ -8916,6 +9013,15 @@ dependencies = [
|
|||||||
"utf8parse",
|
"utf8parse",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wait-timeout"
|
||||||
|
version = "0.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "09ac3b126d3914f9849036f826e054cbabdc8519970b8998ddaf3b5bd3c65f11"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "walkdir"
|
name = "walkdir"
|
||||||
version = "2.5.0"
|
version = "2.5.0"
|
||||||
@@ -9351,6 +9457,20 @@ dependencies = [
|
|||||||
"windows-numerics 0.3.1",
|
"windows-numerics 0.3.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows"
|
||||||
|
version = "0.101.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "fa86febe1d5f623619e56067e9c6f84c368cf94f9f36df738875a0dc5affd752"
|
||||||
|
dependencies = [
|
||||||
|
"windows-collections 0.101.0",
|
||||||
|
"windows-core 0.101.0",
|
||||||
|
"windows-future 0.101.0",
|
||||||
|
"windows-numerics 0.101.0",
|
||||||
|
"windows-reference",
|
||||||
|
"windows-time",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-collections"
|
name = "windows-collections"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
@@ -9369,14 +9489,23 @@ dependencies = [
|
|||||||
"windows-core 0.62.2",
|
"windows-core 0.62.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-collections"
|
||||||
|
version = "0.101.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c988c3f56b2a0cf740d2837950f25c43539ea6c004a5244085ce6749e1c61f29"
|
||||||
|
dependencies = [
|
||||||
|
"windows-core 0.101.0",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-core"
|
name = "windows-core"
|
||||||
version = "0.61.2"
|
version = "0.61.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3"
|
checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-implement",
|
"windows-implement 0.60.2",
|
||||||
"windows-interface",
|
"windows-interface 0.59.3",
|
||||||
"windows-link 0.1.3",
|
"windows-link 0.1.3",
|
||||||
"windows-result 0.3.4",
|
"windows-result 0.3.4",
|
||||||
"windows-strings 0.4.2",
|
"windows-strings 0.4.2",
|
||||||
@@ -9388,13 +9517,39 @@ version = "0.62.2"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb"
|
checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-implement",
|
"windows-implement 0.60.2",
|
||||||
"windows-interface",
|
"windows-interface 0.59.3",
|
||||||
"windows-link 0.2.1",
|
"windows-link 0.2.1",
|
||||||
"windows-result 0.4.1",
|
"windows-result 0.4.1",
|
||||||
"windows-strings 0.5.1",
|
"windows-strings 0.5.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-core"
|
||||||
|
version = "0.100.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "803590c6856f51d15fa2e9fabe4f4703122c8737f72ef2741b4ac09d4c2192f5"
|
||||||
|
dependencies = [
|
||||||
|
"windows-implement 0.100.0",
|
||||||
|
"windows-interface 0.100.0",
|
||||||
|
"windows-link 0.100.0",
|
||||||
|
"windows-result 0.100.0",
|
||||||
|
"windows-strings 0.100.0",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-core"
|
||||||
|
version = "0.101.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "27abecb0bac0f1602c4e0d0c885aca58e9a2a25d852135b96e4d0f9daf989aac"
|
||||||
|
dependencies = [
|
||||||
|
"windows-implement 0.101.0",
|
||||||
|
"windows-interface 0.101.0",
|
||||||
|
"windows-link 0.101.0",
|
||||||
|
"windows-result 0.101.0",
|
||||||
|
"windows-strings 0.101.0",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-future"
|
name = "windows-future"
|
||||||
version = "0.2.1"
|
version = "0.2.1"
|
||||||
@@ -9417,6 +9572,17 @@ dependencies = [
|
|||||||
"windows-threading 0.2.1",
|
"windows-threading 0.2.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-future"
|
||||||
|
version = "0.101.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6c1de418ec955682054a08c9a2925719c76af9408397fd89fc7c2418bd3b2551"
|
||||||
|
dependencies = [
|
||||||
|
"windows-core 0.101.0",
|
||||||
|
"windows-link 0.101.0",
|
||||||
|
"windows-threading 0.101.0",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-implement"
|
name = "windows-implement"
|
||||||
version = "0.60.2"
|
version = "0.60.2"
|
||||||
@@ -9428,6 +9594,28 @@ dependencies = [
|
|||||||
"syn 2.0.119",
|
"syn 2.0.119",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-implement"
|
||||||
|
version = "0.100.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1bc1bc82e5a1b1a4d7255861b07881a0407b552f50a4d8543c0c7276fa96f6e8"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 2.0.119",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-implement"
|
||||||
|
version = "0.101.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "33a7f9008fbe08b219a4d9b2db1ceff71b9ed7f0e02472a3bf2046a2b258f933"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 2.0.119",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-interface"
|
name = "windows-interface"
|
||||||
version = "0.59.3"
|
version = "0.59.3"
|
||||||
@@ -9439,6 +9627,28 @@ dependencies = [
|
|||||||
"syn 2.0.119",
|
"syn 2.0.119",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-interface"
|
||||||
|
version = "0.100.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b3f7005c3b757b9b82c2f40c0e71094ff1080adddaf3e8b6ce99b545d3c48796"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 2.0.119",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-interface"
|
||||||
|
version = "0.101.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "67d1b654cf5aa8120c8c796fe6c88f0e0407512c341e83ea7bb65b933b596474"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 2.0.119",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-link"
|
name = "windows-link"
|
||||||
version = "0.1.3"
|
version = "0.1.3"
|
||||||
@@ -9451,6 +9661,18 @@ version = "0.2.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
|
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-link"
|
||||||
|
version = "0.100.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9b39de7c7fe78858b0144c50c3fc000bab3be17d5e9b85b1053871693c7f7415"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-link"
|
||||||
|
version = "0.101.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f4e57b2aae53a240c62b65069a63eaf8d5fa747f5d0d8e670c5210a98847bce4"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-numerics"
|
name = "windows-numerics"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
@@ -9471,6 +9693,25 @@ dependencies = [
|
|||||||
"windows-link 0.2.1",
|
"windows-link 0.2.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-numerics"
|
||||||
|
version = "0.101.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5d54e417b9761be91da0ab663a5e393e9e54820e55fa9a1d902b978bda3a71ba"
|
||||||
|
dependencies = [
|
||||||
|
"windows-core 0.101.0",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-reference"
|
||||||
|
version = "0.101.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f0a017bb8eab108f37103deaa4eaad24ce324c30c6f72628a59250be24c87466"
|
||||||
|
dependencies = [
|
||||||
|
"windows-core 0.101.0",
|
||||||
|
"windows-time",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-registry"
|
name = "windows-registry"
|
||||||
version = "0.6.1"
|
version = "0.6.1"
|
||||||
@@ -9500,6 +9741,24 @@ dependencies = [
|
|||||||
"windows-link 0.2.1",
|
"windows-link 0.2.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-result"
|
||||||
|
version = "0.100.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "44873a1ef61c85d5e2991db91fe656cfcf0731097e00dff1ac860f1cb3b752a0"
|
||||||
|
dependencies = [
|
||||||
|
"windows-link 0.100.0",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-result"
|
||||||
|
version = "0.101.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a02baed928b12dbc90e3a37d1504af179d275e13427510f6bcded0607c9251a7"
|
||||||
|
dependencies = [
|
||||||
|
"windows-link 0.101.0",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-service"
|
name = "windows-service"
|
||||||
version = "0.8.1"
|
version = "0.8.1"
|
||||||
@@ -9529,6 +9788,24 @@ dependencies = [
|
|||||||
"windows-link 0.2.1",
|
"windows-link 0.2.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-strings"
|
||||||
|
version = "0.100.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6a70b590c684f1d2854f74999896f7c0558f1bdde62f599088599e20ea1d2f60"
|
||||||
|
dependencies = [
|
||||||
|
"windows-link 0.100.0",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-strings"
|
||||||
|
version = "0.101.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3301e29c2a308301e0e84fe4242684b1310864f3e15aba65b4ae41f1a44f7f95"
|
||||||
|
dependencies = [
|
||||||
|
"windows-link 0.101.0",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-sys"
|
name = "windows-sys"
|
||||||
version = "0.45.0"
|
version = "0.45.0"
|
||||||
@@ -9583,6 +9860,15 @@ dependencies = [
|
|||||||
"windows-link 0.2.1",
|
"windows-link 0.2.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-sys"
|
||||||
|
version = "0.101.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "eed2df9f5f458664c87437f6758f0d93085b06433bf66b2b84c23c19f3d2012c"
|
||||||
|
dependencies = [
|
||||||
|
"windows-link 0.101.0",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-targets"
|
name = "windows-targets"
|
||||||
version = "0.42.2"
|
version = "0.42.2"
|
||||||
@@ -9664,6 +9950,24 @@ dependencies = [
|
|||||||
"windows-link 0.2.1",
|
"windows-link 0.2.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-threading"
|
||||||
|
version = "0.101.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4e1e41d72a0564ebe2cbb9487ed918acfc71d541683b84816a424dc3c7939592"
|
||||||
|
dependencies = [
|
||||||
|
"windows-link 0.101.0",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-time"
|
||||||
|
version = "0.101.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "186ef23b1710095987bf5281bd19e3669934d4353946f24cbdcfd0ed4f2deff6"
|
||||||
|
dependencies = [
|
||||||
|
"windows-core 0.101.0",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-version"
|
name = "windows-version"
|
||||||
version = "0.1.7"
|
version = "0.1.7"
|
||||||
|
|||||||
+8
-10
@@ -9,9 +9,6 @@ members = [
|
|||||||
"crates/tauri-plugin-clash-verge-sysinfo",
|
"crates/tauri-plugin-clash-verge-sysinfo",
|
||||||
"crates/clash-verge-i18n",
|
"crates/clash-verge-i18n",
|
||||||
"crates/clash-verge-limiter",
|
"crates/clash-verge-limiter",
|
||||||
"crates/clash-verge-subscription",
|
|
||||||
"crates/clash-verge-profile",
|
|
||||||
"crates/clash-verge-backup-archive",
|
|
||||||
]
|
]
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
|
|
||||||
@@ -62,9 +59,6 @@ clash-verge-logging = { path = "crates/clash-verge-logging" }
|
|||||||
clash-verge-signal = { path = "crates/clash-verge-signal" }
|
clash-verge-signal = { path = "crates/clash-verge-signal" }
|
||||||
clash-verge-i18n = { path = "crates/clash-verge-i18n" }
|
clash-verge-i18n = { path = "crates/clash-verge-i18n" }
|
||||||
clash-verge-limiter = { path = "crates/clash-verge-limiter" }
|
clash-verge-limiter = { path = "crates/clash-verge-limiter" }
|
||||||
clash-verge-subscription = { path = "crates/clash-verge-subscription" }
|
|
||||||
clash-verge-profile = { path = "crates/clash-verge-profile" }
|
|
||||||
clash-verge-backup-archive = { path = "crates/clash-verge-backup-archive" }
|
|
||||||
tracing-estuary = { git = "https://github.com/Tunglies/tracing-estuary.git", branch = "main" }
|
tracing-estuary = { git = "https://github.com/Tunglies/tracing-estuary.git", branch = "main" }
|
||||||
tauri-plugin-clash-verge-sysinfo = { path = "crates/tauri-plugin-clash-verge-sysinfo" }
|
tauri-plugin-clash-verge-sysinfo = { path = "crates/tauri-plugin-clash-verge-sysinfo" }
|
||||||
tracing = "0.1.44"
|
tracing = "0.1.44"
|
||||||
@@ -73,9 +67,9 @@ tauri = { version = "2.12.7" }
|
|||||||
tauri-plugin-clipboard-manager = "2.5.0"
|
tauri-plugin-clipboard-manager = "2.5.0"
|
||||||
parking_lot = "0.13.0"
|
parking_lot = "0.13.0"
|
||||||
anyhow = "1.0.105"
|
anyhow = "1.0.105"
|
||||||
thiserror = "2.0.20"
|
|
||||||
zip = "9.9.0"
|
|
||||||
futures = "0.3.34"
|
futures = "0.3.34"
|
||||||
|
loom = "0.7.3"
|
||||||
|
proptest = "1.12.0"
|
||||||
chrono = "0.4.45"
|
chrono = "0.4.45"
|
||||||
criterion = { version = "0.8.2", features = ["async_tokio"] }
|
criterion = { version = "0.8.2", features = ["async_tokio"] }
|
||||||
tokio = { version = "1.54.1", features = [
|
tokio = { version = "1.54.1", features = [
|
||||||
@@ -99,12 +93,11 @@ serde = { version = "1.0.229" }
|
|||||||
tristr = { git = "https://github.com/Tunglies/tristr", rev = "d849e5cff47a570849c2e1bada0a2b6481cf3378", default-features = false, features = ["serde", "specta"] }
|
tristr = { git = "https://github.com/Tunglies/tristr", rev = "d849e5cff47a570849c2e1bada0a2b6481cf3378", default-features = false, features = ["serde", "specta"] }
|
||||||
serde_json = { version = "1.0.154" }
|
serde_json = { version = "1.0.154" }
|
||||||
serde_yaml_ng = { version = "0.10.0" }
|
serde_yaml_ng = { version = "0.10.0" }
|
||||||
specta = "=2.0.0-rc.26"
|
|
||||||
socket2 = "0.6.5"
|
socket2 = "0.6.5"
|
||||||
|
|
||||||
# *** For Windows platform only ***
|
# *** For Windows platform only ***
|
||||||
deelevate = "0.2.0"
|
deelevate = "0.2.0"
|
||||||
windows-sys = { version = "0.61.2", features = [
|
windows-sys = { version = "0.101.0", features = [
|
||||||
"Win32_Foundation",
|
"Win32_Foundation",
|
||||||
"Win32_NetworkManagement_IpHelper",
|
"Win32_NetworkManagement_IpHelper",
|
||||||
"Win32_Networking_WinSock",
|
"Win32_Networking_WinSock",
|
||||||
@@ -117,6 +110,9 @@ windows-sys = { version = "0.61.2", features = [
|
|||||||
] }
|
] }
|
||||||
# *********************************
|
# *********************************
|
||||||
|
|
||||||
|
[workspace.lints.rust]
|
||||||
|
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(loom)'] }
|
||||||
|
|
||||||
[workspace.lints.clippy]
|
[workspace.lints.clippy]
|
||||||
# fallible_impl_from = "deny" // 过于激进,暂时不开启
|
# fallible_impl_from = "deny" // 过于激进,暂时不开启
|
||||||
# implicit_clone = "deny" // 可能会造成额外开销,暂时不开启
|
# implicit_clone = "deny" // 可能会造成额外开销,暂时不开启
|
||||||
@@ -133,6 +129,7 @@ copy_iterator = "deny"
|
|||||||
correctness = { level = "deny", priority = -1 }
|
correctness = { level = "deny", priority = -1 }
|
||||||
dbg_macro = "warn"
|
dbg_macro = "warn"
|
||||||
equatable_if_let = "deny"
|
equatable_if_let = "deny"
|
||||||
|
expect_used = "warn"
|
||||||
expl_impl_clone_on_copy = "deny"
|
expl_impl_clone_on_copy = "deny"
|
||||||
future_not_send = "deny"
|
future_not_send = "deny"
|
||||||
iter_on_empty_collections = "deny"
|
iter_on_empty_collections = "deny"
|
||||||
@@ -171,6 +168,7 @@ unnecessary_self_imports = "deny"
|
|||||||
unnecessary_wraps = "deny"
|
unnecessary_wraps = "deny"
|
||||||
unused_async = "deny"
|
unused_async = "deny"
|
||||||
unused_trait_names = "deny"
|
unused_trait_names = "deny"
|
||||||
|
unwrap_used = "warn"
|
||||||
use_self = "deny"
|
use_self = "deny"
|
||||||
useless_let_if_seq = "deny"
|
useless_let_if_seq = "deny"
|
||||||
wildcard_imports = "deny"
|
wildcard_imports = "deny"
|
||||||
|
|||||||
@@ -33,7 +33,6 @@
|
|||||||
- 修复检测更新后又发布新版时,应用内更新失败
|
- 修复检测更新后又发布新版时,应用内更新失败
|
||||||
- 修复关闭「自动检查更新」后,手动检查更新时弹窗空白
|
- 修复关闭「自动检查更新」后,手动检查更新时弹窗空白
|
||||||
- 修复订阅响应过大导致内存占用过高,限制单次下载为 4 MiB
|
- 修复订阅响应过大导致内存占用过高,限制单次下载为 4 MiB
|
||||||
- 修复服务端文件名无效时导入的订阅名称为空
|
|
||||||
- 修复全局模式默认停在 `DIRECT` 或 `REJECT` 导致流量未经代理,现自动切换到第一个策略组
|
- 修复全局模式默认停在 `DIRECT` 或 `REJECT` 导致流量未经代理,现自动切换到第一个策略组
|
||||||
- 修复订阅中未加引号的 REALITY `short-id`(如 `1234e123`)被误读为数字,导致订阅无法启用
|
- 修复订阅中未加引号的 REALITY `short-id`(如 `1234e123`)被误读为数字,导致订阅无法启用
|
||||||
- 修复订阅中唯一的代理组名为 `GLOBAL` 或没有代理组时,规则模式下代理页面显示「未获取到代理信息」
|
- 修复订阅中唯一的代理组名为 `GLOBAL` 或没有代理组时,规则模式下代理页面显示「未获取到代理信息」
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
# Clippy loads a single configuration file, so repeat the workspace defaults.
|
|
||||||
avoid-breaking-exported-api = true
|
|
||||||
allow-unwrap-in-tests = true
|
|
||||||
cognitive-complexity-threshold = 25
|
|
||||||
excessive-nesting-threshold = 5
|
|
||||||
+9
-46
@@ -2,34 +2,19 @@
|
|||||||
|
|
||||||
## Choose the boundary
|
## Choose the boundary
|
||||||
|
|
||||||
- Apply Functional Core, Imperative Shell and Ports and Adapters. Keep domain
|
|
||||||
types, invariants, parsing, validation, and deterministic transitions
|
|
||||||
independent of Tauri, concrete OS APIs, and implicit application state.
|
|
||||||
- Keep use cases, async coordination, cancellation, and timeouts in
|
|
||||||
framework-independent application modules. Pass dependencies explicitly.
|
|
||||||
Define ports where an external effect needs a contract. Adapters implement
|
|
||||||
the contracts owned by their consumers. Keep filesystem, network, IPC, process,
|
|
||||||
and OS-specific operations in their adapters.
|
|
||||||
- Extract a capability whose invariants can be owned behind a small API. Before
|
- Extract a capability whose invariants can be owned behind a small API. Before
|
||||||
creating a crate, identify its owner, what callers supply, and what can be
|
creating a crate, identify its owner, what callers supply, and what can be
|
||||||
verified through the crate API. Extract a crate when it provides a useful
|
verified through the crate API. Keep a module when the proposed boundary only
|
||||||
dependency, portability, testing, or ownership boundary. Keep a module when
|
relocates implementation or introduces a pass-through API.
|
||||||
the proposed boundary only relocates implementation or introduces a
|
- Keep the dependency direction from the app to the crate. Resolve app paths,
|
||||||
pass-through API.
|
read product settings, start app-owned tasks, and publish UI events in the app.
|
||||||
- Keep capability crates independent by default. Compose peer capabilities in
|
Pass the values, resources, or callbacks the crate needs. For example,
|
||||||
the application and pass inputs or callbacks through the consumer's API.
|
|
||||||
Depend on another workspace crate for foundational mechanisms such as logging
|
|
||||||
and task primitives, or for a shared domain contract required to enforce the
|
|
||||||
same invariant. Keep tightly coupled rules together when separating them
|
|
||||||
would duplicate that contract or split its ownership.
|
|
||||||
- Keep dependencies pointing toward domain and application contracts. Resolve
|
|
||||||
app paths and read current settings at the application boundary. Pass in the
|
|
||||||
required values, resources, or callbacks. For example,
|
|
||||||
[logging](clash-verge-logging/src/lib.rs) owns its pipeline and writers while the
|
[logging](clash-verge-logging/src/lib.rs) owns its pipeline and writers while the
|
||||||
app supplies directories and limits through `LoggerConfig`.
|
app supplies directories and limits through `LoggerConfig`.
|
||||||
- Run framework-independent tests without starting the desktop app. A platform
|
- Keep framework and platform dependencies scoped to the capability that needs
|
||||||
adapter can own runtime startup when its resource lifetime requires it, as
|
them. Runtime-independent logic should be runnable without the desktop app.
|
||||||
[signal](clash-verge-signal/src/lib.rs) does for Linux shutdown.
|
A platform adapter can own runtime startup when its resource lifetime requires
|
||||||
|
it, as [signal](clash-verge-signal/src/lib.rs) does for Linux shutdown.
|
||||||
|
|
||||||
## Design the API
|
## Design the API
|
||||||
|
|
||||||
@@ -46,14 +31,6 @@
|
|||||||
workspace lints. Reuse workspace dependencies where available and declare
|
workspace lints. Reuse workspace dependencies where available and declare
|
||||||
only the features the crate needs.
|
only the features the crate needs.
|
||||||
|
|
||||||
## Handle fallible input
|
|
||||||
|
|
||||||
- Define crate-owned error types with `thiserror` in a dedicated `error` module.
|
|
||||||
Re-export public errors through their established import paths.
|
|
||||||
- Crates may use `unwrap()` or `expect()` for internal invariants. Propagate
|
|
||||||
errors from required external data and use defaults only when the input
|
|
||||||
contract gives the default a meaning.
|
|
||||||
|
|
||||||
## Own background work
|
## Own background work
|
||||||
|
|
||||||
- Give ordered start, replacement, and cleanup to one task owner. Reuse
|
- Give ordered start, replacement, and cleanup to one task owner. Reuse
|
||||||
@@ -66,20 +43,6 @@
|
|||||||
transaction boundaries and keep the reply path free of locks held by the
|
transaction boundaries and keep the reply path free of locks held by the
|
||||||
waiting caller. Cancel only at safe boundaries and own issued effects through
|
waiting caller. Cancel only at safe boundaries and own issued effects through
|
||||||
completion or explicit reconciliation.
|
completion or explicit reconciliation.
|
||||||
- Distinguish requested effects from completed effects in typed outcomes.
|
|
||||||
Define how failures, cancellation, and timeouts affect publication, retry,
|
|
||||||
rollback, or reconciliation.
|
|
||||||
|
|
||||||
## Validate new crates
|
|
||||||
|
|
||||||
- Fuzz the public boundary before tuning. Exercise malformed input, fallback
|
|
||||||
behavior, and failures that can affect user data. Preserve the corpus and
|
|
||||||
record the baseline revision and dependency resolution.
|
|
||||||
- Try at least one targeted performance improvement. Compare the baseline and
|
|
||||||
candidate on the same workload and build settings. Record stable gains, flat
|
|
||||||
cases, and regressions, and justify which changes to keep.
|
|
||||||
- Fuzz the final candidate again. Use the baseline corpus and compare outputs,
|
|
||||||
diagnostics, and errors with the baseline where behavior should be preserved.
|
|
||||||
|
|
||||||
Verify the extracted contract through its public API when practical. Use
|
Verify the extracted contract through its public API when practical. Use
|
||||||
`cargo test -p <crate>` for focused tests and keep native behavior checks at the
|
`cargo test -p <crate>` for focused tests and keep native behavior checks at the
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "clash-verge-backup-archive"
|
|
||||||
version = "0.1.0"
|
|
||||||
edition = "2024"
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
thiserror = { workspace = true }
|
|
||||||
zip = { workspace = true }
|
|
||||||
|
|
||||||
[lints]
|
|
||||||
workspace = true
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
#[derive(Debug, thiserror::Error)]
|
|
||||||
pub enum ArchiveError {
|
|
||||||
#[error(transparent)]
|
|
||||||
Zip(#[from] zip::result::ZipError),
|
|
||||||
#[error(transparent)]
|
|
||||||
Io(#[from] std::io::Error),
|
|
||||||
#[error("backup contains a symbolic link")]
|
|
||||||
Symlink,
|
|
||||||
#[error("backup contains an invalid path")]
|
|
||||||
InvalidPath,
|
|
||||||
#[error("archive contains profile recovery data")]
|
|
||||||
ReservedEntry,
|
|
||||||
}
|
|
||||||
@@ -1,104 +0,0 @@
|
|||||||
mod error;
|
|
||||||
|
|
||||||
pub use error::ArchiveError;
|
|
||||||
|
|
||||||
use std::{
|
|
||||||
io::{self, Read, Seek, Write},
|
|
||||||
path::{Component, Path},
|
|
||||||
};
|
|
||||||
use zip::{CompressionMethod, ZipArchive, ZipWriter, write::SimpleFileOptions};
|
|
||||||
|
|
||||||
pub struct BackupWriter<W: Write + Seek> {
|
|
||||||
zip: ZipWriter<W>,
|
|
||||||
options: SimpleFileOptions,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<W: Write + Seek> BackupWriter<W> {
|
|
||||||
pub fn new(target: W) -> Result<Self, ArchiveError> {
|
|
||||||
let mut zip = ZipWriter::new(target);
|
|
||||||
zip.add_directory("profiles/", SimpleFileOptions::default())?;
|
|
||||||
let options = SimpleFileOptions::default().compression_method(CompressionMethod::Stored);
|
|
||||||
Ok(Self { zip, options })
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn start_profile<'a>(&'a mut self, filename: &str) -> Result<impl Write + use<'a, W>, ArchiveError> {
|
|
||||||
self.start_file(&format!("profiles/{filename}"))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn start_file<'a>(&'a mut self, name: &str) -> Result<impl Write + use<'a, W>, ArchiveError> {
|
|
||||||
self.zip.start_file_with_options(self.options.name(name.as_bytes()))?;
|
|
||||||
Ok(&mut self.zip)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn finish(self) -> Result<W, ArchiveError> {
|
|
||||||
Ok(self.zip.finish()?)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct ValidatedBackup<R: Read + Seek> {
|
|
||||||
zip: ZipArchive<R>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<R: Read + Seek> ValidatedBackup<R> {
|
|
||||||
pub fn open(source: R, reserved_names: &[&str]) -> Result<Self, ArchiveError> {
|
|
||||||
let mut zip = ZipArchive::new(source)?;
|
|
||||||
for index in 0..zip.len() {
|
|
||||||
let mut entry = zip.by_index(index)?;
|
|
||||||
if entry.is_symlink() {
|
|
||||||
return Err(ArchiveError::Symlink);
|
|
||||||
}
|
|
||||||
let path = entry.enclosed_name().ok_or(ArchiveError::InvalidPath)?;
|
|
||||||
for component in path.components() {
|
|
||||||
let Component::Normal(name) = component else {
|
|
||||||
continue;
|
|
||||||
};
|
|
||||||
let name = name.to_string_lossy();
|
|
||||||
if reserved_names
|
|
||||||
.iter()
|
|
||||||
.any(|reserved| name.eq_ignore_ascii_case(reserved))
|
|
||||||
{
|
|
||||||
return Err(ArchiveError::ReservedEntry);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
io::copy(&mut entry, &mut io::sink())?;
|
|
||||||
}
|
|
||||||
Ok(Self { zip })
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn extract_to(mut self, destination: &Path) -> Result<(), ArchiveError> {
|
|
||||||
self.zip.extract(destination)?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
use std::io::Cursor;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn writes_and_validates_the_backup_layout() -> Result<(), ArchiveError> {
|
|
||||||
let mut writer = BackupWriter::new(Cursor::new(Vec::new()))?;
|
|
||||||
writer.start_profile("example.yaml")?.write_all(b"proxies: []\n")?;
|
|
||||||
writer.start_file("profiles.yaml")?.write_all(b"items: []\n")?;
|
|
||||||
let source = writer.finish()?;
|
|
||||||
|
|
||||||
let mut zip = ZipArchive::new(source.clone())?;
|
|
||||||
assert_eq!(zip.len(), 3);
|
|
||||||
assert_eq!(zip.by_index(0)?.name()?, "profiles/");
|
|
||||||
let profile_time = {
|
|
||||||
let mut entry = zip.by_index(1)?;
|
|
||||||
assert_eq!(entry.name()?, "profiles/example.yaml");
|
|
||||||
assert_eq!(entry.compression(), CompressionMethod::Stored);
|
|
||||||
let mut contents = Vec::new();
|
|
||||||
entry.read_to_end(&mut contents)?;
|
|
||||||
assert_eq!(contents, b"proxies: []\n");
|
|
||||||
entry.last_modified()
|
|
||||||
};
|
|
||||||
let index = zip.by_index(2)?;
|
|
||||||
assert_eq!(index.name()?, "profiles.yaml");
|
|
||||||
assert_eq!(index.last_modified(), profile_time);
|
|
||||||
ValidatedBackup::open(source, &[".profile-refresh", ".profile-refresh.lock"])?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -10,7 +10,7 @@ harness = false
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
parking_lot = { workspace = true }
|
parking_lot = { workspace = true }
|
||||||
thiserror = { workspace = true }
|
anyhow = { workspace = true }
|
||||||
tokio = { workspace = true }
|
tokio = { workspace = true }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ use criterion::{Criterion, criterion_group, criterion_main};
|
|||||||
use std::hint::black_box;
|
use std::hint::black_box;
|
||||||
use tokio::runtime::Runtime;
|
use tokio::runtime::Runtime;
|
||||||
|
|
||||||
use clash_verge_draft::{Draft, DraftConflict};
|
use clash_verge_draft::Draft;
|
||||||
|
|
||||||
#[derive(Default, Clone, Debug)]
|
#[derive(Default, Clone, Debug)]
|
||||||
struct IVerge {
|
struct IVerge {
|
||||||
@@ -99,8 +99,8 @@ pub fn bench_draft(c: &mut Criterion) {
|
|||||||
group.bench_function("with_data_modify_async", |b| {
|
group.bench_function("with_data_modify_async", |b| {
|
||||||
b.to_async(&rt).iter(|| async {
|
b.to_async(&rt).iter(|| async {
|
||||||
let draft = black_box(make_draft());
|
let draft = black_box(make_draft());
|
||||||
let _: Result<(), DraftConflict> = draft
|
let _: Result<(), anyhow::Error> = draft
|
||||||
.with_data_modify(|mut box_data| async move {
|
.with_data_modify::<_, _, _>(|mut box_data| async move {
|
||||||
box_data.enable_auto_launch = Some(!box_data.enable_auto_launch.unwrap_or(false));
|
box_data.enable_auto_launch = Some(!box_data.enable_auto_launch.unwrap_or(false));
|
||||||
Ok((box_data, ()))
|
Ok((box_data, ()))
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
/// Committed data changed before an asynchronous edit could publish.
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, thiserror::Error)]
|
|
||||||
#[error("Optimistic lock failed: Committed data has changed during async operation")]
|
|
||||||
pub struct DraftConflict;
|
|
||||||
|
|
||||||
/// Another transaction is already staging a change to one of the layers asked for.
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
|
|
||||||
#[error("configuration layer {layer} is being changed elsewhere")]
|
|
||||||
pub struct DraftBusy {
|
|
||||||
/// The layer that was already claimed.
|
|
||||||
pub layer: &'static str,
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,3 @@
|
|||||||
mod error;
|
|
||||||
|
|
||||||
pub use error::{DraftBusy, DraftConflict};
|
|
||||||
|
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::sync::atomic::{
|
use std::sync::atomic::{
|
||||||
@@ -95,16 +91,14 @@ impl<T: Clone> Draft<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Optimistically replaces committed data after an asynchronous edit.
|
/// Optimistically replaces committed data after an asynchronous edit.
|
||||||
/// The caller's error type carries both edit failures and publication conflicts.
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub async fn with_data_modify<F, Fut, R, E>(&self, f: F) -> Result<R, E>
|
pub async fn with_data_modify<F, Fut, R>(&self, f: F) -> Result<R, anyhow::Error>
|
||||||
where
|
where
|
||||||
T: Send + Sync + 'static,
|
T: Send + Sync + 'static,
|
||||||
F: FnOnce(T) -> Fut + Send,
|
F: FnOnce(T) -> Fut + Send,
|
||||||
Fut: std::future::Future<Output = Result<(T, R), E>> + Send,
|
Fut: std::future::Future<Output = Result<(T, R), anyhow::Error>> + Send,
|
||||||
E: From<DraftConflict>,
|
|
||||||
{
|
{
|
||||||
let permit = self.acquire_data_modify_permit().await;
|
let _permit = self.acquire_data_modify_permit().await;
|
||||||
let (local, original_arc) = {
|
let (local, original_arc) = {
|
||||||
let guard = self.inner.data.lock();
|
let guard = self.inner.data.lock();
|
||||||
let arc = Arc::clone(&guard.0);
|
let arc = Arc::clone(&guard.0);
|
||||||
@@ -114,9 +108,9 @@ impl<T: Clone> Draft<T> {
|
|||||||
let (new_local, res) = f(local).await?;
|
let (new_local, res) = f(local).await?;
|
||||||
let mut guard = self.inner.data.lock();
|
let mut guard = self.inner.data.lock();
|
||||||
if !Arc::ptr_eq(&guard.0, &original_arc) {
|
if !Arc::ptr_eq(&guard.0, &original_arc) {
|
||||||
drop(guard);
|
return Err(anyhow::anyhow!(
|
||||||
drop(permit);
|
"Optimistic lock failed: Committed data has changed during async operation"
|
||||||
return Err(DraftConflict.into());
|
));
|
||||||
}
|
}
|
||||||
guard.0 = Arc::new(Box::new(new_local));
|
guard.0 = Arc::new(Box::new(new_local));
|
||||||
drop(guard);
|
drop(guard);
|
||||||
@@ -197,6 +191,25 @@ impl<T: Clone + Send + Sync> DraftLayer for Draft<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Another transaction is already staging a change to one of the layers asked for.
|
||||||
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
|
pub struct DraftBusy {
|
||||||
|
/// The layer that was already claimed.
|
||||||
|
pub layer: &'static str,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::fmt::Display for DraftBusy {
|
||||||
|
fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
write!(
|
||||||
|
formatter,
|
||||||
|
"configuration layer {} is being changed elsewhere",
|
||||||
|
self.layer
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::error::Error for DraftBusy {}
|
||||||
|
|
||||||
/// Exclusively claims several draft layers and rolls them all back unless committed.
|
/// Exclusively claims several draft layers and rolls them all back unless committed.
|
||||||
///
|
///
|
||||||
/// A layer has one draft slot, so concurrent transactions cannot be isolated and are rejected.
|
/// A layer has one draft slot, so concurrent transactions cannot be isolated and are rejected.
|
||||||
|
|||||||
@@ -1,7 +1,14 @@
|
|||||||
use std::sync::Arc;
|
use std::{
|
||||||
|
pin::pin,
|
||||||
|
sync::{
|
||||||
|
Arc,
|
||||||
|
atomic::{AtomicBool, Ordering},
|
||||||
|
},
|
||||||
|
task::{Context, Poll, Wake, Waker},
|
||||||
|
};
|
||||||
|
|
||||||
use clash_verge_draft::{Draft, DraftBusy, DraftConflict, DraftTransaction};
|
use clash_verge_draft::{Draft, DraftTransaction};
|
||||||
use tokio::sync::Notify;
|
use tokio::sync::{Notify, oneshot};
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, PartialEq)]
|
#[derive(Clone, Debug, Default, PartialEq)]
|
||||||
struct Config {
|
struct Config {
|
||||||
@@ -28,19 +35,14 @@ fn edits_can_be_committed_or_discarded() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn async_updates_are_serialized() -> Result<(), Box<dyn std::error::Error>> {
|
async fn async_updates_are_serialized() -> anyhow::Result<()> {
|
||||||
let draft = Arc::new(Draft::new(0_u8));
|
let draft = Arc::new(Draft::new(0_u8));
|
||||||
let mut updates = Vec::new();
|
let mut updates = Vec::new();
|
||||||
|
|
||||||
for _ in 0..16 {
|
for _ in 0..16 {
|
||||||
let draft = Arc::clone(&draft);
|
let draft = Arc::clone(&draft);
|
||||||
updates.push(tokio::spawn(async move {
|
updates.push(tokio::spawn(async move {
|
||||||
draft
|
draft.with_data_modify(|value| async move { Ok((value + 1, ())) }).await
|
||||||
.with_data_modify(|value| async move {
|
|
||||||
tokio::task::yield_now().await;
|
|
||||||
Ok::<_, DraftConflict>((value + 1, ()))
|
|
||||||
})
|
|
||||||
.await
|
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
for update in updates {
|
for update in updates {
|
||||||
@@ -52,7 +54,7 @@ async fn async_updates_are_serialized() -> Result<(), Box<dyn std::error::Error>
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn async_update_rejects_a_changed_committed_value() -> Result<(), Box<dyn std::error::Error>> {
|
async fn async_update_rejects_a_changed_committed_value() -> anyhow::Result<()> {
|
||||||
let draft = Arc::new(Draft::new(Config::default()));
|
let draft = Arc::new(Draft::new(Config::default()));
|
||||||
let started = Arc::new(Notify::new());
|
let started = Arc::new(Notify::new());
|
||||||
let finish = Arc::new(Notify::new());
|
let finish = Arc::new(Notify::new());
|
||||||
@@ -66,7 +68,7 @@ async fn async_update_rejects_a_changed_committed_value() -> Result<(), Box<dyn
|
|||||||
started.notify_one();
|
started.notify_one();
|
||||||
finish.notified().await;
|
finish.notified().await;
|
||||||
config.enabled = true;
|
config.enabled = true;
|
||||||
Ok::<_, DraftConflict>((config, ()))
|
Ok((config, ()))
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
})
|
})
|
||||||
@@ -77,14 +79,55 @@ async fn async_update_rejects_a_changed_committed_value() -> Result<(), Box<dyn
|
|||||||
draft.apply();
|
draft.apply();
|
||||||
finish.notify_one();
|
finish.notify_one();
|
||||||
|
|
||||||
assert_eq!(update.await?, Err(DraftConflict));
|
assert!(update.await?.is_err());
|
||||||
assert!(!draft.data_arc().enabled);
|
assert!(!draft.data_arc().enabled);
|
||||||
assert_eq!(draft.data_arc().port, 7897);
|
assert_eq!(draft.data_arc().port, 7897);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn transaction_commits_every_layer() -> Result<(), DraftBusy> {
|
fn parked_async_update_is_woken_after_optimistic_conflict() {
|
||||||
|
#[derive(Default)]
|
||||||
|
struct WakeFlag(AtomicBool);
|
||||||
|
|
||||||
|
impl Wake for WakeFlag {
|
||||||
|
fn wake(self: Arc<Self>) {
|
||||||
|
self.0.store(true, Ordering::Relaxed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let draft = Draft::new(1);
|
||||||
|
let (finish, finished) = oneshot::channel();
|
||||||
|
let mut owner = pin!(draft.with_data_modify(|value| async move {
|
||||||
|
finished.await?;
|
||||||
|
Ok((value + 10, ()))
|
||||||
|
}));
|
||||||
|
let mut owner_context = Context::from_waker(Waker::noop());
|
||||||
|
assert!(owner.as_mut().poll(&mut owner_context).is_pending());
|
||||||
|
|
||||||
|
let wake_flag = Arc::new(WakeFlag::default());
|
||||||
|
let waker = Waker::from(Arc::clone(&wake_flag));
|
||||||
|
let mut waiter_context = Context::from_waker(&waker);
|
||||||
|
let mut waiter = pin!(draft.with_data_modify(|value| async move { Ok((value + 1, value)) }));
|
||||||
|
|
||||||
|
// The fast retry wakes once before the waiter parks on Notify.
|
||||||
|
assert!(waiter.as_mut().poll(&mut waiter_context).is_pending());
|
||||||
|
assert!(wake_flag.0.swap(false, Ordering::Relaxed), "fast retry did not wake");
|
||||||
|
assert!(waiter.as_mut().poll(&mut waiter_context).is_pending());
|
||||||
|
assert!(!wake_flag.0.load(Ordering::Relaxed), "waiter did not park");
|
||||||
|
|
||||||
|
draft.edit_draft(|value| *value = 7);
|
||||||
|
draft.apply();
|
||||||
|
assert!(finish.send(()).is_ok());
|
||||||
|
assert!(matches!(owner.as_mut().poll(&mut owner_context), Poll::Ready(Err(_))));
|
||||||
|
assert_eq!(**draft.data_arc(), 7);
|
||||||
|
assert!(wake_flag.0.load(Ordering::Relaxed), "parked waiter was not notified");
|
||||||
|
assert!(matches!(waiter.as_mut().poll(&mut waiter_context), Poll::Ready(Ok(7))));
|
||||||
|
assert_eq!(**draft.data_arc(), 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn transaction_commits_every_layer() -> anyhow::Result<()> {
|
||||||
let first = Draft::new(1_u8);
|
let first = Draft::new(1_u8);
|
||||||
let second = Draft::new(String::from("a"));
|
let second = Draft::new(String::from("a"));
|
||||||
let transaction = DraftTransaction::begin(vec![&first, &second])?;
|
let transaction = DraftTransaction::begin(vec![&first, &second])?;
|
||||||
@@ -99,7 +142,7 @@ fn transaction_commits_every_layer() -> Result<(), DraftBusy> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn dropped_transaction_rolls_every_layer_back() -> Result<(), DraftBusy> {
|
fn dropped_transaction_rolls_every_layer_back() -> anyhow::Result<()> {
|
||||||
let first = Draft::new(1_u8);
|
let first = Draft::new(1_u8);
|
||||||
let second = Draft::new(String::from("a"));
|
let second = Draft::new(String::from("a"));
|
||||||
|
|
||||||
@@ -115,12 +158,17 @@ fn dropped_transaction_rolls_every_layer_back() -> Result<(), DraftBusy> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn transaction_claims_are_exclusive_and_release_partial_claims() -> Result<(), DraftBusy> {
|
fn transaction_claims_are_exclusive_and_release_partial_claims() -> anyhow::Result<()> {
|
||||||
let first = Draft::new(1_u8);
|
let first = Draft::new(1_u8);
|
||||||
let second = Draft::new(2_u8);
|
let second = Draft::new(2_u16);
|
||||||
let held = DraftTransaction::begin(vec![&second])?;
|
let held = DraftTransaction::begin(vec![&second])?;
|
||||||
|
|
||||||
assert!(DraftTransaction::begin(vec![&first, &second]).is_err());
|
let busy = DraftTransaction::begin(vec![&first, &second])
|
||||||
|
.err()
|
||||||
|
.ok_or_else(|| anyhow::anyhow!("transaction claimed an already-held layer"))?;
|
||||||
|
let layer = std::any::type_name::<u16>();
|
||||||
|
assert_eq!(busy.layer, layer);
|
||||||
|
assert!(busy.to_string().contains(layer));
|
||||||
let available = DraftTransaction::begin(vec![&first])?;
|
let available = DraftTransaction::begin(vec![&first])?;
|
||||||
|
|
||||||
drop(available);
|
drop(available);
|
||||||
|
|||||||
@@ -5,5 +5,11 @@ edition = "2024"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
proptest = { workspace = true }
|
||||||
|
|
||||||
|
[target.'cfg(loom)'.dependencies]
|
||||||
|
loom = { workspace = true }
|
||||||
|
|
||||||
[lints]
|
[lints]
|
||||||
workspace = true
|
workspace = true
|
||||||
|
|||||||
@@ -1,5 +1,12 @@
|
|||||||
|
#[cfg(loom)]
|
||||||
|
use loom::sync::Arc;
|
||||||
|
#[cfg(loom)]
|
||||||
|
use loom::sync::atomic::AtomicU64;
|
||||||
|
#[cfg(not(loom))]
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::sync::atomic::{AtomicU64, Ordering};
|
#[cfg(not(loom))]
|
||||||
|
use std::sync::atomic::AtomicU64;
|
||||||
|
use std::sync::atomic::Ordering;
|
||||||
use std::time::{Duration, SystemTime, UNIX_EPOCH};
|
use std::time::{Duration, SystemTime, UNIX_EPOCH};
|
||||||
|
|
||||||
pub type SystemLimiter = Limiter<SystemClock>;
|
pub type SystemLimiter = Limiter<SystemClock>;
|
||||||
@@ -38,6 +45,7 @@ pub struct Limiter<C: Clock = SystemClock> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<C: Clock> Limiter<C> {
|
impl<C: Clock> Limiter<C> {
|
||||||
|
#[cfg(not(loom))]
|
||||||
pub const fn new(period: Duration, clock: C) -> Self {
|
pub const fn new(period: Duration, clock: C) -> Self {
|
||||||
Self {
|
Self {
|
||||||
last_run_ms: AtomicU64::new(0),
|
last_run_ms: AtomicU64::new(0),
|
||||||
@@ -46,11 +54,21 @@ impl<C: Clock> Limiter<C> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn check(&self) -> bool {
|
#[cfg(loom)]
|
||||||
let now = self.clock.now_ms();
|
pub fn new(period: Duration, clock: C) -> Self {
|
||||||
let last = self.last_run_ms.load(Ordering::Relaxed);
|
Self {
|
||||||
|
last_run_ms: AtomicU64::new(0),
|
||||||
|
period_ms: period.as_millis() as u64,
|
||||||
|
clock,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if now < last + self.period_ms && now >= last {
|
pub fn check(&self) -> bool {
|
||||||
|
// Load before sampling so a stale sample cannot move a newer admission backward.
|
||||||
|
let last = self.last_run_ms.load(Ordering::Relaxed);
|
||||||
|
let now = self.clock.now_ms();
|
||||||
|
|
||||||
|
if now >= last && now - last < self.period_ms {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,6 +92,22 @@ mod tests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn system_clock_reports_unix_epoch_milliseconds() {
|
||||||
|
const MAX_DRIFT_MS: u64 = 5 * 60 * 1_000;
|
||||||
|
|
||||||
|
let wall_clock_ms = SystemTime::now()
|
||||||
|
.duration_since(UNIX_EPOCH)
|
||||||
|
.unwrap_or_default()
|
||||||
|
.as_millis() as u64;
|
||||||
|
let clock_ms = SystemClock.now_ms();
|
||||||
|
|
||||||
|
assert!(
|
||||||
|
clock_ms.abs_diff(wall_clock_ms) <= MAX_DRIFT_MS,
|
||||||
|
"SystemClock::now_ms() should return Unix epoch milliseconds, got {clock_ms} while wall clock is {wall_clock_ms}"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn enforces_the_period_boundary() {
|
fn enforces_the_period_boundary() {
|
||||||
let clock = MockClock(AtomicU64::new(1_000));
|
let clock = MockClock(AtomicU64::new(1_000));
|
||||||
@@ -100,7 +134,10 @@ mod tests {
|
|||||||
}
|
}
|
||||||
let admitted = handles
|
let admitted = handles
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|handle| handle.join().unwrap_or(false))
|
.map(|handle| match handle.join() {
|
||||||
|
Ok(admitted) => admitted,
|
||||||
|
Err(panic) => std::panic::resume_unwind(panic),
|
||||||
|
})
|
||||||
.filter(|passed| *passed)
|
.filter(|passed| *passed)
|
||||||
.count();
|
.count();
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,225 @@
|
|||||||
|
#![cfg(loom)]
|
||||||
|
|
||||||
|
use std::sync::atomic::Ordering;
|
||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
|
use clash_verge_limiter::{Clock, Limiter};
|
||||||
|
use loom::sync::Arc;
|
||||||
|
use loom::sync::atomic::{AtomicBool, AtomicU64, AtomicUsize};
|
||||||
|
|
||||||
|
const PERIOD_MS: u64 = 100;
|
||||||
|
const START_MS: u64 = 1_000;
|
||||||
|
|
||||||
|
struct MockClock(AtomicU64);
|
||||||
|
|
||||||
|
impl Clock for MockClock {
|
||||||
|
fn now_ms(&self) -> u64 {
|
||||||
|
self.0.load(Ordering::SeqCst)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type TestLimiter = Limiter<Arc<MockClock>>;
|
||||||
|
|
||||||
|
struct AdvancingClock(AtomicU64);
|
||||||
|
|
||||||
|
impl Clock for AdvancingClock {
|
||||||
|
fn now_ms(&self) -> u64 {
|
||||||
|
self.0.fetch_add(1, Ordering::SeqCst)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn limiter_at(now_ms: u64) -> (Arc<MockClock>, Arc<TestLimiter>) {
|
||||||
|
let clock = Arc::new(MockClock(AtomicU64::new(now_ms)));
|
||||||
|
let limiter = Limiter::new(Duration::from_millis(PERIOD_MS), Arc::clone(&clock));
|
||||||
|
(clock, Arc::new(limiter))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn run_two_concurrent_checks<C: Clock + 'static>(limiter: &Arc<Limiter<C>>) -> usize {
|
||||||
|
let handles: [_; 2] = std::array::from_fn(|_| {
|
||||||
|
let limiter = Arc::clone(limiter);
|
||||||
|
loom::thread::spawn(move || limiter.check())
|
||||||
|
});
|
||||||
|
|
||||||
|
handles
|
||||||
|
.into_iter()
|
||||||
|
.map(|handle| match handle.join() {
|
||||||
|
Ok(admitted) => admitted,
|
||||||
|
Err(panic) => std::panic::resume_unwind(panic),
|
||||||
|
})
|
||||||
|
.filter(|admitted| *admitted)
|
||||||
|
.count()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn admits_exactly_one_caller_in_an_eligible_window() {
|
||||||
|
loom::model(|| {
|
||||||
|
let (_clock, limiter) = limiter_at(START_MS);
|
||||||
|
|
||||||
|
assert_eq!(run_two_concurrent_checks(&limiter), 1);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn rejects_concurrent_callers_inside_the_restricted_period() {
|
||||||
|
loom::model(|| {
|
||||||
|
let (clock, limiter) = limiter_at(START_MS);
|
||||||
|
assert!(limiter.check());
|
||||||
|
|
||||||
|
clock.0.store(START_MS + PERIOD_MS - 1, Ordering::SeqCst);
|
||||||
|
|
||||||
|
assert_eq!(run_two_concurrent_checks(&limiter), 0);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn admits_exactly_one_caller_at_the_period_boundary() {
|
||||||
|
loom::model(|| {
|
||||||
|
let (clock, limiter) = limiter_at(START_MS);
|
||||||
|
assert!(limiter.check());
|
||||||
|
|
||||||
|
clock.0.store(START_MS + PERIOD_MS, Ordering::SeqCst);
|
||||||
|
|
||||||
|
assert_eq!(run_two_concurrent_checks(&limiter), 1);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn concurrent_clock_advancement_admits_exactly_one_caller() {
|
||||||
|
loom::model(|| {
|
||||||
|
let clock = Arc::new(AdvancingClock(AtomicU64::new(START_MS)));
|
||||||
|
let limiter = Arc::new(Limiter::new(Duration::from_millis(PERIOD_MS), Arc::clone(&clock)));
|
||||||
|
|
||||||
|
assert_eq!(run_two_concurrent_checks(&limiter), 1);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
struct StaleClock {
|
||||||
|
current: AtomicU64,
|
||||||
|
reads: AtomicUsize,
|
||||||
|
stale_reads: usize,
|
||||||
|
sampled: AtomicUsize,
|
||||||
|
released: AtomicBool,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl StaleClock {
|
||||||
|
fn new(now_ms: u64, stale_reads: usize) -> Self {
|
||||||
|
Self {
|
||||||
|
current: AtomicU64::new(now_ms),
|
||||||
|
reads: AtomicUsize::new(0),
|
||||||
|
stale_reads,
|
||||||
|
sampled: AtomicUsize::new(0),
|
||||||
|
released: AtomicBool::new(false),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn release(&self) {
|
||||||
|
self.released.store(true, Ordering::SeqCst);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Clock for StaleClock {
|
||||||
|
fn now_ms(&self) -> u64 {
|
||||||
|
if self.reads.fetch_add(1, Ordering::SeqCst) < self.stale_reads {
|
||||||
|
let stale = self.current.load(Ordering::SeqCst);
|
||||||
|
self.sampled.fetch_add(1, Ordering::SeqCst);
|
||||||
|
|
||||||
|
// Parking can wake spuriously; re-check the release flag on each
|
||||||
|
// wake. Unparking after setting the flag avoids a lost wakeup.
|
||||||
|
while !self.released.load(Ordering::SeqCst) {
|
||||||
|
loom::thread::park();
|
||||||
|
}
|
||||||
|
|
||||||
|
stale
|
||||||
|
} else {
|
||||||
|
self.current.load(Ordering::SeqCst)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Regression: a caller that sampled the clock before a newer admission must
|
||||||
|
/// not overwrite that admission when it resumes.
|
||||||
|
#[test]
|
||||||
|
fn stale_clock_sample_does_not_reopen_the_period() {
|
||||||
|
loom::model(|| {
|
||||||
|
const LATER_MS: u64 = START_MS + PERIOD_MS * 10;
|
||||||
|
|
||||||
|
let clock = Arc::new(StaleClock::new(START_MS, 1));
|
||||||
|
let limiter = Arc::new(Limiter::new(Duration::from_millis(PERIOD_MS), Arc::clone(&clock)));
|
||||||
|
|
||||||
|
let stale_caller = {
|
||||||
|
let limiter = Arc::clone(&limiter);
|
||||||
|
loom::thread::spawn(move || limiter.check())
|
||||||
|
};
|
||||||
|
|
||||||
|
while clock.sampled.load(Ordering::SeqCst) < 1 {
|
||||||
|
loom::thread::yield_now();
|
||||||
|
}
|
||||||
|
clock.current.store(LATER_MS, Ordering::SeqCst);
|
||||||
|
|
||||||
|
let later_caller = {
|
||||||
|
let limiter = Arc::clone(&limiter);
|
||||||
|
loom::thread::spawn(move || limiter.check())
|
||||||
|
};
|
||||||
|
|
||||||
|
let later_admitted = later_caller.join().unwrap();
|
||||||
|
assert!(
|
||||||
|
later_admitted,
|
||||||
|
"the later caller must be admitted before the stale caller resumes"
|
||||||
|
);
|
||||||
|
|
||||||
|
clock.release();
|
||||||
|
stale_caller.thread().unpark();
|
||||||
|
|
||||||
|
let stale_admitted = stale_caller.join().unwrap();
|
||||||
|
let reopened = limiter.check();
|
||||||
|
|
||||||
|
assert!(
|
||||||
|
!stale_admitted,
|
||||||
|
"stale caller must not be admitted after the later caller"
|
||||||
|
);
|
||||||
|
assert!(
|
||||||
|
!reopened,
|
||||||
|
"stale caller admitted={stale_admitted} moved last_run_ms from {LATER_MS} back to {START_MS}"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn multiple_stale_clock_samples_cannot_reopen_the_period() {
|
||||||
|
loom::model(|| {
|
||||||
|
const LATER_MS: u64 = START_MS + PERIOD_MS * 10;
|
||||||
|
|
||||||
|
let clock = Arc::new(StaleClock::new(START_MS, 2));
|
||||||
|
let limiter = Arc::new(Limiter::new(Duration::from_millis(PERIOD_MS), Arc::clone(&clock)));
|
||||||
|
|
||||||
|
let stale_callers: [_; 2] = std::array::from_fn(|_| {
|
||||||
|
let limiter = Arc::clone(&limiter);
|
||||||
|
loom::thread::spawn(move || limiter.check())
|
||||||
|
});
|
||||||
|
|
||||||
|
while clock.sampled.load(Ordering::SeqCst) < 2 {
|
||||||
|
loom::thread::yield_now();
|
||||||
|
}
|
||||||
|
clock.current.store(LATER_MS, Ordering::SeqCst);
|
||||||
|
assert!(
|
||||||
|
limiter.check(),
|
||||||
|
"the later caller must be admitted before the stale callers resume"
|
||||||
|
);
|
||||||
|
|
||||||
|
clock.release();
|
||||||
|
for caller in &stale_callers {
|
||||||
|
caller.thread().unpark();
|
||||||
|
}
|
||||||
|
|
||||||
|
let stale_admitted = stale_callers
|
||||||
|
.into_iter()
|
||||||
|
.map(|caller| caller.join().unwrap())
|
||||||
|
.filter(|admitted| *admitted)
|
||||||
|
.count();
|
||||||
|
assert_eq!(
|
||||||
|
stale_admitted, 0,
|
||||||
|
"stale callers must not be admitted after the later caller"
|
||||||
|
);
|
||||||
|
assert!(!limiter.check(), "stale callers reopened the period at {LATER_MS}");
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
# Seeds for failure cases proptest has generated in the past. It is
|
||||||
|
# automatically read and these particular cases re-run before any
|
||||||
|
# novel cases are generated.
|
||||||
|
#
|
||||||
|
# It is recommended to check this file in to source control so that
|
||||||
|
# everyone who runs the test benefits from these saved cases.
|
||||||
|
cc 0139d921e3faaf32821ee0c596b0d495ffc72ce94200b8d5a795883db56305e6 # shrinks to period = 56, start = 18446744073709551560
|
||||||
@@ -0,0 +1,211 @@
|
|||||||
|
#![cfg(not(loom))]
|
||||||
|
|
||||||
|
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
|
use clash_verge_limiter::{Clock, Limiter};
|
||||||
|
use proptest::prelude::*;
|
||||||
|
use proptest::test_runner::FileFailurePersistence;
|
||||||
|
|
||||||
|
const CASES: u32 = 10_000;
|
||||||
|
const MAX_PERIOD_MS: u64 = 100_000;
|
||||||
|
const MAX_START_MS: u64 = 1_000_000;
|
||||||
|
const MAX_DELTA_MS: u64 = 10_000;
|
||||||
|
|
||||||
|
/// Returns one clock value per call, in order. The test supplies exactly as
|
||||||
|
/// many values as the limiter will read.
|
||||||
|
struct SequenceClock {
|
||||||
|
values: Vec<u64>,
|
||||||
|
next: AtomicUsize,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl SequenceClock {
|
||||||
|
const fn new(values: Vec<u64>) -> Self {
|
||||||
|
Self {
|
||||||
|
values,
|
||||||
|
next: AtomicUsize::new(0),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Clock for SequenceClock {
|
||||||
|
fn now_ms(&self) -> u64 {
|
||||||
|
let index = self.next.fetch_add(1, Ordering::SeqCst);
|
||||||
|
self.values[index]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn timestamps(start: u64, deltas: &[u64]) -> Vec<u64> {
|
||||||
|
let mut now = start;
|
||||||
|
let mut values = Vec::with_capacity(deltas.len() + 1);
|
||||||
|
values.push(now);
|
||||||
|
for delta in deltas {
|
||||||
|
now += delta;
|
||||||
|
values.push(now);
|
||||||
|
}
|
||||||
|
values
|
||||||
|
}
|
||||||
|
|
||||||
|
proptest! {
|
||||||
|
#![proptest_config(ProptestConfig {
|
||||||
|
cases: CASES,
|
||||||
|
failure_persistence: Some(Box::new(FileFailurePersistence::Direct(concat!(
|
||||||
|
env!("CARGO_MANIFEST_DIR"),
|
||||||
|
"/tests/properties.proptest-regressions"
|
||||||
|
)))),
|
||||||
|
..ProptestConfig::default()
|
||||||
|
})]
|
||||||
|
|
||||||
|
/// For positive periods and nondecreasing time, admission is equivalent to
|
||||||
|
/// reaching the next allowed timestamp after the previous admission.
|
||||||
|
#[test]
|
||||||
|
fn sequential_results_match_the_next_allowed_time_contract(
|
||||||
|
period in 1u64..=MAX_PERIOD_MS,
|
||||||
|
start in MAX_PERIOD_MS..=MAX_START_MS,
|
||||||
|
deltas in prop::collection::vec(0u64..=MAX_DELTA_MS, 0..64),
|
||||||
|
) {
|
||||||
|
let times = timestamps(start, &deltas);
|
||||||
|
let clock = SequenceClock::new(times.clone());
|
||||||
|
let limiter = Limiter::new(Duration::from_millis(period), &clock);
|
||||||
|
let mut last_admitted = None;
|
||||||
|
|
||||||
|
for now in times {
|
||||||
|
let expected = match last_admitted {
|
||||||
|
None => true,
|
||||||
|
Some(last) => now >= last + period,
|
||||||
|
};
|
||||||
|
let actual = limiter.check();
|
||||||
|
prop_assert!(
|
||||||
|
actual == expected,
|
||||||
|
"period={} now={} last={:?}",
|
||||||
|
period,
|
||||||
|
now,
|
||||||
|
last_admitted
|
||||||
|
);
|
||||||
|
if actual {
|
||||||
|
last_admitted = Some(now);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// An admission at the period boundary is accepted, while a repeated or
|
||||||
|
/// pre-boundary check is rejected.
|
||||||
|
#[test]
|
||||||
|
fn period_boundary_and_repeated_checks_follow_the_period(
|
||||||
|
period in 1u64..=MAX_PERIOD_MS,
|
||||||
|
start in MAX_PERIOD_MS..=MAX_START_MS,
|
||||||
|
) {
|
||||||
|
let boundary = start + period;
|
||||||
|
let clock = SequenceClock::new(vec![start, start, boundary - 1, boundary]);
|
||||||
|
let limiter = Limiter::new(Duration::from_millis(period), &clock);
|
||||||
|
|
||||||
|
prop_assert!(limiter.check(), "first check at {}", start);
|
||||||
|
prop_assert!(!limiter.check(), "repeated check at {}", start);
|
||||||
|
prop_assert!(!limiter.check(), "pre-boundary check at {}", boundary - 1);
|
||||||
|
prop_assert!(limiter.check(), "boundary check at {}", boundary);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Any two admitted timestamps in a monotonic sequence are separated by at
|
||||||
|
/// least one configured period.
|
||||||
|
#[test]
|
||||||
|
fn admitted_timestamps_are_at_least_one_period_apart(
|
||||||
|
period in 1u64..=MAX_PERIOD_MS,
|
||||||
|
start in MAX_PERIOD_MS..=MAX_START_MS,
|
||||||
|
deltas in prop::collection::vec(0u64..=MAX_DELTA_MS, 0..64),
|
||||||
|
) {
|
||||||
|
let times = timestamps(start, &deltas);
|
||||||
|
let clock = SequenceClock::new(times.clone());
|
||||||
|
let limiter = Limiter::new(Duration::from_millis(period), &clock);
|
||||||
|
let mut admitted = Vec::new();
|
||||||
|
|
||||||
|
for now in times {
|
||||||
|
if limiter.check() {
|
||||||
|
admitted.push(now);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for pair in admitted.windows(2) {
|
||||||
|
prop_assert!(
|
||||||
|
pair[1] - pair[0] >= period,
|
||||||
|
"period={} admitted pair={:?}",
|
||||||
|
period,
|
||||||
|
pair
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A rejected duplicate at the current admission timestamp must not change
|
||||||
|
/// the outcomes of later checks.
|
||||||
|
#[test]
|
||||||
|
fn rejected_checks_do_not_change_future_admissions(
|
||||||
|
period in 1u64..=MAX_PERIOD_MS,
|
||||||
|
start in MAX_PERIOD_MS..=MAX_START_MS,
|
||||||
|
deltas in prop::collection::vec(0u64..=MAX_DELTA_MS, 0..64),
|
||||||
|
) {
|
||||||
|
let base_times = timestamps(start, &deltas);
|
||||||
|
let base_clock = SequenceClock::new(base_times.clone());
|
||||||
|
let base = Limiter::new(Duration::from_millis(period), &base_clock);
|
||||||
|
let base_results: Vec<bool> = base_times.iter().map(|_| base.check()).collect();
|
||||||
|
|
||||||
|
let mut repeated_times = vec![start, start];
|
||||||
|
repeated_times.extend_from_slice(&base_times[1..]);
|
||||||
|
let repeated_len = repeated_times.len();
|
||||||
|
let repeated_clock = SequenceClock::new(repeated_times);
|
||||||
|
let repeated = Limiter::new(Duration::from_millis(period), &repeated_clock);
|
||||||
|
let repeated_results: Vec<bool> = (0..repeated_len).map(|_| repeated.check()).collect();
|
||||||
|
|
||||||
|
prop_assert!(repeated_results[0]);
|
||||||
|
prop_assert!(!repeated_results[1]);
|
||||||
|
prop_assert_eq!(&base_results[1..], &repeated_results[2..]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Every sub-millisecond period is represented as zero milliseconds, so it
|
||||||
|
/// must produce the same admissions as `Duration::ZERO`. This deliberately
|
||||||
|
/// does not assert a policy for zero periods.
|
||||||
|
#[test]
|
||||||
|
fn zero_and_submillisecond_periods_are_equivalent(
|
||||||
|
nanos in 0u64..1_000_000,
|
||||||
|
start in 0u64..=MAX_START_MS,
|
||||||
|
deltas in prop::collection::vec(0u64..=MAX_DELTA_MS, 0..64),
|
||||||
|
) {
|
||||||
|
let times = timestamps(start, &deltas);
|
||||||
|
let zero_clock = SequenceClock::new(times.clone());
|
||||||
|
let zero = Limiter::new(Duration::ZERO, &zero_clock);
|
||||||
|
let submillisecond_clock = SequenceClock::new(times.clone());
|
||||||
|
let submillisecond =
|
||||||
|
Limiter::new(Duration::from_nanos(nanos), &submillisecond_clock);
|
||||||
|
|
||||||
|
for now in times {
|
||||||
|
prop_assert_eq!(
|
||||||
|
zero.check(),
|
||||||
|
submillisecond.check(),
|
||||||
|
"nanos={} now={}",
|
||||||
|
nanos,
|
||||||
|
now
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Regression: timestamp arithmetic must not overflow near `u64::MAX`.
|
||||||
|
#[test]
|
||||||
|
fn extreme_timestamp_and_period_do_not_overflow(
|
||||||
|
period in 1u64..=1_000,
|
||||||
|
start in (u64::MAX - 1_000)..=u64::MAX,
|
||||||
|
) {
|
||||||
|
let clock = SequenceClock::new(vec![start, start]);
|
||||||
|
let limiter = Limiter::new(Duration::from_millis(period), &clock);
|
||||||
|
|
||||||
|
prop_assert!(limiter.check());
|
||||||
|
prop_assert!(!limiter.check());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn max_timestamp_boundary_does_not_overflow() {
|
||||||
|
let clock = SequenceClock::new(vec![u64::MAX - 1, u64::MAX, u64::MAX]);
|
||||||
|
let limiter = Limiter::new(Duration::from_millis(1), &clock);
|
||||||
|
|
||||||
|
assert!(limiter.check());
|
||||||
|
assert!(limiter.check());
|
||||||
|
assert!(!limiter.check());
|
||||||
|
}
|
||||||
@@ -6,7 +6,7 @@ edition = "2024"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
log = { workspace = true }
|
log = { workspace = true }
|
||||||
parking_lot = { workspace = true }
|
parking_lot = { workspace = true }
|
||||||
thiserror = { workspace = true }
|
anyhow = { workspace = true }
|
||||||
flexi_logger = { workspace = true }
|
flexi_logger = { workspace = true }
|
||||||
tracing-estuary = { workspace = true }
|
tracing-estuary = { workspace = true }
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
#[derive(Debug, thiserror::Error)]
|
|
||||||
pub enum LoggerError {
|
|
||||||
#[error(transparent)]
|
|
||||||
Pipeline(Box<dyn std::error::Error + Send + Sync>),
|
|
||||||
#[error(transparent)]
|
|
||||||
Sidecar(#[from] flexi_logger::FlexiLoggerError),
|
|
||||||
#[error("failed to get tracing pipeline, make sure it init")]
|
|
||||||
PipelineUnavailable,
|
|
||||||
#[error("failed to reset log writer: {0}")]
|
|
||||||
ResetWriter(String),
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,3 @@
|
|||||||
mod error;
|
|
||||||
|
|
||||||
pub use error::LoggerError;
|
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
collections::VecDeque,
|
collections::VecDeque,
|
||||||
fmt,
|
fmt,
|
||||||
@@ -14,6 +10,7 @@ use std::{
|
|||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use anyhow::{Result, bail};
|
||||||
use flexi_logger::{
|
use flexi_logger::{
|
||||||
Cleanup, Criterion, DeferredNow, FileSpec, Naming,
|
Cleanup, Criterion, DeferredNow, FileSpec, Naming,
|
||||||
writers::{FileLogWriter, FileLogWriterBuilder, LogWriter as _},
|
writers::{FileLogWriter, FileLogWriterBuilder, LogWriter as _},
|
||||||
@@ -180,7 +177,7 @@ impl Logger {
|
|||||||
|
|
||||||
/// Installs the global tracing pipeline. `RUST_LOG` (parsed as a bare
|
/// Installs the global tracing pipeline. `RUST_LOG` (parsed as a bare
|
||||||
/// level) overrides the configured level.
|
/// level) overrides the configured level.
|
||||||
pub fn init(&self, cfg: &LoggerConfig) -> Result<(), LoggerError> {
|
pub fn init(&self, cfg: &LoggerConfig) -> Result<()> {
|
||||||
let log_level = std::env::var("RUST_LOG")
|
let log_level = std::env::var("RUST_LOG")
|
||||||
.ok()
|
.ok()
|
||||||
.and_then(|v| LevelFilter::from_str(v.trim()).ok())
|
.and_then(|v| LevelFilter::from_str(v.trim()).ok())
|
||||||
@@ -189,15 +186,14 @@ impl Logger {
|
|||||||
let pipeline = tracing_estuary::PipelineBuilder::new()
|
let pipeline = tracing_estuary::PipelineBuilder::new()
|
||||||
.default_level(log_level)
|
.default_level(log_level)
|
||||||
.file_writer(self.generate_file_log_writer())
|
.file_writer(self.generate_file_log_writer())
|
||||||
.init()
|
.init()?;
|
||||||
.map_err(|error| LoggerError::Pipeline(error.into_boxed_dyn_error()))?;
|
|
||||||
self.pipeline.set(pipeline).ok();
|
self.pipeline.set(pipeline).ok();
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Installs the sidecar file writer and the panic hook. Safe to call when
|
/// Installs the sidecar file writer and the panic hook. Safe to call when
|
||||||
/// the pipeline is owned elsewhere (e.g. a devtools-provided subscriber).
|
/// the pipeline is owned elsewhere (e.g. a devtools-provided subscriber).
|
||||||
pub fn init_sidecar(&self, cfg: &LoggerConfig) -> Result<(), LoggerError> {
|
pub fn init_sidecar(&self, cfg: &LoggerConfig) -> Result<()> {
|
||||||
self.store_config(cfg);
|
self.store_config(cfg);
|
||||||
self.ensure_sidecar_writer(self.generate_sidecar_builder())?;
|
self.ensure_sidecar_writer(self.generate_sidecar_builder())?;
|
||||||
|
|
||||||
@@ -249,7 +245,7 @@ impl Logger {
|
|||||||
/// Ensures the sidecar writer exists and points at `builder`'s config:
|
/// Ensures the sidecar writer exists and points at `builder`'s config:
|
||||||
/// built once, then reset in place — flexi's flusher thread cannot be
|
/// built once, then reset in place — flexi's flusher thread cannot be
|
||||||
/// stopped, so every dropped writer would leak a thread and an fd.
|
/// stopped, so every dropped writer would leak a thread and an fd.
|
||||||
fn ensure_sidecar_writer(&self, builder: FileLogWriterBuilder) -> Result<(), LoggerError> {
|
fn ensure_sidecar_writer(&self, builder: FileLogWriterBuilder) -> Result<()> {
|
||||||
let sidecar = self.sidecar_file_writer.write();
|
let sidecar = self.sidecar_file_writer.write();
|
||||||
match sidecar.as_ref() {
|
match sidecar.as_ref() {
|
||||||
Some(writer) => {
|
Some(writer) => {
|
||||||
@@ -300,29 +296,27 @@ impl Logger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// only update app log level
|
/// only update app log level
|
||||||
pub fn update_log_level(&self, level: LevelFilter) -> Result<(), LoggerError> {
|
pub fn update_log_level(&self, level: LevelFilter) -> Result<()> {
|
||||||
if let Some(pipeline) = self.pipeline.get() {
|
if let Some(pipeline) = self.pipeline.get() {
|
||||||
pipeline
|
pipeline.filter.set_default_level(level)?;
|
||||||
.filter
|
|
||||||
.set_default_level(level)
|
|
||||||
.map_err(|error| LoggerError::Pipeline(error.into_boxed_dyn_error()))?;
|
|
||||||
} else {
|
} else {
|
||||||
return Err(LoggerError::PipelineUnavailable);
|
bail!("failed to get tracing pipeline, make sure it init");
|
||||||
};
|
};
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Rebuilds both file writers with the new limits.
|
/// Rebuilds both file writers with the new limits.
|
||||||
pub fn update_log_config(&self, log_max_size: u64, log_max_count: usize) -> Result<(), LoggerError> {
|
pub fn update_log_config(&self, log_max_size: u64, log_max_count: usize) -> Result<()> {
|
||||||
self.log_max_size.store(log_max_size, Ordering::SeqCst);
|
self.log_max_size.store(log_max_size, Ordering::SeqCst);
|
||||||
self.log_max_count.store(log_max_count, Ordering::SeqCst);
|
self.log_max_count.store(log_max_count, Ordering::SeqCst);
|
||||||
if let Some(pipeline) = self.pipeline.get() {
|
if let Some(pipeline) = self.pipeline.get() {
|
||||||
let log_file_writer = self.generate_file_log_writer();
|
let log_file_writer = self.generate_file_log_writer();
|
||||||
if let Some(sink) = pipeline.sink.as_ref() {
|
if let Some(sink) = pipeline.sink.as_ref() {
|
||||||
sink.reset(log_file_writer).map_err(LoggerError::ResetWriter)?;
|
sink.reset(log_file_writer)
|
||||||
|
.map_err(|error| anyhow::anyhow!("failed to reset log writer: {error}"))?;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return Err(LoggerError::PipelineUnavailable);
|
bail!("failed to get tracing pipeline, make sure it init");
|
||||||
};
|
};
|
||||||
self.ensure_sidecar_writer(self.generate_sidecar_builder())?;
|
self.ensure_sidecar_writer(self.generate_sidecar_builder())?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "clash-verge-profile"
|
|
||||||
version = "0.1.0"
|
|
||||||
edition = "2024"
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
serde = { workspace = true, features = ["derive"] }
|
|
||||||
specta = { workspace = true, features = ["derive"] }
|
|
||||||
thiserror = { workspace = true }
|
|
||||||
tristr = { workspace = true }
|
|
||||||
|
|
||||||
[dev-dependencies]
|
|
||||||
serde_json = { workspace = true }
|
|
||||||
serde_yaml_ng = { workspace = true }
|
|
||||||
|
|
||||||
[lints]
|
|
||||||
workspace = true
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
#[derive(Debug, thiserror::Error)]
|
|
||||||
#[error("failed to get the profile item \"uid:{uid}\"")]
|
|
||||||
pub struct ProfileNotFound {
|
|
||||||
pub(super) uid: String,
|
|
||||||
}
|
|
||||||
@@ -1,410 +0,0 @@
|
|||||||
mod error;
|
|
||||||
pub mod selected_nodes;
|
|
||||||
mod subscription_schedule;
|
|
||||||
|
|
||||||
pub use error::ProfileNotFound;
|
|
||||||
pub use subscription_schedule::SubscriptionSchedule;
|
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
use tristr::alias::String;
|
|
||||||
|
|
||||||
macro_rules! patch_opt_field {
|
|
||||||
($lv:expr, $rv:expr, $key:tt) => {
|
|
||||||
if ($rv.$key).is_some() {
|
|
||||||
$lv.$key = $rv.$key.clone();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize, Default, specta::Type)]
|
|
||||||
#[serde(default)]
|
|
||||||
pub struct PrfItem {
|
|
||||||
pub uid: Option<String>,
|
|
||||||
|
|
||||||
/// enum value: remote | local | script | merge
|
|
||||||
#[serde(rename = "type")]
|
|
||||||
pub itype: Option<String>,
|
|
||||||
pub name: Option<String>,
|
|
||||||
pub file: Option<String>,
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
|
||||||
pub desc: Option<String>,
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
|
||||||
pub url: Option<String>,
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
|
||||||
pub selected: Option<Vec<PrfSelected>>,
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
|
||||||
pub extra: Option<PrfExtra>,
|
|
||||||
pub updated: Option<usize>,
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
|
||||||
pub option: Option<PrfOption>,
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
|
||||||
pub home: Option<String>,
|
|
||||||
#[serde(skip)]
|
|
||||||
pub file_data: Option<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Default, Debug, Clone, Deserialize, Serialize, PartialEq, Eq, specta::Type)]
|
|
||||||
#[serde(default)]
|
|
||||||
pub struct PrfSelected {
|
|
||||||
pub name: Option<String>,
|
|
||||||
pub now: Option<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Default, Debug, Clone, Copy, Deserialize, Serialize, specta::Type)]
|
|
||||||
pub struct PrfExtra {
|
|
||||||
pub upload: u64,
|
|
||||||
pub download: u64,
|
|
||||||
pub total: u64,
|
|
||||||
pub expire: u64,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Default, Debug, Clone, Deserialize, Serialize, PartialEq, Eq, specta::Type)]
|
|
||||||
#[serde(default)]
|
|
||||||
pub struct PrfOption {
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
|
||||||
pub user_agent: Option<String>,
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
|
||||||
pub with_proxy: Option<bool>,
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
|
||||||
pub self_proxy: Option<bool>,
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
|
||||||
pub update_interval: Option<u64>,
|
|
||||||
/// HTTP request timeout in seconds
|
|
||||||
/// default is 60 seconds
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
|
||||||
pub timeout_seconds: Option<u64>,
|
|
||||||
/// default is `false`
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
|
||||||
pub danger_accept_invalid_certs: Option<bool>,
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
|
||||||
pub allow_auto_update: Option<bool>,
|
|
||||||
pub merge: Option<String>,
|
|
||||||
pub script: Option<String>,
|
|
||||||
pub rules: Option<String>,
|
|
||||||
pub proxies: Option<String>,
|
|
||||||
pub groups: Option<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl PrfOption {
|
|
||||||
pub fn merge(one: Option<&Self>, other: Option<&Self>) -> Option<Self> {
|
|
||||||
match (one, other) {
|
|
||||||
(Some(a_ref), Some(b_ref)) => {
|
|
||||||
let mut result = a_ref.clone();
|
|
||||||
patch_opt_field!(result, b_ref, user_agent);
|
|
||||||
patch_opt_field!(result, b_ref, with_proxy);
|
|
||||||
patch_opt_field!(result, b_ref, self_proxy);
|
|
||||||
patch_opt_field!(result, b_ref, danger_accept_invalid_certs);
|
|
||||||
patch_opt_field!(result, b_ref, allow_auto_update);
|
|
||||||
patch_opt_field!(result, b_ref, update_interval);
|
|
||||||
patch_opt_field!(result, b_ref, merge);
|
|
||||||
patch_opt_field!(result, b_ref, script);
|
|
||||||
patch_opt_field!(result, b_ref, rules);
|
|
||||||
patch_opt_field!(result, b_ref, proxies);
|
|
||||||
patch_opt_field!(result, b_ref, groups);
|
|
||||||
patch_opt_field!(result, b_ref, timeout_seconds);
|
|
||||||
Some(result)
|
|
||||||
}
|
|
||||||
(Some(a_ref), None) => Some(a_ref.clone()),
|
|
||||||
(None, Some(b_ref)) => Some(b_ref.clone()),
|
|
||||||
(None, None) => None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
macro_rules! current_field {
|
|
||||||
($name:ident, $field:ident) => {
|
|
||||||
pub fn $name(&self) -> Option<&String> {
|
|
||||||
self.option.as_ref().and_then(|o| o.$field.as_ref())
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
impl PrfItem {
|
|
||||||
current_field!(current_merge, merge);
|
|
||||||
current_field!(current_script, script);
|
|
||||||
current_field!(current_rules, rules);
|
|
||||||
current_field!(current_proxies, proxies);
|
|
||||||
current_field!(current_groups, groups);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Define the `profiles.yaml` schema
|
|
||||||
#[derive(Default, Debug, Clone, Deserialize, Serialize, specta::Type)]
|
|
||||||
#[serde(default)]
|
|
||||||
pub struct IProfiles {
|
|
||||||
pub current: Option<String>,
|
|
||||||
pub items: Option<Vec<PrfItem>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct IProfilePreview<'a> {
|
|
||||||
pub uid: &'a String,
|
|
||||||
pub name: &'a String,
|
|
||||||
pub is_current: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct ProfileDeletePlan {
|
|
||||||
pub deleting_current: bool,
|
|
||||||
pub files: Vec<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl IProfiles {
|
|
||||||
pub fn patch_current(&mut self, current: Option<&String>) {
|
|
||||||
let items = self.items.get_or_insert_with(Vec::new);
|
|
||||||
if let Some(current) = current
|
|
||||||
&& items.iter().any(|item| item.uid.as_ref() == Some(current))
|
|
||||||
{
|
|
||||||
self.current = Some(current.clone());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_item(&self, uid: impl AsRef<str>) -> Result<&PrfItem, ProfileNotFound> {
|
|
||||||
let uid_str = uid.as_ref();
|
|
||||||
|
|
||||||
if let Some(items) = self.items.as_ref() {
|
|
||||||
for each in items.iter() {
|
|
||||||
if let Some(uid_val) = &each.uid
|
|
||||||
&& uid_val.as_str() == uid_str
|
|
||||||
{
|
|
||||||
return Ok(each);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Err(ProfileNotFound {
|
|
||||||
uid: uid_str.to_owned(),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Inserts a prepared entry after any required body write.
|
|
||||||
pub fn append_item(&mut self, item: &PrfItem) {
|
|
||||||
if self.current.is_none() && matches!(item.itype.as_deref(), Some("remote" | "local")) {
|
|
||||||
self.current = item.uid.clone();
|
|
||||||
}
|
|
||||||
|
|
||||||
self.items.get_or_insert_with(Vec::new).push(item.clone());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns true if both IDs were found, including when the item stayed at its old position.
|
|
||||||
pub fn reorder(&mut self, active_id: &str, over_id: &str) -> bool {
|
|
||||||
let Some(items) = self.items.as_mut() else {
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
let old_index = items.iter().rposition(|item| item.uid.as_deref() == Some(active_id));
|
|
||||||
let new_index = items.iter().rposition(|item| item.uid.as_deref() == Some(over_id));
|
|
||||||
let (Some(old_idx), Some(new_idx)) = (old_index, new_index) else {
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
let item = items.remove(old_idx);
|
|
||||||
items.insert(new_idx, item);
|
|
||||||
true
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn plan_delete_item(&mut self, uid: &str) -> Result<ProfileDeletePlan, ProfileNotFound> {
|
|
||||||
let deleting_current = self.current.as_deref().is_none_or(|current| current == uid);
|
|
||||||
let delete_uids = self.get_item(uid)?.option.as_ref().map_or_else(Vec::new, |op| {
|
|
||||||
[
|
|
||||||
op.merge.clone(),
|
|
||||||
op.script.clone(),
|
|
||||||
op.rules.clone(),
|
|
||||||
op.proxies.clone(),
|
|
||||||
op.groups.clone(),
|
|
||||||
]
|
|
||||||
.into_iter()
|
|
||||||
.collect::<Vec<_>>()
|
|
||||||
});
|
|
||||||
let mut items = self.items.take().unwrap_or_default();
|
|
||||||
let mut files = Vec::new();
|
|
||||||
|
|
||||||
if let Some(file) = take_item_file_by_uid(&mut items, Some(uid)) {
|
|
||||||
files.push(file);
|
|
||||||
}
|
|
||||||
|
|
||||||
for delete_uid in delete_uids {
|
|
||||||
if let Some(file) = take_item_file_by_uid(&mut items, delete_uid.as_deref()) {
|
|
||||||
files.push(file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if deleting_current {
|
|
||||||
self.current = None;
|
|
||||||
for item in items.iter() {
|
|
||||||
if matches!(item.itype.as_deref(), Some("remote" | "local")) {
|
|
||||||
self.current = item.uid.clone();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
self.items = Some(items);
|
|
||||||
Ok(ProfileDeletePlan {
|
|
||||||
deleting_current,
|
|
||||||
files,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn profiles_preview(&self) -> Option<Vec<IProfilePreview<'_>>> {
|
|
||||||
self.items.as_ref().map(|items| {
|
|
||||||
items
|
|
||||||
.iter()
|
|
||||||
.filter_map(|e| {
|
|
||||||
if let (Some(uid), Some(name)) = (e.uid.as_ref(), e.name.as_ref()) {
|
|
||||||
let is_current = self.current.as_ref() == Some(uid);
|
|
||||||
let preview = IProfilePreview { uid, name, is_current };
|
|
||||||
Some(preview)
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.collect()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn take_item_file_by_uid(items: &mut Vec<PrfItem>, target_uid: Option<&str>) -> Option<String> {
|
|
||||||
let index = items.iter().position(|item| item.uid.as_deref() == target_uid)?;
|
|
||||||
items.remove(index).file
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn old_index_preserves_missing_and_explicit_values() -> Result<(), Box<dyn std::error::Error>> {
|
|
||||||
let mut profiles: IProfiles = serde_yaml_ng::from_str(
|
|
||||||
r#"
|
|
||||||
current: first
|
|
||||||
items:
|
|
||||||
- uid: first
|
|
||||||
type: remote
|
|
||||||
option: {allow_auto_update: false, update_interval: 0, merge: ""}
|
|
||||||
file_data: ignored
|
|
||||||
- uid: second
|
|
||||||
name: ""
|
|
||||||
"#,
|
|
||||||
)?;
|
|
||||||
let first = profiles.get_item("first")?;
|
|
||||||
assert!(first.file_data.is_none());
|
|
||||||
assert_eq!(first.current_merge().map(String::as_str), Some(""));
|
|
||||||
assert!(first.current_script().is_none());
|
|
||||||
if let Some(items) = profiles.items.as_mut() {
|
|
||||||
items[0].file_data = Some("in memory".into());
|
|
||||||
}
|
|
||||||
assert_eq!(
|
|
||||||
serde_json::to_value(&profiles)?,
|
|
||||||
serde_json::json!({
|
|
||||||
"current": "first",
|
|
||||||
"items": [
|
|
||||||
{"uid": "first", "type": "remote", "name": null, "file": null, "updated": null,
|
|
||||||
"option": {"allow_auto_update": false, "update_interval": 0, "merge": "",
|
|
||||||
"script": null, "rules": null, "proxies": null, "groups": null}},
|
|
||||||
{"uid": "second", "type": null, "name": "", "file": null, "updated": null}
|
|
||||||
]
|
|
||||||
})
|
|
||||||
);
|
|
||||||
assert_eq!(
|
|
||||||
serde_json::to_value(serde_yaml_ng::from_str::<IProfiles>("{}")?)?,
|
|
||||||
serde_json::json!({"current": null, "items": null})
|
|
||||||
);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn merge_overrides_only_explicit_values() {
|
|
||||||
let base = PrfOption {
|
|
||||||
user_agent: Some("original".into()),
|
|
||||||
allow_auto_update: Some(true),
|
|
||||||
update_interval: Some(60),
|
|
||||||
merge: Some("original-merge".into()),
|
|
||||||
..Default::default()
|
|
||||||
};
|
|
||||||
let overrides = PrfOption {
|
|
||||||
user_agent: Some("".into()),
|
|
||||||
allow_auto_update: Some(false),
|
|
||||||
update_interval: Some(0),
|
|
||||||
..Default::default()
|
|
||||||
};
|
|
||||||
let expected = PrfOption {
|
|
||||||
merge: base.merge.clone(),
|
|
||||||
..overrides.clone()
|
|
||||||
};
|
|
||||||
assert_eq!(PrfOption::merge(Some(&base), Some(&overrides)), Some(expected));
|
|
||||||
assert_eq!(PrfOption::merge(None, None), None);
|
|
||||||
assert_eq!(
|
|
||||||
PrfOption::merge(None, Some(&PrfOption::default())),
|
|
||||||
Some(PrfOption::default())
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn lookup_preview_and_reorder_preserve_duplicate_uid_rules() -> Result<(), Box<dyn std::error::Error>> {
|
|
||||||
let mut profiles: IProfiles = serde_yaml_ng::from_str(
|
|
||||||
r#"
|
|
||||||
current: duplicate
|
|
||||||
items:
|
|
||||||
- {uid: duplicate, name: first}
|
|
||||||
- {uid: duplicate, name: last}
|
|
||||||
- {uid: target, name: ""}
|
|
||||||
- {name: no UID}
|
|
||||||
"#,
|
|
||||||
)?;
|
|
||||||
assert_eq!(profiles.get_item("duplicate")?.name.as_deref(), Some("first"));
|
|
||||||
assert!(!profiles.reorder("missing", "target"));
|
|
||||||
assert!(!profiles.reorder("duplicate", "missing"));
|
|
||||||
assert!(profiles.reorder("duplicate", "duplicate"));
|
|
||||||
assert!(profiles.reorder("duplicate", "target"));
|
|
||||||
let preview = profiles.profiles_preview().unwrap_or_default();
|
|
||||||
let names: Vec<_> = preview
|
|
||||||
.iter()
|
|
||||||
.map(|item| (item.name.as_str(), item.is_current))
|
|
||||||
.collect();
|
|
||||||
assert_eq!(names, [("first", true), ("", false), ("last", true)]);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn current_patch_initializes_missing_items_and_only_selects_an_existing_uid() {
|
|
||||||
let mut profiles = IProfiles::default();
|
|
||||||
profiles.patch_current(None);
|
|
||||||
assert!(matches!(&profiles.items, Some(items) if items.is_empty()));
|
|
||||||
assert!(profiles.current.is_none());
|
|
||||||
profiles.append_item(&PrfItem {
|
|
||||||
uid: Some("script".into()),
|
|
||||||
itype: Some("script".into()),
|
|
||||||
..Default::default()
|
|
||||||
});
|
|
||||||
assert!(profiles.current.is_none());
|
|
||||||
profiles.append_item(&PrfItem {
|
|
||||||
uid: Some("local".into()),
|
|
||||||
itype: Some("local".into()),
|
|
||||||
..Default::default()
|
|
||||||
});
|
|
||||||
assert_eq!(profiles.current.as_deref(), Some("local"));
|
|
||||||
profiles.patch_current(None);
|
|
||||||
profiles.patch_current(Some(&String::from("missing")));
|
|
||||||
assert_eq!(profiles.current.as_deref(), Some("local"));
|
|
||||||
profiles.patch_current(Some(&String::from("script")));
|
|
||||||
assert_eq!(profiles.current.as_deref(), Some("script"));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn delete_plan_preserves_file_order_and_legacy_missing_uid_matching() -> Result<(), Box<dyn std::error::Error>> {
|
|
||||||
let mut profiles: IProfiles = serde_yaml_ng::from_str(
|
|
||||||
r"
|
|
||||||
items:
|
|
||||||
- {uid: active, type: remote, file: first.yaml, option: {merge: owned}}
|
|
||||||
- {uid: owned, type: merge, file: owned.yaml}
|
|
||||||
- {type: script, file: missing-uid.js}
|
|
||||||
- {uid: next, type: local, file: next.yaml}
|
|
||||||
",
|
|
||||||
)?;
|
|
||||||
let plan = profiles.plan_delete_item("active")?;
|
|
||||||
assert!(plan.deleting_current);
|
|
||||||
assert_eq!(
|
|
||||||
plan.files,
|
|
||||||
["first.yaml", "owned.yaml", "missing-uid.js"].map(String::from)
|
|
||||||
);
|
|
||||||
assert_eq!(profiles.current.as_deref(), Some("next"));
|
|
||||||
assert!(profiles.get_item("owned").is_err());
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,147 +0,0 @@
|
|||||||
use super::PrfSelected;
|
|
||||||
use std::collections::HashSet;
|
|
||||||
use tristr::alias::String;
|
|
||||||
|
|
||||||
pub struct SelectedGroup<'a> {
|
|
||||||
pub members: Option<&'a [std::string::String]>,
|
|
||||||
pub current: Option<&'a str>,
|
|
||||||
pub selectable: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
|
||||||
pub struct SelectedNodesPlan {
|
|
||||||
pub selected: Vec<PrfSelected>,
|
|
||||||
pub activations: Vec<(String, String)>,
|
|
||||||
pub repaired_count: usize,
|
|
||||||
}
|
|
||||||
|
|
||||||
fn node_is_available(available_nodes: &[std::string::String], node: &str) -> bool {
|
|
||||||
available_nodes.iter().any(|available| available == node)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn selected_nodes_need_confirmation<'a, Snapshot>(
|
|
||||||
selected: &[PrfSelected],
|
|
||||||
snapshot: &'a Snapshot,
|
|
||||||
lookup: impl Fn(&'a Snapshot, &str) -> Option<SelectedGroup<'a>>,
|
|
||||||
) -> bool {
|
|
||||||
selected.iter().any(|selected_item| {
|
|
||||||
let (Some(group_name), Some(node)) = (&selected_item.name, &selected_item.now) else {
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
let Some(group) = lookup(snapshot, group_name) else {
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
let Some(available_nodes) = group.members.filter(|nodes| !nodes.is_empty()) else {
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
!node_is_available(available_nodes, node)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn reconcile_selected_nodes<'a, Snapshot>(
|
|
||||||
selected: &[PrfSelected],
|
|
||||||
previous: Option<&'a Snapshot>,
|
|
||||||
current: &'a Snapshot,
|
|
||||||
lookup: impl Fn(&'a Snapshot, &str) -> Option<SelectedGroup<'a>>,
|
|
||||||
) -> SelectedNodesPlan {
|
|
||||||
let mut plan = SelectedNodesPlan {
|
|
||||||
selected: Vec::with_capacity(selected.len()),
|
|
||||||
activations: Vec::new(),
|
|
||||||
repaired_count: 0,
|
|
||||||
};
|
|
||||||
let mut seen_groups = HashSet::new();
|
|
||||||
let mut unique_selected = selected
|
|
||||||
.iter()
|
|
||||||
.rev()
|
|
||||||
.filter(|item| item.name.as_deref().is_some_and(|name| seen_groups.insert(name)))
|
|
||||||
.collect::<Vec<_>>();
|
|
||||||
unique_selected.reverse();
|
|
||||||
plan.repaired_count += selected.len() - unique_selected.len();
|
|
||||||
|
|
||||||
for selected_item in unique_selected {
|
|
||||||
let (Some(group_name), Some(node)) = (&selected_item.name, &selected_item.now) else {
|
|
||||||
plan.repaired_count += 1;
|
|
||||||
continue;
|
|
||||||
};
|
|
||||||
let Some(group) = lookup(current, group_name) else {
|
|
||||||
if previous.is_some_and(|snapshot| lookup(snapshot, group_name).is_none()) {
|
|
||||||
plan.repaired_count += 1;
|
|
||||||
} else {
|
|
||||||
plan.selected.push(selected_item.clone());
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
};
|
|
||||||
let Some(available_nodes) = group.members.filter(|nodes| !nodes.is_empty()) else {
|
|
||||||
// Provider-backed groups can be temporarily incomplete immediately after a reload.
|
|
||||||
plan.selected.push(selected_item.clone());
|
|
||||||
continue;
|
|
||||||
};
|
|
||||||
if !group.selectable {
|
|
||||||
let preferred_node = group
|
|
||||||
.current
|
|
||||||
.filter(|current| node_is_available(available_nodes, current))
|
|
||||||
.or_else(|| node_is_available(available_nodes, node).then_some(node.as_str()));
|
|
||||||
let Some(preferred_node) = preferred_node else {
|
|
||||||
plan.repaired_count += 1;
|
|
||||||
continue;
|
|
||||||
};
|
|
||||||
plan.repaired_count += usize::from(preferred_node != node.as_str());
|
|
||||||
plan.selected.push(PrfSelected {
|
|
||||||
name: Some(group_name.clone()),
|
|
||||||
now: Some(preferred_node.into()),
|
|
||||||
});
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if node_is_available(available_nodes, node) {
|
|
||||||
plan.selected.push(selected_item.clone());
|
|
||||||
if group.current != Some(node.as_str()) {
|
|
||||||
plan.activations.push((group_name.clone(), node.clone()));
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
let missing_was_confirmed = previous
|
|
||||||
.and_then(|snapshot| lookup(snapshot, group_name))
|
|
||||||
.and_then(|group| group.members)
|
|
||||||
.filter(|nodes| !nodes.is_empty())
|
|
||||||
.is_some_and(|nodes| !node_is_available(nodes, node));
|
|
||||||
if !missing_was_confirmed {
|
|
||||||
plan.selected.push(selected_item.clone());
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
plan.repaired_count += 1;
|
|
||||||
if let Some(current_node) = group
|
|
||||||
.current
|
|
||||||
.filter(|current| node_is_available(available_nodes, current))
|
|
||||||
{
|
|
||||||
plan.selected.push(PrfSelected {
|
|
||||||
name: Some(group_name.clone()),
|
|
||||||
now: Some(current_node.into()),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
plan
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns recorded selections whose groups have not reached the requested node.
|
|
||||||
pub fn unsettled_selections<'a, Snapshot>(
|
|
||||||
selected: &[PrfSelected],
|
|
||||||
snapshot: &'a Snapshot,
|
|
||||||
lookup: impl Fn(&'a Snapshot, &str) -> Option<SelectedGroup<'a>>,
|
|
||||||
) -> Vec<String> {
|
|
||||||
selected
|
|
||||||
.iter()
|
|
||||||
.filter_map(|item| {
|
|
||||||
let (Some(group_name), Some(node)) = (&item.name, &item.now) else {
|
|
||||||
return None;
|
|
||||||
};
|
|
||||||
match lookup(snapshot, group_name) {
|
|
||||||
Some(group) if group.current == Some(node.as_str()) => None,
|
|
||||||
_ => Some(group_name.clone()),
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.collect()
|
|
||||||
}
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
use super::PrfItem;
|
|
||||||
use std::time::Duration;
|
|
||||||
|
|
||||||
/// Scheduling policy for a Profile, independent of the task queue and clock.
|
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
|
||||||
pub struct SubscriptionSchedule {
|
|
||||||
pub interval_minutes: u64,
|
|
||||||
pub first_delay: Duration,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl SubscriptionSchedule {
|
|
||||||
pub fn for_profile(item: &PrfItem, initializing: bool, now: i64) -> Option<Self> {
|
|
||||||
let option = item.option.as_ref()?;
|
|
||||||
let interval = option.update_interval.filter(|interval| *interval > 0)?;
|
|
||||||
if !option.allow_auto_update.unwrap_or(true) {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut schedule = Self::new(interval, item.updated, now);
|
|
||||||
// Startup historically treats an explicit zero timestamp as overdue.
|
|
||||||
if initializing && item.updated == Some(0) {
|
|
||||||
schedule.first_delay = Duration::ZERO;
|
|
||||||
}
|
|
||||||
Some(schedule)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn new(interval_minutes: u64, updated: Option<usize>, now: i64) -> Self {
|
|
||||||
let full = Self::interval_duration(interval_minutes);
|
|
||||||
let elapsed = updated
|
|
||||||
.filter(|updated| *updated > 0)
|
|
||||||
.map_or(0, |updated| now.saturating_sub(updated as i64).max(0) as u64);
|
|
||||||
|
|
||||||
Self {
|
|
||||||
interval_minutes,
|
|
||||||
first_delay: full.saturating_sub(Duration::from_secs(elapsed)),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub const fn interval_duration(interval_minutes: u64) -> Duration {
|
|
||||||
Duration::from_secs(interval_minutes.saturating_mul(60))
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The UI deadline is based on the last saved update. The queue can delay retries further.
|
|
||||||
pub fn reported_deadline(interval_minutes: u64, updated: Option<usize>) -> Option<i64> {
|
|
||||||
let updated = i64::try_from(updated.filter(|updated| *updated > 0)?).ok()?;
|
|
||||||
let interval = i64::try_from(interval_minutes).ok()?.checked_mul(60)?;
|
|
||||||
updated.checked_add(interval)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -4,7 +4,7 @@ version = "0.1.0"
|
|||||||
edition = "2024"
|
edition = "2024"
|
||||||
rust-version = "1.91"
|
rust-version = "1.91"
|
||||||
|
|
||||||
[target.'cfg(target_os = "linux")'.dependencies]
|
[dependencies]
|
||||||
clash-verge-logging = { workspace = true }
|
clash-verge-logging = { workspace = true }
|
||||||
log = { workspace = true }
|
log = { workspace = true }
|
||||||
tokio = { workspace = true, features = ["signal"] }
|
tokio = { workspace = true, features = ["signal"] }
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "clash-verge-subscription"
|
|
||||||
version = "0.1.0"
|
|
||||||
edition = "2024"
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
thiserror = { workspace = true }
|
|
||||||
http = "1"
|
|
||||||
percent-encoding = "2.3.2"
|
|
||||||
serde_yaml_ng = { workspace = true }
|
|
||||||
url = "2.5"
|
|
||||||
|
|
||||||
[lints]
|
|
||||||
workspace = true
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
use percent_encoding::percent_decode_str;
|
|
||||||
use std::borrow::Cow;
|
|
||||||
use url::Url;
|
|
||||||
|
|
||||||
pub struct SubscriptionLink<'a> {
|
|
||||||
pub url: Cow<'a, str>,
|
|
||||||
pub name: Option<Cow<'a, str>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn decode_subscription_link(link: &Url) -> Option<SubscriptionLink<'_>> {
|
|
||||||
if !matches!(link.scheme(), "clash" | "clash-verge") {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
|
|
||||||
// The embedded URL can contain unescaped query separators of its own.
|
|
||||||
let raw_url = link.query()?.split_once("url=")?.1.trim();
|
|
||||||
let name = link.query_pairs().find(|(key, _)| key == "name").map(|(_, name)| name);
|
|
||||||
Some(SubscriptionLink {
|
|
||||||
url: decode_subscription_url(raw_url),
|
|
||||||
name,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
fn decode_subscription_url(raw_url: &str) -> Cow<'_, str> {
|
|
||||||
let mut candidate = Cow::Borrowed(raw_url);
|
|
||||||
if Url::parse(raw_url).is_ok() {
|
|
||||||
return candidate;
|
|
||||||
}
|
|
||||||
|
|
||||||
for _ in 0..2 {
|
|
||||||
let decoded = percent_decode_str(&candidate).decode_utf8_lossy();
|
|
||||||
if decoded == candidate {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
candidate = Cow::Owned(decoded.into_owned());
|
|
||||||
if Url::parse(&candidate).is_ok() {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
candidate
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn preserves_nested_query_separators_and_decodes_wrapped_links() -> Result<(), url::ParseError> {
|
|
||||||
let plain = Url::parse("clash://install-config?name=Work%20VPN&url=https://example.invalid/sub?a=1&b=2")?;
|
|
||||||
let link = decode_subscription_link(&plain).expect("plain subscription link");
|
|
||||||
assert_eq!(link.name.as_deref(), Some("Work VPN"));
|
|
||||||
assert!(matches!(link.url, Cow::Borrowed("https://example.invalid/sub?a=1&b=2")));
|
|
||||||
|
|
||||||
let encoded = Url::parse("clash-verge://install-config?url=https%253A%252F%252Fexample.invalid%252Fsub")?;
|
|
||||||
let link = decode_subscription_link(&encoded).expect("double-encoded subscription link");
|
|
||||||
assert_eq!(link.url, "https://example.invalid/sub");
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
#[derive(Debug, thiserror::Error)]
|
|
||||||
pub enum SubscriptionError {
|
|
||||||
#[error("the remote profile data is invalid yaml")]
|
|
||||||
InvalidYaml(#[source] serde_yaml_ng::Error),
|
|
||||||
#[error("profile does not contain `proxies` or `proxy-providers`")]
|
|
||||||
MissingProviders,
|
|
||||||
}
|
|
||||||
@@ -1,193 +0,0 @@
|
|||||||
mod deep_link;
|
|
||||||
mod error;
|
|
||||||
|
|
||||||
pub use deep_link::{SubscriptionLink, decode_subscription_link};
|
|
||||||
pub use error::SubscriptionError;
|
|
||||||
|
|
||||||
use http::HeaderMap;
|
|
||||||
use percent_encoding::percent_decode_str;
|
|
||||||
use serde_yaml_ng::Mapping;
|
|
||||||
use url::Url;
|
|
||||||
|
|
||||||
pub struct SubscriptionDocument<'a> {
|
|
||||||
pub body: &'a str,
|
|
||||||
pub filename: Option<String>,
|
|
||||||
pub usage: Option<SubscriptionUsage>,
|
|
||||||
pub update_interval_minutes: Option<u64>,
|
|
||||||
pub home: Option<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct SubscriptionUsage {
|
|
||||||
pub upload: u64,
|
|
||||||
pub download: u64,
|
|
||||||
pub total: u64,
|
|
||||||
pub expire: u64,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn decode_subscription<'a>(
|
|
||||||
url: &Url,
|
|
||||||
headers: &HeaderMap,
|
|
||||||
body: &'a str,
|
|
||||||
) -> Result<SubscriptionDocument<'a>, SubscriptionError> {
|
|
||||||
let body = body.trim_start_matches('\u{feff}');
|
|
||||||
let yaml = serde_yaml_ng::from_str::<Mapping>(body).map_err(SubscriptionError::InvalidYaml)?;
|
|
||||||
|
|
||||||
if !yaml.contains_key("proxies") && !yaml.contains_key("proxy-providers") {
|
|
||||||
return Err(SubscriptionError::MissingProviders);
|
|
||||||
}
|
|
||||||
|
|
||||||
let usage = headers.iter().find_map(|(name, value)| {
|
|
||||||
let prefix = name.as_str().strip_suffix("subscription-userinfo")?;
|
|
||||||
if !prefix.is_empty() && !prefix.ends_with('-') {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
|
|
||||||
let value = value.to_str().unwrap_or("");
|
|
||||||
Some(SubscriptionUsage {
|
|
||||||
upload: find_field(value, "upload", |field| field.parse().ok()).unwrap_or(0),
|
|
||||||
download: find_field(value, "download", |field| field.parse().ok()).unwrap_or(0),
|
|
||||||
total: find_field(value, "total", |field| field.parse().ok()).unwrap_or(0),
|
|
||||||
expire: find_field(value, "expire", |field| field.parse().ok()).unwrap_or(0),
|
|
||||||
})
|
|
||||||
});
|
|
||||||
let update_interval_minutes = headers.get("profile-update-interval").and_then(|value| {
|
|
||||||
let hours = value.to_str().ok()?.parse::<u64>().ok()?;
|
|
||||||
hours.checked_mul(60)
|
|
||||||
});
|
|
||||||
let home = headers
|
|
||||||
.get("profile-web-page-url")
|
|
||||||
.and_then(|value| value.to_str().ok())
|
|
||||||
.and_then(normalize_profile_home_url);
|
|
||||||
|
|
||||||
Ok(SubscriptionDocument {
|
|
||||||
body,
|
|
||||||
filename: subscription_filename(url, headers),
|
|
||||||
usage,
|
|
||||||
update_interval_minutes,
|
|
||||||
home,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
fn subscription_filename(url: &Url, headers: &HeaderMap) -> Option<String> {
|
|
||||||
if let Some(value) = headers.get("content-disposition") {
|
|
||||||
let disposition = format!("{value:?}");
|
|
||||||
let disposition = disposition.trim_matches('"');
|
|
||||||
if let Some(encoded) = find_field(disposition, "filename*", Some)
|
|
||||||
&& let Ok(decoded) = percent_decode_str(encoded).decode_utf8()
|
|
||||||
&& let Some(filename) = decoded.split("''").last()
|
|
||||||
&& !filename.trim().is_empty()
|
|
||||||
{
|
|
||||||
return Some(filename.to_owned());
|
|
||||||
}
|
|
||||||
if let Some(filename) = find_field(disposition, "filename", Some).map(|name| name.trim_matches('"'))
|
|
||||||
&& !filename.trim().is_empty()
|
|
||||||
{
|
|
||||||
return Some(filename.to_owned());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let url = url.as_str();
|
|
||||||
let path = url.split_once('?').map_or(url, |(path, _)| path);
|
|
||||||
let filename = path.rsplit_once('/').map_or(path, |(_, filename)| filename);
|
|
||||||
let filename = percent_decode_str(filename).decode_utf8_lossy();
|
|
||||||
if filename.trim().is_empty() {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
Some(filename.into_owned())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn normalize_profile_home_url(raw: &str) -> Option<String> {
|
|
||||||
let url = Url::parse(raw.trim()).ok()?;
|
|
||||||
|
|
||||||
if !matches!(url.scheme(), "http" | "https") {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
|
|
||||||
url.host_str()?;
|
|
||||||
Some(url.as_str().into())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn find_field<'a, T>(target: &'a str, key: &str, mut parse: impl FnMut(&'a str) -> Option<T>) -> Option<T> {
|
|
||||||
target.split(';').map(str::trim).find_map(|s| {
|
|
||||||
let (name, value) = s.split_once('=')?;
|
|
||||||
if name != key {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
|
|
||||||
parse(value)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
use http::HeaderValue;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn decodes_metadata_and_preserves_provider_only_yaml() -> Result<(), Box<dyn std::error::Error>> {
|
|
||||||
let url = Url::parse("https://example.com/fallback.yaml")?;
|
|
||||||
let mut headers = HeaderMap::new();
|
|
||||||
headers.insert(
|
|
||||||
"content-disposition",
|
|
||||||
HeaderValue::from_static("attachment; filename*=UTF-8''My%20Profile.yaml; filename=fallback.yaml"),
|
|
||||||
);
|
|
||||||
headers.insert(
|
|
||||||
"x-amz-meta-subscription-userinfo",
|
|
||||||
HeaderValue::from_static("upload=1; download=2; total=3; expire=4"),
|
|
||||||
);
|
|
||||||
headers.insert("profile-update-interval", HeaderValue::from_static("2"));
|
|
||||||
headers.insert(
|
|
||||||
"profile-web-page-url",
|
|
||||||
HeaderValue::from_static(" https://example.com "),
|
|
||||||
);
|
|
||||||
let yaml = "# keep this comment\nproxy-providers: {}\n";
|
|
||||||
let body = format!("\u{feff}{yaml}");
|
|
||||||
|
|
||||||
let document = decode_subscription(&url, &headers, &body)?;
|
|
||||||
assert_eq!(document.body, yaml);
|
|
||||||
assert_eq!(document.filename.as_deref(), Some("My Profile.yaml"));
|
|
||||||
assert_eq!(document.update_interval_minutes, Some(120));
|
|
||||||
assert_eq!(document.home.as_deref(), Some("https://example.com/"));
|
|
||||||
let usage = document.usage.ok_or("missing subscription usage")?;
|
|
||||||
assert_eq!((usage.upload, usage.download, usage.total, usage.expire), (1, 2, 3, 4));
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn falls_back_when_suggested_filename_is_invalid_or_empty() -> Result<(), Box<dyn std::error::Error>> {
|
|
||||||
let url = Url::parse("https://example.com/url.yaml?token=value")?;
|
|
||||||
let root_url = Url::parse("https://example.com/")?;
|
|
||||||
for (disposition, url, expected) in [
|
|
||||||
(
|
|
||||||
"attachment; filename*=UTF-8''%FF; filename=valid.yaml",
|
|
||||||
&url,
|
|
||||||
Some("valid.yaml"),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"attachment; filename*=UTF-8''; filename=valid.yaml",
|
|
||||||
&url,
|
|
||||||
Some("valid.yaml"),
|
|
||||||
),
|
|
||||||
("attachment; filename*=UTF-8''%FF", &url, Some("url.yaml")),
|
|
||||||
("attachment; filename=", &root_url, None),
|
|
||||||
] {
|
|
||||||
let mut headers = HeaderMap::new();
|
|
||||||
headers.insert("content-disposition", HeaderValue::from_static(disposition));
|
|
||||||
let document = decode_subscription(url, &headers, "proxies: []")?;
|
|
||||||
assert_eq!(document.filename.as_deref(), expected);
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn ignores_overflowing_server_interval() -> Result<(), Box<dyn std::error::Error>> {
|
|
||||||
let url = Url::parse("https://example.com/My%20Profile.yaml?token=value")?;
|
|
||||||
let mut headers = HeaderMap::new();
|
|
||||||
headers.insert("profile-update-interval", HeaderValue::from_str(&u64::MAX.to_string())?);
|
|
||||||
|
|
||||||
let document = decode_subscription(&url, &headers, "proxies: []")?;
|
|
||||||
assert_eq!(document.update_interval_minutes, None);
|
|
||||||
assert_eq!(document.filename.as_deref(), Some("My Profile.yaml"));
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
//! Task drivers and retry primitives with caller-managed runtime and cancellation.
|
//! Single-owner task drivers with caller-managed runtime and cancellation.
|
||||||
|
|
||||||
pub mod countdown;
|
pub mod countdown;
|
||||||
pub mod retry;
|
|
||||||
pub mod scheduled_task;
|
pub mod scheduled_task;
|
||||||
pub mod watch_task;
|
pub mod watch_task;
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ parking_lot = { workspace = true }
|
|||||||
serde = { workspace = true, features = ["derive"] }
|
serde = { workspace = true, features = ["derive"] }
|
||||||
# sysinfo 0.38.2 conflicts with dark-light
|
# sysinfo 0.38.2 conflicts with dark-light
|
||||||
# see https://github.com/GuillaumeGomez/sysinfo/issues/1623
|
# see https://github.com/GuillaumeGomez/sysinfo/issues/1623
|
||||||
sysinfo = { version = "0.40.4", default-features = false, features = ["network", "system"] }
|
sysinfo = { version = "0.40.5", default-features = false, features = ["network", "system"] }
|
||||||
|
|
||||||
[target.'cfg(not(windows))'.dependencies]
|
[target.'cfg(not(windows))'.dependencies]
|
||||||
libc = "0.2.191"
|
libc = "0.2.191"
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import pluginImportX from 'eslint-plugin-import-x'
|
|||||||
import pluginReactCompiler from 'eslint-plugin-react-compiler'
|
import pluginReactCompiler from 'eslint-plugin-react-compiler'
|
||||||
import pluginReactHooks from 'eslint-plugin-react-hooks'
|
import pluginReactHooks from 'eslint-plugin-react-hooks'
|
||||||
import pluginReactRefresh from 'eslint-plugin-react-refresh'
|
import pluginReactRefresh from 'eslint-plugin-react-refresh'
|
||||||
import PluginSukka from 'eslint-plugin-sukka'
|
|
||||||
import pluginUnusedImports from 'eslint-plugin-unused-imports'
|
import pluginUnusedImports from 'eslint-plugin-unused-imports'
|
||||||
import globals from 'globals'
|
import globals from 'globals'
|
||||||
import tseslint from 'typescript-eslint'
|
import tseslint from 'typescript-eslint'
|
||||||
@@ -112,7 +111,6 @@ export default defineConfig([
|
|||||||
'import-x': pluginImportX,
|
'import-x': pluginImportX,
|
||||||
'react-refresh': pluginReactRefresh,
|
'react-refresh': pluginReactRefresh,
|
||||||
'unused-imports': pluginUnusedImports,
|
'unused-imports': pluginUnusedImports,
|
||||||
sukka: PluginSukka,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
extends: [
|
extends: [
|
||||||
@@ -182,7 +180,6 @@ export default defineConfig([
|
|||||||
'@eslint-react/no-unused-class-component-members': 'error',
|
'@eslint-react/no-unused-class-component-members': 'error',
|
||||||
'@eslint-react/no-unused-state': 'error',
|
'@eslint-react/no-unused-state': 'error',
|
||||||
'@eslint-react/jsx-no-useless-fragment': 'warn',
|
'@eslint-react/jsx-no-useless-fragment': 'warn',
|
||||||
'sukka/react-prefer-destructuring-assignment': 'warn',
|
|
||||||
|
|
||||||
// TypeScript
|
// TypeScript
|
||||||
'@typescript-eslint/no-explicit-any': 'off',
|
'@typescript-eslint/no-explicit-any': 'off',
|
||||||
|
|||||||
@@ -57,8 +57,6 @@
|
|||||||
"ahooks": "^3.10.0",
|
"ahooks": "^3.10.0",
|
||||||
"cidr-block": "^2.3.0",
|
"cidr-block": "^2.3.0",
|
||||||
"dayjs": "1.11.23",
|
"dayjs": "1.11.23",
|
||||||
"foxact": "^0.3.12",
|
|
||||||
"foxts": "^5.9.1",
|
|
||||||
"i18next": "^27.0.0",
|
"i18next": "^27.0.0",
|
||||||
"js-yaml": "^5.4.2",
|
"js-yaml": "^5.4.2",
|
||||||
"lodash-es": "^4.18.1",
|
"lodash-es": "^4.18.1",
|
||||||
@@ -107,7 +105,6 @@
|
|||||||
"eslint-plugin-react-compiler": "19.1.0-rc.2",
|
"eslint-plugin-react-compiler": "19.1.0-rc.2",
|
||||||
"eslint-plugin-react-hooks": "^7.1.1",
|
"eslint-plugin-react-hooks": "^7.1.1",
|
||||||
"eslint-plugin-react-refresh": "^0.5.7",
|
"eslint-plugin-react-refresh": "^0.5.7",
|
||||||
"eslint-plugin-sukka": "^10.2.0",
|
|
||||||
"eslint-plugin-unused-imports": "^4.4.1",
|
"eslint-plugin-unused-imports": "^4.4.1",
|
||||||
"globals": "^17.12.0",
|
"globals": "^17.12.0",
|
||||||
"https-proxy-agent": "^9.1.0",
|
"https-proxy-agent": "^9.1.0",
|
||||||
|
|||||||
Generated
+58
-247
@@ -248,12 +248,6 @@ importers:
|
|||||||
dayjs:
|
dayjs:
|
||||||
specifier: 1.11.23
|
specifier: 1.11.23
|
||||||
version: 1.11.23
|
version: 1.11.23
|
||||||
foxact:
|
|
||||||
specifier: ^0.3.12
|
|
||||||
version: 0.3.12(react-dom@19.3.1(react@19.3.1))(react@19.3.1)
|
|
||||||
foxts:
|
|
||||||
specifier: ^5.9.1
|
|
||||||
version: 5.9.1
|
|
||||||
i18next:
|
i18next:
|
||||||
specifier: ^27.0.0
|
specifier: ^27.0.0
|
||||||
version: 27.0.1(typescript@6.0.3)
|
version: 27.0.1(typescript@6.0.3)
|
||||||
@@ -353,10 +347,10 @@ importers:
|
|||||||
version: 13.15.10
|
version: 13.15.10
|
||||||
'@vitejs/plugin-legacy':
|
'@vitejs/plugin-legacy':
|
||||||
specifier: ^8.2.3
|
specifier: ^8.2.3
|
||||||
version: 8.2.3(terser@5.51.2)(vite@8.3.3(@types/node@26.6.5)(jiti@2.7.0)(sass@1.104.1)(terser@5.51.2)(yaml@2.9.1))
|
version: 8.2.3(terser@5.51.3)(vite@8.3.3(@types/node@26.6.5)(jiti@2.7.0)(sass@1.104.1)(terser@5.51.3)(yaml@2.9.1))
|
||||||
'@vitejs/plugin-react':
|
'@vitejs/plugin-react':
|
||||||
specifier: ^6.1.1
|
specifier: ^6.1.1
|
||||||
version: 6.1.1(vite@8.3.3(@types/node@26.6.5)(jiti@2.7.0)(sass@1.104.1)(terser@5.51.2)(yaml@2.9.1))
|
version: 6.1.1(vite@8.3.3(@types/node@26.6.5)(jiti@2.7.0)(sass@1.104.1)(terser@5.51.3)(yaml@2.9.1))
|
||||||
adm-zip:
|
adm-zip:
|
||||||
specifier: ^0.6.1
|
specifier: ^0.6.1
|
||||||
version: 0.6.1
|
version: 0.6.1
|
||||||
@@ -377,13 +371,13 @@ importers:
|
|||||||
version: 10.16.0(jiti@2.7.0)
|
version: 10.16.0(jiti@2.7.0)
|
||||||
eslint-import-resolver-typescript:
|
eslint-import-resolver-typescript:
|
||||||
specifier: ^4.4.5
|
specifier: ^4.4.5
|
||||||
version: 4.4.5(eslint-plugin-import-x@4.18.1(@typescript-eslint/utils@8.70.0(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3))(eslint@10.16.0(jiti@2.7.0)))(eslint@10.16.0(jiti@2.7.0))
|
version: 4.4.5(eslint-plugin-import-x@4.18.1(@typescript-eslint/utils@8.74.0(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3))(eslint@10.16.0(jiti@2.7.0)))(eslint@10.16.0(jiti@2.7.0))
|
||||||
eslint-plugin-es-x:
|
eslint-plugin-es-x:
|
||||||
specifier: ^10.0.1
|
specifier: ^10.0.1
|
||||||
version: 10.0.1(eslint@10.16.0(jiti@2.7.0))
|
version: 10.0.1(eslint@10.16.0(jiti@2.7.0))
|
||||||
eslint-plugin-import-x:
|
eslint-plugin-import-x:
|
||||||
specifier: ^4.18.1
|
specifier: ^4.18.1
|
||||||
version: 4.18.1(@typescript-eslint/utils@8.70.0(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3))(eslint@10.16.0(jiti@2.7.0))
|
version: 4.18.1(@typescript-eslint/utils@8.74.0(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3))(eslint@10.16.0(jiti@2.7.0))
|
||||||
eslint-plugin-react-compiler:
|
eslint-plugin-react-compiler:
|
||||||
specifier: 19.1.0-rc.2
|
specifier: 19.1.0-rc.2
|
||||||
version: 19.1.0-rc.2(eslint@10.16.0(jiti@2.7.0))
|
version: 19.1.0-rc.2(eslint@10.16.0(jiti@2.7.0))
|
||||||
@@ -393,9 +387,6 @@ importers:
|
|||||||
eslint-plugin-react-refresh:
|
eslint-plugin-react-refresh:
|
||||||
specifier: ^0.5.7
|
specifier: ^0.5.7
|
||||||
version: 0.5.7(eslint@10.16.0(jiti@2.7.0))
|
version: 0.5.7(eslint@10.16.0(jiti@2.7.0))
|
||||||
eslint-plugin-sukka:
|
|
||||||
specifier: ^10.2.0
|
|
||||||
version: 10.2.0(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
|
||||||
eslint-plugin-unused-imports:
|
eslint-plugin-unused-imports:
|
||||||
specifier: ^4.4.1
|
specifier: ^4.4.1
|
||||||
version: 4.4.1(@typescript-eslint/eslint-plugin@8.74.0(@typescript-eslint/parser@8.74.0(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3))(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3))(eslint@10.16.0(jiti@2.7.0))
|
version: 4.4.1(@typescript-eslint/eslint-plugin@8.74.0(@typescript-eslint/parser@8.74.0(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3))(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3))(eslint@10.16.0(jiti@2.7.0))
|
||||||
@@ -425,7 +416,7 @@ importers:
|
|||||||
version: 8.0.2
|
version: 8.0.2
|
||||||
terser:
|
terser:
|
||||||
specifier: ^5.51.2
|
specifier: ^5.51.2
|
||||||
version: 5.51.2
|
version: 5.51.3
|
||||||
tsrs:
|
tsrs:
|
||||||
specifier: 0.20.0-ts7.1.0-beta
|
specifier: 0.20.0-ts7.1.0-beta
|
||||||
version: 0.20.0-ts7.1.0-beta
|
version: 0.20.0-ts7.1.0-beta
|
||||||
@@ -437,13 +428,13 @@ importers:
|
|||||||
version: 8.74.0(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
version: 8.74.0(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
||||||
vite:
|
vite:
|
||||||
specifier: ^8.3.0
|
specifier: ^8.3.0
|
||||||
version: 8.3.3(@types/node@26.6.5)(jiti@2.7.0)(sass@1.104.1)(terser@5.51.2)(yaml@2.9.1)
|
version: 8.3.3(@types/node@26.6.5)(jiti@2.7.0)(sass@1.104.1)(terser@5.51.3)(yaml@2.9.1)
|
||||||
vite-plugin-svgr:
|
vite-plugin-svgr:
|
||||||
specifier: ^5.2.0
|
specifier: ^5.2.0
|
||||||
version: 5.2.0(typescript@6.0.3)(vite@8.3.3(@types/node@26.6.5)(jiti@2.7.0)(sass@1.104.1)(terser@5.51.2)(yaml@2.9.1))
|
version: 5.2.0(typescript@6.0.3)(vite@8.3.3(@types/node@26.6.5)(jiti@2.7.0)(sass@1.104.1)(terser@5.51.3)(yaml@2.9.1))
|
||||||
vitest:
|
vitest:
|
||||||
specifier: ^5.0.3
|
specifier: ^5.0.3
|
||||||
version: 5.1.2(@types/node@26.6.5)(vite@8.3.3(@types/node@26.6.5)(jiti@2.7.0)(sass@1.104.1)(terser@5.51.2)(yaml@2.9.1))
|
version: 5.1.2(@types/node@26.6.5)(vite@8.3.3(@types/node@26.6.5)(jiti@2.7.0)(sass@1.104.1)(terser@5.51.3)(yaml@2.9.1))
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
|
|
||||||
@@ -2162,45 +2153,22 @@ packages:
|
|||||||
eslint: ^8.57.0 || ^9.0.0 || ^10.0.0
|
eslint: ^8.57.0 || ^9.0.0 || ^10.0.0
|
||||||
typescript: '>=4.8.4 <6.1.0'
|
typescript: '>=4.8.4 <6.1.0'
|
||||||
|
|
||||||
'@typescript-eslint/project-service@8.70.0':
|
|
||||||
resolution: {integrity: sha512-hFHbTNqhU9G+2eKFXCBVb1tjFT/LceiJ4+HfLO4pTpDI0KHi6iajpcFFkaSQ9gXmCh7n82A0PthaayEdN6mspQ==}
|
|
||||||
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
|
||||||
peerDependencies:
|
|
||||||
typescript: '>=4.8.4 <6.1.0'
|
|
||||||
|
|
||||||
'@typescript-eslint/project-service@8.74.0':
|
'@typescript-eslint/project-service@8.74.0':
|
||||||
resolution: {integrity: sha512-z/mymuE+JlEeSFIv3Mo70EvgG1Zz74Hl0IDfExfXutARAP834bt+MppTD7mVAwmZO0GdxdOAi0jbTam749eH6g==}
|
resolution: {integrity: sha512-z/mymuE+JlEeSFIv3Mo70EvgG1Zz74Hl0IDfExfXutARAP834bt+MppTD7mVAwmZO0GdxdOAi0jbTam749eH6g==}
|
||||||
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
typescript: '>=4.8.4 <6.1.0'
|
typescript: '>=4.8.4 <6.1.0'
|
||||||
|
|
||||||
'@typescript-eslint/scope-manager@8.70.0':
|
|
||||||
resolution: {integrity: sha512-8nP3Kwh5hlgZ4FicGvmznAmJe8UL4sdU8tLukrPaMuQmDuk4Y8xYfzu/aYZW4xT2JCgc7H/TpDI5cGlxcWJSqQ==}
|
|
||||||
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
|
||||||
|
|
||||||
'@typescript-eslint/scope-manager@8.74.0':
|
'@typescript-eslint/scope-manager@8.74.0':
|
||||||
resolution: {integrity: sha512-kpOdpu4CpWN5U38ox3f727DwWRBtUAVhyUJtqTBYe5gf2wYoxac7PgKP14txrxN7ICVtcjlLdzjqfRgpSnDKvQ==}
|
resolution: {integrity: sha512-kpOdpu4CpWN5U38ox3f727DwWRBtUAVhyUJtqTBYe5gf2wYoxac7PgKP14txrxN7ICVtcjlLdzjqfRgpSnDKvQ==}
|
||||||
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
||||||
|
|
||||||
'@typescript-eslint/tsconfig-utils@8.70.0':
|
|
||||||
resolution: {integrity: sha512-adnkeeNq9Sq1sUf4+FRVc0KdgYghzsgFpZSQVZVvY0LCuUuN0FnQgyGzCJeC4fW1cdXseBAjU2EOqUIjbNcZUw==}
|
|
||||||
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
|
||||||
peerDependencies:
|
|
||||||
typescript: '>=4.8.4 <6.1.0'
|
|
||||||
|
|
||||||
'@typescript-eslint/tsconfig-utils@8.74.0':
|
'@typescript-eslint/tsconfig-utils@8.74.0':
|
||||||
resolution: {integrity: sha512-p07wAuaS6BjCYgOSXKJi4YhvTnAf7fiG37e9THcpnYaQEt2QiTTYZWKwUFNgeRiywiMudazhzgddAirZ0GgHtQ==}
|
resolution: {integrity: sha512-p07wAuaS6BjCYgOSXKJi4YhvTnAf7fiG37e9THcpnYaQEt2QiTTYZWKwUFNgeRiywiMudazhzgddAirZ0GgHtQ==}
|
||||||
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
typescript: '>=4.8.4 <6.1.0'
|
typescript: '>=4.8.4 <6.1.0'
|
||||||
|
|
||||||
'@typescript-eslint/type-utils@8.70.0':
|
|
||||||
resolution: {integrity: sha512-NUMKIhYVaVIVLnRL9CRt+VVcuLgSHUCpXn4/+K8wql+vdInUzvx8BjUO1oJ7cG9shjFJKtF8F8Hh2kCh3/KBVw==}
|
|
||||||
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
|
||||||
peerDependencies:
|
|
||||||
eslint: ^8.57.0 || ^9.0.0 || ^10.0.0
|
|
||||||
typescript: '>=4.8.4 <6.1.0'
|
|
||||||
|
|
||||||
'@typescript-eslint/type-utils@8.74.0':
|
'@typescript-eslint/type-utils@8.74.0':
|
||||||
resolution: {integrity: sha512-CV3Y3la8l3F9ANfxcfpgSSiQgJTe4IeLEoZV4O/gcW86Ugp8X6SKiQ0vm+QegXaRIbbDMokZZSF3A1CgiU/kPw==}
|
resolution: {integrity: sha512-CV3Y3la8l3F9ANfxcfpgSSiQgJTe4IeLEoZV4O/gcW86Ugp8X6SKiQ0vm+QegXaRIbbDMokZZSF3A1CgiU/kPw==}
|
||||||
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
||||||
@@ -2208,20 +2176,10 @@ packages:
|
|||||||
eslint: ^8.57.0 || ^9.0.0 || ^10.0.0
|
eslint: ^8.57.0 || ^9.0.0 || ^10.0.0
|
||||||
typescript: '>=4.8.4 <6.1.0'
|
typescript: '>=4.8.4 <6.1.0'
|
||||||
|
|
||||||
'@typescript-eslint/types@8.70.0':
|
|
||||||
resolution: {integrity: sha512-asTOIYhDg4zdzOScCyaytrsV3cR6B4ecPQlXw/dJIm7J/MZTtCtfVII9JD8Geh4jTCrK/Xe6cg5UevoleMcoJQ==}
|
|
||||||
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
|
||||||
|
|
||||||
'@typescript-eslint/types@8.74.0':
|
'@typescript-eslint/types@8.74.0':
|
||||||
resolution: {integrity: sha512-MpnMrJCVNpP1iVL8NiHkQZgQqIMBH5ewDGUPBh1pqQXwFtMFjsl1M03QcYPXmv6stCKEiF0PN7CGbU1ZbXFzEA==}
|
resolution: {integrity: sha512-MpnMrJCVNpP1iVL8NiHkQZgQqIMBH5ewDGUPBh1pqQXwFtMFjsl1M03QcYPXmv6stCKEiF0PN7CGbU1ZbXFzEA==}
|
||||||
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
||||||
|
|
||||||
'@typescript-eslint/typescript-estree@8.70.0':
|
|
||||||
resolution: {integrity: sha512-d9NmHMPEKQ7QCLLm1jI3zmoQBwT5KwFYjXBJ9ymZfKCUU+5rmTRykKAFvH5Qn/ZCds3CEAFS9OC9M/jkl0X2bA==}
|
|
||||||
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
|
||||||
peerDependencies:
|
|
||||||
typescript: '>=4.8.4 <6.1.0'
|
|
||||||
|
|
||||||
'@typescript-eslint/typescript-estree@8.74.0':
|
'@typescript-eslint/typescript-estree@8.74.0':
|
||||||
resolution: {integrity: sha512-wL348k6l92DNG+kPP5rVpKwNBoz7a3xRZy3TPKc1uymQttd7u7gcMv3eENmcuh4CjC4mO3FTM0DYstFXMyDLuw==}
|
resolution: {integrity: sha512-wL348k6l92DNG+kPP5rVpKwNBoz7a3xRZy3TPKc1uymQttd7u7gcMv3eENmcuh4CjC4mO3FTM0DYstFXMyDLuw==}
|
||||||
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
||||||
@@ -2232,13 +2190,6 @@ packages:
|
|||||||
'@typescript/native':
|
'@typescript/native':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@typescript-eslint/utils@8.70.0':
|
|
||||||
resolution: {integrity: sha512-oZmtKJz/4fufZ2p3+Cn3ijEojcdfR+1zYDH2xKYrEly0dR/Q/1xUPRCOlKGxod78nWlU2UnDe09GZ3TaknBFGA==}
|
|
||||||
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
|
||||||
peerDependencies:
|
|
||||||
eslint: ^8.57.0 || ^9.0.0 || ^10.0.0
|
|
||||||
typescript: '>=4.8.4 <6.1.0'
|
|
||||||
|
|
||||||
'@typescript-eslint/utils@8.74.0':
|
'@typescript-eslint/utils@8.74.0':
|
||||||
resolution: {integrity: sha512-IpWXPxXXomzxyTcvjhZJexgdvtTR1TooLAPpuxzaGqQ8BHll1lf4Ysp/BTE/l0U5TJ+x1j7B4bEM8pLRrvY+XA==}
|
resolution: {integrity: sha512-IpWXPxXXomzxyTcvjhZJexgdvtTR1TooLAPpuxzaGqQ8BHll1lf4Ysp/BTE/l0U5TJ+x1j7B4bEM8pLRrvY+XA==}
|
||||||
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
||||||
@@ -2246,10 +2197,6 @@ packages:
|
|||||||
eslint: ^8.57.0 || ^9.0.0 || ^10.0.0
|
eslint: ^8.57.0 || ^9.0.0 || ^10.0.0
|
||||||
typescript: '>=4.8.4 <6.1.0'
|
typescript: '>=4.8.4 <6.1.0'
|
||||||
|
|
||||||
'@typescript-eslint/visitor-keys@8.70.0':
|
|
||||||
resolution: {integrity: sha512-BoC8PiO4Hkdo0TVJh9Ntxr5MxPDI7/oFsrygN5ADelFSeXG/qgNuucIGA+L5Z6JpPTE/uRfcTWtscjbUaufepQ==}
|
|
||||||
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
|
||||||
|
|
||||||
'@typescript-eslint/visitor-keys@8.74.0':
|
'@typescript-eslint/visitor-keys@8.74.0':
|
||||||
resolution: {integrity: sha512-XSZmOtMUbWCBIM+2BK134FyMFxmll1mW2mPLk/PSwYQYzGIPMgJAqL929U4qXVizLv7Xq5b7r41/o7Ombuwk0g==}
|
resolution: {integrity: sha512-XSZmOtMUbWCBIM+2BK134FyMFxmll1mW2mPLk/PSwYQYzGIPMgJAqL929U4qXVizLv7Xq5b7r41/o7Ombuwk0g==}
|
||||||
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
||||||
@@ -2569,9 +2516,6 @@ packages:
|
|||||||
resolution: {integrity: sha512-zlnpg0jNcibNrO7GG9IeHH7maWFeCz+Ja1wx/7tZNU5ASSSSZ+/qZciM0/LHCYxSdqv5h2sdbQ/PXYdOuetXvA==}
|
resolution: {integrity: sha512-zlnpg0jNcibNrO7GG9IeHH7maWFeCz+Ja1wx/7tZNU5ASSSSZ+/qZciM0/LHCYxSdqv5h2sdbQ/PXYdOuetXvA==}
|
||||||
engines: {node: '>=0.10'}
|
engines: {node: '>=0.10'}
|
||||||
|
|
||||||
client-only@0.0.1:
|
|
||||||
resolution: {integrity: sha512-IV3Ou0jSMzZrd3pZ48nLkT9DA7Ag1pnPzaiQhpW7c3RbcqqzvzzVu+L8gfqMp/8IM2MQtSiqaCxrrcfu8I8rMA==}
|
|
||||||
|
|
||||||
clsx@2.1.1:
|
clsx@2.1.1:
|
||||||
resolution: {integrity: sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==}
|
resolution: {integrity: sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==}
|
||||||
engines: {node: '>=6'}
|
engines: {node: '>=6'}
|
||||||
@@ -2850,12 +2794,6 @@ packages:
|
|||||||
eslint: '*'
|
eslint: '*'
|
||||||
typescript: '*'
|
typescript: '*'
|
||||||
|
|
||||||
eslint-plugin-sukka@10.2.0:
|
|
||||||
resolution: {integrity: sha512-BbErYY/fymqL7Te5yiDeBGfSF7QMxzZrT4SQpFI2e8ecRun3oYbL5aJm4kzFfeUzNZ/hET8T7pedpaH1fuXXHg==}
|
|
||||||
peerDependencies:
|
|
||||||
eslint: '>=9.29.0'
|
|
||||||
typescript: '*'
|
|
||||||
|
|
||||||
eslint-plugin-unused-imports@4.4.1:
|
eslint-plugin-unused-imports@4.4.1:
|
||||||
resolution: {integrity: sha512-oZGYUz1X3sRMGUB+0cZyK2VcvRX5lm/vB56PgNNcU+7ficUCKm66oZWKUubXWnOuPjQ8PvmXtCViXBMONPe7tQ==}
|
resolution: {integrity: sha512-oZGYUz1X3sRMGUB+0cZyK2VcvRX5lm/vB56PgNNcU+7ficUCKm66oZWKUubXWnOuPjQ8PvmXtCViXBMONPe7tQ==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
@@ -2929,9 +2867,6 @@ packages:
|
|||||||
event-emitter@0.3.5:
|
event-emitter@0.3.5:
|
||||||
resolution: {integrity: sha512-D9rRn9y7kLPnJ+hMq7S/nhvoKwwvVJahBi2BPmx3bvbsEdK3W9ii8cBSGjP+72/LnM4n6fo3+dkCX5FeTQruXA==}
|
resolution: {integrity: sha512-D9rRn9y7kLPnJ+hMq7S/nhvoKwwvVJahBi2BPmx3bvbsEdK3W9ii8cBSGjP+72/LnM4n6fo3+dkCX5FeTQruXA==}
|
||||||
|
|
||||||
event-target-bus@1.1.0:
|
|
||||||
resolution: {integrity: sha512-24JX34nM0qRcsj7KvtLbVpMcX8ZQYmb0+0a6viaV2GJtVFg5UGyJyDLITkBipJIG0fSscNskI2PxdhTBIMeg8g==}
|
|
||||||
|
|
||||||
expect-type@1.4.0:
|
expect-type@1.4.0:
|
||||||
resolution: {integrity: sha512-KfYbmpRm0VbLjEvVa9yGwCi9GI34xvi7A/HXYWQO65CSD2u3MczUJSuwXKFIxlGsgBQizV9q5J9NHj4VG0n+pA==}
|
resolution: {integrity: sha512-KfYbmpRm0VbLjEvVa9yGwCi9GI34xvi7A/HXYWQO65CSD2u3MczUJSuwXKFIxlGsgBQizV9q5J9NHj4VG0n+pA==}
|
||||||
engines: {node: '>=12.0.0'}
|
engines: {node: '>=12.0.0'}
|
||||||
@@ -2945,10 +2880,6 @@ packages:
|
|||||||
fast-deep-equal@3.1.3:
|
fast-deep-equal@3.1.3:
|
||||||
resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==}
|
resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==}
|
||||||
|
|
||||||
fast-fnv1a@1.0.0:
|
|
||||||
resolution: {integrity: sha512-Y7iaFmz24pNJX+nqXgDuyHYFTfV9XPWJRfqp0hlG0Xuz1vKnelwLwvmKkbvVVvp5WzYWnrovBTLdk2PWkOYzCg==}
|
|
||||||
engines: {node: ^22.15.0 || ^23.8.0 || >=24.0.0}
|
|
||||||
|
|
||||||
fast-json-stable-stringify@2.1.0:
|
fast-json-stable-stringify@2.1.0:
|
||||||
resolution: {integrity: sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==}
|
resolution: {integrity: sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==}
|
||||||
|
|
||||||
@@ -2983,10 +2914,6 @@ packages:
|
|||||||
flatted@3.4.4:
|
flatted@3.4.4:
|
||||||
resolution: {integrity: sha512-5+ybhBZANEJxaH3X5evAFatUxLfEHSr7n6kYJ+1Qd0mUqr4eu9gIf6GDbWHf8RJijHrjjO8G+la14SlL2SeS1Q==}
|
resolution: {integrity: sha512-5+ybhBZANEJxaH3X5evAFatUxLfEHSr7n6kYJ+1Qd0mUqr4eu9gIf6GDbWHf8RJijHrjjO8G+la14SlL2SeS1Q==}
|
||||||
|
|
||||||
fnv1a52@1.0.0:
|
|
||||||
resolution: {integrity: sha512-dUnV6Uok578HuGYTC/EM0LqeXewXBCHsh/kmLkdcqN1zgSy7K3gCIrshPBS5JwW20XSaRv4Vnz7z8lMjOV8jWw==}
|
|
||||||
engines: {node: '>=18.0.0'}
|
|
||||||
|
|
||||||
follow-redirects@1.16.2:
|
follow-redirects@1.16.2:
|
||||||
resolution: {integrity: sha512-/kVP2U8z596Ia0gwFrwyIeo74ta5aVmSeU1FfAUMAmcEP5EP7zydmag3SLiN64NaRKef3lxsq7i/g7ltJQDGow==}
|
resolution: {integrity: sha512-/kVP2U8z596Ia0gwFrwyIeo74ta5aVmSeU1FfAUMAmcEP5EP7zydmag3SLiN64NaRKef3lxsq7i/g7ltJQDGow==}
|
||||||
engines: {node: '>=4.0'}
|
engines: {node: '>=4.0'}
|
||||||
@@ -3005,20 +2932,6 @@ packages:
|
|||||||
engines: {node: ^20.12.0 || >=22}
|
engines: {node: ^20.12.0 || >=22}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
|
|
||||||
foxact@0.3.12:
|
|
||||||
resolution: {integrity: sha512-sXE1plDgAUsKWzqbAMq/+ifRI3TSOnDPmyZGoaniW9AhtZqk3cOEUSC0jC4a4srvLf4PXwtCB+zQczBdxHGSDA==}
|
|
||||||
peerDependencies:
|
|
||||||
react: '*'
|
|
||||||
react-dom: '*'
|
|
||||||
peerDependenciesMeta:
|
|
||||||
react:
|
|
||||||
optional: true
|
|
||||||
react-dom:
|
|
||||||
optional: true
|
|
||||||
|
|
||||||
foxts@5.9.1:
|
|
||||||
resolution: {integrity: sha512-NrIHGlf4LZGTjjGlVi3gmMbtvC4871SFUflu9yb8X91FYppAk+WMiYS6ZlaEgkPqAkgIGNeq+Y5YCL80GL6v8g==}
|
|
||||||
|
|
||||||
fsevents@2.3.3:
|
fsevents@2.3.3:
|
||||||
resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==}
|
resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==}
|
||||||
engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0}
|
engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0}
|
||||||
@@ -3368,9 +3281,6 @@ packages:
|
|||||||
lru-queue@0.1.0:
|
lru-queue@0.1.0:
|
||||||
resolution: {integrity: sha512-BpdYkt9EvGl8OfWHDQPISVpcl5xZthb+XPsbELj5AQXxIC8IriDZIQYjBJPEm5rS420sjZ0TLEzRcq5KdBhYrQ==}
|
resolution: {integrity: sha512-BpdYkt9EvGl8OfWHDQPISVpcl5xZthb+XPsbELj5AQXxIC8IriDZIQYjBJPEm5rS420sjZ0TLEzRcq5KdBhYrQ==}
|
||||||
|
|
||||||
magic-string@1.4.1:
|
|
||||||
resolution: {integrity: sha512-8lyCu36ErXR0J9uaGKlKQoiLZKmtI63YGLE8G2o9jyRPdr4X47LusSOwgOJOzcVtp81fTAAjxR7BwKz682Jhow==}
|
|
||||||
|
|
||||||
magic-string@1.4.5:
|
magic-string@1.4.5:
|
||||||
resolution: {integrity: sha512-oLLC2+YvQUfAa+vxoufE/yc1icb87M9iXIRqAoR/2EhE/8cb3SF/+Gi0c2By1B+5Vz2e2vQtUvHiu1+63Znh+w==}
|
resolution: {integrity: sha512-oLLC2+YvQUfAa+vxoufE/yc1icb87M9iXIRqAoR/2EhE/8cb3SF/+Gi0c2By1B+5Vz2e2vQtUvHiu1+63Znh+w==}
|
||||||
|
|
||||||
@@ -3490,10 +3400,6 @@ packages:
|
|||||||
resolution: {integrity: sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==}
|
resolution: {integrity: sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==}
|
||||||
engines: {node: '>= 0.6'}
|
engines: {node: '>= 0.6'}
|
||||||
|
|
||||||
minimatch@10.2.6:
|
|
||||||
resolution: {integrity: sha512-vpLQEs+VLCr1nU0BXS07maYoFwlDAH0gngQuuttxIwutDFEMHq2blX+8vpgxDdK3J1PwjCJiep77OitTZ4Ll1A==}
|
|
||||||
engines: {node: 18 || 20 || >=22}
|
|
||||||
|
|
||||||
minimatch@11.0.9:
|
minimatch@11.0.9:
|
||||||
resolution: {integrity: sha512-KCFkfyjqerNlSstjlhIGNXIKZGA/6O4V4RlhZ+Dsr621SPPw0mzlypE9D9ZOoPiVefHID+j7/XuMMlqfD/F60Q==}
|
resolution: {integrity: sha512-KCFkfyjqerNlSstjlhIGNXIKZGA/6O4V4RlhZ+Dsr621SPPw0mzlypE9D9ZOoPiVefHID+j7/XuMMlqfD/F60Q==}
|
||||||
engines: {node: 20 || >=22}
|
engines: {node: 20 || >=22}
|
||||||
@@ -3833,9 +3739,6 @@ packages:
|
|||||||
engines: {node: '>=10'}
|
engines: {node: '>=10'}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
|
|
||||||
server-only@0.0.1:
|
|
||||||
resolution: {integrity: sha512-qepMx2JxAa5jjfzxG79yPPq+8BuFToHd1hm7kI+Z4zAq1ftQiP7HcxMhDDItrbtwVeLg/cY2JnKnrcFkmiswNA==}
|
|
||||||
|
|
||||||
shebang-command@2.0.0:
|
shebang-command@2.0.0:
|
||||||
resolution: {integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==}
|
resolution: {integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==}
|
||||||
engines: {node: '>=8'}
|
engines: {node: '>=8'}
|
||||||
@@ -3926,8 +3829,8 @@ packages:
|
|||||||
resolution: {gitHosted: true, integrity: sha512-4nRJ9eBOdd+mT9KaqEhUNya8bh/zaHHAJMBRgFR62KxSZ0S77mcjkB6Bz2xmHqPdYrhbi58aD6UcybEp4a6UyA==, tarball: https://codeload.github.com/clash-verge-rev/tauri-plugin-mihomo/tar.gz/7e4fa8642cf6c394ed88b5a969420d8eab60087f}
|
resolution: {gitHosted: true, integrity: sha512-4nRJ9eBOdd+mT9KaqEhUNya8bh/zaHHAJMBRgFR62KxSZ0S77mcjkB6Bz2xmHqPdYrhbi58aD6UcybEp4a6UyA==, tarball: https://codeload.github.com/clash-verge-rev/tauri-plugin-mihomo/tar.gz/7e4fa8642cf6c394ed88b5a969420d8eab60087f}
|
||||||
version: 0.7.1
|
version: 0.7.1
|
||||||
|
|
||||||
terser@5.51.2:
|
terser@5.51.3:
|
||||||
resolution: {integrity: sha512-bWnjSNscmuI+GJze6ZupnHP8G/cTcsJF+bXCeQknk2SHQsgbNJnLrqiH9jZ2W4STPVXH2mDKKRX3iwPhc9Cn/Q==}
|
resolution: {integrity: sha512-j5jPZZ6Sz0Eg2unusKhdRzUhUlHXJ3Bw2AkIXyJ6AqajWwihUlZOdJS+KSnZzmtVk6mFGdm3hHg0+M2sgyEz5Q==}
|
||||||
engines: {node: '>=10'}
|
engines: {node: '>=10'}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
|
|
||||||
@@ -5150,12 +5053,13 @@ snapshots:
|
|||||||
'@eslint-react/ast@5.20.5(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)':
|
'@eslint-react/ast@5.20.5(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@typescript-eslint/types': 8.74.0
|
'@typescript-eslint/types': 8.74.0
|
||||||
'@typescript-eslint/typescript-estree': 8.70.0(typescript@6.0.3)
|
'@typescript-eslint/typescript-estree': 8.74.0(typescript@6.0.3)
|
||||||
'@typescript-eslint/utils': 8.70.0(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
'@typescript-eslint/utils': 8.74.0(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
||||||
eslint: 10.16.0(jiti@2.7.0)
|
eslint: 10.16.0(jiti@2.7.0)
|
||||||
string-ts: 2.3.1
|
string-ts: 2.3.1
|
||||||
typescript: 6.0.3
|
typescript: 6.0.3
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
|
- '@typescript/native'
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
'@eslint-react/core@5.20.5(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)':
|
'@eslint-react/core@5.20.5(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)':
|
||||||
@@ -5166,11 +5070,12 @@ snapshots:
|
|||||||
'@eslint-react/var': 5.20.5(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
'@eslint-react/var': 5.20.5(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
||||||
'@typescript-eslint/scope-manager': 8.74.0
|
'@typescript-eslint/scope-manager': 8.74.0
|
||||||
'@typescript-eslint/types': 8.74.0
|
'@typescript-eslint/types': 8.74.0
|
||||||
'@typescript-eslint/utils': 8.70.0(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
'@typescript-eslint/utils': 8.74.0(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
||||||
eslint: 10.16.0(jiti@2.7.0)
|
eslint: 10.16.0(jiti@2.7.0)
|
||||||
ts-pattern: 5.9.0
|
ts-pattern: 5.9.0
|
||||||
typescript: 6.0.3
|
typescript: 6.0.3
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
|
- '@typescript/native'
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
'@eslint-react/eslint-plugin@5.20.5(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)':
|
'@eslint-react/eslint-plugin@5.20.5(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)':
|
||||||
@@ -5185,14 +5090,16 @@ snapshots:
|
|||||||
eslint-plugin-react-x: 5.20.5(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
eslint-plugin-react-x: 5.20.5(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
||||||
typescript: 6.0.3
|
typescript: 6.0.3
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
|
- '@typescript/native'
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
'@eslint-react/eslint@5.20.5(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)':
|
'@eslint-react/eslint@5.20.5(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@typescript-eslint/utils': 8.70.0(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
'@typescript-eslint/utils': 8.74.0(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
||||||
eslint: 10.16.0(jiti@2.7.0)
|
eslint: 10.16.0(jiti@2.7.0)
|
||||||
typescript: 6.0.3
|
typescript: 6.0.3
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
|
- '@typescript/native'
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
'@eslint-react/jsx@5.20.5(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)':
|
'@eslint-react/jsx@5.20.5(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)':
|
||||||
@@ -5202,22 +5109,24 @@ snapshots:
|
|||||||
'@eslint-react/shared': 5.20.5(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
'@eslint-react/shared': 5.20.5(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
||||||
'@eslint-react/var': 5.20.5(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
'@eslint-react/var': 5.20.5(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
||||||
'@typescript-eslint/types': 8.74.0
|
'@typescript-eslint/types': 8.74.0
|
||||||
'@typescript-eslint/utils': 8.70.0(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
'@typescript-eslint/utils': 8.74.0(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
||||||
eslint: 10.16.0(jiti@2.7.0)
|
eslint: 10.16.0(jiti@2.7.0)
|
||||||
ts-pattern: 5.9.0
|
ts-pattern: 5.9.0
|
||||||
typescript: 6.0.3
|
typescript: 6.0.3
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
|
- '@typescript/native'
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
'@eslint-react/shared@5.20.5(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)':
|
'@eslint-react/shared@5.20.5(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@eslint-react/eslint': 5.20.5(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
'@eslint-react/eslint': 5.20.5(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
||||||
'@typescript-eslint/utils': 8.70.0(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
'@typescript-eslint/utils': 8.74.0(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
||||||
eslint: 10.16.0(jiti@2.7.0)
|
eslint: 10.16.0(jiti@2.7.0)
|
||||||
ts-pattern: 5.9.0
|
ts-pattern: 5.9.0
|
||||||
typescript: 6.0.3
|
typescript: 6.0.3
|
||||||
zod: 4.6.5
|
zod: 4.6.5
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
|
- '@typescript/native'
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
'@eslint-react/var@5.20.5(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)':
|
'@eslint-react/var@5.20.5(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)':
|
||||||
@@ -5226,11 +5135,12 @@ snapshots:
|
|||||||
'@eslint-react/eslint': 5.20.5(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
'@eslint-react/eslint': 5.20.5(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
||||||
'@typescript-eslint/scope-manager': 8.74.0
|
'@typescript-eslint/scope-manager': 8.74.0
|
||||||
'@typescript-eslint/types': 8.74.0
|
'@typescript-eslint/types': 8.74.0
|
||||||
'@typescript-eslint/utils': 8.70.0(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
'@typescript-eslint/utils': 8.74.0(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
||||||
eslint: 10.16.0(jiti@2.7.0)
|
eslint: 10.16.0(jiti@2.7.0)
|
||||||
ts-pattern: 5.9.0
|
ts-pattern: 5.9.0
|
||||||
typescript: 6.0.3
|
typescript: 6.0.3
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
|
- '@typescript/native'
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
'@eslint/config-array@0.23.7':
|
'@eslint/config-array@0.23.7':
|
||||||
@@ -5995,15 +5905,6 @@ snapshots:
|
|||||||
- '@typescript/native'
|
- '@typescript/native'
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
'@typescript-eslint/project-service@8.70.0(typescript@6.0.3)':
|
|
||||||
dependencies:
|
|
||||||
'@typescript-eslint/tsconfig-utils': 8.70.0(typescript@6.0.3)
|
|
||||||
'@typescript-eslint/types': 8.74.0
|
|
||||||
debug: 4.4.3
|
|
||||||
typescript: 6.0.3
|
|
||||||
transitivePeerDependencies:
|
|
||||||
- supports-color
|
|
||||||
|
|
||||||
'@typescript-eslint/project-service@8.74.0(typescript@6.0.3)':
|
'@typescript-eslint/project-service@8.74.0(typescript@6.0.3)':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@typescript-eslint/tsconfig-utils': 8.74.0(typescript@6.0.3)
|
'@typescript-eslint/tsconfig-utils': 8.74.0(typescript@6.0.3)
|
||||||
@@ -6013,36 +5914,15 @@ snapshots:
|
|||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
'@typescript-eslint/scope-manager@8.70.0':
|
|
||||||
dependencies:
|
|
||||||
'@typescript-eslint/types': 8.70.0
|
|
||||||
'@typescript-eslint/visitor-keys': 8.70.0
|
|
||||||
|
|
||||||
'@typescript-eslint/scope-manager@8.74.0':
|
'@typescript-eslint/scope-manager@8.74.0':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@typescript-eslint/types': 8.74.0
|
'@typescript-eslint/types': 8.74.0
|
||||||
'@typescript-eslint/visitor-keys': 8.74.0
|
'@typescript-eslint/visitor-keys': 8.74.0
|
||||||
|
|
||||||
'@typescript-eslint/tsconfig-utils@8.70.0(typescript@6.0.3)':
|
|
||||||
dependencies:
|
|
||||||
typescript: 6.0.3
|
|
||||||
|
|
||||||
'@typescript-eslint/tsconfig-utils@8.74.0(typescript@6.0.3)':
|
'@typescript-eslint/tsconfig-utils@8.74.0(typescript@6.0.3)':
|
||||||
dependencies:
|
dependencies:
|
||||||
typescript: 6.0.3
|
typescript: 6.0.3
|
||||||
|
|
||||||
'@typescript-eslint/type-utils@8.70.0(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)':
|
|
||||||
dependencies:
|
|
||||||
'@typescript-eslint/types': 8.70.0
|
|
||||||
'@typescript-eslint/typescript-estree': 8.70.0(typescript@6.0.3)
|
|
||||||
'@typescript-eslint/utils': 8.70.0(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
|
||||||
debug: 4.4.3
|
|
||||||
eslint: 10.16.0(jiti@2.7.0)
|
|
||||||
ts-api-utils: 2.5.0(typescript@6.0.3)
|
|
||||||
typescript: 6.0.3
|
|
||||||
transitivePeerDependencies:
|
|
||||||
- supports-color
|
|
||||||
|
|
||||||
'@typescript-eslint/type-utils@8.74.0(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)':
|
'@typescript-eslint/type-utils@8.74.0(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@typescript-eslint/types': 8.74.0
|
'@typescript-eslint/types': 8.74.0
|
||||||
@@ -6056,25 +5936,8 @@ snapshots:
|
|||||||
- '@typescript/native'
|
- '@typescript/native'
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
'@typescript-eslint/types@8.70.0': {}
|
|
||||||
|
|
||||||
'@typescript-eslint/types@8.74.0': {}
|
'@typescript-eslint/types@8.74.0': {}
|
||||||
|
|
||||||
'@typescript-eslint/typescript-estree@8.70.0(typescript@6.0.3)':
|
|
||||||
dependencies:
|
|
||||||
'@typescript-eslint/project-service': 8.70.0(typescript@6.0.3)
|
|
||||||
'@typescript-eslint/tsconfig-utils': 8.70.0(typescript@6.0.3)
|
|
||||||
'@typescript-eslint/types': 8.70.0
|
|
||||||
'@typescript-eslint/visitor-keys': 8.70.0
|
|
||||||
debug: 4.4.3
|
|
||||||
minimatch: 10.2.6
|
|
||||||
semver: 7.8.5
|
|
||||||
tinyglobby: 0.2.17
|
|
||||||
ts-api-utils: 2.5.0(typescript@6.0.3)
|
|
||||||
typescript: 6.0.3
|
|
||||||
transitivePeerDependencies:
|
|
||||||
- supports-color
|
|
||||||
|
|
||||||
'@typescript-eslint/typescript-estree@8.74.0(typescript@6.0.3)':
|
'@typescript-eslint/typescript-estree@8.74.0(typescript@6.0.3)':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@typescript-eslint/project-service': 8.74.0(typescript@6.0.3)
|
'@typescript-eslint/project-service': 8.74.0(typescript@6.0.3)
|
||||||
@@ -6090,17 +5953,6 @@ snapshots:
|
|||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
'@typescript-eslint/utils@8.70.0(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)':
|
|
||||||
dependencies:
|
|
||||||
'@eslint-community/eslint-utils': 4.10.1(eslint@10.16.0(jiti@2.7.0))
|
|
||||||
'@typescript-eslint/scope-manager': 8.70.0
|
|
||||||
'@typescript-eslint/types': 8.70.0
|
|
||||||
'@typescript-eslint/typescript-estree': 8.70.0(typescript@6.0.3)
|
|
||||||
eslint: 10.16.0(jiti@2.7.0)
|
|
||||||
typescript: 6.0.3
|
|
||||||
transitivePeerDependencies:
|
|
||||||
- supports-color
|
|
||||||
|
|
||||||
'@typescript-eslint/utils@8.74.0(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)':
|
'@typescript-eslint/utils@8.74.0(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@eslint-community/eslint-utils': 4.10.1(eslint@10.16.0(jiti@2.7.0))
|
'@eslint-community/eslint-utils': 4.10.1(eslint@10.16.0(jiti@2.7.0))
|
||||||
@@ -6113,11 +5965,6 @@ snapshots:
|
|||||||
- '@typescript/native'
|
- '@typescript/native'
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
'@typescript-eslint/visitor-keys@8.70.0':
|
|
||||||
dependencies:
|
|
||||||
'@typescript-eslint/types': 8.70.0
|
|
||||||
eslint-visitor-keys: 5.0.1
|
|
||||||
|
|
||||||
'@typescript-eslint/visitor-keys@8.74.0':
|
'@typescript-eslint/visitor-keys@8.74.0':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@typescript-eslint/types': 8.74.0
|
'@typescript-eslint/types': 8.74.0
|
||||||
@@ -6195,7 +6042,7 @@ snapshots:
|
|||||||
'@unrs/resolver-binding-win32-x64-msvc@1.12.2':
|
'@unrs/resolver-binding-win32-x64-msvc@1.12.2':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@vitejs/plugin-legacy@8.2.3(terser@5.51.2)(vite@8.3.3(@types/node@26.6.5)(jiti@2.7.0)(sass@1.104.1)(terser@5.51.2)(yaml@2.9.1))':
|
'@vitejs/plugin-legacy@8.2.3(terser@5.51.3)(vite@8.3.3(@types/node@26.6.5)(jiti@2.7.0)(sass@1.104.1)(terser@5.51.3)(yaml@2.9.1))':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@babel/core': 7.29.7
|
'@babel/core': 7.29.7
|
||||||
'@babel/plugin-transform-dynamic-import': 7.29.7(@babel/core@7.29.7)
|
'@babel/plugin-transform-dynamic-import': 7.29.7(@babel/core@7.29.7)
|
||||||
@@ -6206,27 +6053,27 @@ snapshots:
|
|||||||
browserslist: 4.29.0
|
browserslist: 4.29.0
|
||||||
browserslist-to-esbuild: 2.1.1(browserslist@4.29.0)
|
browserslist-to-esbuild: 2.1.1(browserslist@4.29.0)
|
||||||
core-js: 3.50.0
|
core-js: 3.50.0
|
||||||
magic-string: 1.4.1
|
magic-string: 1.4.5
|
||||||
regenerator-runtime: 0.14.1
|
regenerator-runtime: 0.14.1
|
||||||
systemjs: 6.15.1
|
systemjs: 6.15.1
|
||||||
terser: 5.51.2
|
terser: 5.51.3
|
||||||
vite: 8.3.3(@types/node@26.6.5)(jiti@2.7.0)(sass@1.104.1)(terser@5.51.2)(yaml@2.9.1)
|
vite: 8.3.3(@types/node@26.6.5)(jiti@2.7.0)(sass@1.104.1)(terser@5.51.3)(yaml@2.9.1)
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
'@vitejs/plugin-react@6.1.1(vite@8.3.3(@types/node@26.6.5)(jiti@2.7.0)(sass@1.104.1)(terser@5.51.2)(yaml@2.9.1))':
|
'@vitejs/plugin-react@6.1.1(vite@8.3.3(@types/node@26.6.5)(jiti@2.7.0)(sass@1.104.1)(terser@5.51.3)(yaml@2.9.1))':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@rolldown/pluginutils': 1.0.1
|
'@rolldown/pluginutils': 1.0.1
|
||||||
vite: 8.3.3(@types/node@26.6.5)(jiti@2.7.0)(sass@1.104.1)(terser@5.51.2)(yaml@2.9.1)
|
vite: 8.3.3(@types/node@26.6.5)(jiti@2.7.0)(sass@1.104.1)(terser@5.51.3)(yaml@2.9.1)
|
||||||
|
|
||||||
'@vitest/mocker@5.1.2(vite@8.3.3(@types/node@26.6.5)(jiti@2.7.0)(sass@1.104.1)(terser@5.51.2)(yaml@2.9.1))':
|
'@vitest/mocker@5.1.2(vite@8.3.3(@types/node@26.6.5)(jiti@2.7.0)(sass@1.104.1)(terser@5.51.3)(yaml@2.9.1))':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@jridgewell/trace-mapping': 0.3.31
|
'@jridgewell/trace-mapping': 0.3.31
|
||||||
'@vitest/spy': 5.1.2
|
'@vitest/spy': 5.1.2
|
||||||
estree-walker: 3.0.3
|
estree-walker: 3.0.3
|
||||||
magic-string: 1.4.5
|
magic-string: 1.4.5
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
vite: 8.3.3(@types/node@26.6.5)(jiti@2.7.0)(sass@1.104.1)(terser@5.51.2)(yaml@2.9.1)
|
vite: 8.3.3(@types/node@26.6.5)(jiti@2.7.0)(sass@1.104.1)(terser@5.51.3)(yaml@2.9.1)
|
||||||
|
|
||||||
'@vitest/spy@5.1.2': {}
|
'@vitest/spy@5.1.2': {}
|
||||||
|
|
||||||
@@ -6390,8 +6237,6 @@ snapshots:
|
|||||||
memoizee: 0.4.17
|
memoizee: 0.4.17
|
||||||
timers-ext: 0.1.8
|
timers-ext: 0.1.8
|
||||||
|
|
||||||
client-only@0.0.1: {}
|
|
||||||
|
|
||||||
clsx@2.1.1: {}
|
clsx@2.1.1: {}
|
||||||
|
|
||||||
combined-stream@1.0.8:
|
combined-stream@1.0.8:
|
||||||
@@ -6564,7 +6409,7 @@ snapshots:
|
|||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
unrs-resolver: 1.12.2
|
unrs-resolver: 1.12.2
|
||||||
|
|
||||||
eslint-import-resolver-typescript@4.4.5(eslint-plugin-import-x@4.18.1(@typescript-eslint/utils@8.70.0(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3))(eslint@10.16.0(jiti@2.7.0)))(eslint@10.16.0(jiti@2.7.0)):
|
eslint-import-resolver-typescript@4.4.5(eslint-plugin-import-x@4.18.1(@typescript-eslint/utils@8.74.0(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3))(eslint@10.16.0(jiti@2.7.0)))(eslint@10.16.0(jiti@2.7.0)):
|
||||||
dependencies:
|
dependencies:
|
||||||
debug: 4.4.3
|
debug: 4.4.3
|
||||||
eslint: 10.16.0(jiti@2.7.0)
|
eslint: 10.16.0(jiti@2.7.0)
|
||||||
@@ -6575,7 +6420,7 @@ snapshots:
|
|||||||
tinyglobby: 0.2.17
|
tinyglobby: 0.2.17
|
||||||
unrs-resolver: 1.12.2
|
unrs-resolver: 1.12.2
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
eslint-plugin-import-x: 4.18.1(@typescript-eslint/utils@8.70.0(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3))(eslint@10.16.0(jiti@2.7.0))
|
eslint-plugin-import-x: 4.18.1(@typescript-eslint/utils@8.74.0(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3))(eslint@10.16.0(jiti@2.7.0))
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
@@ -6586,7 +6431,7 @@ snapshots:
|
|||||||
eslint: 10.16.0(jiti@2.7.0)
|
eslint: 10.16.0(jiti@2.7.0)
|
||||||
eslint-type-tracer: 0.5.2(eslint@10.16.0(jiti@2.7.0))
|
eslint-type-tracer: 0.5.2(eslint@10.16.0(jiti@2.7.0))
|
||||||
|
|
||||||
eslint-plugin-import-x@4.18.1(@typescript-eslint/utils@8.70.0(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3))(eslint@10.16.0(jiti@2.7.0)):
|
eslint-plugin-import-x@4.18.1(@typescript-eslint/utils@8.74.0(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3))(eslint@10.16.0(jiti@2.7.0)):
|
||||||
dependencies:
|
dependencies:
|
||||||
'@typescript-eslint/types': 8.74.0
|
'@typescript-eslint/types': 8.74.0
|
||||||
cjs-module-lexer: 2.3.0
|
cjs-module-lexer: 2.3.0
|
||||||
@@ -6601,7 +6446,7 @@ snapshots:
|
|||||||
stable-hash-x: 0.2.0
|
stable-hash-x: 0.2.0
|
||||||
unrs-resolver: 1.12.2
|
unrs-resolver: 1.12.2
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
'@typescript-eslint/utils': 8.70.0(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
'@typescript-eslint/utils': 8.74.0(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
@@ -6626,11 +6471,12 @@ snapshots:
|
|||||||
'@eslint-react/shared': 5.20.5(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
'@eslint-react/shared': 5.20.5(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
||||||
'@eslint-react/var': 5.20.5(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
'@eslint-react/var': 5.20.5(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
||||||
'@typescript-eslint/types': 8.74.0
|
'@typescript-eslint/types': 8.74.0
|
||||||
'@typescript-eslint/utils': 8.70.0(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
'@typescript-eslint/utils': 8.74.0(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
||||||
compare-versions: 6.1.1
|
compare-versions: 6.1.1
|
||||||
eslint: 10.16.0(jiti@2.7.0)
|
eslint: 10.16.0(jiti@2.7.0)
|
||||||
typescript: 6.0.3
|
typescript: 6.0.3
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
|
- '@typescript/native'
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
eslint-plugin-react-hooks@7.1.1(eslint@10.16.0(jiti@2.7.0)):
|
eslint-plugin-react-hooks@7.1.1(eslint@10.16.0(jiti@2.7.0)):
|
||||||
@@ -6652,10 +6498,11 @@ snapshots:
|
|||||||
'@eslint-react/jsx': 5.20.5(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
'@eslint-react/jsx': 5.20.5(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
||||||
'@eslint-react/shared': 5.20.5(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
'@eslint-react/shared': 5.20.5(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
||||||
'@typescript-eslint/types': 8.74.0
|
'@typescript-eslint/types': 8.74.0
|
||||||
'@typescript-eslint/utils': 8.70.0(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
'@typescript-eslint/utils': 8.74.0(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
||||||
eslint: 10.16.0(jiti@2.7.0)
|
eslint: 10.16.0(jiti@2.7.0)
|
||||||
typescript: 6.0.3
|
typescript: 6.0.3
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
|
- '@typescript/native'
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
eslint-plugin-react-naming-convention@5.20.5(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3):
|
eslint-plugin-react-naming-convention@5.20.5(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3):
|
||||||
@@ -6666,11 +6513,12 @@ snapshots:
|
|||||||
'@eslint-react/shared': 5.20.5(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
'@eslint-react/shared': 5.20.5(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
||||||
'@eslint-react/var': 5.20.5(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
'@eslint-react/var': 5.20.5(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
||||||
'@typescript-eslint/types': 8.74.0
|
'@typescript-eslint/types': 8.74.0
|
||||||
'@typescript-eslint/utils': 8.70.0(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
'@typescript-eslint/utils': 8.74.0(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
||||||
eslint: 10.16.0(jiti@2.7.0)
|
eslint: 10.16.0(jiti@2.7.0)
|
||||||
ts-pattern: 5.9.0
|
ts-pattern: 5.9.0
|
||||||
typescript: 6.0.3
|
typescript: 6.0.3
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
|
- '@typescript/native'
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
eslint-plugin-react-refresh@0.5.7(eslint@10.16.0(jiti@2.7.0)):
|
eslint-plugin-react-refresh@0.5.7(eslint@10.16.0(jiti@2.7.0)):
|
||||||
@@ -6685,10 +6533,11 @@ snapshots:
|
|||||||
'@eslint-react/shared': 5.20.5(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
'@eslint-react/shared': 5.20.5(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
||||||
'@eslint-react/var': 5.20.5(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
'@eslint-react/var': 5.20.5(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
||||||
'@typescript-eslint/types': 8.74.0
|
'@typescript-eslint/types': 8.74.0
|
||||||
'@typescript-eslint/utils': 8.70.0(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
'@typescript-eslint/utils': 8.74.0(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
||||||
eslint: 10.16.0(jiti@2.7.0)
|
eslint: 10.16.0(jiti@2.7.0)
|
||||||
typescript: 6.0.3
|
typescript: 6.0.3
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
|
- '@typescript/native'
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
eslint-plugin-react-web-api@5.20.5(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3):
|
eslint-plugin-react-web-api@5.20.5(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3):
|
||||||
@@ -6699,11 +6548,12 @@ snapshots:
|
|||||||
'@eslint-react/shared': 5.20.5(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
'@eslint-react/shared': 5.20.5(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
||||||
'@eslint-react/var': 5.20.5(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
'@eslint-react/var': 5.20.5(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
||||||
'@typescript-eslint/types': 8.74.0
|
'@typescript-eslint/types': 8.74.0
|
||||||
'@typescript-eslint/utils': 8.70.0(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
'@typescript-eslint/utils': 8.74.0(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
||||||
eslint: 10.16.0(jiti@2.7.0)
|
eslint: 10.16.0(jiti@2.7.0)
|
||||||
ts-pattern: 5.9.0
|
ts-pattern: 5.9.0
|
||||||
typescript: 6.0.3
|
typescript: 6.0.3
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
|
- '@typescript/native'
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
eslint-plugin-react-x@5.20.5(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3):
|
eslint-plugin-react-x@5.20.5(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3):
|
||||||
@@ -6715,10 +6565,10 @@ snapshots:
|
|||||||
'@eslint-react/shared': 5.20.5(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
'@eslint-react/shared': 5.20.5(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
||||||
'@eslint-react/var': 5.20.5(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
'@eslint-react/var': 5.20.5(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
||||||
'@typescript-eslint/scope-manager': 8.74.0
|
'@typescript-eslint/scope-manager': 8.74.0
|
||||||
'@typescript-eslint/type-utils': 8.70.0(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
'@typescript-eslint/type-utils': 8.74.0(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
||||||
'@typescript-eslint/types': 8.74.0
|
'@typescript-eslint/types': 8.74.0
|
||||||
'@typescript-eslint/typescript-estree': 8.70.0(typescript@6.0.3)
|
'@typescript-eslint/typescript-estree': 8.74.0(typescript@6.0.3)
|
||||||
'@typescript-eslint/utils': 8.70.0(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
'@typescript-eslint/utils': 8.74.0(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
||||||
compare-versions: 6.1.1
|
compare-versions: 6.1.1
|
||||||
eslint: 10.16.0(jiti@2.7.0)
|
eslint: 10.16.0(jiti@2.7.0)
|
||||||
string-ts: 2.3.1
|
string-ts: 2.3.1
|
||||||
@@ -6726,16 +6576,7 @@ snapshots:
|
|||||||
ts-pattern: 5.9.0
|
ts-pattern: 5.9.0
|
||||||
typescript: 6.0.3
|
typescript: 6.0.3
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- '@typescript/native'
|
||||||
|
|
||||||
eslint-plugin-sukka@10.2.0(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3):
|
|
||||||
dependencies:
|
|
||||||
'@typescript-eslint/types': 8.74.0
|
|
||||||
'@typescript-eslint/utils': 8.70.0(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3)
|
|
||||||
eslint: 10.16.0(jiti@2.7.0)
|
|
||||||
foxts: 5.9.1
|
|
||||||
typescript: 6.0.3
|
|
||||||
transitivePeerDependencies:
|
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
eslint-plugin-unused-imports@4.4.1(@typescript-eslint/eslint-plugin@8.74.0(@typescript-eslint/parser@8.74.0(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3))(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3))(eslint@10.16.0(jiti@2.7.0)):
|
eslint-plugin-unused-imports@4.4.1(@typescript-eslint/eslint-plugin@8.74.0(@typescript-eslint/parser@8.74.0(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3))(eslint@10.16.0(jiti@2.7.0))(typescript@6.0.3))(eslint@10.16.0(jiti@2.7.0)):
|
||||||
@@ -6835,8 +6676,6 @@ snapshots:
|
|||||||
d: 1.0.2
|
d: 1.0.2
|
||||||
es5-ext: 0.10.64
|
es5-ext: 0.10.64
|
||||||
|
|
||||||
event-target-bus@1.1.0: {}
|
|
||||||
|
|
||||||
expect-type@1.4.0: {}
|
expect-type@1.4.0: {}
|
||||||
|
|
||||||
ext@1.7.0:
|
ext@1.7.0:
|
||||||
@@ -6847,8 +6686,6 @@ snapshots:
|
|||||||
|
|
||||||
fast-deep-equal@3.1.3: {}
|
fast-deep-equal@3.1.3: {}
|
||||||
|
|
||||||
fast-fnv1a@1.0.0: {}
|
|
||||||
|
|
||||||
fast-json-stable-stringify@2.1.0: {}
|
fast-json-stable-stringify@2.1.0: {}
|
||||||
|
|
||||||
fast-levenshtein@2.0.6: {}
|
fast-levenshtein@2.0.6: {}
|
||||||
@@ -6880,8 +6717,6 @@ snapshots:
|
|||||||
|
|
||||||
flatted@3.4.4: {}
|
flatted@3.4.4: {}
|
||||||
|
|
||||||
fnv1a52@1.0.0: {}
|
|
||||||
|
|
||||||
follow-redirects@1.16.2(debug@4.4.3):
|
follow-redirects@1.16.2(debug@4.4.3):
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
debug: 4.4.3
|
debug: 4.4.3
|
||||||
@@ -6904,20 +6739,6 @@ snapshots:
|
|||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- '@clack/prompts'
|
- '@clack/prompts'
|
||||||
|
|
||||||
foxact@0.3.12(react-dom@19.3.1(react@19.3.1))(react@19.3.1):
|
|
||||||
dependencies:
|
|
||||||
client-only: 0.0.1
|
|
||||||
event-target-bus: 1.1.0
|
|
||||||
server-only: 0.0.1
|
|
||||||
optionalDependencies:
|
|
||||||
react: 19.3.1
|
|
||||||
react-dom: 19.3.1(react@19.3.1)
|
|
||||||
|
|
||||||
foxts@5.9.1:
|
|
||||||
dependencies:
|
|
||||||
fast-fnv1a: 1.0.0
|
|
||||||
fnv1a52: 1.0.0
|
|
||||||
|
|
||||||
fsevents@2.3.3:
|
fsevents@2.3.3:
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
@@ -7278,10 +7099,6 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
es5-ext: 0.10.64
|
es5-ext: 0.10.64
|
||||||
|
|
||||||
magic-string@1.4.1:
|
|
||||||
dependencies:
|
|
||||||
'@jridgewell/sourcemap-codec': 1.6.0
|
|
||||||
|
|
||||||
magic-string@1.4.5:
|
magic-string@1.4.5:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@jridgewell/sourcemap-codec': 1.6.0
|
'@jridgewell/sourcemap-codec': 1.6.0
|
||||||
@@ -7533,10 +7350,6 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
mime-db: 1.52.0
|
mime-db: 1.52.0
|
||||||
|
|
||||||
minimatch@10.2.6:
|
|
||||||
dependencies:
|
|
||||||
brace-expansion: 5.0.12
|
|
||||||
|
|
||||||
minimatch@11.0.9:
|
minimatch@11.0.9:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@isaacs/nonrecursive-glob-match': 1.1.0
|
'@isaacs/nonrecursive-glob-match': 1.1.0
|
||||||
@@ -7921,8 +7734,6 @@ snapshots:
|
|||||||
|
|
||||||
semver@7.8.5: {}
|
semver@7.8.5: {}
|
||||||
|
|
||||||
server-only@0.0.1: {}
|
|
||||||
|
|
||||||
shebang-command@2.0.0:
|
shebang-command@2.0.0:
|
||||||
dependencies:
|
dependencies:
|
||||||
shebang-regex: 3.0.0
|
shebang-regex: 3.0.0
|
||||||
@@ -7994,7 +7805,7 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
'@tauri-apps/api': 2.12.5
|
'@tauri-apps/api': 2.12.5
|
||||||
|
|
||||||
terser@5.51.2:
|
terser@5.51.3:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@jridgewell/source-map': 0.3.11
|
'@jridgewell/source-map': 0.3.11
|
||||||
acorn: 8.18.0
|
acorn: 8.18.0
|
||||||
@@ -8177,18 +7988,18 @@ snapshots:
|
|||||||
'@types/unist': 3.0.3
|
'@types/unist': 3.0.3
|
||||||
vfile-message: 4.0.3
|
vfile-message: 4.0.3
|
||||||
|
|
||||||
vite-plugin-svgr@5.2.0(typescript@6.0.3)(vite@8.3.3(@types/node@26.6.5)(jiti@2.7.0)(sass@1.104.1)(terser@5.51.2)(yaml@2.9.1)):
|
vite-plugin-svgr@5.2.0(typescript@6.0.3)(vite@8.3.3(@types/node@26.6.5)(jiti@2.7.0)(sass@1.104.1)(terser@5.51.3)(yaml@2.9.1)):
|
||||||
dependencies:
|
dependencies:
|
||||||
'@rollup/pluginutils': 5.4.0
|
'@rollup/pluginutils': 5.4.0
|
||||||
'@svgr/core': 8.1.0(typescript@6.0.3)
|
'@svgr/core': 8.1.0(typescript@6.0.3)
|
||||||
'@svgr/plugin-jsx': 8.1.0(@svgr/core@8.1.0(typescript@6.0.3))
|
'@svgr/plugin-jsx': 8.1.0(@svgr/core@8.1.0(typescript@6.0.3))
|
||||||
vite: 8.3.3(@types/node@26.6.5)(jiti@2.7.0)(sass@1.104.1)(terser@5.51.2)(yaml@2.9.1)
|
vite: 8.3.3(@types/node@26.6.5)(jiti@2.7.0)(sass@1.104.1)(terser@5.51.3)(yaml@2.9.1)
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- rollup
|
- rollup
|
||||||
- supports-color
|
- supports-color
|
||||||
- typescript
|
- typescript
|
||||||
|
|
||||||
vite@8.3.3(@types/node@26.6.5)(jiti@2.7.0)(sass@1.104.1)(terser@5.51.2)(yaml@2.9.1):
|
vite@8.3.3(@types/node@26.6.5)(jiti@2.7.0)(sass@1.104.1)(terser@5.51.3)(yaml@2.9.1):
|
||||||
dependencies:
|
dependencies:
|
||||||
lightningcss: 1.33.0
|
lightningcss: 1.33.0
|
||||||
picomatch: 4.0.7
|
picomatch: 4.0.7
|
||||||
@@ -8200,13 +8011,13 @@ snapshots:
|
|||||||
fsevents: 2.3.3
|
fsevents: 2.3.3
|
||||||
jiti: 2.7.0
|
jiti: 2.7.0
|
||||||
sass: 1.104.1
|
sass: 1.104.1
|
||||||
terser: 5.51.2
|
terser: 5.51.3
|
||||||
yaml: 2.9.1
|
yaml: 2.9.1
|
||||||
|
|
||||||
vitest@5.1.2(@types/node@26.6.5)(vite@8.3.3(@types/node@26.6.5)(jiti@2.7.0)(sass@1.104.1)(terser@5.51.2)(yaml@2.9.1)):
|
vitest@5.1.2(@types/node@26.6.5)(vite@8.3.3(@types/node@26.6.5)(jiti@2.7.0)(sass@1.104.1)(terser@5.51.3)(yaml@2.9.1)):
|
||||||
dependencies:
|
dependencies:
|
||||||
'@types/chai': 5.2.3
|
'@types/chai': 5.2.3
|
||||||
'@vitest/mocker': 5.1.2(vite@8.3.3(@types/node@26.6.5)(jiti@2.7.0)(sass@1.104.1)(terser@5.51.2)(yaml@2.9.1))
|
'@vitest/mocker': 5.1.2(vite@8.3.3(@types/node@26.6.5)(jiti@2.7.0)(sass@1.104.1)(terser@5.51.3)(yaml@2.9.1))
|
||||||
chai: 6.3.0
|
chai: 6.3.0
|
||||||
es-module-lexer: 2.3.2
|
es-module-lexer: 2.3.2
|
||||||
expect-type: 1.4.0
|
expect-type: 1.4.0
|
||||||
@@ -8217,7 +8028,7 @@ snapshots:
|
|||||||
tinybench: 6.2.5
|
tinybench: 6.2.5
|
||||||
tinyexec: 1.3.1
|
tinyexec: 1.3.1
|
||||||
tinyglobby: 0.2.17
|
tinyglobby: 0.2.17
|
||||||
vite: 8.3.3(@types/node@26.6.5)(jiti@2.7.0)(sass@1.104.1)(terser@5.51.2)(yaml@2.9.1)
|
vite: 8.3.3(@types/node@26.6.5)(jiti@2.7.0)(sass@1.104.1)(terser@5.51.3)(yaml@2.9.1)
|
||||||
why-is-node-running: 3.2.1
|
why-is-node-running: 3.2.1
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
'@types/node': 26.6.5
|
'@types/node': 26.6.5
|
||||||
|
|||||||
+3
-10
@@ -1,17 +1,10 @@
|
|||||||
# Backend Architecture Guardrails
|
# Backend Architecture Guardrails
|
||||||
|
|
||||||
Follow [Workspace Crate Architecture](../crates/AGENTS.md) when changing
|
Use [Workspace Crate Architecture](../crates/AGENTS.md) when extracting backend
|
||||||
backend capability boundaries, reusable orchestration, or background task
|
capabilities or changing background task ownership.
|
||||||
ownership.
|
|
||||||
|
|
||||||
- **Tauri adapter.** Commands validate transport input, delegate to application
|
|
||||||
use cases, and map results and errors to IPC. Tauri wires dependencies and
|
|
||||||
owns desktop lifecycle, window and tray integration, and event delivery.
|
|
||||||
Keep domain validation and reusable orchestration independent of command
|
|
||||||
handlers and framework state.
|
|
||||||
- **Configuration and effects.** `config` owns source configuration, drafts, and
|
- **Configuration and effects.** `config` owns source configuration, drafts, and
|
||||||
persistence coordination. Persistence adapters perform storage and recovery.
|
persistence. The effects layer classifies every Verge patch field, including
|
||||||
The effects layer classifies every Verge patch field, including
|
|
||||||
fields without effects and platform-specific fields, and reconciles requested
|
fields without effects and platform-specific fields, and reconciles requested
|
||||||
state in dependency order. Publish rollbackable state after persistence and
|
state in dependency order. Publish rollbackable state after persistence and
|
||||||
commit. On failure, preserve already applied runtime effects, independently
|
commit. On failure, preserve already applied runtime effects, independently
|
||||||
|
|||||||
@@ -36,9 +36,6 @@ clash-verge-media-unlock = { workspace = true }
|
|||||||
clash-verge-logging = { workspace = true }
|
clash-verge-logging = { workspace = true }
|
||||||
clash-verge-i18n = { workspace = true }
|
clash-verge-i18n = { workspace = true }
|
||||||
clash-verge-limiter = { workspace = true }
|
clash-verge-limiter = { workspace = true }
|
||||||
clash-verge-subscription = { workspace = true }
|
|
||||||
clash-verge-profile = { workspace = true }
|
|
||||||
clash-verge-backup-archive = { workspace = true }
|
|
||||||
tauri-plugin-clash-verge-sysinfo = { workspace = true }
|
tauri-plugin-clash-verge-sysinfo = { workspace = true }
|
||||||
tauri-plugin-clipboard-manager = { workspace = true }
|
tauri-plugin-clipboard-manager = { workspace = true }
|
||||||
tauri = { workspace = true, features = [
|
tauri = { workspace = true, features = [
|
||||||
@@ -79,7 +76,7 @@ tauri-plugin-dialog = "2.8.4"
|
|||||||
tauri-plugin-fs = "2.7.1"
|
tauri-plugin-fs = "2.7.1"
|
||||||
tauri-plugin-deep-link = "2.6.3"
|
tauri-plugin-deep-link = "2.6.3"
|
||||||
tauri-plugin-window-state = "2.5.0"
|
tauri-plugin-window-state = "2.5.0"
|
||||||
zip = { workspace = true }
|
zip = "9.9.0"
|
||||||
flate2 = "1.1.11"
|
flate2 = "1.1.11"
|
||||||
reqwest_dav = "0.4.0"
|
reqwest_dav = "0.4.0"
|
||||||
aes-gcm = { version = "0.11.1" }
|
aes-gcm = { version = "0.11.1" }
|
||||||
@@ -89,7 +86,7 @@ getrandom = "0.4.3"
|
|||||||
futures = { workspace = true }
|
futures = { workspace = true }
|
||||||
gethostname = "1.1.0"
|
gethostname = "1.1.0"
|
||||||
tauri-plugin-notification = "2.8.1"
|
tauri-plugin-notification = "2.8.1"
|
||||||
backon = { version = "1.6.0", features = ["tokio-sleep"] }
|
backon = { version = "1.7.0", features = ["tokio-sleep"] }
|
||||||
tauri-plugin-http = "2.9.0"
|
tauri-plugin-http = "2.9.0"
|
||||||
tracing = { workspace = true }
|
tracing = { workspace = true }
|
||||||
tauri-plugin-devtools = { version = "2.2.3", optional = true }
|
tauri-plugin-devtools = { version = "2.2.3", optional = true }
|
||||||
@@ -100,7 +97,7 @@ clash_verge_service_ipc = { git = "https://github.com/clash-verge-rev/clash-verg
|
|||||||
] }
|
] }
|
||||||
arc-swap = "1.9.5"
|
arc-swap = "1.9.5"
|
||||||
tokio-rustls = "0.26.6"
|
tokio-rustls = "0.26.6"
|
||||||
rustls = { version = "0.23.46", features = ["ring"] }
|
rustls = { version = "0.23.47", features = ["ring"] }
|
||||||
webpki-roots = "1.0.12"
|
webpki-roots = "1.0.12"
|
||||||
dark-light = "3.0.0"
|
dark-light = "3.0.0"
|
||||||
bytes = "1.12.2"
|
bytes = "1.12.2"
|
||||||
@@ -146,7 +143,7 @@ quick-xml = "0.42.0"
|
|||||||
runas = "=1.2.0"
|
runas = "=1.2.0"
|
||||||
winreg = "0.56.0"
|
winreg = "0.56.0"
|
||||||
windows-service = "0.8.1"
|
windows-service = "0.8.1"
|
||||||
windows = { version = "0.62.2", features = [
|
windows = { version = "0.101.0", features = [
|
||||||
"Win32_System_Com",
|
"Win32_System_Com",
|
||||||
"Win32_System_Ole",
|
"Win32_System_Ole",
|
||||||
"Win32_System_TaskScheduler",
|
"Win32_System_TaskScheduler",
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
#![deny(clippy::expect_used, clippy::unwrap_used)]
|
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
if std::env::var("CARGO_CFG_TARGET_OS").as_deref() == Ok("windows")
|
if std::env::var("CARGO_CFG_TARGET_OS").as_deref() == Ok("windows")
|
||||||
&& std::env::var("CARGO_CFG_TARGET_ENV").as_deref() == Ok("msvc")
|
&& std::env::var("CARGO_CFG_TARGET_ENV").as_deref() == Ok("msvc")
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
#![deny(clippy::expect_used, clippy::unwrap_used)]
|
|
||||||
|
|
||||||
// Dev-only target: Tauri ships everything under src/bin/ to /usr/bin in deb/rpm
|
// Dev-only target: Tauri ships everything under src/bin/ to /usr/bin in deb/rpm
|
||||||
// bundles (PR #8131), so this generator must stay an example, never a bin.
|
// bundles (PR #8131), so this generator must stay an example, never a bin.
|
||||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
|||||||
@@ -5,13 +5,12 @@ use crate::core::notify::NoticeStatus;
|
|||||||
use crate::utils::window_manager::WindowManager;
|
use crate::utils::window_manager::WindowManager;
|
||||||
use crate::{
|
use crate::{
|
||||||
config::{
|
config::{
|
||||||
Config, IProfiles, PrfItem, PrfOption, build_remote_profile,
|
Config, IProfiles, PrfItem, PrfOption,
|
||||||
profiles::{
|
profiles::{
|
||||||
PROFILE_WRITE_LOCK, cleanup_profile_files, profiles_append_item_safe,
|
PROFILE_WRITE_LOCK, profiles_append_item_with_filedata_safe, profiles_patch_item_safe,
|
||||||
profiles_append_item_with_filedata_safe, profiles_patch_item_safe, profiles_reorder_safe,
|
profiles_reorder_safe, profiles_save_file_safe,
|
||||||
profiles_save_file_safe, save_profiles,
|
|
||||||
},
|
},
|
||||||
read_profile_item_file,
|
profiles_append_item_safe,
|
||||||
},
|
},
|
||||||
core::{CoreManager, handle, timer::Timer, tray::Tray, validate::ValidationOutcome},
|
core::{CoreManager, handle, timer::Timer, tray::Tray, validate::ValidationOutcome},
|
||||||
feat,
|
feat,
|
||||||
@@ -72,7 +71,7 @@ pub async fn enhance_profiles() -> CmdResult<ValidationOutcome> {
|
|||||||
#[tracing::instrument(skip_all, level = "info", fields(url = %help::mask_url(&url), uid = tracing::field::Empty))]
|
#[tracing::instrument(skip_all, level = "info", fields(url = %help::mask_url(&url), uid = tracing::field::Empty))]
|
||||||
#[specta::specta]
|
#[specta::specta]
|
||||||
pub async fn import_profile(url: std::string::String, option: Option<PrfOption>) -> CmdResult {
|
pub async fn import_profile(url: std::string::String, option: Option<PrfOption>) -> CmdResult {
|
||||||
let item = &mut match build_remote_profile(&url, None, None, option.as_ref()).await {
|
let item = &mut match PrfItem::from_url(&url, None, None, option.as_ref()).await {
|
||||||
Ok(it) => it,
|
Ok(it) => it,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
logging!(error, Type::Cmd, "[导入订阅] 下载失败: {e:#}");
|
logging!(error, Type::Cmd, "[导入订阅] 下载失败: {e:#}");
|
||||||
@@ -160,10 +159,9 @@ pub async fn delete_profile(index: std::string::String) -> CmdResult {
|
|||||||
|
|
||||||
let profiles = Config::profiles().await;
|
let profiles = Config::profiles().await;
|
||||||
let result = profiles
|
let result = profiles
|
||||||
.with_data_modify::<_, _, _, anyhow::Error>(|mut candidate| async move {
|
.with_data_modify(|mut candidate| async move {
|
||||||
let original = candidate.clone();
|
let original = candidate.clone();
|
||||||
let plan = candidate.plan_delete_item(&index)?;
|
let (should_update, plan) = candidate.plan_delete_item(&index)?;
|
||||||
let should_update = plan.deleting_current;
|
|
||||||
let guard = if should_update {
|
let guard = if should_update {
|
||||||
match CoreManager::global()
|
match CoreManager::global()
|
||||||
.update_config_forced_with_profiles(&candidate, &original)
|
.update_config_forced_with_profiles(&candidate, &original)
|
||||||
@@ -173,11 +171,11 @@ pub async fn delete_profile(index: std::string::String) -> CmdResult {
|
|||||||
Err(outcome) => return Ok((original, Err(outcome))),
|
Err(outcome) => return Ok((original, Err(outcome))),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
save_profiles(&candidate).await?;
|
candidate.save_file().await?;
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
let current = candidate.current.clone();
|
let current = candidate.current.clone();
|
||||||
cleanup_profile_files(plan.files).await;
|
plan.cleanup().await;
|
||||||
Ok((candidate, Ok((should_update, current, guard))))
|
Ok((candidate, Ok((should_update, current, guard))))
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
@@ -212,11 +210,15 @@ pub async fn delete_profile(index: std::string::String) -> CmdResult {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn restore_previous_profile(prev_profile: &String) -> CmdResult<()> {
|
async fn restore_previous_profile(prev_profile: &str) -> CmdResult<()> {
|
||||||
logging!(info, Type::Cmd, "尝试恢复到之前的配置: {}", prev_profile);
|
logging!(info, Type::Cmd, "尝试恢复到之前的配置: {}", prev_profile);
|
||||||
|
let restore_profiles = IProfiles {
|
||||||
|
current: Some(prev_profile.into()),
|
||||||
|
items: None,
|
||||||
|
};
|
||||||
Config::profiles()
|
Config::profiles()
|
||||||
.await
|
.await
|
||||||
.edit_draft(|d| d.patch_current(Some(prev_profile)));
|
.edit_draft(|d| d.patch_config(&restore_profiles));
|
||||||
Config::profiles().await.apply();
|
Config::profiles().await.apply();
|
||||||
crate::process::AsyncHandler::spawn(|| async move {
|
crate::process::AsyncHandler::spawn(|| async move {
|
||||||
if let Err(e) = profiles_save_file_safe().await {
|
if let Err(e) = profiles_save_file_safe().await {
|
||||||
@@ -234,7 +236,10 @@ async fn commit_current_profile(profiles: &Draft<IProfiles>, current: Option<Str
|
|||||||
|
|
||||||
profiles
|
profiles
|
||||||
.with_data_modify(|mut committed| async move {
|
.with_data_modify(|mut committed| async move {
|
||||||
committed.patch_current(Some(¤t));
|
committed.patch_config(&IProfiles {
|
||||||
|
current: Some(current),
|
||||||
|
items: None,
|
||||||
|
});
|
||||||
Ok((committed, ()))
|
Ok((committed, ()))
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
@@ -392,12 +397,16 @@ pub async fn patch_profiles_config(profiles: ProfileSelection) -> CmdResult<Vali
|
|||||||
});
|
});
|
||||||
let _profile_write_guard = PROFILE_WRITE_LOCK.lock().await;
|
let _profile_write_guard = PROFILE_WRITE_LOCK.lock().await;
|
||||||
|
|
||||||
|
let profiles = IProfiles {
|
||||||
|
current: profiles.current,
|
||||||
|
items: None,
|
||||||
|
};
|
||||||
let target_profile = profiles.current.as_ref();
|
let target_profile = profiles.current.as_ref();
|
||||||
|
|
||||||
let previous_profile = Config::profiles().await.data_arc().current.clone();
|
let previous_profile = Config::profiles().await.data_arc().current.clone();
|
||||||
|
|
||||||
Config::profiles().await.edit_draft(|d| {
|
Config::profiles().await.edit_draft(|d| {
|
||||||
d.patch_current(target_profile);
|
d.patch_config(&profiles);
|
||||||
});
|
});
|
||||||
|
|
||||||
perform_config_update(target_profile, previous_profile.as_ref())
|
perform_config_update(target_profile, previous_profile.as_ref())
|
||||||
@@ -483,17 +492,20 @@ pub async fn view_profile(index: std::string::String) -> CmdResult {
|
|||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
#[specta::specta]
|
#[specta::specta]
|
||||||
pub async fn read_profile_file(index: std::string::String) -> CmdResult<std::string::String> {
|
pub async fn read_profile_file(index: std::string::String) -> CmdResult<std::string::String> {
|
||||||
let file = {
|
let item = {
|
||||||
let profiles = Config::profiles().await;
|
let profiles = Config::profiles().await;
|
||||||
let profiles_ref = profiles.latest_arc();
|
let profiles_ref = profiles.latest_arc();
|
||||||
profiles_ref
|
PrfItem {
|
||||||
|
file: profiles_ref
|
||||||
.get_item(&index)
|
.get_item(&index)
|
||||||
.with_error_code("PROFILE_READ_FAILED")?
|
.with_error_code("PROFILE_READ_FAILED")?
|
||||||
.file
|
.file
|
||||||
.clone()
|
.to_owned(),
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(file) = file.as_ref() {
|
if let Some(file) = item.file.as_ref() {
|
||||||
let path = dirs::app_profiles_dir()
|
let path = dirs::app_profiles_dir()
|
||||||
.with_error_code("PROFILE_READ_FAILED")?
|
.with_error_code("PROFILE_READ_FAILED")?
|
||||||
.join(file.as_str());
|
.join(file.as_str());
|
||||||
@@ -509,9 +521,7 @@ pub async fn read_profile_file(index: std::string::String) -> CmdResult<std::str
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let data = read_profile_item_file(file.as_deref())
|
let data = item.read_file().await.with_error_code("PROFILE_READ_FAILED")?;
|
||||||
.await
|
|
||||||
.with_error_code("PROFILE_READ_FAILED")?;
|
|
||||||
Ok(data.into())
|
Ok(data.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -565,11 +575,16 @@ mod tests {
|
|||||||
current: Some("a".into()),
|
current: Some("a".into()),
|
||||||
items: Some(vec![profile("a"), profile("b")]),
|
items: Some(vec![profile("a"), profile("b")]),
|
||||||
});
|
});
|
||||||
profiles.edit_draft(|draft| draft.patch_current(Some(&"b".into())));
|
profiles.edit_draft(|draft| {
|
||||||
|
draft.patch_config(&IProfiles {
|
||||||
|
current: Some("b".into()),
|
||||||
|
items: None,
|
||||||
|
});
|
||||||
|
});
|
||||||
profiles
|
profiles
|
||||||
.with_data_modify(|mut committed| async move {
|
.with_data_modify(|mut committed| async move {
|
||||||
committed.items.get_or_insert_with(Vec::new).push(profile("new"));
|
committed.items.get_or_insert_with(Vec::new).push(profile("new"));
|
||||||
Ok::<_, clash_verge_draft::DraftConflict>((committed, ()))
|
Ok((committed, ()))
|
||||||
})
|
})
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ use super::CmdResult;
|
|||||||
use crate::{
|
use crate::{
|
||||||
cmd::StringifyErr as _,
|
cmd::StringifyErr as _,
|
||||||
cmd::validate::{ValidationNoticeTarget, handle_validation_notice},
|
cmd::validate::{ValidationNoticeTarget, handle_validation_notice},
|
||||||
config::{Config, IProfiles, read_profile_item_file},
|
config::{Config, IProfiles, PrfItem},
|
||||||
core::auto_backup::{self, AutoBackupTrigger},
|
core::auto_backup::{self, AutoBackupTrigger},
|
||||||
core::{
|
core::{
|
||||||
CoreManager, handle,
|
CoreManager, handle,
|
||||||
@@ -58,7 +58,13 @@ pub async fn save_profile_file(
|
|||||||
))
|
))
|
||||||
})?;
|
})?;
|
||||||
let original_content = if original_existed {
|
let original_content = if original_existed {
|
||||||
read_profile_item_file(Some(rel_path.as_str())).await.stringify_err()?
|
PrfItem {
|
||||||
|
file: Some(rel_path.clone()),
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
|
.read_file()
|
||||||
|
.await
|
||||||
|
.stringify_err()?
|
||||||
} else {
|
} else {
|
||||||
String::new()
|
String::new()
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
use super::{IClashTemp, IProfiles, IVerge, MixedPort};
|
use super::{IClashTemp, IProfiles, IVerge, MixedPort};
|
||||||
use crate::core::notify::NoticeStatus;
|
use crate::core::notify::NoticeStatus;
|
||||||
use crate::{
|
use crate::{
|
||||||
config::{
|
config::{PrfItem, profiles_append_item_to_safe, runtime::IRuntime},
|
||||||
prfitem::{build_merge_profile, build_script_profile},
|
|
||||||
profiles::{load_profiles, profiles_append_item_to_safe, save_profiles},
|
|
||||||
runtime::IRuntime,
|
|
||||||
},
|
|
||||||
constants::{files, timing},
|
constants::{files, timing},
|
||||||
core::{
|
core::{
|
||||||
CoreManager,
|
CoreManager,
|
||||||
@@ -49,7 +45,7 @@ impl Config {
|
|||||||
Self {
|
Self {
|
||||||
clash_config: Draft::new(IClashTemp::new().await),
|
clash_config: Draft::new(IClashTemp::new().await),
|
||||||
verge_config: Draft::new(IVerge::new().await),
|
verge_config: Draft::new(IVerge::new().await),
|
||||||
profiles_config: Draft::new(load_profiles().await),
|
profiles_config: Draft::new(IProfiles::new().await),
|
||||||
runtime_config: Draft::new(IRuntime::default()),
|
runtime_config: Draft::new(IRuntime::default()),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -141,11 +137,11 @@ impl Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if profiles.latest_arc().get_item("Merge").is_err() {
|
if profiles.latest_arc().get_item("Merge").is_err() {
|
||||||
let merge_item = &mut build_merge_profile(Some("Merge".into()));
|
let merge_item = &mut PrfItem::from_merge(Some("Merge".into()));
|
||||||
profiles_append_item_to_safe(&profiles, merge_item).await?;
|
profiles_append_item_to_safe(&profiles, merge_item).await?;
|
||||||
}
|
}
|
||||||
if profiles.latest_arc().get_item("Script").is_err() {
|
if profiles.latest_arc().get_item("Script").is_err() {
|
||||||
let script_item = &mut build_script_profile(Some("Script".into()));
|
let script_item = &mut PrfItem::from_script(Some("Script".into()));
|
||||||
profiles_append_item_to_safe(&profiles, script_item).await?;
|
profiles_append_item_to_safe(&profiles, script_item).await?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -314,7 +310,7 @@ impl Config {
|
|||||||
let _profile_write = super::profiles::PROFILE_WRITE_LOCK.lock().await;
|
let _profile_write = super::profiles::PROFILE_WRITE_LOCK.lock().await;
|
||||||
let profiles = Self::profiles().await;
|
let profiles = Self::profiles().await;
|
||||||
profiles.apply();
|
profiles.apply();
|
||||||
logging_error!(Type::Config, save_profiles(&profiles.data_arc()).await);
|
logging_error!(Type::Config, profiles.data_arc().save_file().await);
|
||||||
});
|
});
|
||||||
|
|
||||||
let _ = tokio::join!(save_clash_task, save_verge_task, save_profiles_task);
|
let _ = tokio::join!(save_clash_task, save_verge_task, save_profiles_task);
|
||||||
|
|||||||
@@ -12,11 +12,7 @@ pub(crate) mod snapshot;
|
|||||||
mod verge;
|
mod verge;
|
||||||
|
|
||||||
pub(crate) use self::config::Config;
|
pub(crate) use self::config::Config;
|
||||||
pub(crate) use self::prfitem::{
|
pub use self::{clash::*, encrypt::*, mixed_port::*, prfitem::*, profiles::*, verge::*};
|
||||||
build_remote_profile, download_subscription, prepare_remote_refresh, read_profile_item_file,
|
|
||||||
};
|
|
||||||
pub use self::{clash::*, encrypt::*, mixed_port::*, profiles::*, verge::*};
|
|
||||||
pub use clash_verge_profile::{PrfExtra, PrfItem, PrfOption, PrfSelected};
|
|
||||||
|
|
||||||
macro_rules! patch_opt_field {
|
macro_rules! patch_opt_field {
|
||||||
($lv:expr, $rv:expr, $key:tt) => {
|
($lv:expr, $rv:expr, $key:tt) => {
|
||||||
|
|||||||
+280
-206
@@ -1,4 +1,4 @@
|
|||||||
use super::{PrfExtra, PrfItem, PrfOption};
|
use super::patch_opt_field;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
config::profiles,
|
config::profiles,
|
||||||
@@ -9,7 +9,8 @@ use crate::{
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
use anyhow::{Context as _, Result, bail};
|
use anyhow::{Context as _, Result, bail};
|
||||||
use clash_verge_subscription::decode_subscription;
|
use serde::{Deserialize, Serialize};
|
||||||
|
use serde_yaml_ng::Mapping;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use tokio::fs;
|
use tokio::fs;
|
||||||
use tristr::alias::String;
|
use tristr::alias::String;
|
||||||
@@ -17,8 +18,129 @@ use tristr::alias::String;
|
|||||||
use reqwest_dav::re_exports::url::form_urlencoded;
|
use reqwest_dav::re_exports::url::form_urlencoded;
|
||||||
use tauri::Url;
|
use tauri::Url;
|
||||||
|
|
||||||
|
pub(super) fn normalize_profile_home_url(raw: &str) -> Option<String> {
|
||||||
|
let url = Url::parse(raw.trim()).ok()?;
|
||||||
|
|
||||||
|
if !matches!(url.scheme(), "http" | "https") {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
|
url.host_str()?;
|
||||||
|
Some(url.as_str().into())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Deserialize, Serialize, Default, specta::Type)]
|
||||||
|
#[serde(default)]
|
||||||
|
pub struct PrfItem {
|
||||||
|
pub uid: Option<String>,
|
||||||
|
|
||||||
|
/// enum value: remote | local | script | merge
|
||||||
|
#[serde(rename = "type")]
|
||||||
|
pub itype: Option<String>,
|
||||||
|
pub name: Option<String>,
|
||||||
|
pub file: Option<String>,
|
||||||
|
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub desc: Option<String>,
|
||||||
|
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub url: Option<String>,
|
||||||
|
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub selected: Option<Vec<PrfSelected>>,
|
||||||
|
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub extra: Option<PrfExtra>,
|
||||||
|
|
||||||
|
pub updated: Option<usize>,
|
||||||
|
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub option: Option<PrfOption>,
|
||||||
|
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub home: Option<String>,
|
||||||
|
|
||||||
|
#[serde(skip)]
|
||||||
|
pub file_data: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Default, Debug, Clone, Deserialize, Serialize, PartialEq, Eq, specta::Type)]
|
||||||
|
#[serde(default)]
|
||||||
|
pub struct PrfSelected {
|
||||||
|
pub name: Option<String>,
|
||||||
|
pub now: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Default, Debug, Clone, Copy, Deserialize, Serialize, specta::Type)]
|
||||||
|
pub struct PrfExtra {
|
||||||
|
pub upload: u64,
|
||||||
|
pub download: u64,
|
||||||
|
pub total: u64,
|
||||||
|
pub expire: u64,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Default, Debug, Clone, Deserialize, Serialize, PartialEq, Eq, specta::Type)]
|
||||||
|
#[serde(default)]
|
||||||
|
pub struct PrfOption {
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub user_agent: Option<String>,
|
||||||
|
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub with_proxy: Option<bool>,
|
||||||
|
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub self_proxy: Option<bool>,
|
||||||
|
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub update_interval: Option<u64>,
|
||||||
|
|
||||||
|
/// HTTP request timeout in seconds
|
||||||
|
/// default is 60 seconds
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub timeout_seconds: Option<u64>,
|
||||||
|
|
||||||
|
/// default is `false`
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub danger_accept_invalid_certs: Option<bool>,
|
||||||
|
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub allow_auto_update: Option<bool>,
|
||||||
|
pub merge: Option<String>,
|
||||||
|
pub script: Option<String>,
|
||||||
|
pub rules: Option<String>,
|
||||||
|
pub proxies: Option<String>,
|
||||||
|
pub groups: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PrfOption {
|
||||||
|
pub(crate) fn merge(one: Option<&Self>, other: Option<&Self>) -> Option<Self> {
|
||||||
|
match (one, other) {
|
||||||
|
(Some(a_ref), Some(b_ref)) => {
|
||||||
|
let mut result = a_ref.clone();
|
||||||
|
patch_opt_field!(result, b_ref, user_agent);
|
||||||
|
patch_opt_field!(result, b_ref, with_proxy);
|
||||||
|
patch_opt_field!(result, b_ref, self_proxy);
|
||||||
|
patch_opt_field!(result, b_ref, danger_accept_invalid_certs);
|
||||||
|
patch_opt_field!(result, b_ref, allow_auto_update);
|
||||||
|
patch_opt_field!(result, b_ref, update_interval);
|
||||||
|
patch_opt_field!(result, b_ref, merge);
|
||||||
|
patch_opt_field!(result, b_ref, script);
|
||||||
|
patch_opt_field!(result, b_ref, rules);
|
||||||
|
patch_opt_field!(result, b_ref, proxies);
|
||||||
|
patch_opt_field!(result, b_ref, groups);
|
||||||
|
patch_opt_field!(result, b_ref, timeout_seconds);
|
||||||
|
Some(result)
|
||||||
|
}
|
||||||
|
(Some(a_ref), None) => Some(a_ref.clone()),
|
||||||
|
(None, Some(b_ref)) => Some(b_ref.clone()),
|
||||||
|
(None, None) => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PrfItem {
|
||||||
/// Builds an item from a partial value that must include `itype`.
|
/// Builds an item from a partial value that must include `itype`.
|
||||||
pub(super) async fn build_profile(item: &PrfItem, file_data: Option<String>) -> Result<PrfItem> {
|
pub(super) async fn from(item: &Self, file_data: Option<String>) -> Result<Self> {
|
||||||
let itype = item
|
let itype = item
|
||||||
.itype
|
.itype
|
||||||
.as_ref()
|
.as_ref()
|
||||||
@@ -32,19 +154,19 @@ pub(super) async fn build_profile(item: &PrfItem, file_data: Option<String>) ->
|
|||||||
let name = item.name.as_ref();
|
let name = item.name.as_ref();
|
||||||
let desc = item.desc.as_ref();
|
let desc = item.desc.as_ref();
|
||||||
let option = item.option.as_ref();
|
let option = item.option.as_ref();
|
||||||
build_remote_profile(url, name, desc, option).await
|
Self::from_url(url, name, desc, option).await
|
||||||
}
|
}
|
||||||
"local" => {
|
"local" => {
|
||||||
let name = item.name.clone().unwrap_or_else(|| "Local File".into());
|
let name = item.name.clone().unwrap_or_else(|| "Local File".into());
|
||||||
let desc = item.desc.clone().unwrap_or_else(|| "".into());
|
let desc = item.desc.clone().unwrap_or_else(|| "".into());
|
||||||
let option = item.option.as_ref();
|
let option = item.option.as_ref();
|
||||||
from_local(name, desc, file_data, option).await
|
Self::from_local(name, desc, file_data, option).await
|
||||||
}
|
}
|
||||||
typ => bail!("invalid profile item type \"{typ}\""),
|
typ => bail!("invalid profile item type \"{typ}\""),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn append_companion_item(item: &mut PrfItem) -> Result<String> {
|
async fn append_companion_item(item: &mut Self) -> Result<String> {
|
||||||
profiles::profiles_append_item_safe(item).await?;
|
profiles::profiles_append_item_safe(item).await?;
|
||||||
item.uid
|
item.uid
|
||||||
.clone()
|
.clone()
|
||||||
@@ -59,19 +181,19 @@ async fn ensure_companion_items(
|
|||||||
groups: &mut Option<String>,
|
groups: &mut Option<String>,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
if merge.is_none() {
|
if merge.is_none() {
|
||||||
*merge = Some(append_companion_item(&mut build_merge_profile(None)).await?);
|
*merge = Some(Self::append_companion_item(&mut Self::from_merge(None)).await?);
|
||||||
}
|
}
|
||||||
if script.is_none() {
|
if script.is_none() {
|
||||||
*script = Some(append_companion_item(&mut build_script_profile(None)).await?);
|
*script = Some(Self::append_companion_item(&mut Self::from_script(None)).await?);
|
||||||
}
|
}
|
||||||
if rules.is_none() {
|
if rules.is_none() {
|
||||||
*rules = Some(append_companion_item(&mut from_rules()).await?);
|
*rules = Some(Self::append_companion_item(&mut Self::from_rules()).await?);
|
||||||
}
|
}
|
||||||
if proxies.is_none() {
|
if proxies.is_none() {
|
||||||
*proxies = Some(append_companion_item(&mut from_proxies()).await?);
|
*proxies = Some(Self::append_companion_item(&mut Self::from_proxies()).await?);
|
||||||
}
|
}
|
||||||
if groups.is_none() {
|
if groups.is_none() {
|
||||||
*groups = Some(append_companion_item(&mut from_groups()).await?);
|
*groups = Some(Self::append_companion_item(&mut Self::from_groups()).await?);
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -81,7 +203,7 @@ async fn from_local(
|
|||||||
desc: String,
|
desc: String,
|
||||||
file_data: Option<String>,
|
file_data: Option<String>,
|
||||||
option: Option<&PrfOption>,
|
option: Option<&PrfOption>,
|
||||||
) -> Result<PrfItem> {
|
) -> Result<Self> {
|
||||||
let uid = help::get_uid("L").into();
|
let uid = help::get_uid("L").into();
|
||||||
let file = format!("{uid}.yaml").into();
|
let file = format!("{uid}.yaml").into();
|
||||||
let opt_ref = option.as_ref();
|
let opt_ref = option.as_ref();
|
||||||
@@ -92,8 +214,8 @@ async fn from_local(
|
|||||||
let mut proxies = opt_ref.and_then(|o| o.proxies.clone());
|
let mut proxies = opt_ref.and_then(|o| o.proxies.clone());
|
||||||
let mut groups = opt_ref.and_then(|o| o.groups.clone());
|
let mut groups = opt_ref.and_then(|o| o.groups.clone());
|
||||||
|
|
||||||
ensure_companion_items(&mut merge, &mut script, &mut rules, &mut proxies, &mut groups).await?;
|
Self::ensure_companion_items(&mut merge, &mut script, &mut rules, &mut proxies, &mut groups).await?;
|
||||||
Ok(PrfItem {
|
Ok(Self {
|
||||||
uid: Some(uid),
|
uid: Some(uid),
|
||||||
itype: Some("local".into()),
|
itype: Some("local".into()),
|
||||||
name: Some(name),
|
name: Some(name),
|
||||||
@@ -117,67 +239,24 @@ async fn from_local(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) struct DownloadedSubscription {
|
pub(crate) async fn from_url(
|
||||||
url: Url,
|
|
||||||
suggested_name: Option<std::string::String>,
|
|
||||||
extra: Option<PrfExtra>,
|
|
||||||
update_interval_minutes: Option<u64>,
|
|
||||||
home: Option<String>,
|
|
||||||
body: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) struct RemoteProfileRefresh {
|
|
||||||
pub(super) extra: Option<PrfExtra>,
|
|
||||||
pub(super) home: Option<String>,
|
|
||||||
pub(super) updated: usize,
|
|
||||||
pub(super) option: PrfOption,
|
|
||||||
pub(super) body: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) async fn build_remote_profile(
|
|
||||||
url: &str,
|
url: &str,
|
||||||
name: Option<&String>,
|
name: Option<&String>,
|
||||||
desc: Option<&String>,
|
desc: Option<&String>,
|
||||||
option: Option<&PrfOption>,
|
option: Option<&PrfOption>,
|
||||||
) -> Result<PrfItem> {
|
) -> Result<Self> {
|
||||||
let mut downloaded = download_subscription(url, option).await?;
|
|
||||||
let uid: String = help::get_uid("R").into();
|
|
||||||
let file = format!("{uid}.yaml").into();
|
|
||||||
let name = name
|
|
||||||
.cloned()
|
|
||||||
.or_else(|| downloaded.suggested_name.take().map(Into::into))
|
|
||||||
.unwrap_or_else(|| "Remote File".into());
|
|
||||||
let url = downloaded.url.as_str().into();
|
|
||||||
let RemoteProfileRefresh {
|
|
||||||
extra,
|
|
||||||
home,
|
|
||||||
updated,
|
|
||||||
option,
|
|
||||||
body,
|
|
||||||
} = prepare_remote_refresh(downloaded, option).await?;
|
|
||||||
|
|
||||||
Ok(PrfItem {
|
|
||||||
uid: Some(uid),
|
|
||||||
itype: Some("remote".into()),
|
|
||||||
name: Some(name),
|
|
||||||
desc: desc.cloned(),
|
|
||||||
file: Some(file),
|
|
||||||
url: Some(url),
|
|
||||||
selected: None,
|
|
||||||
extra,
|
|
||||||
option: Some(option),
|
|
||||||
home,
|
|
||||||
updated: Some(updated),
|
|
||||||
file_data: Some(body),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) async fn download_subscription(url: &str, option: Option<&PrfOption>) -> Result<DownloadedSubscription> {
|
|
||||||
let with_proxy = option.is_some_and(|o| o.with_proxy.unwrap_or(false));
|
let with_proxy = option.is_some_and(|o| o.with_proxy.unwrap_or(false));
|
||||||
let self_proxy = option.is_some_and(|o| o.self_proxy.unwrap_or(false));
|
let self_proxy = option.is_some_and(|o| o.self_proxy.unwrap_or(false));
|
||||||
let accept_invalid_certs = option.is_some_and(|o| o.danger_accept_invalid_certs.unwrap_or(false));
|
let accept_invalid_certs = option.is_some_and(|o| o.danger_accept_invalid_certs.unwrap_or(false));
|
||||||
|
let allow_auto_update = Some(allow_auto_update_enabled(option));
|
||||||
let user_agent = option.and_then(|o| o.user_agent.clone());
|
let user_agent = option.and_then(|o| o.user_agent.clone());
|
||||||
|
let update_interval = option.and_then(|o| o.update_interval);
|
||||||
let timeout = option.and_then(|o| o.timeout_seconds).unwrap_or(20);
|
let timeout = option.and_then(|o| o.timeout_seconds).unwrap_or(20);
|
||||||
|
let mut merge = option.and_then(|o| o.merge.clone());
|
||||||
|
let mut script = option.and_then(|o| o.script.clone());
|
||||||
|
let mut rules = option.and_then(|o| o.rules.clone());
|
||||||
|
let mut proxies = option.and_then(|o| o.proxies.clone());
|
||||||
|
let mut groups = option.and_then(|o| o.groups.clone());
|
||||||
|
|
||||||
let proxy_type = if self_proxy {
|
let proxy_type = if self_proxy {
|
||||||
ProxyType::Localhost
|
ProxyType::Localhost
|
||||||
@@ -194,7 +273,7 @@ pub(crate) async fn download_subscription(url: &str, option: Option<&PrfOption>)
|
|||||||
url.as_str(),
|
url.as_str(),
|
||||||
proxy_type,
|
proxy_type,
|
||||||
Some(timeout),
|
Some(timeout),
|
||||||
user_agent,
|
user_agent.clone(),
|
||||||
accept_invalid_certs,
|
accept_invalid_certs,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
@@ -211,57 +290,113 @@ pub(crate) async fn download_subscription(url: &str, option: Option<&PrfOption>)
|
|||||||
bail!("failed to fetch remote profile with status {status_code}")
|
bail!("failed to fetch remote profile with status {status_code}")
|
||||||
}
|
}
|
||||||
|
|
||||||
let document = decode_subscription(&url, resp.headers(), resp.text())?;
|
let header = resp.headers();
|
||||||
let extra = document.usage.map(|usage| PrfExtra {
|
|
||||||
upload: usage.upload,
|
let extra;
|
||||||
download: usage.download,
|
'extra: {
|
||||||
total: usage.total,
|
for (k, v) in header.iter() {
|
||||||
expire: usage.expire,
|
let key_lower = k.as_str().to_ascii_lowercase();
|
||||||
|
// Accept standard custom-metadata prefixes (x-amz-meta-, x-obs-meta-, x-cos-meta-, etc.).
|
||||||
|
if key_lower
|
||||||
|
.strip_suffix("subscription-userinfo")
|
||||||
|
.is_some_and(|prefix| prefix.is_empty() || prefix.ends_with('-'))
|
||||||
|
{
|
||||||
|
let sub_info = v.to_str().unwrap_or("");
|
||||||
|
extra = Some(PrfExtra {
|
||||||
|
upload: help::parse_str(sub_info, "upload").unwrap_or(0),
|
||||||
|
download: help::parse_str(sub_info, "download").unwrap_or(0),
|
||||||
|
total: help::parse_str(sub_info, "total").unwrap_or(0),
|
||||||
|
expire: help::parse_str(sub_info, "expire").unwrap_or(0),
|
||||||
});
|
});
|
||||||
Ok(DownloadedSubscription {
|
break 'extra;
|
||||||
suggested_name: document.filename,
|
}
|
||||||
update_interval_minutes: document.update_interval_minutes,
|
}
|
||||||
home: document.home.map(Into::into),
|
extra = None;
|
||||||
body: document.body.into(),
|
|
||||||
url,
|
|
||||||
extra,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) async fn prepare_remote_refresh(
|
let filename = match header.get("Content-Disposition") {
|
||||||
downloaded: DownloadedSubscription,
|
Some(value) => {
|
||||||
option: Option<&PrfOption>,
|
let filename = format!("{value:?}");
|
||||||
) -> Result<RemoteProfileRefresh> {
|
let filename = filename.trim_matches('"');
|
||||||
let mut resolved = PrfOption {
|
match help::parse_str::<String>(filename, "filename*") {
|
||||||
update_interval: option
|
Some(filename) => {
|
||||||
.and_then(|o| o.update_interval)
|
let iter = percent_encoding::percent_decode(filename.as_bytes());
|
||||||
.or(downloaded.update_interval_minutes),
|
let filename = iter.decode_utf8().unwrap_or_default();
|
||||||
merge: option.and_then(|o| o.merge.clone()),
|
filename.split("''").last().map(|s| s.into())
|
||||||
script: option.and_then(|o| o.script.clone()),
|
}
|
||||||
rules: option.and_then(|o| o.rules.clone()),
|
None => match help::parse_str::<String>(filename, "filename") {
|
||||||
proxies: option.and_then(|o| o.proxies.clone()),
|
Some(filename) => {
|
||||||
groups: option.and_then(|o| o.groups.clone()),
|
let filename = filename.trim_matches('"');
|
||||||
allow_auto_update: Some(allow_auto_update_enabled(option)),
|
Some(filename.into())
|
||||||
..PrfOption::default()
|
}
|
||||||
|
None => None,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
Some(crate::utils::help::get_last_part_and_decode(url.as_str()).unwrap_or_else(|| "Remote File".into()))
|
||||||
|
}
|
||||||
};
|
};
|
||||||
ensure_companion_items(
|
let update_interval = match update_interval {
|
||||||
&mut resolved.merge,
|
Some(val) => Some(val),
|
||||||
&mut resolved.script,
|
None => match header.get("profile-update-interval") {
|
||||||
&mut resolved.rules,
|
Some(value) => match value.to_str().unwrap_or("").parse::<u64>() {
|
||||||
&mut resolved.proxies,
|
Ok(val) => Some(val * 60), // hour -> min
|
||||||
&mut resolved.groups,
|
Err(_) => None,
|
||||||
)
|
},
|
||||||
.await?;
|
None => None,
|
||||||
Ok(RemoteProfileRefresh {
|
},
|
||||||
extra: downloaded.extra,
|
};
|
||||||
home: downloaded.home,
|
|
||||||
updated: chrono::Local::now().timestamp() as usize,
|
let home = header
|
||||||
option: resolved,
|
.get("profile-web-page-url")
|
||||||
body: downloaded.body,
|
.and_then(|value| value.to_str().ok())
|
||||||
|
.and_then(normalize_profile_home_url);
|
||||||
|
|
||||||
|
let uid = help::get_uid("R").into();
|
||||||
|
let file = format!("{uid}.yaml").into();
|
||||||
|
let name = name.map_or_else(
|
||||||
|
|| filename.map_or_else(|| "Remote File".into(), |s| s.into()),
|
||||||
|
|s| s.to_owned(),
|
||||||
|
);
|
||||||
|
let data = resp.text();
|
||||||
|
|
||||||
|
let data = data.trim_start_matches('\u{feff}');
|
||||||
|
|
||||||
|
let yaml = serde_yaml_ng::from_str::<Mapping>(data).context("the remote profile data is invalid yaml")?;
|
||||||
|
|
||||||
|
if !yaml.contains_key("proxies") && !yaml.contains_key("proxy-providers") {
|
||||||
|
bail!("profile does not contain `proxies` or `proxy-providers`");
|
||||||
|
}
|
||||||
|
|
||||||
|
Self::ensure_companion_items(&mut merge, &mut script, &mut rules, &mut proxies, &mut groups).await?;
|
||||||
|
|
||||||
|
Ok(Self {
|
||||||
|
uid: Some(uid),
|
||||||
|
itype: Some("remote".into()),
|
||||||
|
name: Some(name),
|
||||||
|
desc: desc.cloned(),
|
||||||
|
file: Some(file),
|
||||||
|
url: Some(url.as_str().into()),
|
||||||
|
selected: None,
|
||||||
|
extra,
|
||||||
|
option: Some(PrfOption {
|
||||||
|
update_interval,
|
||||||
|
merge,
|
||||||
|
script,
|
||||||
|
rules,
|
||||||
|
proxies,
|
||||||
|
groups,
|
||||||
|
allow_auto_update,
|
||||||
|
..PrfOption::default()
|
||||||
|
}),
|
||||||
|
home,
|
||||||
|
updated: Some(chrono::Local::now().timestamp() as usize),
|
||||||
|
file_data: Some(data.into()),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn build_merge_profile(uid: Option<String>) -> PrfItem {
|
pub(super) fn from_merge(uid: Option<String>) -> Self {
|
||||||
let (id, template) = if let Some(uid) = uid {
|
let (id, template) = if let Some(uid) = uid {
|
||||||
(uid, tmpl::ITEM_MERGE.into())
|
(uid, tmpl::ITEM_MERGE.into())
|
||||||
} else {
|
} else {
|
||||||
@@ -269,7 +404,7 @@ pub(super) fn build_merge_profile(uid: Option<String>) -> PrfItem {
|
|||||||
};
|
};
|
||||||
let file = format!("{id}.yaml").into();
|
let file = format!("{id}.yaml").into();
|
||||||
|
|
||||||
PrfItem {
|
Self {
|
||||||
uid: Some(id),
|
uid: Some(id),
|
||||||
itype: Some("merge".into()),
|
itype: Some("merge".into()),
|
||||||
file: Some(file),
|
file: Some(file),
|
||||||
@@ -279,14 +414,14 @@ pub(super) fn build_merge_profile(uid: Option<String>) -> PrfItem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn build_script_profile(uid: Option<String>) -> PrfItem {
|
pub(super) fn from_script(uid: Option<String>) -> Self {
|
||||||
let id = if let Some(uid) = uid {
|
let id = if let Some(uid) = uid {
|
||||||
uid
|
uid
|
||||||
} else {
|
} else {
|
||||||
help::get_uid("s").into()
|
help::get_uid("s").into()
|
||||||
};
|
};
|
||||||
let file = format!("{id}.js").into(); // js ext
|
let file = format!("{id}.js").into(); // js ext
|
||||||
PrfItem {
|
Self {
|
||||||
uid: Some(id),
|
uid: Some(id),
|
||||||
itype: Some("script".into()),
|
itype: Some("script".into()),
|
||||||
file: Some(file),
|
file: Some(file),
|
||||||
@@ -296,11 +431,11 @@ pub(super) fn build_script_profile(uid: Option<String>) -> PrfItem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_seq_item(prefix: &str, itype: &str, template: &str) -> PrfItem {
|
fn new_seq_item(prefix: &str, itype: &str, template: &str) -> Self {
|
||||||
let uid = help::get_uid(prefix).into();
|
let uid = help::get_uid(prefix).into();
|
||||||
let file = format!("{uid}.yaml").into(); // yaml ext
|
let file = format!("{uid}.yaml").into(); // yaml ext
|
||||||
|
|
||||||
PrfItem {
|
Self {
|
||||||
uid: Some(uid),
|
uid: Some(uid),
|
||||||
itype: Some(itype.into()),
|
itype: Some(itype.into()),
|
||||||
file: Some(file),
|
file: Some(file),
|
||||||
@@ -310,26 +445,46 @@ fn new_seq_item(prefix: &str, itype: &str, template: &str) -> PrfItem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_rules() -> PrfItem {
|
fn from_rules() -> Self {
|
||||||
new_seq_item("r", "rules", tmpl::ITEM_RULES)
|
Self::new_seq_item("r", "rules", tmpl::ITEM_RULES)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_proxies() -> PrfItem {
|
fn from_proxies() -> Self {
|
||||||
new_seq_item("p", "proxies", tmpl::ITEM_PROXIES)
|
Self::new_seq_item("p", "proxies", tmpl::ITEM_PROXIES)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_groups() -> PrfItem {
|
fn from_groups() -> Self {
|
||||||
new_seq_item("g", "groups", tmpl::ITEM_GROUPS)
|
Self::new_seq_item("g", "groups", tmpl::ITEM_GROUPS)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) async fn read_profile_item_file(file: Option<&str>) -> Result<String> {
|
pub(crate) async fn read_file(&self) -> Result<String> {
|
||||||
let file = file.ok_or_else(|| anyhow::anyhow!("could not find the file"))?;
|
let file = self
|
||||||
let path = dirs::app_profiles_dir()?.join(file);
|
.file
|
||||||
|
.as_ref()
|
||||||
|
.ok_or_else(|| anyhow::anyhow!("could not find the file"))?;
|
||||||
|
let path = dirs::app_profiles_dir()?.join(file.as_str());
|
||||||
let content = fs::read_to_string(&path)
|
let content = fs::read_to_string(&path)
|
||||||
.await
|
.await
|
||||||
.with_context(|| format!("failed to read the file \"{}\"", path.display()))?;
|
.with_context(|| format!("failed to read the file \"{}\"", path.display()))?;
|
||||||
Ok(content.into())
|
Ok(content.into())
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
macro_rules! current_field {
|
||||||
|
($name:ident, $field:ident) => {
|
||||||
|
pub(crate) fn $name(&self) -> Option<&String> {
|
||||||
|
self.option.as_ref().and_then(|o| o.$field.as_ref())
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PrfItem {
|
||||||
|
current_field!(current_merge, merge);
|
||||||
|
current_field!(current_script, script);
|
||||||
|
current_field!(current_rules, rules);
|
||||||
|
current_field!(current_proxies, proxies);
|
||||||
|
current_field!(current_groups, groups);
|
||||||
|
}
|
||||||
|
|
||||||
fn allow_auto_update_enabled(option: Option<&PrfOption>) -> bool {
|
fn allow_auto_update_enabled(option: Option<&PrfOption>) -> bool {
|
||||||
option.and_then(|o| o.allow_auto_update).unwrap_or(true)
|
option.and_then(|o| o.allow_auto_update).unwrap_or(true)
|
||||||
@@ -363,84 +518,3 @@ fn fix_dirty_url(input: &str) -> Result<Url> {
|
|||||||
|
|
||||||
Ok(url)
|
Ok(url)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
use tokio::{
|
|
||||||
io::{AsyncBufReadExt as _, AsyncWriteExt as _, BufReader},
|
|
||||||
net::TcpListener,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[tokio::test]
|
|
||||||
async fn import_and_refresh_share_subscription_decoding() -> Result<()> {
|
|
||||||
const BODY: &str = "# keep this comment\nproxies: []\n";
|
|
||||||
let listener = TcpListener::bind("127.0.0.1:0").await?;
|
|
||||||
let url = format!("http://{}/subscription", listener.local_addr()?);
|
|
||||||
let server = tokio::spawn(async move {
|
|
||||||
let response = format!(
|
|
||||||
"HTTP/1.1 200 OK\r\nContent-Length: {}\r\nConnection: close\r\n\
|
|
||||||
Content-Disposition: attachment; filename=remote.yaml\r\n\
|
|
||||||
Profile-Update-Interval: 2\r\n\
|
|
||||||
Profile-Web-Page-Url: https://example.invalid/\r\n\
|
|
||||||
Subscription-Userinfo: upload=1; download=2; total=3; expire=4\r\n\r\n{BODY}",
|
|
||||||
BODY.len()
|
|
||||||
);
|
|
||||||
for _ in 0..2 {
|
|
||||||
let (socket, _) = listener.accept().await?;
|
|
||||||
let mut socket = BufReader::new(socket);
|
|
||||||
let mut line = std::string::String::new();
|
|
||||||
loop {
|
|
||||||
line.clear();
|
|
||||||
if socket.read_line(&mut line).await? == 0 || line == "\r\n" {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
socket.get_mut().write_all(response.as_bytes()).await?;
|
|
||||||
}
|
|
||||||
Ok::<_, std::io::Error>(())
|
|
||||||
});
|
|
||||||
let option = PrfOption {
|
|
||||||
update_interval: Some(0),
|
|
||||||
allow_auto_update: Some(false),
|
|
||||||
timeout_seconds: Some(5),
|
|
||||||
merge: Some("test-merge".into()),
|
|
||||||
script: Some("test-script".into()),
|
|
||||||
rules: Some("test-rules".into()),
|
|
||||||
proxies: Some("test-proxies".into()),
|
|
||||||
groups: Some("test-groups".into()),
|
|
||||||
..Default::default()
|
|
||||||
};
|
|
||||||
let item: clash_verge_profile::PrfItem = build_remote_profile(&url, None, None, Some(&option)).await?;
|
|
||||||
let refresh_option = PrfOption {
|
|
||||||
update_interval: None,
|
|
||||||
..option
|
|
||||||
};
|
|
||||||
let downloaded = download_subscription(&url, Some(&refresh_option)).await?;
|
|
||||||
let refresh = prepare_remote_refresh(downloaded, Some(&refresh_option)).await?;
|
|
||||||
server.await??;
|
|
||||||
assert_eq!(item.itype.as_deref(), Some("remote"));
|
|
||||||
assert_eq!(item.name.as_deref(), Some("remote.yaml"));
|
|
||||||
assert_eq!(item.home.as_deref(), Some("https://example.invalid/"));
|
|
||||||
assert_eq!(item.file_data.as_deref(), Some(BODY));
|
|
||||||
assert_eq!(item.current_merge().map(String::as_str), Some("test-merge"));
|
|
||||||
let usage = item.extra.context("expected decoded usage")?;
|
|
||||||
assert_eq!((usage.upload, usage.download, usage.total, usage.expire), (1, 2, 3, 4));
|
|
||||||
let fetched_option = item.option.context("expected profile options")?;
|
|
||||||
assert_eq!(fetched_option.update_interval, Some(0));
|
|
||||||
assert_eq!(fetched_option.allow_auto_update, Some(false));
|
|
||||||
|
|
||||||
assert_eq!(refresh.body.as_str(), BODY);
|
|
||||||
assert_eq!(refresh.home, item.home);
|
|
||||||
let usage = refresh.extra.context("expected refresh usage")?;
|
|
||||||
assert_eq!((usage.upload, usage.download, usage.total, usage.expire), (1, 2, 3, 4));
|
|
||||||
assert_eq!(
|
|
||||||
refresh.option,
|
|
||||||
PrfOption {
|
|
||||||
update_interval: Some(120),
|
|
||||||
..fetched_option
|
|
||||||
}
|
|
||||||
);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
+438
-134
@@ -1,8 +1,9 @@
|
|||||||
use super::{
|
use super::{
|
||||||
PrfItem, PrfOption, PrfSelected, patch_opt_field,
|
PrfOption, patch_opt_field,
|
||||||
prfitem::{RemoteProfileRefresh, build_profile},
|
prfitem::{PrfItem, PrfSelected, normalize_profile_home_url},
|
||||||
};
|
};
|
||||||
use crate::core::notify::{Refresh, announce};
|
use crate::core::notify::{Refresh, announce};
|
||||||
|
use crate::utils::retry::{RetryError, RetryPolicy, retry, retry_with_state};
|
||||||
use crate::{
|
use crate::{
|
||||||
core::{handle, tray::Tray},
|
core::{handle, tray::Tray},
|
||||||
process::AsyncHandler,
|
process::AsyncHandler,
|
||||||
@@ -14,17 +15,12 @@ use crate::{
|
|||||||
use anyhow::{Context as _, Result, bail};
|
use anyhow::{Context as _, Result, bail};
|
||||||
use clash_verge_draft::Draft;
|
use clash_verge_draft::Draft;
|
||||||
use clash_verge_logging::{Type, logging};
|
use clash_verge_logging::{Type, logging};
|
||||||
use clash_verge_profile::selected_nodes::{
|
|
||||||
SelectedGroup, reconcile_selected_nodes, selected_nodes_need_confirmation, unsettled_selections,
|
|
||||||
};
|
|
||||||
pub use clash_verge_profile::{IProfilePreview, IProfiles};
|
|
||||||
use clash_verge_subscription::normalize_profile_home_url;
|
|
||||||
use clash_verge_task::retry::{RetryError, RetryPolicy, retry, retry_with_state};
|
|
||||||
use futures::FutureExt as _;
|
use futures::FutureExt as _;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_yaml_ng::Mapping;
|
use serde_yaml_ng::Mapping;
|
||||||
use std::num::NonZeroUsize;
|
use std::num::NonZeroUsize;
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::{HashMap, HashSet},
|
||||||
panic::AssertUnwindSafe,
|
panic::AssertUnwindSafe,
|
||||||
path::{Component, Path},
|
path::{Component, Path},
|
||||||
sync::OnceLock,
|
sync::OnceLock,
|
||||||
@@ -52,11 +48,31 @@ const SELECTED_NODES_SETTLE_INTERVAL: Duration = Duration::from_secs(1);
|
|||||||
/// Bounds startup waiting; remaining selections continue restoring in the background.
|
/// Bounds startup waiting; remaining selections continue restoring in the background.
|
||||||
const SELECTED_NODES_FIRST_PASS_BUDGET: Duration = Duration::from_secs(3);
|
const SELECTED_NODES_FIRST_PASS_BUDGET: Duration = Duration::from_secs(3);
|
||||||
|
|
||||||
pub(crate) async fn cleanup_profile_files(files: Vec<String>) {
|
/// Define the `profiles.yaml` schema
|
||||||
|
#[derive(Default, Debug, Clone, Deserialize, Serialize, specta::Type)]
|
||||||
|
#[serde(default)]
|
||||||
|
pub struct IProfiles {
|
||||||
|
pub current: Option<String>,
|
||||||
|
|
||||||
|
pub items: Option<Vec<PrfItem>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct IProfilePreview<'a> {
|
||||||
|
pub uid: &'a String,
|
||||||
|
pub name: &'a String,
|
||||||
|
pub is_current: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) struct ProfileDeletePlan {
|
||||||
|
files: Vec<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ProfileDeletePlan {
|
||||||
|
pub(crate) async fn cleanup(self) {
|
||||||
let Ok(dir) = dirs::app_profiles_dir() else {
|
let Ok(dir) = dirs::app_profiles_dir() else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
for file in files {
|
for file in self.files {
|
||||||
let path = dir.join(file.as_str());
|
let path = dir.join(file.as_str());
|
||||||
if let Err(error) = path.remove_if_exists().await {
|
if let Err(error) = path.remove_if_exists().await {
|
||||||
logging!(
|
logging!(
|
||||||
@@ -68,17 +84,24 @@ pub(crate) async fn cleanup_profile_files(files: Vec<String>) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) async fn load_profiles() -> IProfiles {
|
impl IProfiles {
|
||||||
|
fn take_item_file_by_uid(items: &mut Vec<PrfItem>, target_uid: Option<&str>) -> Option<String> {
|
||||||
|
let index = items.iter().position(|item| item.uid.as_deref() == target_uid)?;
|
||||||
|
items.remove(index).file
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn new() -> Self {
|
||||||
let path = match dirs::profiles_path() {
|
let path = match dirs::profiles_path() {
|
||||||
Ok(p) => p,
|
Ok(p) => p,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
logging!(error, Type::Config, "failed to get profiles path: {err:#}");
|
logging!(error, Type::Config, "failed to get profiles path: {err:#}");
|
||||||
return IProfiles::default();
|
return Self::default();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
match help::read_yaml::<IProfiles>(&path).await {
|
match help::read_yaml::<Self>(&path).await {
|
||||||
Ok(mut profiles) => {
|
Ok(mut profiles) => {
|
||||||
let items = profiles.items.get_or_insert_with(Vec::new);
|
let items = profiles.items.get_or_insert_with(Vec::new);
|
||||||
let mut home_changed = false;
|
let mut home_changed = false;
|
||||||
@@ -103,29 +126,57 @@ pub(crate) async fn load_profiles() -> IProfiles {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if home_changed && let Err(err) = save_profiles(&profiles).await {
|
if home_changed && let Err(err) = profiles.save_file().await {
|
||||||
logging!(error, Type::Config, "无法保存已清理的 profiles.yaml: {err:#}");
|
logging!(error, Type::Config, "无法保存已清理的 profiles.yaml: {err:#}");
|
||||||
}
|
}
|
||||||
profiles
|
profiles
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
logging!(error, Type::Config, "failed to read profiles.yaml: {err:#}");
|
logging!(error, Type::Config, "failed to read profiles.yaml: {err:#}");
|
||||||
IProfiles::default()
|
Self::default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) async fn save_profiles(profiles: &IProfiles) -> Result<()> {
|
pub async fn save_file(&self) -> Result<()> {
|
||||||
help::save_yaml(
|
help::save_yaml(&dirs::profiles_path()?, self, Some("# Profiles Config for Clash Verge")).await
|
||||||
&dirs::profiles_path()?,
|
|
||||||
profiles,
|
|
||||||
Some("# Profiles Config for Clash Verge"),
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn append_item(profiles: &mut IProfiles, item: &mut PrfItem) -> Result<()> {
|
/// 只修改current,valid和chain
|
||||||
if item.uid.is_none() {
|
pub fn patch_config(&mut self, patch: &Self) {
|
||||||
|
if self.items.is_none() {
|
||||||
|
self.items = Some(vec![]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(current) = &patch.current
|
||||||
|
&& let Some(items) = self.items.as_ref()
|
||||||
|
{
|
||||||
|
let some_uid = Some(current);
|
||||||
|
if items.iter().any(|e| e.uid.as_ref() == some_uid) {
|
||||||
|
self.current = some_uid.cloned();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_item(&self, uid: impl AsRef<str>) -> Result<&PrfItem> {
|
||||||
|
let uid_str = uid.as_ref();
|
||||||
|
|
||||||
|
if let Some(items) = self.items.as_ref() {
|
||||||
|
for each in items.iter() {
|
||||||
|
if let Some(uid_val) = &each.uid
|
||||||
|
&& uid_val.as_str() == uid_str
|
||||||
|
{
|
||||||
|
return Ok(each);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bail!("failed to get the profile item \"uid:{}\"", uid_str);
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn append_item(&mut self, item: &mut PrfItem) -> Result<()> {
|
||||||
|
let uid = &item.uid;
|
||||||
|
if uid.is_none() {
|
||||||
bail!("the uid should not be null");
|
bail!("the uid should not be null");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,16 +196,43 @@ async fn append_item(profiles: &mut IProfiles, item: &mut PrfItem) -> Result<()>
|
|||||||
.with_context(|| format!("failed to write to file \"{file}\""))?;
|
.with_context(|| format!("failed to write to file \"{file}\""))?;
|
||||||
}
|
}
|
||||||
|
|
||||||
profiles.append_item(item);
|
if self.current.is_none() && (item.itype == Some("remote".into()) || item.itype == Some("local".into())) {
|
||||||
|
self.current = uid.to_owned();
|
||||||
|
}
|
||||||
|
|
||||||
|
if self.items.is_none() {
|
||||||
|
self.items = Some(vec![]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(items) = self.items.as_mut() {
|
||||||
|
items.push(item.to_owned());
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn patch_item(profiles: &mut IProfiles, uid: &str, item: &PrfItem) -> Result<()> {
|
async fn reorder(&mut self, active_id: &str, over_id: &str) -> Result<()> {
|
||||||
if let Some(file) = &item.file {
|
{
|
||||||
validate_profile_file(file)?;
|
let Some(items) = self.items.as_mut() else {
|
||||||
|
return Ok(());
|
||||||
|
};
|
||||||
|
let old_index = items.iter().rposition(|item| item.uid.as_deref() == Some(active_id));
|
||||||
|
let new_index = items.iter().rposition(|item| item.uid.as_deref() == Some(over_id));
|
||||||
|
let (Some(old_idx), Some(new_idx)) = (old_index, new_index) else {
|
||||||
|
return Ok(());
|
||||||
|
};
|
||||||
|
let item = items.remove(old_idx);
|
||||||
|
items.insert(new_idx, item);
|
||||||
|
}
|
||||||
|
self.save_file().await
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut items = profiles.items.take().unwrap_or_default();
|
async fn patch_item(&mut self, uid: &str, item: &PrfItem) -> Result<()> {
|
||||||
|
if let Some(file) = &item.file {
|
||||||
|
Self::validate_profile_file(file)?;
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut items = self.items.take().unwrap_or_default();
|
||||||
|
|
||||||
for each in items.iter_mut() {
|
for each in items.iter_mut() {
|
||||||
if each.uid.as_deref() == Some(uid) {
|
if each.uid.as_deref() == Some(uid) {
|
||||||
@@ -168,12 +246,12 @@ async fn patch_item(profiles: &mut IProfiles, uid: &str, item: &PrfItem) -> Resu
|
|||||||
patch_opt_field!(each, item, updated);
|
patch_opt_field!(each, item, updated);
|
||||||
patch_opt_field!(each, item, option);
|
patch_opt_field!(each, item, option);
|
||||||
|
|
||||||
profiles.items = Some(items);
|
self.items = Some(items);
|
||||||
return save_profiles(profiles).await;
|
return self.save_file().await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
profiles.items = Some(items);
|
self.items = Some(items);
|
||||||
bail!("failed to find the profile item \"uid:{uid}\"")
|
bail!("failed to find the profile item \"uid:{uid}\"")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,37 +272,48 @@ fn validate_profile_file(file: &str) -> Result<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Updates fields returned by a remote profile refresh.
|
/// Updates fields returned by a remote profile refresh.
|
||||||
async fn apply_remote_refresh(profiles: &mut IProfiles, uid: &str, refresh: RemoteProfileRefresh) -> Result<()> {
|
async fn update_item(&mut self, uid: &str, item: &mut PrfItem) -> Result<()> {
|
||||||
let _ = profiles.get_item(uid)?;
|
if self.items.is_none() {
|
||||||
|
self.items = Some(vec![]);
|
||||||
|
}
|
||||||
|
|
||||||
|
let _ = self.get_item(uid)?;
|
||||||
|
|
||||||
|
if let Some(items) = self.items.as_mut() {
|
||||||
|
for each in items.iter_mut() {
|
||||||
|
if each.uid.as_deref() == Some(uid) {
|
||||||
|
each.extra = item.extra;
|
||||||
|
each.updated = item.updated;
|
||||||
|
each.home = item.home.to_owned();
|
||||||
|
each.option = PrfOption::merge(each.option.as_ref(), item.option.as_ref());
|
||||||
|
if let Some(file_data) = item.file_data.take() {
|
||||||
|
let file = each.file.take();
|
||||||
|
let file =
|
||||||
|
file.unwrap_or_else(|| item.file.take().unwrap_or_else(|| format!("{}.yaml", uid).into()));
|
||||||
|
|
||||||
|
each.file = Some(file.clone());
|
||||||
|
|
||||||
if let Some(each) = profiles
|
|
||||||
.items
|
|
||||||
.iter_mut()
|
|
||||||
.flatten()
|
|
||||||
.find(|item| item.uid.as_deref() == Some(uid))
|
|
||||||
{
|
|
||||||
each.extra = refresh.extra;
|
|
||||||
each.updated = Some(refresh.updated);
|
|
||||||
each.home = refresh.home;
|
|
||||||
each.option = PrfOption::merge(each.option.as_ref(), Some(&refresh.option));
|
|
||||||
let file = each
|
|
||||||
.file
|
|
||||||
.get_or_insert_with(|| format!("{}.yaml", help::get_uid("R")).into());
|
|
||||||
let path = dirs::app_profiles_dir()?.join(file.as_str());
|
let path = dirs::app_profiles_dir()?.join(file.as_str());
|
||||||
fs::write(&path, refresh.body.as_bytes())
|
|
||||||
|
fs::write(&path, file_data.as_bytes())
|
||||||
.await
|
.await
|
||||||
.with_context(|| format!("failed to write to file \"{file}\""))?;
|
.with_context(|| format!("failed to write to file \"{file}\""))?;
|
||||||
}
|
}
|
||||||
|
|
||||||
save_profiles(profiles).await
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
self.save_file().await
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Raise intervals below `min_minutes`. `None`/`0` mean "never auto-update", left alone.
|
/// Raise intervals below `min_minutes`. `None`/`0` mean "never auto-update", left alone.
|
||||||
/// Returns how many changed so the caller can skip a pointless write.
|
/// Returns how many changed so the caller can skip a pointless write.
|
||||||
pub(crate) fn raise_short_update_intervals(profiles: &mut IProfiles, min_minutes: u64) -> usize {
|
pub fn raise_short_update_intervals(&mut self, min_minutes: u64) -> usize {
|
||||||
let mut raised = 0;
|
let mut raised = 0;
|
||||||
|
|
||||||
for item in profiles.items.iter_mut().flatten() {
|
for item in self.items.iter_mut().flatten() {
|
||||||
let Some(option) = item.option.as_mut() else {
|
let Some(option) = item.option.as_mut() else {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
@@ -240,8 +329,49 @@ pub(crate) fn raise_short_update_intervals(profiles: &mut IProfiles, min_minutes
|
|||||||
raised
|
raised
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) async fn current_mapping(profiles: &IProfiles) -> Result<Mapping> {
|
pub(crate) fn plan_delete_item(&mut self, uid: &str) -> Result<(bool, ProfileDeletePlan)> {
|
||||||
match (profiles.current.as_ref(), profiles.items.as_ref()) {
|
let deleting_current = self.current.as_deref().is_none_or(|current| current == uid);
|
||||||
|
let delete_uids = self.get_item(uid)?.option.as_ref().map_or_else(Vec::new, |op| {
|
||||||
|
[
|
||||||
|
op.merge.clone(),
|
||||||
|
op.script.clone(),
|
||||||
|
op.rules.clone(),
|
||||||
|
op.proxies.clone(),
|
||||||
|
op.groups.clone(),
|
||||||
|
]
|
||||||
|
.into_iter()
|
||||||
|
.collect::<Vec<_>>()
|
||||||
|
});
|
||||||
|
let mut items = self.items.take().unwrap_or_default();
|
||||||
|
let mut files = Vec::new();
|
||||||
|
|
||||||
|
if let Some(file) = Self::take_item_file_by_uid(&mut items, Some(uid)) {
|
||||||
|
files.push(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
for delete_uid in delete_uids {
|
||||||
|
if let Some(file) = Self::take_item_file_by_uid(&mut items, delete_uid.as_deref()) {
|
||||||
|
files.push(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if deleting_current {
|
||||||
|
self.current = None;
|
||||||
|
for item in items.iter() {
|
||||||
|
if item.itype == Some("remote".into()) || item.itype == Some("local".into()) {
|
||||||
|
self.current = item.uid.clone();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
self.items = Some(items);
|
||||||
|
Ok((deleting_current, ProfileDeletePlan { files }))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 获取current指向的订阅内容
|
||||||
|
pub async fn current_mapping(&self) -> Result<Mapping> {
|
||||||
|
match (self.current.as_ref(), self.items.as_ref()) {
|
||||||
(Some(current), Some(items)) => {
|
(Some(current), Some(items)) => {
|
||||||
if let Some(item) = items.iter().find(|e| e.uid.as_ref() == Some(current)) {
|
if let Some(item) = items.iter().find(|e| e.uid.as_ref() == Some(current)) {
|
||||||
let file_path = match item.file.as_ref() {
|
let file_path = match item.file.as_ref() {
|
||||||
@@ -256,11 +386,29 @@ pub(crate) async fn current_mapping(profiles: &IProfiles) -> Result<Mapping> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn profiles_preview(&self) -> Option<Vec<IProfilePreview<'_>>> {
|
||||||
|
self.items.as_ref().map(|items| {
|
||||||
|
items
|
||||||
|
.iter()
|
||||||
|
.filter_map(|e| {
|
||||||
|
if let (Some(uid), Some(name)) = (e.uid.as_ref(), e.name.as_ref()) {
|
||||||
|
let is_current = self.current.as_ref() == Some(uid);
|
||||||
|
let preview = IProfilePreview { uid, name, is_current };
|
||||||
|
Some(preview)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.collect()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// These helpers serialize asynchronous operations against committed profile data.
|
// These helpers serialize asynchronous operations against committed profile data.
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
|
|
||||||
pub(crate) async fn profiles_append_item_with_filedata_safe(item: &PrfItem, file_data: Option<String>) -> Result<()> {
|
pub(crate) async fn profiles_append_item_with_filedata_safe(item: &PrfItem, file_data: Option<String>) -> Result<()> {
|
||||||
let item = &mut build_profile(item, file_data).await?;
|
let item = &mut PrfItem::from(item, file_data).await?;
|
||||||
profiles_append_item_safe(item).await
|
profiles_append_item_safe(item).await
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,57 +435,147 @@ pub(crate) async fn profiles_append_item_safe(item: &mut PrfItem) -> Result<()>
|
|||||||
pub(super) async fn profiles_append_item_to_safe(profiles: &Draft<IProfiles>, item: &mut PrfItem) -> Result<()> {
|
pub(super) async fn profiles_append_item_to_safe(profiles: &Draft<IProfiles>, item: &mut PrfItem) -> Result<()> {
|
||||||
profiles
|
profiles
|
||||||
.with_data_modify(|mut profiles| async move {
|
.with_data_modify(|mut profiles| async move {
|
||||||
append_item(&mut profiles, item).await?;
|
profiles.append_item(item).await?;
|
||||||
Ok((profiles, ()))
|
Ok((profiles, ()))
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) async fn profiles_patch_item_safe(index: &str, item: &PrfItem) -> Result<()> {
|
pub(crate) async fn profiles_patch_item_safe(index: &str, item: &PrfItem) -> Result<()> {
|
||||||
with_profiles_edit(|mut profiles| async move {
|
with_profiles_edit(|mut profiles| async move { profiles.patch_item(index, item).await.map(|_| profiles) }).await
|
||||||
patch_item(&mut profiles, index, item).await?;
|
|
||||||
Ok(profiles)
|
|
||||||
})
|
|
||||||
.await
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) async fn profiles_reorder_safe(active_id: &str, over_id: &str) -> Result<()> {
|
pub(crate) async fn profiles_reorder_safe(active_id: &str, over_id: &str) -> Result<()> {
|
||||||
with_profiles_edit(|mut profiles| async move {
|
with_profiles_edit(|mut profiles| async move { profiles.reorder(active_id, over_id).await.map(|_| profiles) }).await
|
||||||
if profiles.reorder(active_id, over_id) {
|
|
||||||
save_profiles(&profiles).await?;
|
|
||||||
}
|
|
||||||
Ok(profiles)
|
|
||||||
})
|
|
||||||
.await
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) async fn profiles_save_file_safe() -> Result<()> {
|
pub(crate) async fn profiles_save_file_safe() -> Result<()> {
|
||||||
with_profiles_edit(|profiles| async move { save_profiles(&profiles).await.map(|_| profiles) }).await
|
with_profiles_edit(|profiles| async move { profiles.save_file().await.map(|_| profiles) }).await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) async fn apply_remote_refresh_safe(index: &str, url: &str, refresh: RemoteProfileRefresh) -> Result<()> {
|
pub(crate) async fn profiles_update_item_safe(index: &str, item: &mut PrfItem) -> Result<()> {
|
||||||
with_profiles_edit(|mut profiles| async move {
|
with_profiles_edit(|mut profiles| async move { profiles.update_item(index, item).await.map(|_| profiles) }).await
|
||||||
let current = profiles.get_item(index)?;
|
}
|
||||||
anyhow::ensure!(
|
|
||||||
current.itype.as_deref() == Some("remote") && current.url.as_deref() == Some(url),
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
"profile source changed during refresh"
|
struct SelectedNodesPlan {
|
||||||
);
|
selected: Vec<PrfSelected>,
|
||||||
apply_remote_refresh(&mut profiles, index, refresh).await?;
|
activations: Vec<(String, String)>,
|
||||||
Ok(profiles)
|
repaired_count: usize,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn node_is_available(available_nodes: &[std::string::String], node: &str) -> bool {
|
||||||
|
available_nodes.iter().any(|available| available == node)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn selected_nodes_need_confirmation(selected: &[PrfSelected], proxies: &Proxies) -> bool {
|
||||||
|
selected.iter().any(|selected_item| {
|
||||||
|
let (Some(group_name), Some(node)) = (&selected_item.name, &selected_item.now) else {
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
let Some(group) = proxies.proxies.get(group_name.as_str()) else {
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
let Some(available_nodes) = group.all.as_deref().filter(|nodes| !nodes.is_empty()) else {
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
!node_is_available(available_nodes, node)
|
||||||
})
|
})
|
||||||
.await
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn selected_group<'a>(snapshot: &'a Proxies, name: &str) -> Option<SelectedGroup<'a>> {
|
fn reconcile_selected_nodes(
|
||||||
let group = snapshot.proxies.get(name)?;
|
selected: &[PrfSelected],
|
||||||
Some(SelectedGroup {
|
previous: Option<&Proxies>,
|
||||||
members: group.all.as_deref(),
|
proxies: &Proxies,
|
||||||
current: group.now.as_deref(),
|
) -> SelectedNodesPlan {
|
||||||
selectable: matches!(
|
let mut plan = SelectedNodesPlan {
|
||||||
group.proxy_type,
|
selected: Vec::with_capacity(selected.len()),
|
||||||
|
activations: Vec::new(),
|
||||||
|
repaired_count: 0,
|
||||||
|
};
|
||||||
|
let mut seen_groups = HashSet::new();
|
||||||
|
let mut unique_selected = selected
|
||||||
|
.iter()
|
||||||
|
.rev()
|
||||||
|
.filter(|item| item.name.as_ref().is_some_and(|name| seen_groups.insert(name.clone())))
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
unique_selected.reverse();
|
||||||
|
plan.repaired_count += selected.len() - unique_selected.len();
|
||||||
|
|
||||||
|
for selected_item in unique_selected {
|
||||||
|
let (Some(group_name), Some(node)) = (&selected_item.name, &selected_item.now) else {
|
||||||
|
plan.repaired_count += 1;
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
let Some(group) = proxies.proxies.get(group_name.as_str()) else {
|
||||||
|
if previous.is_some_and(|snapshot| !snapshot.proxies.contains_key(group_name.as_str())) {
|
||||||
|
plan.repaired_count += 1;
|
||||||
|
} else {
|
||||||
|
plan.selected.push(selected_item.clone());
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
let Some(available_nodes) = group.all.as_deref().filter(|nodes| !nodes.is_empty()) else {
|
||||||
|
// Provider-backed groups can be temporarily incomplete immediately after a reload.
|
||||||
|
plan.selected.push(selected_item.clone());
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
let is_selectable_group = matches!(
|
||||||
|
&group.proxy_type,
|
||||||
ProxyType::Selector | ProxyType::URLTest | ProxyType::Fallback | ProxyType::LoadBalance
|
ProxyType::Selector | ProxyType::URLTest | ProxyType::Fallback | ProxyType::LoadBalance
|
||||||
),
|
);
|
||||||
})
|
if !is_selectable_group {
|
||||||
|
let preferred_node = group
|
||||||
|
.now
|
||||||
|
.as_deref()
|
||||||
|
.filter(|current| node_is_available(available_nodes, current))
|
||||||
|
.or_else(|| node_is_available(available_nodes, node).then_some(node.as_str()));
|
||||||
|
if let Some(preferred_node) = preferred_node {
|
||||||
|
if preferred_node != node.as_str() {
|
||||||
|
plan.repaired_count += 1;
|
||||||
|
}
|
||||||
|
plan.selected.push(PrfSelected {
|
||||||
|
name: Some(group_name.clone()),
|
||||||
|
now: Some(preferred_node.into()),
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
plan.repaired_count += 1;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if node_is_available(available_nodes, node) {
|
||||||
|
plan.selected.push(selected_item.clone());
|
||||||
|
if group.now.as_deref() != Some(node.as_str()) {
|
||||||
|
plan.activations.push((group_name.clone(), node.clone()));
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
let missing_was_confirmed = previous
|
||||||
|
.and_then(|snapshot| snapshot.proxies.get(group_name.as_str()))
|
||||||
|
.and_then(|group| group.all.as_deref())
|
||||||
|
.filter(|nodes| !nodes.is_empty())
|
||||||
|
.is_some_and(|nodes| !node_is_available(nodes, node));
|
||||||
|
if !missing_was_confirmed {
|
||||||
|
plan.selected.push(selected_item.clone());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
plan.repaired_count += 1;
|
||||||
|
if let Some(current_node) = group
|
||||||
|
.now
|
||||||
|
.as_deref()
|
||||||
|
.filter(|current| node_is_available(available_nodes, current))
|
||||||
|
{
|
||||||
|
plan.selected.push(PrfSelected {
|
||||||
|
name: Some(group_name.clone()),
|
||||||
|
now: Some(current_node.into()),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
plan
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Cancels restoration so it cannot overwrite a newer selection or profile snapshot.
|
/// Cancels restoration so it cannot overwrite a newer selection or profile snapshot.
|
||||||
@@ -545,7 +783,7 @@ pub(crate) async fn record_selected_node(group_name: &str, node: &str) -> Result
|
|||||||
now: Some(node.into()),
|
now: Some(node.into()),
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
save_profiles(&profiles).await?;
|
profiles.save_file().await?;
|
||||||
Ok((profiles, true))
|
Ok((profiles, true))
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
@@ -574,7 +812,7 @@ pub(crate) async fn forget_selected_node(group_name: &str) -> Result<()> {
|
|||||||
if !selected.is_empty() {
|
if !selected.is_empty() {
|
||||||
item.selected = Some(selected);
|
item.selected = Some(selected);
|
||||||
}
|
}
|
||||||
save_profiles(&profiles).await?;
|
profiles.save_file().await?;
|
||||||
Ok((profiles, true))
|
Ok((profiles, true))
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
@@ -605,12 +843,28 @@ async fn persist_reconciled_selected(
|
|||||||
}
|
}
|
||||||
|
|
||||||
profile.selected = (!selected.is_empty()).then_some(selected);
|
profile.selected = (!selected.is_empty()).then_some(selected);
|
||||||
save_profiles(&profiles).await?;
|
profiles.save_file().await?;
|
||||||
Ok((profiles, true))
|
Ok((profiles, true))
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns recorded selections whose groups have not reached the requested node.
|
||||||
|
fn unsettled_selections(selected: &[PrfSelected], proxies: &Proxies) -> Vec<String> {
|
||||||
|
selected
|
||||||
|
.iter()
|
||||||
|
.filter_map(|item| {
|
||||||
|
let (Some(group_name), Some(node)) = (&item.name, &item.now) else {
|
||||||
|
return None;
|
||||||
|
};
|
||||||
|
match proxies.proxies.get(group_name.as_str()) {
|
||||||
|
Some(group) if group.now.as_deref() == Some(node.as_str()) => None,
|
||||||
|
_ => Some(group_name.clone()),
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.collect()
|
||||||
|
}
|
||||||
|
|
||||||
/// Retries selections while provider-backed groups finish loading.
|
/// Retries selections while provider-backed groups finish loading.
|
||||||
async fn settle_pending_selections(selected: &[PrfSelected], completed: &mut HashMap<String, String>, generation: u64) {
|
async fn settle_pending_selections(selected: &[PrfSelected], completed: &mut HashMap<String, String>, generation: u64) {
|
||||||
let deadline = Instant::now() + SELECTED_NODES_SETTLE_DEADLINE;
|
let deadline = Instant::now() + SELECTED_NODES_SETTLE_DEADLINE;
|
||||||
@@ -637,7 +891,7 @@ async fn settle_pending_selections(selected: &[PrfSelected], completed: &mut Has
|
|||||||
if !is_activation_current(*generation) {
|
if !is_activation_current(*generation) {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
let pending = unsettled_selections(selected, &snapshot, selected_group);
|
let pending = unsettled_selections(selected, &snapshot);
|
||||||
if pending.is_empty() {
|
if pending.is_empty() {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
@@ -651,7 +905,7 @@ async fn settle_pending_selections(selected: &[PrfSelected], completed: &mut Has
|
|||||||
);
|
);
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
let plan = reconcile_selected_nodes(selected, None, &snapshot, selected_group);
|
let plan = reconcile_selected_nodes(selected, None, &snapshot);
|
||||||
if apply_activations(&plan.activations, completed, *generation)
|
if apply_activations(&plan.activations, completed, *generation)
|
||||||
.await
|
.await
|
||||||
.is_none()
|
.is_none()
|
||||||
@@ -679,8 +933,8 @@ async fn activate_selected_nodes_worker(
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
let needs_confirmation = selected_nodes_need_confirmation(&selected, &first_snapshot, selected_group);
|
let needs_confirmation = selected_nodes_need_confirmation(&selected, &first_snapshot);
|
||||||
let immediate_plan = reconcile_selected_nodes(&selected, None, &first_snapshot, selected_group);
|
let immediate_plan = reconcile_selected_nodes(&selected, None, &first_snapshot);
|
||||||
logging!(
|
logging!(
|
||||||
debug,
|
debug,
|
||||||
Type::Config,
|
Type::Config,
|
||||||
@@ -708,8 +962,7 @@ async fn activate_selected_nodes_worker(
|
|||||||
if !is_activation_current(generation) {
|
if !is_activation_current(generation) {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
let confirmed_plan =
|
let confirmed_plan = reconcile_selected_nodes(&selected, Some(&first_snapshot), &second_snapshot);
|
||||||
reconcile_selected_nodes(&selected, Some(&first_snapshot), &second_snapshot, selected_group);
|
|
||||||
logging!(
|
logging!(
|
||||||
debug,
|
debug,
|
||||||
Type::Config,
|
Type::Config,
|
||||||
@@ -874,6 +1127,19 @@ mod tests {
|
|||||||
use super::*;
|
use super::*;
|
||||||
use tauri_plugin_mihomo::models::Proxy;
|
use tauri_plugin_mihomo::models::Proxy;
|
||||||
|
|
||||||
|
fn deletion_item(uid: &str, kind: &str, file: &str, merge: Option<&str>) -> PrfItem {
|
||||||
|
PrfItem {
|
||||||
|
uid: Some(uid.into()),
|
||||||
|
itype: Some(kind.into()),
|
||||||
|
file: Some(file.into()),
|
||||||
|
option: merge.map(|uid| PrfOption {
|
||||||
|
merge: Some(uid.into()),
|
||||||
|
..PrfOption::default()
|
||||||
|
}),
|
||||||
|
..PrfItem::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn interval_item(uid: &str, update_interval: Option<u64>) -> PrfItem {
|
fn interval_item(uid: &str, update_interval: Option<u64>) -> PrfItem {
|
||||||
PrfItem {
|
PrfItem {
|
||||||
uid: Some(uid.into()),
|
uid: Some(uid.into()),
|
||||||
@@ -886,6 +1152,43 @@ mod tests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn missing_reorder_ids_preserve_ordered_items() -> Result<()> {
|
||||||
|
let mut profiles = IProfiles {
|
||||||
|
current: Some("a".into()),
|
||||||
|
items: Some(vec![
|
||||||
|
PrfItem {
|
||||||
|
uid: Some("a".into()),
|
||||||
|
..PrfItem::default()
|
||||||
|
},
|
||||||
|
PrfItem {
|
||||||
|
uid: Some("b".into()),
|
||||||
|
..PrfItem::default()
|
||||||
|
},
|
||||||
|
PrfItem {
|
||||||
|
uid: Some("c".into()),
|
||||||
|
..PrfItem::default()
|
||||||
|
},
|
||||||
|
]),
|
||||||
|
};
|
||||||
|
let expected = Some(vec![Some("a"), Some("b"), Some("c")]);
|
||||||
|
|
||||||
|
profiles.reorder("missing", "b").await?;
|
||||||
|
let ordered_uids = profiles
|
||||||
|
.items
|
||||||
|
.as_ref()
|
||||||
|
.map(|items| items.iter().map(|item| item.uid.as_deref()).collect::<Vec<_>>());
|
||||||
|
assert_eq!(ordered_uids, expected);
|
||||||
|
|
||||||
|
profiles.reorder("a", "missing").await?;
|
||||||
|
let ordered_uids = profiles
|
||||||
|
.items
|
||||||
|
.as_ref()
|
||||||
|
.map(|items| items.iter().map(|item| item.uid.as_deref()).collect::<Vec<_>>());
|
||||||
|
assert_eq!(ordered_uids, expected);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn raising_intervals_only_touches_those_scheduled_too_often() {
|
fn raising_intervals_only_touches_those_scheduled_too_often() {
|
||||||
let mut profiles = IProfiles {
|
let mut profiles = IProfiles {
|
||||||
@@ -906,7 +1209,7 @@ mod tests {
|
|||||||
]),
|
]),
|
||||||
};
|
};
|
||||||
|
|
||||||
assert_eq!(raise_short_update_intervals(&mut profiles, 1440), 2);
|
assert_eq!(profiles.raise_short_update_intervals(1440), 2);
|
||||||
|
|
||||||
let intervals: Vec<Option<u64>> = profiles
|
let intervals: Vec<Option<u64>> = profiles
|
||||||
.items
|
.items
|
||||||
@@ -920,12 +1223,32 @@ mod tests {
|
|||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
raise_short_update_intervals(&mut profiles, 1440),
|
profiles.raise_short_update_intervals(1440),
|
||||||
0,
|
0,
|
||||||
"a second pass must be a no-op, so re-running the migration cannot churn the file"
|
"a second pass must be a no-op, so re-running the migration cannot churn the file"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn delete_plan_defers_files_and_selects_replacement() -> Result<()> {
|
||||||
|
let mut profiles = IProfiles {
|
||||||
|
current: Some("a".into()),
|
||||||
|
items: Some(vec![
|
||||||
|
deletion_item("a", "remote", "a.yaml", Some("owned")),
|
||||||
|
deletion_item("owned", "merge", "owned.yaml", None),
|
||||||
|
deletion_item("b", "local", "b.yaml", None),
|
||||||
|
]),
|
||||||
|
};
|
||||||
|
|
||||||
|
let (should_update, plan) = profiles.plan_delete_item("a")?;
|
||||||
|
|
||||||
|
assert!(should_update);
|
||||||
|
assert_eq!(profiles.current.as_deref(), Some("b"));
|
||||||
|
assert_eq!(plan.files, vec![String::from("a.yaml"), String::from("owned.yaml")]);
|
||||||
|
assert!(profiles.get_item("owned").is_err());
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
fn selected(group: &str, node: &str) -> PrfSelected {
|
fn selected(group: &str, node: &str) -> PrfSelected {
|
||||||
PrfSelected {
|
PrfSelected {
|
||||||
name: Some(group.into()),
|
name: Some(group.into()),
|
||||||
@@ -979,13 +1302,13 @@ mod tests {
|
|||||||
let unloaded = proxies(vec![("provider-group", &[], None)]);
|
let unloaded = proxies(vec![("provider-group", &[], None)]);
|
||||||
|
|
||||||
assert!(
|
assert!(
|
||||||
reconcile_selected_nodes(&saved, Some(&unloaded), &unloaded, selected_group)
|
reconcile_selected_nodes(&saved, Some(&unloaded), &unloaded)
|
||||||
.activations
|
.activations
|
||||||
.is_empty(),
|
.is_empty(),
|
||||||
"nothing can be activated while the group is empty"
|
"nothing can be activated while the group is empty"
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
unsettled_selections(&saved, &unloaded, selected_group),
|
unsettled_selections(&saved, &unloaded),
|
||||||
vec![String::from("provider-group")],
|
vec![String::from("provider-group")],
|
||||||
"so the restore must keep looking rather than call it done"
|
"so the restore must keep looking rather than call it done"
|
||||||
);
|
);
|
||||||
@@ -997,7 +1320,7 @@ mod tests {
|
|||||||
let loaded = proxies(vec![("Proxy", &["Node A", "Node B"], Some("Node A"))]);
|
let loaded = proxies(vec![("Proxy", &["Node A", "Node B"], Some("Node A"))]);
|
||||||
|
|
||||||
assert!(
|
assert!(
|
||||||
unsettled_selections(&saved, &loaded, selected_group).is_empty(),
|
unsettled_selections(&saved, &loaded).is_empty(),
|
||||||
"a group already on its node needs nothing, even though it produces no activation"
|
"a group already on its node needs nothing, even though it produces no activation"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1009,10 +1332,7 @@ mod tests {
|
|||||||
let saved = vec![selected("Proxy", "Node A")];
|
let saved = vec![selected("Proxy", "Node A")];
|
||||||
let wrong = proxies(vec![("Proxy", &["Node A", "Node B"], Some("Node B"))]);
|
let wrong = proxies(vec![("Proxy", &["Node A", "Node B"], Some("Node B"))]);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(unsettled_selections(&saved, &wrong), vec![String::from("Proxy")]);
|
||||||
unsettled_selections(&saved, &wrong, selected_group),
|
|
||||||
vec![String::from("Proxy")]
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -1030,7 +1350,7 @@ mod tests {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
assert!(unsettled_selections(&malformed, &proxies(vec![]), selected_group).is_empty());
|
assert!(unsettled_selections(&malformed, &proxies(vec![])).is_empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -1042,7 +1362,7 @@ mod tests {
|
|||||||
let saved = vec![selected("provider-group", "saved")];
|
let saved = vec![selected("provider-group", "saved")];
|
||||||
let empty = proxies(vec![]);
|
let empty = proxies(vec![]);
|
||||||
|
|
||||||
let plan = reconcile_selected_nodes(&saved, Some(&empty), &empty, selected_group);
|
let plan = reconcile_selected_nodes(&saved, Some(&empty), &empty);
|
||||||
|
|
||||||
assert!(
|
assert!(
|
||||||
plan.selected.is_empty(),
|
plan.selected.is_empty(),
|
||||||
@@ -1059,7 +1379,7 @@ mod tests {
|
|||||||
let had_it = proxies(vec![("provider-group", &["saved"], Some("saved"))]);
|
let had_it = proxies(vec![("provider-group", &["saved"], Some("saved"))]);
|
||||||
let lost_it = proxies(vec![]);
|
let lost_it = proxies(vec![]);
|
||||||
|
|
||||||
let plan = reconcile_selected_nodes(&saved, Some(&had_it), &lost_it, selected_group);
|
let plan = reconcile_selected_nodes(&saved, Some(&had_it), &lost_it);
|
||||||
|
|
||||||
assert_eq!(plan.selected, saved);
|
assert_eq!(plan.selected, saved);
|
||||||
assert_eq!(plan.repaired_count, 0);
|
assert_eq!(plan.repaired_count, 0);
|
||||||
@@ -1085,7 +1405,6 @@ mod tests {
|
|||||||
&saved,
|
&saved,
|
||||||
None,
|
None,
|
||||||
&proxies(vec![("group", &["current", "saved"], Some("current"))]),
|
&proxies(vec![("group", &["current", "saved"], Some("current"))]),
|
||||||
selected_group,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(plan.selected, saved);
|
assert_eq!(plan.selected, saved);
|
||||||
@@ -1096,12 +1415,7 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn replaces_missing_node_with_valid_current_node() {
|
fn replaces_missing_node_with_valid_current_node() {
|
||||||
let snapshot = proxies(vec![("group", &["current"], Some("current"))]);
|
let snapshot = proxies(vec![("group", &["current"], Some("current"))]);
|
||||||
let plan = reconcile_selected_nodes(
|
let plan = reconcile_selected_nodes(&[selected("group", "renamed-node")], Some(&snapshot), &snapshot);
|
||||||
&[selected("group", "renamed-node")],
|
|
||||||
Some(&snapshot),
|
|
||||||
&snapshot,
|
|
||||||
selected_group,
|
|
||||||
);
|
|
||||||
|
|
||||||
assert_eq!(plan.selected, vec![selected("group", "current")]);
|
assert_eq!(plan.selected, vec![selected("group", "current")]);
|
||||||
assert!(plan.activations.is_empty());
|
assert!(plan.activations.is_empty());
|
||||||
@@ -1114,12 +1428,7 @@ mod tests {
|
|||||||
("group", &["current"], Some("current")),
|
("group", &["current"], Some("current")),
|
||||||
("other-node", &[], None),
|
("other-node", &[], None),
|
||||||
]);
|
]);
|
||||||
let plan = reconcile_selected_nodes(
|
let plan = reconcile_selected_nodes(&[selected("group", "other-node")], Some(&snapshot), &snapshot);
|
||||||
&[selected("group", "other-node")],
|
|
||||||
Some(&snapshot),
|
|
||||||
&snapshot,
|
|
||||||
selected_group,
|
|
||||||
);
|
|
||||||
|
|
||||||
assert_eq!(plan.selected, vec![selected("group", "current")]);
|
assert_eq!(plan.selected, vec![selected("group", "current")]);
|
||||||
assert!(plan.activations.is_empty());
|
assert!(plan.activations.is_empty());
|
||||||
@@ -1141,7 +1450,7 @@ mod tests {
|
|||||||
)]),
|
)]),
|
||||||
};
|
};
|
||||||
|
|
||||||
let plan = reconcile_selected_nodes(&[selected("group", "saved")], None, &snapshot, selected_group);
|
let plan = reconcile_selected_nodes(&[selected("group", "saved")], None, &snapshot);
|
||||||
|
|
||||||
assert_eq!(plan.selected, vec![selected("group", "current")]);
|
assert_eq!(plan.selected, vec![selected("group", "current")]);
|
||||||
assert!(plan.activations.is_empty());
|
assert!(plan.activations.is_empty());
|
||||||
@@ -1159,7 +1468,6 @@ mod tests {
|
|||||||
],
|
],
|
||||||
Some(&snapshot),
|
Some(&snapshot),
|
||||||
&snapshot,
|
&snapshot,
|
||||||
selected_group,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
assert!(plan.selected.is_empty());
|
assert!(plan.selected.is_empty());
|
||||||
@@ -1173,8 +1481,8 @@ mod tests {
|
|||||||
let incomplete = proxies(vec![("group", &[], None)]);
|
let incomplete = proxies(vec![("group", &[], None)]);
|
||||||
let complete = proxies(vec![("group", &["current"], Some("current"))]);
|
let complete = proxies(vec![("group", &["current"], Some("current"))]);
|
||||||
|
|
||||||
let incomplete_plan = reconcile_selected_nodes(&saved, None, &incomplete, selected_group);
|
let incomplete_plan = reconcile_selected_nodes(&saved, None, &incomplete);
|
||||||
let one_snapshot_plan = reconcile_selected_nodes(&saved, None, &complete, selected_group);
|
let one_snapshot_plan = reconcile_selected_nodes(&saved, None, &complete);
|
||||||
|
|
||||||
assert_eq!(incomplete_plan.selected, saved);
|
assert_eq!(incomplete_plan.selected, saved);
|
||||||
assert_eq!(incomplete_plan.repaired_count, 0);
|
assert_eq!(incomplete_plan.repaired_count, 0);
|
||||||
@@ -1188,7 +1496,7 @@ mod tests {
|
|||||||
let incomplete = Proxies::default();
|
let incomplete = Proxies::default();
|
||||||
let complete = proxies(vec![("group", &["current", "saved"], Some("current"))]);
|
let complete = proxies(vec![("group", &["current", "saved"], Some("current"))]);
|
||||||
|
|
||||||
let plan = reconcile_selected_nodes(&saved, Some(&incomplete), &complete, selected_group);
|
let plan = reconcile_selected_nodes(&saved, Some(&incomplete), &complete);
|
||||||
|
|
||||||
assert_eq!(plan.selected, saved);
|
assert_eq!(plan.selected, saved);
|
||||||
assert_eq!(plan.activations, vec![("group".into(), "saved".into())]);
|
assert_eq!(plan.activations, vec![("group".into(), "saved".into())]);
|
||||||
@@ -1200,7 +1508,7 @@ mod tests {
|
|||||||
let saved = vec![selected("group", "old"), selected("group", "new")];
|
let saved = vec![selected("group", "old"), selected("group", "new")];
|
||||||
let snapshot = proxies(vec![("group", &["old", "new"], Some("old"))]);
|
let snapshot = proxies(vec![("group", &["old", "new"], Some("old"))]);
|
||||||
|
|
||||||
let plan = reconcile_selected_nodes(&saved, None, &snapshot, selected_group);
|
let plan = reconcile_selected_nodes(&saved, None, &snapshot);
|
||||||
|
|
||||||
assert_eq!(plan.selected, vec![selected("group", "new")]);
|
assert_eq!(plan.selected, vec![selected("group", "new")]);
|
||||||
assert_eq!(plan.activations, vec![("group".into(), "new".into())]);
|
assert_eq!(plan.activations, vec![("group".into(), "new".into())]);
|
||||||
@@ -1215,12 +1523,8 @@ mod tests {
|
|||||||
("stale-group", &["fallback"], Some("fallback")),
|
("stale-group", &["fallback"], Some("fallback")),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(selected_nodes_need_confirmation(
|
assert!(selected_nodes_need_confirmation(&saved, &first_snapshot));
|
||||||
&saved,
|
let immediate_plan = reconcile_selected_nodes(&saved, None, &first_snapshot);
|
||||||
&first_snapshot,
|
|
||||||
selected_group
|
|
||||||
));
|
|
||||||
let immediate_plan = reconcile_selected_nodes(&saved, None, &first_snapshot, selected_group);
|
|
||||||
|
|
||||||
assert_eq!(immediate_plan.selected, saved);
|
assert_eq!(immediate_plan.selected, saved);
|
||||||
assert_eq!(immediate_plan.activations, vec![("valid-group".into(), "saved".into())]);
|
assert_eq!(immediate_plan.activations, vec![("valid-group".into(), "saved".into())]);
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ use crate::{config::Config, process::AsyncHandler, utils::dirs};
|
|||||||
use anyhow::Error;
|
use anyhow::Error;
|
||||||
use arc_swap::{ArcSwap, ArcSwapOption};
|
use arc_swap::{ArcSwap, ArcSwapOption};
|
||||||
use backon::{ConstantBuilder, Retryable as _};
|
use backon::{ConstantBuilder, Retryable as _};
|
||||||
use clash_verge_backup_archive::BackupWriter;
|
|
||||||
use clash_verge_logging::{Type, logging};
|
use clash_verge_logging::{Type, logging};
|
||||||
use reqwest_dav::list_cmd::{ListEntity, ListFile, ListMultiStatus};
|
use reqwest_dav::list_cmd::{ListEntity, ListFile, ListMultiStatus};
|
||||||
use std::{
|
use std::{
|
||||||
@@ -16,6 +15,7 @@ use std::{
|
|||||||
};
|
};
|
||||||
use tokio::{fs, time::timeout};
|
use tokio::{fs, time::timeout};
|
||||||
use tristr::alias::String;
|
use tristr::alias::String;
|
||||||
|
use zip::write::SimpleFileOptions;
|
||||||
|
|
||||||
const APP_VERSION: &str = env!("CARGO_PKG_VERSION");
|
const APP_VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||||
|
|
||||||
@@ -275,7 +275,9 @@ pub async fn create_backup() -> Result<(String, PathBuf), Error> {
|
|||||||
|
|
||||||
let value = zip_path.clone();
|
let value = zip_path.clone();
|
||||||
let file = AsyncHandler::spawn_blocking(move || std::fs::File::create(&value)).await??;
|
let file = AsyncHandler::spawn_blocking(move || std::fs::File::create(&value)).await??;
|
||||||
let mut archive = BackupWriter::new(file)?;
|
let mut zip = zip::ZipWriter::new(file);
|
||||||
|
zip.add_directory("profiles/", SimpleFileOptions::default())?;
|
||||||
|
let options = SimpleFileOptions::default().compression_method(zip::CompressionMethod::Stored);
|
||||||
|
|
||||||
if let Ok(mut entries) = fs::read_dir(dirs::app_profiles_dir()?).await {
|
if let Ok(mut entries) = fs::read_dir(dirs::app_profiles_dir()?).await {
|
||||||
while let Some(entry) = entries.next_entry().await? {
|
while let Some(entry) = entries.next_entry().await? {
|
||||||
@@ -285,16 +287,15 @@ pub async fn create_backup() -> Result<(String, PathBuf), Error> {
|
|||||||
let file_name = file_name_os
|
let file_name = file_name_os
|
||||||
.to_str()
|
.to_str()
|
||||||
.ok_or_else(|| anyhow::Error::msg("Invalid file name encoding"))?;
|
.ok_or_else(|| anyhow::Error::msg("Invalid file name encoding"))?;
|
||||||
let mut entry = archive.start_profile(file_name)?;
|
let backup_path = format!("profiles/{}", file_name);
|
||||||
|
zip.start_file(backup_path, options)?;
|
||||||
let file_content = fs::read(&path).await?;
|
let file_content = fs::read(&path).await?;
|
||||||
entry.write_all(&file_content)?;
|
zip.write_all(&file_content)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
zip.start_file(dirs::CLASH_CONFIG, options)?;
|
||||||
archive
|
zip.write_all(fs::read(dirs::clash_path()?).await?.as_slice())?;
|
||||||
.start_file(dirs::CLASH_CONFIG)?
|
|
||||||
.write_all(&fs::read(dirs::clash_path()?).await?)?;
|
|
||||||
|
|
||||||
let verge_text = fs::read_to_string(dirs::verge_path()?).await?;
|
let verge_text = fs::read_to_string(dirs::verge_path()?).await?;
|
||||||
let mut verge_config: serde_json::Value = serde_yaml_ng::from_str(&verge_text)?;
|
let mut verge_config: serde_json::Value = serde_yaml_ng::from_str(&verge_text)?;
|
||||||
@@ -303,20 +304,17 @@ pub async fn create_backup() -> Result<(String, PathBuf), Error> {
|
|||||||
obj.remove("webdav_password");
|
obj.remove("webdav_password");
|
||||||
obj.remove("webdav_url");
|
obj.remove("webdav_url");
|
||||||
}
|
}
|
||||||
archive
|
zip.start_file(dirs::VERGE_CONFIG, options)?;
|
||||||
.start_file(dirs::VERGE_CONFIG)?
|
zip.write_all(serde_yaml_ng::to_string(&verge_config)?.as_bytes())?;
|
||||||
.write_all(serde_yaml_ng::to_string(&verge_config)?.as_bytes())?;
|
|
||||||
|
|
||||||
let dns_config_path = dirs::app_home_dir()?.join(DNS_CONFIG);
|
let dns_config_path = dirs::app_home_dir()?.join(DNS_CONFIG);
|
||||||
if dns_config_path.exists() {
|
if dns_config_path.exists() {
|
||||||
archive
|
zip.start_file(DNS_CONFIG, options)?;
|
||||||
.start_file(DNS_CONFIG)?
|
zip.write_all(fs::read(&dns_config_path).await?.as_slice())?;
|
||||||
.write_all(&fs::read(&dns_config_path).await?)?;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
archive
|
zip.start_file(dirs::PROFILE_YAML, options)?;
|
||||||
.start_file(dirs::PROFILE_YAML)?
|
zip.write_all(fs::read(dirs::profiles_path()?).await?.as_slice())?;
|
||||||
.write_all(&fs::read(dirs::profiles_path()?).await?)?;
|
zip.finish()?;
|
||||||
archive.finish()?;
|
|
||||||
Ok((zip_file_name, zip_path))
|
Ok((zip_file_name, zip_path))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ use super::{CoreManager, PROFILE_SELECTIONS_PENDING_COMMIT, RunningMode};
|
|||||||
use crate::core::notify::NoticeStatus;
|
use crate::core::notify::NoticeStatus;
|
||||||
use crate::core::service::StageRequest;
|
use crate::core::service::StageRequest;
|
||||||
use crate::{
|
use crate::{
|
||||||
config::{Config, IProfiles, profiles::save_profiles, runtime::IRuntime},
|
config::{Config, IProfiles, runtime::IRuntime},
|
||||||
constants::timing,
|
constants::timing,
|
||||||
core::{
|
core::{
|
||||||
handle,
|
handle,
|
||||||
@@ -243,7 +243,7 @@ impl CoreManager {
|
|||||||
crate::config::profiles::restore_selected_nodes().await;
|
crate::config::profiles::restore_selected_nodes().await;
|
||||||
return Ok(Err(outcome));
|
return Ok(Err(outcome));
|
||||||
}
|
}
|
||||||
match save_profiles(candidate).await {
|
match candidate.save_file().await {
|
||||||
Ok(()) => {
|
Ok(()) => {
|
||||||
tracing::Span::current().record("outcome", "committed");
|
tracing::Span::current().record("outcome", "committed");
|
||||||
Ok(Ok(guard))
|
Ok(Ok(guard))
|
||||||
|
|||||||
@@ -235,7 +235,7 @@ impl CoreManager {
|
|||||||
anyhow::bail!("core startup blocked after mixed proxy port fallback failure: {reason}");
|
anyhow::bail!("core startup blocked after mixed proxy port fallback failure: {reason}");
|
||||||
}
|
}
|
||||||
|
|
||||||
use clash_verge_task::retry::{RetryError, RetryPolicy, retry};
|
use crate::utils::retry::{RetryError, RetryPolicy, retry};
|
||||||
retry(
|
retry(
|
||||||
RetryPolicy::fixed(
|
RetryPolicy::fixed(
|
||||||
std::num::NonZeroUsize::MIN.saturating_add(MAX_PORT_FALLBACK_RETRIES),
|
std::num::NonZeroUsize::MIN.saturating_add(MAX_PORT_FALLBACK_RETRIES),
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
use super::claim_core_readiness_generation;
|
use super::claim_core_readiness_generation;
|
||||||
use super::{CoreManager, PROFILE_SELECTIONS_PENDING_COMMIT, RunningMode};
|
use super::{CoreManager, PROFILE_SELECTIONS_PENDING_COMMIT, RunningMode};
|
||||||
|
use crate::utils::retry::{RetryError, RetryPolicy, retry};
|
||||||
use crate::{
|
use crate::{
|
||||||
AsyncHandler,
|
AsyncHandler,
|
||||||
config::Config,
|
config::Config,
|
||||||
@@ -10,7 +11,6 @@ use crate::{
|
|||||||
};
|
};
|
||||||
use anyhow::{Context as _, Result};
|
use anyhow::{Context as _, Result};
|
||||||
use clash_verge_logging::Type;
|
use clash_verge_logging::Type;
|
||||||
use clash_verge_task::retry::{RetryError, RetryPolicy, retry};
|
|
||||||
use futures::{
|
use futures::{
|
||||||
FutureExt as _,
|
FutureExt as _,
|
||||||
future::{Map, Shared},
|
future::{Map, Shared},
|
||||||
|
|||||||
@@ -555,7 +555,7 @@ pub async fn clear() -> Result<()> {
|
|||||||
|
|
||||||
/// A failed system call is usually a transient RPC hiccup, so give it a few tries.
|
/// A failed system call is usually a transient RPC hiccup, so give it a few tries.
|
||||||
async fn clear_with_retry() -> Result<()> {
|
async fn clear_with_retry() -> Result<()> {
|
||||||
use clash_verge_task::retry::{RetryError, RetryPolicy, retry};
|
use crate::utils::retry::{RetryError, RetryPolicy, retry};
|
||||||
retry(
|
retry(
|
||||||
RetryPolicy::fixed(
|
RetryPolicy::fixed(
|
||||||
std::num::NonZeroUsize::MIN.saturating_add((CLEAR_ATTEMPTS - 1) as usize),
|
std::num::NonZeroUsize::MIN.saturating_add((CLEAR_ATTEMPTS - 1) as usize),
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ impl<E: RunStateEnv> RunStateStore<E> {
|
|||||||
|
|
||||||
/// Retries transport failures but stops at the first readable reply, including a rejection.
|
/// Retries transport failures but stops at the first readable reply, including a rejection.
|
||||||
pub async fn await_ready(&self, attempts: usize, interval: Duration) -> Result<RunState, ReadyWaitError> {
|
pub async fn await_ready(&self, attempts: usize, interval: Duration) -> Result<RunState, ReadyWaitError> {
|
||||||
use clash_verge_task::retry::{RetryError, RetryPolicy, retry};
|
use crate::utils::retry::{RetryError, RetryPolicy, retry};
|
||||||
let attempts = std::num::NonZeroUsize::new(attempts).ok_or_else(|| {
|
let attempts = std::num::NonZeroUsize::new(attempts).ok_or_else(|| {
|
||||||
ReadyWaitError::Unreachable(anyhow::anyhow!(
|
ReadyWaitError::Unreachable(anyhow::anyhow!(
|
||||||
"service readiness wait was configured with no attempts"
|
"service readiness wait was configured with no attempts"
|
||||||
|
|||||||
@@ -1282,7 +1282,7 @@ async fn create_sync_temp(target: &Path) -> Result<(PathBuf, tokio::fs::File)> {
|
|||||||
.with_context(|| format!("failed to create provider cache directory {}", parent.display()))?;
|
.with_context(|| format!("failed to create provider cache directory {}", parent.display()))?;
|
||||||
}
|
}
|
||||||
let name = target.file_name().map_or_default(|name| name.to_string_lossy());
|
let name = target.file_name().map_or_default(|name| name.to_string_lossy());
|
||||||
use clash_verge_task::retry::{RetryError, RetryPolicy, retry};
|
use crate::utils::retry::{RetryError, RetryPolicy, retry};
|
||||||
retry(
|
retry(
|
||||||
RetryPolicy::fixed(std::num::NonZeroUsize::MIN.saturating_add(7), std::time::Duration::ZERO),
|
RetryPolicy::fixed(std::num::NonZeroUsize::MIN.saturating_add(7), std::time::Duration::ZERO),
|
||||||
|_| async {
|
|_| async {
|
||||||
@@ -1699,7 +1699,7 @@ async fn recover_after_owner_loss_while_locked(reason: OwnerRecoveryReason) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn clear_proxy_after_owner_loss() {
|
async fn clear_proxy_after_owner_loss() {
|
||||||
use clash_verge_task::retry::{RetryError, RetryPolicy, retry};
|
use crate::utils::retry::{RetryError, RetryPolicy, retry};
|
||||||
let result = retry(
|
let result = retry(
|
||||||
RetryPolicy::fixed(
|
RetryPolicy::fixed(
|
||||||
std::num::NonZeroUsize::MIN.saturating_add(2),
|
std::num::NonZeroUsize::MIN.saturating_add(2),
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ use crate::{
|
|||||||
use anyhow::{Context as _, Result};
|
use anyhow::{Context as _, Result};
|
||||||
use clash_verge_draft::Draft;
|
use clash_verge_draft::Draft;
|
||||||
use clash_verge_logging::{Type, logging, logging_error};
|
use clash_verge_logging::{Type, logging, logging_error};
|
||||||
use clash_verge_profile::SubscriptionSchedule as TaskSchedule;
|
|
||||||
use futures::{FutureExt as _, StreamExt as _};
|
use futures::{FutureExt as _, StreamExt as _};
|
||||||
use std::{collections::HashMap, panic::AssertUnwindSafe, time::Duration};
|
use std::{collections::HashMap, panic::AssertUnwindSafe, time::Duration};
|
||||||
use tokio::{
|
use tokio::{
|
||||||
@@ -25,6 +24,28 @@ enum TimerCommand {
|
|||||||
TaskFinished(String),
|
TaskFinished(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Next update is due at `updated + interval`, but the queue only takes a delay from now.
|
||||||
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
|
struct TaskSchedule {
|
||||||
|
interval_minutes: u64,
|
||||||
|
first_delay: Duration,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TaskSchedule {
|
||||||
|
/// No recorded `updated` -> full interval. Deadline already past -> `ZERO`, fires at once.
|
||||||
|
fn new(interval_minutes: u64, updated: Option<usize>, now: i64) -> Self {
|
||||||
|
let full = Timer::interval_duration(interval_minutes);
|
||||||
|
let elapsed = updated
|
||||||
|
.filter(|updated| *updated > 0)
|
||||||
|
.map_or(0, |updated| now.saturating_sub(updated as i64).max(0) as u64);
|
||||||
|
|
||||||
|
Self {
|
||||||
|
interval_minutes,
|
||||||
|
first_delay: full.saturating_sub(Duration::from_secs(elapsed)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct TaskState {
|
struct TaskState {
|
||||||
key: Option<Key>,
|
key: Option<Key>,
|
||||||
interval_minutes: u64,
|
interval_minutes: u64,
|
||||||
@@ -101,9 +122,16 @@ impl Timer {
|
|||||||
let mut new_map = HashMap::new();
|
let mut new_map = HashMap::new();
|
||||||
|
|
||||||
for item in items {
|
for item in items {
|
||||||
if let Some(uid) = &item.uid
|
if let Some(option) = item.option.as_ref()
|
||||||
&& let Some(schedule) = TaskSchedule::for_profile(item, initializing, now)
|
&& let (Some(interval), Some(uid)) = (option.update_interval, &item.uid)
|
||||||
|
&& option.allow_auto_update.unwrap_or(true)
|
||||||
|
&& interval > 0
|
||||||
{
|
{
|
||||||
|
let mut schedule = TaskSchedule::new(interval, item.updated, now);
|
||||||
|
// Startup historically treats an explicit zero timestamp as overdue.
|
||||||
|
if initializing && item.updated == Some(0) {
|
||||||
|
schedule.first_delay = Duration::ZERO;
|
||||||
|
}
|
||||||
new_map.insert(uid.clone(), schedule);
|
new_map.insert(uid.clone(), schedule);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -289,7 +317,7 @@ impl Timer {
|
|||||||
|
|
||||||
// Full interval, not from `updated`: a failed run leaves `updated` in the past, so
|
// Full interval, not from `updated`: a failed run leaves `updated` in the past, so
|
||||||
// counting from it would retry at zero delay and spin.
|
// counting from it would retry at zero delay and spin.
|
||||||
let key = Self::schedule_task(queue, &uid, TaskSchedule::interval_duration(state.interval_minutes));
|
let key = Self::schedule_task(queue, &uid, Self::interval_duration(state.interval_minutes));
|
||||||
state.key = Some(key);
|
state.key = Some(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -302,6 +330,10 @@ impl Timer {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const fn interval_duration(interval_minutes: u64) -> Duration {
|
||||||
|
Duration::from_secs(interval_minutes.saturating_mul(60))
|
||||||
|
}
|
||||||
|
|
||||||
fn schedule_task(queue: &mut DelayQueue<String>, uid: &str, delay: Duration) -> Key {
|
fn schedule_task(queue: &mut DelayQueue<String>, uid: &str, delay: Duration) -> Key {
|
||||||
queue.insert(String::from(uid), delay)
|
queue.insert(String::from(uid), delay)
|
||||||
}
|
}
|
||||||
@@ -316,8 +348,10 @@ impl Timer {
|
|||||||
|
|
||||||
fn next_update_time(tasks: &HashMap<String, TaskState>, profiles: &IProfiles, uid: &str) -> Option<i64> {
|
fn next_update_time(tasks: &HashMap<String, TaskState>, profiles: &IProfiles, uid: &str) -> Option<i64> {
|
||||||
let task = tasks.get(uid).filter(|task| !task.retired)?;
|
let task = tasks.get(uid).filter(|task| !task.retired)?;
|
||||||
let updated = profiles.get_item(uid).ok()?.updated;
|
let updated = profiles.get_item(uid).ok()?.updated.filter(|updated| *updated > 0)?;
|
||||||
TaskSchedule::reported_deadline(task.interval_minutes, updated)
|
let updated = i64::try_from(updated).ok()?;
|
||||||
|
let interval = i64::try_from(task.interval_minutes).ok()?.checked_mul(60)?;
|
||||||
|
updated.checked_add(interval)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn emit_update_event(uid: &str, is_start: bool) {
|
fn emit_update_event(uid: &str, is_start: bool) {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ use crate::config::dns::{DnsOverrideState, dns_override_source};
|
|||||||
use crate::core::handle::Handle;
|
use crate::core::handle::Handle;
|
||||||
use crate::utils::dirs;
|
use crate::utils::dirs;
|
||||||
use crate::{
|
use crate::{
|
||||||
config::{Config, IProfiles, IVerge, PrfItem, profiles::current_mapping},
|
config::{Config, IProfiles, IVerge, PrfItem},
|
||||||
constants,
|
constants,
|
||||||
utils::tmpl,
|
utils::tmpl,
|
||||||
};
|
};
|
||||||
@@ -174,7 +174,8 @@ async fn collect_profile_items(profiles: &IProfiles) -> Result<ProfileItems> {
|
|||||||
None => return Ok(ProfileItems::default()),
|
None => return Ok(ProfileItems::default()),
|
||||||
};
|
};
|
||||||
|
|
||||||
let current = current_mapping(profiles)
|
let current = profiles
|
||||||
|
.current_mapping()
|
||||||
.await
|
.await
|
||||||
.with_context(|| format!("failed to read current profile \"{current_profile_uid}\""))?;
|
.with_context(|| format!("failed to read current profile \"{current_profile_uid}\""))?;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
config::{Config, IClashTemp, IVerge, profiles::load_profiles},
|
config::{Config, IClashTemp, IProfiles, IVerge},
|
||||||
core::{CoreManager, auto_backup, backup, proxy_control, proxy_control::SystemProxyStateUnknown},
|
core::{CoreManager, auto_backup, backup, proxy_control, proxy_control::SystemProxyStateUnknown},
|
||||||
process::AsyncHandler,
|
process::AsyncHandler,
|
||||||
utils::{
|
utils::{
|
||||||
@@ -46,7 +46,7 @@ async fn finalize_restored_verge_config(
|
|||||||
});
|
});
|
||||||
clash_draft.apply();
|
clash_draft.apply();
|
||||||
|
|
||||||
let restored_profiles = load_profiles().await;
|
let restored_profiles = IProfiles::new().await;
|
||||||
let profiles_draft = Config::profiles().await;
|
let profiles_draft = Config::profiles().await;
|
||||||
profiles_draft.edit_draft(|d| {
|
profiles_draft.edit_draft(|d| {
|
||||||
*d = restored_profiles;
|
*d = restored_profiles;
|
||||||
|
|||||||
@@ -349,7 +349,7 @@ fn stage_core(target: &Path, package: &[u8], version: &str) -> Result<StagedCore
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn create_staging_file(directory: &Path, core_name: &OsStr) -> Result<(PathBuf, File)> {
|
fn create_staging_file(directory: &Path, core_name: &OsStr) -> Result<(PathBuf, File)> {
|
||||||
use clash_verge_task::retry::{RetryError, RetryPolicy, retry_sync};
|
use crate::utils::retry::{RetryError, RetryPolicy, retry_sync};
|
||||||
retry_sync(
|
retry_sync(
|
||||||
RetryPolicy::fixed(
|
RetryPolicy::fixed(
|
||||||
std::num::NonZeroUsize::MIN.saturating_add(31),
|
std::num::NonZeroUsize::MIN.saturating_add(31),
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use crate::{
|
|||||||
config::{
|
config::{
|
||||||
Config,
|
Config,
|
||||||
dns::{ProfileDnsSettings, dns_override_source},
|
dns::{ProfileDnsSettings, dns_override_source},
|
||||||
profiles::{PROFILE_WRITE_LOCK, current_mapping},
|
profiles::PROFILE_WRITE_LOCK,
|
||||||
},
|
},
|
||||||
constants::files::DNS_CONFIG,
|
constants::files::DNS_CONFIG,
|
||||||
core::CoreManager,
|
core::CoreManager,
|
||||||
@@ -36,7 +36,7 @@ pub async fn set_dns_override(
|
|||||||
);
|
);
|
||||||
let source = dns_override_source(
|
let source = dns_override_source(
|
||||||
profiles.current.as_deref().unwrap_or_default(),
|
profiles.current.as_deref().unwrap_or_default(),
|
||||||
¤t_mapping(&profiles).await?,
|
&profiles.current_mapping().await?,
|
||||||
)?;
|
)?;
|
||||||
if enabled && let Some(source) = source.as_ref().filter(|source| Some(*source) != confirmation.as_ref()) {
|
if enabled && let Some(source) = source.as_ref().filter(|source| Some(*source) != confirmation.as_ref()) {
|
||||||
return Ok(DnsOverrideOutcome::ConfirmationRequired { source: source.clone() });
|
return Ok(DnsOverrideOutcome::ConfirmationRequired { source: source.clone() });
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ mod icon;
|
|||||||
mod listener;
|
mod listener;
|
||||||
mod profile;
|
mod profile;
|
||||||
mod proxy;
|
mod proxy;
|
||||||
mod subscription;
|
|
||||||
mod tun;
|
mod tun;
|
||||||
mod window;
|
mod window;
|
||||||
|
|
||||||
@@ -23,6 +22,5 @@ pub use icon::*;
|
|||||||
pub use listener::*;
|
pub use listener::*;
|
||||||
pub use profile::*;
|
pub use profile::*;
|
||||||
pub use proxy::*;
|
pub use proxy::*;
|
||||||
pub use subscription::update_profile;
|
|
||||||
pub use tun::*;
|
pub use tun::*;
|
||||||
pub use window::*;
|
pub use window::*;
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
|
use crate::core::notify::NoticeStatus;
|
||||||
use crate::core::notify::{Refresh, announce};
|
use crate::core::notify::{Refresh, announce};
|
||||||
use crate::{
|
use crate::{
|
||||||
cmd,
|
cmd,
|
||||||
config::Config,
|
config::{Config, PrfItem, PrfOption, profiles::profiles_update_item_safe},
|
||||||
core::{CoreManager, handle, tray, validate::ValidationOutcome},
|
core::{CoreManager, handle, tray, validate::ValidationOutcome},
|
||||||
process::AsyncHandler,
|
process::AsyncHandler,
|
||||||
|
utils::help::{mask_err, mask_url},
|
||||||
};
|
};
|
||||||
use anyhow::Result;
|
use anyhow::{Result, bail};
|
||||||
use clash_verge_logging::{Type, logging};
|
use clash_verge_logging::{Type, logging};
|
||||||
use std::collections::{HashMap, HashSet};
|
use std::collections::{HashMap, HashSet};
|
||||||
use tauri_plugin_mihomo::models::{Proxy, ProxyType, Rule};
|
use tauri_plugin_mihomo::models::{Proxy, ProxyType, Rule};
|
||||||
@@ -199,6 +201,179 @@ async fn finish_proxy_switch(stale_proxies: Vec<std::string::String>) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn should_update_profile(uid: &str, ignore_auto_update: bool) -> Result<Option<(String, Option<PrfOption>)>> {
|
||||||
|
let profiles = Config::profiles().await;
|
||||||
|
let profiles = profiles.latest_arc();
|
||||||
|
let item = profiles.get_item(uid)?;
|
||||||
|
let is_remote = item.itype.as_ref().is_some_and(|s| s == "remote");
|
||||||
|
|
||||||
|
if !is_remote {
|
||||||
|
logging!(info, Type::Config, "[订阅更新] 不是远程订阅,跳过更新");
|
||||||
|
Ok(None)
|
||||||
|
} else if item.url.is_none() {
|
||||||
|
logging!(warn, Type::Config, "[订阅更新] 缺少URL,无法更新");
|
||||||
|
bail!("failed to get the profile item url");
|
||||||
|
} else if !ignore_auto_update && !item.option.as_ref().and_then(|o| o.allow_auto_update).unwrap_or(true) {
|
||||||
|
logging!(info, Type::Config, "[订阅更新] 禁止自动更新,跳过更新");
|
||||||
|
Ok(None)
|
||||||
|
} else {
|
||||||
|
logging!(
|
||||||
|
info,
|
||||||
|
Type::Config,
|
||||||
|
"[订阅更新] 远程订阅,URL: {}",
|
||||||
|
mask_url(
|
||||||
|
item.url
|
||||||
|
.as_ref()
|
||||||
|
.ok_or_else(|| anyhow::anyhow!("Profile URL is None"))?
|
||||||
|
)
|
||||||
|
);
|
||||||
|
Ok(Some((
|
||||||
|
item.url.clone().ok_or_else(|| anyhow::anyhow!("Profile URL is None"))?,
|
||||||
|
item.option.clone(),
|
||||||
|
)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tracing::instrument(skip_all, level = "info", fields(uid = %uid, strategy = tracing::field::Empty, configured_elapsed = tracing::field::Empty, clash_elapsed = tracing::field::Empty, system_elapsed = tracing::field::Empty))]
|
||||||
|
async fn perform_profile_update(
|
||||||
|
uid: &str,
|
||||||
|
url: &str,
|
||||||
|
opt: Option<&PrfOption>,
|
||||||
|
option: Option<&PrfOption>,
|
||||||
|
is_mannual_trigger: bool,
|
||||||
|
) -> Result<()> {
|
||||||
|
let merged_opt = PrfOption::merge(opt, option);
|
||||||
|
let profiles = Config::profiles().await;
|
||||||
|
let profiles_arc = profiles.latest_arc();
|
||||||
|
let profile_name = profiles_arc
|
||||||
|
.get_item(uid)
|
||||||
|
.ok()
|
||||||
|
.and_then(|item| item.name.clone())
|
||||||
|
.unwrap_or_else(|| String::from("UnKnown Profile"));
|
||||||
|
|
||||||
|
#[derive(Clone, Copy)]
|
||||||
|
enum Strategy {
|
||||||
|
Configured,
|
||||||
|
Clash,
|
||||||
|
System,
|
||||||
|
}
|
||||||
|
|
||||||
|
let result =
|
||||||
|
crate::utils::retry::try_strategies(Strategy::Configured, [Strategy::Clash, Strategy::System], |strategy| {
|
||||||
|
let mut options = merged_opt.clone();
|
||||||
|
async move {
|
||||||
|
let (name, success, failure) = match strategy {
|
||||||
|
Strategy::Configured => (
|
||||||
|
"configured",
|
||||||
|
"[订阅更新] 更新订阅配置成功",
|
||||||
|
"[订阅更新] 直接更新失败: {},尝试使用Clash代理更新",
|
||||||
|
),
|
||||||
|
Strategy::Clash => (
|
||||||
|
"clash",
|
||||||
|
"[订阅更新] 使用 Clash代理 更新订阅配置成功",
|
||||||
|
"[订阅更新] Clash代理更新失败: {},尝试使用系统代理更新",
|
||||||
|
),
|
||||||
|
Strategy::System => (
|
||||||
|
"system",
|
||||||
|
"[订阅更新] 使用 系统代理 更新订阅配置成功",
|
||||||
|
"[订阅更新] 系统代理更新失败: {},所有重试均已失败",
|
||||||
|
),
|
||||||
|
};
|
||||||
|
match strategy {
|
||||||
|
Strategy::Configured => {}
|
||||||
|
Strategy::Clash | Strategy::System => {
|
||||||
|
let option = options.get_or_insert_with(PrfOption::default);
|
||||||
|
option.self_proxy = Some(matches!(strategy, Strategy::Clash));
|
||||||
|
option.with_proxy = Some(matches!(strategy, Strategy::System));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tracing::Span::current().record("strategy", name);
|
||||||
|
let started = std::time::Instant::now();
|
||||||
|
let result = PrfItem::from_url(url, None, None, options.as_ref()).await;
|
||||||
|
let elapsed_field = match strategy {
|
||||||
|
Strategy::Configured => "configured_elapsed",
|
||||||
|
Strategy::Clash => "clash_elapsed",
|
||||||
|
Strategy::System => "system_elapsed",
|
||||||
|
};
|
||||||
|
tracing::Span::current().record(elapsed_field, tracing::field::debug(started.elapsed()));
|
||||||
|
match &result {
|
||||||
|
Ok(_) => logging!(info, Type::Config, "{success}"),
|
||||||
|
Err(error) => logging!(
|
||||||
|
warn,
|
||||||
|
Type::Config,
|
||||||
|
"{}",
|
||||||
|
failure.replace("{}", &mask_err(&format!("{error:#}")))
|
||||||
|
),
|
||||||
|
}
|
||||||
|
result
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.await;
|
||||||
|
let last_err = match result {
|
||||||
|
Ok((strategy, mut item)) => {
|
||||||
|
// A persistence error must not replay a successful download with another transport.
|
||||||
|
profiles_update_item_safe(uid, &mut item).await?;
|
||||||
|
if !matches!(strategy, Strategy::Configured) {
|
||||||
|
handle::Handle::notice(NoticeStatus::UpdateWithClashProxy, profile_name.as_str());
|
||||||
|
}
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
Err(error) => error,
|
||||||
|
};
|
||||||
|
|
||||||
|
let last_err = mask_err(&last_err.to_string());
|
||||||
|
if is_mannual_trigger {
|
||||||
|
handle::Handle::notice(
|
||||||
|
NoticeStatus::UpdateFailedEvenWithClash,
|
||||||
|
format!("{profile_name} - {last_err}"),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
bail!(last_err)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tracing::instrument(skip_all, level = "info", fields(uid = %uid, manual = is_mannual_trigger))]
|
||||||
|
pub async fn update_profile(uid: &str, option: Option<&PrfOption>, is_mannual_trigger: bool) -> Result<()> {
|
||||||
|
let url_opt = should_update_profile(uid, is_mannual_trigger).await?;
|
||||||
|
|
||||||
|
let profile_persisted = match url_opt {
|
||||||
|
Some((url, opt)) => {
|
||||||
|
perform_profile_update(uid, &url, opt.as_ref(), option, is_mannual_trigger).await?;
|
||||||
|
true
|
||||||
|
}
|
||||||
|
None => false,
|
||||||
|
};
|
||||||
|
let profiles = Config::profiles().await;
|
||||||
|
let is_current = profiles.latest_arc().current.as_deref() == Some(uid);
|
||||||
|
let should_refresh = is_current || (!profile_persisted && is_mannual_trigger);
|
||||||
|
|
||||||
|
if should_refresh {
|
||||||
|
logging!(debug, Type::Config, "[订阅更新] 更新内核配置");
|
||||||
|
match CoreManager::global().update_config_with_force(is_mannual_trigger).await {
|
||||||
|
Ok(outcome) if outcome.is_valid() => announce(Refresh::Clash),
|
||||||
|
Ok(outcome @ (ValidationOutcome::Skipped { .. } | ValidationOutcome::Busy)) if !is_mannual_trigger => {
|
||||||
|
logging!(info, Type::Config, "[订阅更新] 本次配置刷新已跳过: {}", outcome);
|
||||||
|
}
|
||||||
|
result => {
|
||||||
|
let message = match result {
|
||||||
|
Ok(outcome) => outcome.to_string(),
|
||||||
|
Err(err) => err.to_string(),
|
||||||
|
};
|
||||||
|
let message = mask_err(&message);
|
||||||
|
let message = if profile_persisted {
|
||||||
|
format!("订阅已保存,但未能确认已应用到内核: {message}")
|
||||||
|
} else {
|
||||||
|
message
|
||||||
|
};
|
||||||
|
logging!(error, Type::Config, "[订阅更新] 更新失败: {}", message);
|
||||||
|
handle::Handle::notice(NoticeStatus::UpdateFailed, message.as_str());
|
||||||
|
bail!(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
/// 增强配置
|
/// 增强配置
|
||||||
pub async fn enhance_profiles() -> Result<ValidationOutcome> {
|
pub async fn enhance_profiles() -> Result<ValidationOutcome> {
|
||||||
CoreManager::global().update_config_forced().await
|
CoreManager::global().update_config_forced().await
|
||||||
|
|||||||
@@ -1,196 +0,0 @@
|
|||||||
use crate::{
|
|
||||||
config::{Config, PrfOption, download_subscription, prepare_remote_refresh, profiles::apply_remote_refresh_safe},
|
|
||||||
core::{
|
|
||||||
CoreManager, handle,
|
|
||||||
notify::{NoticeStatus, Refresh, announce},
|
|
||||||
validate::ValidationOutcome,
|
|
||||||
},
|
|
||||||
utils::help::{mask_err, mask_url},
|
|
||||||
};
|
|
||||||
use anyhow::{Result, bail};
|
|
||||||
use clash_verge_logging::{Type, logging};
|
|
||||||
use tristr::alias::String;
|
|
||||||
|
|
||||||
async fn should_update_profile(uid: &str, ignore_auto_update: bool) -> Result<Option<(String, Option<PrfOption>)>> {
|
|
||||||
let profiles = Config::profiles().await;
|
|
||||||
let profiles = profiles.latest_arc();
|
|
||||||
let item = profiles.get_item(uid)?;
|
|
||||||
let is_remote = item.itype.as_ref().is_some_and(|s| s == "remote");
|
|
||||||
|
|
||||||
if !is_remote {
|
|
||||||
logging!(info, Type::Config, "[订阅更新] 不是远程订阅,跳过更新");
|
|
||||||
Ok(None)
|
|
||||||
} else if item.url.is_none() {
|
|
||||||
logging!(warn, Type::Config, "[订阅更新] 缺少URL,无法更新");
|
|
||||||
bail!("failed to get the profile item url");
|
|
||||||
} else if !ignore_auto_update && !item.option.as_ref().and_then(|o| o.allow_auto_update).unwrap_or(true) {
|
|
||||||
logging!(info, Type::Config, "[订阅更新] 禁止自动更新,跳过更新");
|
|
||||||
Ok(None)
|
|
||||||
} else {
|
|
||||||
logging!(
|
|
||||||
info,
|
|
||||||
Type::Config,
|
|
||||||
"[订阅更新] 远程订阅,URL: {}",
|
|
||||||
mask_url(
|
|
||||||
item.url
|
|
||||||
.as_ref()
|
|
||||||
.ok_or_else(|| anyhow::anyhow!("Profile URL is None"))?
|
|
||||||
)
|
|
||||||
);
|
|
||||||
Ok(Some((
|
|
||||||
item.url.clone().ok_or_else(|| anyhow::anyhow!("Profile URL is None"))?,
|
|
||||||
item.option.clone(),
|
|
||||||
)))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[tracing::instrument(skip_all, level = "info", fields(uid = %uid, strategy = tracing::field::Empty, configured_elapsed = tracing::field::Empty, clash_elapsed = tracing::field::Empty, system_elapsed = tracing::field::Empty))]
|
|
||||||
async fn perform_profile_update(
|
|
||||||
uid: &str,
|
|
||||||
url: &str,
|
|
||||||
opt: Option<&PrfOption>,
|
|
||||||
option: Option<&PrfOption>,
|
|
||||||
is_manual_trigger: bool,
|
|
||||||
) -> Result<()> {
|
|
||||||
let merged_opt = PrfOption::merge(opt, option);
|
|
||||||
let profiles = Config::profiles().await;
|
|
||||||
let profiles_arc = profiles.latest_arc();
|
|
||||||
let profile_name = profiles_arc
|
|
||||||
.get_item(uid)
|
|
||||||
.ok()
|
|
||||||
.and_then(|item| item.name.clone())
|
|
||||||
.unwrap_or_else(|| String::from("UnKnown Profile"));
|
|
||||||
|
|
||||||
#[derive(Clone, Copy)]
|
|
||||||
enum Strategy {
|
|
||||||
Configured,
|
|
||||||
Clash,
|
|
||||||
System,
|
|
||||||
}
|
|
||||||
|
|
||||||
let result = clash_verge_task::retry::try_strategies(
|
|
||||||
Strategy::Configured,
|
|
||||||
[Strategy::Clash, Strategy::System],
|
|
||||||
|strategy| {
|
|
||||||
let mut options = merged_opt.clone();
|
|
||||||
async move {
|
|
||||||
let (name, success, failure) = match strategy {
|
|
||||||
Strategy::Configured => (
|
|
||||||
"configured",
|
|
||||||
"[订阅更新] 更新订阅配置成功",
|
|
||||||
"[订阅更新] 直接更新失败: {},尝试使用Clash代理更新",
|
|
||||||
),
|
|
||||||
Strategy::Clash => (
|
|
||||||
"clash",
|
|
||||||
"[订阅更新] 使用 Clash代理 更新订阅配置成功",
|
|
||||||
"[订阅更新] Clash代理更新失败: {},尝试使用系统代理更新",
|
|
||||||
),
|
|
||||||
Strategy::System => (
|
|
||||||
"system",
|
|
||||||
"[订阅更新] 使用 系统代理 更新订阅配置成功",
|
|
||||||
"[订阅更新] 系统代理更新失败: {},所有重试均已失败",
|
|
||||||
),
|
|
||||||
};
|
|
||||||
match strategy {
|
|
||||||
Strategy::Configured => {}
|
|
||||||
Strategy::Clash | Strategy::System => {
|
|
||||||
let option = options.get_or_insert_with(PrfOption::default);
|
|
||||||
option.self_proxy = Some(matches!(strategy, Strategy::Clash));
|
|
||||||
option.with_proxy = Some(matches!(strategy, Strategy::System));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tracing::Span::current().record("strategy", name);
|
|
||||||
let started = std::time::Instant::now();
|
|
||||||
let result = download_subscription(url, options.as_ref()).await;
|
|
||||||
let elapsed_field = match strategy {
|
|
||||||
Strategy::Configured => "configured_elapsed",
|
|
||||||
Strategy::Clash => "clash_elapsed",
|
|
||||||
Strategy::System => "system_elapsed",
|
|
||||||
};
|
|
||||||
tracing::Span::current().record(elapsed_field, tracing::field::debug(started.elapsed()));
|
|
||||||
match &result {
|
|
||||||
Ok(_) => logging!(info, Type::Config, "{success}"),
|
|
||||||
Err(error) => logging!(
|
|
||||||
warn,
|
|
||||||
Type::Config,
|
|
||||||
"{}",
|
|
||||||
failure.replace("{}", &mask_err(&format!("{error:#}")))
|
|
||||||
),
|
|
||||||
}
|
|
||||||
result
|
|
||||||
}
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.await;
|
|
||||||
let last_err = match result {
|
|
||||||
Ok((strategy, downloaded)) => {
|
|
||||||
// A persistence error must not replay a successful download with another transport.
|
|
||||||
let profiles = Config::profiles().await;
|
|
||||||
let snapshot = profiles.latest_arc();
|
|
||||||
let current = snapshot.get_item(uid)?;
|
|
||||||
anyhow::ensure!(
|
|
||||||
current.itype.as_deref() == Some("remote") && current.url.as_deref() == Some(url),
|
|
||||||
"profile source changed during refresh"
|
|
||||||
);
|
|
||||||
let refresh = prepare_remote_refresh(downloaded, merged_opt.as_ref()).await?;
|
|
||||||
apply_remote_refresh_safe(uid, url, refresh).await?;
|
|
||||||
if !matches!(strategy, Strategy::Configured) {
|
|
||||||
handle::Handle::notice(NoticeStatus::UpdateWithClashProxy, profile_name.as_str());
|
|
||||||
}
|
|
||||||
return Ok(());
|
|
||||||
}
|
|
||||||
Err(error) => error,
|
|
||||||
};
|
|
||||||
|
|
||||||
let last_err = mask_err(&last_err.to_string());
|
|
||||||
if is_manual_trigger {
|
|
||||||
handle::Handle::notice(
|
|
||||||
NoticeStatus::UpdateFailedEvenWithClash,
|
|
||||||
format!("{profile_name} - {last_err}"),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
bail!(last_err)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[tracing::instrument(skip_all, level = "info", fields(uid = %uid, manual = is_manual_trigger))]
|
|
||||||
pub async fn update_profile(uid: &str, option: Option<&PrfOption>, is_manual_trigger: bool) -> Result<()> {
|
|
||||||
let url_opt = should_update_profile(uid, is_manual_trigger).await?;
|
|
||||||
|
|
||||||
let profile_persisted = match url_opt {
|
|
||||||
Some((url, opt)) => {
|
|
||||||
perform_profile_update(uid, &url, opt.as_ref(), option, is_manual_trigger).await?;
|
|
||||||
true
|
|
||||||
}
|
|
||||||
None => false,
|
|
||||||
};
|
|
||||||
let profiles = Config::profiles().await;
|
|
||||||
let is_current = profiles.latest_arc().current.as_deref() == Some(uid);
|
|
||||||
let should_refresh = is_current || (!profile_persisted && is_manual_trigger);
|
|
||||||
|
|
||||||
if should_refresh {
|
|
||||||
logging!(debug, Type::Config, "[订阅更新] 更新内核配置");
|
|
||||||
match CoreManager::global().update_config_with_force(is_manual_trigger).await {
|
|
||||||
Ok(outcome) if outcome.is_valid() => announce(Refresh::Clash),
|
|
||||||
Ok(outcome @ (ValidationOutcome::Skipped { .. } | ValidationOutcome::Busy)) if !is_manual_trigger => {
|
|
||||||
logging!(info, Type::Config, "[订阅更新] 本次配置刷新已跳过: {}", outcome);
|
|
||||||
}
|
|
||||||
result => {
|
|
||||||
let message = match result {
|
|
||||||
Ok(outcome) => outcome.to_string(),
|
|
||||||
Err(err) => err.to_string(),
|
|
||||||
};
|
|
||||||
let message = mask_err(&message);
|
|
||||||
let message = if profile_persisted {
|
|
||||||
format!("订阅已保存,但未能确认已应用到内核: {message}")
|
|
||||||
} else {
|
|
||||||
message
|
|
||||||
};
|
|
||||||
logging!(error, Type::Config, "[订阅更新] 更新失败: {}", message);
|
|
||||||
handle::Handle::notice(NoticeStatus::UpdateFailed, message.as_str());
|
|
||||||
bail!(message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
#![allow(non_snake_case)]
|
#![allow(non_snake_case)]
|
||||||
#![deny(clippy::expect_used, clippy::unwrap_used)]
|
|
||||||
#![recursion_limit = "512"]
|
#![recursion_limit = "512"]
|
||||||
|
|
||||||
mod cmd;
|
mod cmd;
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||||
#![deny(clippy::expect_used, clippy::unwrap_used)]
|
|
||||||
|
|
||||||
use std::process::ExitCode;
|
use std::process::ExitCode;
|
||||||
#[cfg(not(all(feature = "perf-harness", target_os = "macos")))]
|
#[cfg(not(all(feature = "perf-harness", target_os = "macos")))]
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ use serde_yaml_ng::{Mapping, Value};
|
|||||||
use std::{
|
use std::{
|
||||||
mem::DropGuard,
|
mem::DropGuard,
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
|
str::FromStr,
|
||||||
};
|
};
|
||||||
use tokio::io::AsyncWriteExt as _;
|
use tokio::io::AsyncWriteExt as _;
|
||||||
|
|
||||||
@@ -211,6 +212,16 @@ pub fn get_uid(prefix: &str) -> String {
|
|||||||
format!("{prefix}{id}")
|
format!("{prefix}{id}")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn parse_str<T: FromStr>(target: &str, key: &str) -> Option<T> {
|
||||||
|
target.split(';').map(str::trim).find_map(|s| {
|
||||||
|
let mut parts = s.splitn(2, '=');
|
||||||
|
match (parts.next(), parts.next()) {
|
||||||
|
(Some(k), Some(v)) if k == key => v.parse::<T>().ok(),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
pub fn hex_encode(bytes: &[u8]) -> String {
|
pub fn hex_encode(bytes: &[u8]) -> String {
|
||||||
const HEX: &[u8; 16] = b"0123456789abcdef";
|
const HEX: &[u8; 16] = b"0123456789abcdef";
|
||||||
let mut out = String::with_capacity(bytes.len() * 2);
|
let mut out = String::with_capacity(bytes.len() * 2);
|
||||||
@@ -296,6 +307,18 @@ pub fn mask_err(err: &str) -> String {
|
|||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_last_part_and_decode(url: &str) -> Option<String> {
|
||||||
|
let path = url.split('?').next().unwrap_or("");
|
||||||
|
let segments: Vec<&str> = path.split('/').collect();
|
||||||
|
let last_segment = segments.last()?;
|
||||||
|
|
||||||
|
Some(
|
||||||
|
percent_encoding::percent_decode_str(last_segment)
|
||||||
|
.decode_utf8_lossy()
|
||||||
|
.to_string(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn open_file(path: PathBuf) -> Result<()> {
|
pub fn open_file(path: PathBuf) -> Result<()> {
|
||||||
open::that_detached(path.as_os_str())?;
|
open::that_detached(path.as_os_str())?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
config::{
|
config::{Config, IClashTemp, IProfiles, IVerge},
|
||||||
Config, IClashTemp, IProfiles, IVerge,
|
|
||||||
profiles::{raise_short_update_intervals, save_profiles},
|
|
||||||
},
|
|
||||||
constants,
|
constants,
|
||||||
core::handle,
|
core::handle,
|
||||||
logging,
|
logging,
|
||||||
@@ -269,9 +266,9 @@ pub async fn migrate_short_update_intervals() -> Result<()> {
|
|||||||
if profiles.items.is_none() {
|
if profiles.items.is_none() {
|
||||||
anyhow::bail!("profiles.yaml was not loaded; refusing to record the migration as done");
|
anyhow::bail!("profiles.yaml was not loaded; refusing to record the migration as done");
|
||||||
}
|
}
|
||||||
let raised = raise_short_update_intervals(&mut profiles, min);
|
let raised = profiles.raise_short_update_intervals(min);
|
||||||
if raised > 0 {
|
if raised > 0 {
|
||||||
save_profiles(&profiles).await?;
|
profiles.save_file().await?;
|
||||||
}
|
}
|
||||||
Ok((profiles, raised))
|
Ok((profiles, raised))
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ fn current_user_home() -> anyhow::Result<PathBuf> {
|
|||||||
}
|
}
|
||||||
.max(1024);
|
.max(1024);
|
||||||
|
|
||||||
use clash_verge_task::retry::{RetryError, RetryPolicy, retry_sync};
|
use crate::utils::retry::{RetryError, RetryPolicy, retry_sync};
|
||||||
retry_sync(
|
retry_sync(
|
||||||
RetryPolicy::fixed(
|
RetryPolicy::fixed(
|
||||||
std::num::NonZeroUsize::MIN.saturating_add(11),
|
std::num::NonZeroUsize::MIN.saturating_add(11),
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ pub(crate) mod network;
|
|||||||
pub use crate::core::notify::desktop as notification;
|
pub use crate::core::notify::desktop as notification;
|
||||||
pub mod port;
|
pub mod port;
|
||||||
pub mod resolve;
|
pub mod resolve;
|
||||||
|
pub mod retry;
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
pub mod schtasks;
|
pub mod schtasks;
|
||||||
pub mod server;
|
pub mod server;
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
use crate::core::notify::NoticeStatus;
|
use crate::core::notify::NoticeStatus;
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
use percent_encoding::percent_decode_str;
|
||||||
use tauri::Url;
|
use tauri::Url;
|
||||||
use tristr::alias::String;
|
use tristr::alias::String;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
config::{Config, PrfItem, build_remote_profile, profiles},
|
config::{Config, PrfItem, profiles},
|
||||||
core::{CoreManager, handle, timer::Timer},
|
core::{CoreManager, handle, timer::Timer},
|
||||||
utils::help,
|
utils::help,
|
||||||
};
|
};
|
||||||
use clash_verge_logging::{Type, logging, logging_error};
|
use clash_verge_logging::{Type, logging, logging_error};
|
||||||
use clash_verge_subscription::decode_subscription_link;
|
|
||||||
|
|
||||||
pub(super) async fn resolve_scheme(param: &str) -> Result<()> {
|
pub(super) async fn resolve_scheme(param: &str) -> Result<()> {
|
||||||
let param_str = if param.starts_with("[") && param.len() > 4 {
|
let param_str = if param.starts_with("[") && param.len() > 4 {
|
||||||
@@ -26,7 +26,7 @@ pub(super) async fn resolve_scheme(param: &str) -> Result<()> {
|
|||||||
let link_parsed = Url::parse(param_str)
|
let link_parsed = Url::parse(param_str)
|
||||||
.map_err(|e| anyhow::anyhow!("failed to parse deep link: {e:?}, param: {masked_deep_link}"))?;
|
.map_err(|e| anyhow::anyhow!("failed to parse deep link: {e:?}, param: {masked_deep_link}"))?;
|
||||||
|
|
||||||
let Some(link) = decode_subscription_link(&link_parsed) else {
|
let Some((url, name)) = extract_subscription_info(&link_parsed) else {
|
||||||
logging!(
|
logging!(
|
||||||
warn,
|
warn,
|
||||||
Type::Config,
|
Type::Config,
|
||||||
@@ -35,11 +35,51 @@ pub(super) async fn resolve_scheme(param: &str) -> Result<()> {
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
};
|
};
|
||||||
|
|
||||||
let name = link.name.map(String::from);
|
import_subscription(&url, name.as_ref()).await;
|
||||||
import_subscription(&link.url, name.as_ref()).await;
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn extract_subscription_info(link_parsed: &Url) -> Option<(std::string::String, Option<String>)> {
|
||||||
|
if !matches!(link_parsed.scheme(), "clash" | "clash-verge") {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
|
let name = link_parsed
|
||||||
|
.query_pairs()
|
||||||
|
.find(|(key, _)| key == "name")
|
||||||
|
.map(|(_, value)| value.into());
|
||||||
|
let url = extract_subscription_url(link_parsed)?;
|
||||||
|
Some((url, name))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn extract_subscription_url(link_parsed: &Url) -> Option<std::string::String> {
|
||||||
|
let query = link_parsed.query()?;
|
||||||
|
let prefix = "url=";
|
||||||
|
let pos = query.find(prefix)?;
|
||||||
|
let raw_url = query[pos + prefix.len()..].trim();
|
||||||
|
Some(decode_subscription_url(raw_url))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn decode_subscription_url(raw_url: &str) -> std::string::String {
|
||||||
|
// Avoid double-decoding nested subscription URLs; decode only when needed.
|
||||||
|
if Url::parse(raw_url).is_ok() {
|
||||||
|
return raw_url.to_string();
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut candidate = raw_url.to_string();
|
||||||
|
for _ in 0..2 {
|
||||||
|
let next = percent_decode_str(&candidate).decode_utf8_lossy().to_string();
|
||||||
|
if next == candidate {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
candidate = next;
|
||||||
|
if Url::parse(&candidate).is_ok() {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
candidate
|
||||||
|
}
|
||||||
|
|
||||||
async fn import_subscription(url: &str, name: Option<&String>) {
|
async fn import_subscription(url: &str, name: Option<&String>) {
|
||||||
let had_current_profile = {
|
let had_current_profile = {
|
||||||
let profiles = Config::profiles().await;
|
let profiles = Config::profiles().await;
|
||||||
@@ -73,7 +113,7 @@ async fn import_subscription(url: &str, name: Option<&String>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn fetch_profile_item(url: &str, name: Option<&String>) -> Option<PrfItem> {
|
async fn fetch_profile_item(url: &str, name: Option<&String>) -> Option<PrfItem> {
|
||||||
match build_remote_profile(url, name, None, None).await {
|
match PrfItem::from_url(url, name, None, None).await {
|
||||||
Ok(item) => Some(item),
|
Ok(item) => Some(item),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
logging!(error, Type::Config, "failed to parse profile from url: {:?}", e);
|
logging!(error, Type::Config, "failed to parse profile from url: {:?}", e);
|
||||||
|
|||||||
@@ -21,29 +21,25 @@ pub enum RetryError<E> {
|
|||||||
Stop(E),
|
Stop(E),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<E> RetryError<E> {
|
|
||||||
fn into_inner(self) -> E {
|
|
||||||
match self {
|
|
||||||
Self::Retry(error) | Self::Stop(error) => error,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn retry<T: Send, E: Send, Fut: Future<Output = Result<T, RetryError<E>>> + Send>(
|
pub async fn retry<T: Send, E: Send, Fut: Future<Output = Result<T, RetryError<E>>> + Send>(
|
||||||
policy: RetryPolicy,
|
policy: RetryPolicy,
|
||||||
mut operation: impl FnMut(usize) -> Fut + Send,
|
mut operation: impl FnMut(usize) -> Fut + Send,
|
||||||
) -> Result<T, E> {
|
) -> Result<T, E> {
|
||||||
let mut result = operation(0).await;
|
let mut result = operation(0).await;
|
||||||
for (index, delay) in policy.delays().enumerate() {
|
for (index, delay) in policy.delays().enumerate() {
|
||||||
if !matches!(result, Err(RetryError::Retry(_))) {
|
match result {
|
||||||
break;
|
Ok(_) | Err(RetryError::Stop(_)) => break,
|
||||||
}
|
Err(RetryError::Retry(_)) => {
|
||||||
if !delay.is_zero() {
|
if !delay.is_zero() {
|
||||||
tokio::time::sleep(delay).await;
|
tokio::time::sleep(delay).await;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
result = operation(index + 1).await;
|
result = operation(index + 1).await;
|
||||||
}
|
}
|
||||||
result.map_err(RetryError::into_inner)
|
result.map_err(|error| match error {
|
||||||
|
RetryError::Retry(error) | RetryError::Stop(error) => error,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn try_strategies<
|
pub async fn try_strategies<
|
||||||
@@ -57,14 +53,15 @@ pub async fn try_strategies<
|
|||||||
rest: [S; N],
|
rest: [S; N],
|
||||||
mut operation: impl FnMut(S) -> Fut + Send,
|
mut operation: impl FnMut(S) -> Fut + Send,
|
||||||
) -> Result<(S, T), E> {
|
) -> Result<(S, T), E> {
|
||||||
let mut result = operation(first).await.map(|value| (first, value));
|
retry(
|
||||||
for strategy in rest {
|
RetryPolicy::fixed(NonZeroUsize::MIN.saturating_add(N), Duration::ZERO),
|
||||||
if result.is_ok() {
|
move |attempt| {
|
||||||
break;
|
let strategy = if attempt == 0 { first } else { rest[attempt - 1] };
|
||||||
}
|
let future = operation(strategy);
|
||||||
result = operation(strategy).await.map(|value| (strategy, value));
|
async move { future.await.map(|value| (strategy, value)).map_err(RetryError::Retry) }
|
||||||
}
|
},
|
||||||
result
|
)
|
||||||
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn retry_with_state<S: Send, T: Send, E: Send>(
|
pub async fn retry_with_state<S: Send, T: Send, E: Send>(
|
||||||
@@ -74,15 +71,19 @@ pub async fn retry_with_state<S: Send, T: Send, E: Send>(
|
|||||||
) -> Result<T, E> {
|
) -> Result<T, E> {
|
||||||
let mut result = operation(&mut state, 0).await;
|
let mut result = operation(&mut state, 0).await;
|
||||||
for (index, delay) in policy.delays().enumerate() {
|
for (index, delay) in policy.delays().enumerate() {
|
||||||
if !matches!(result, Err(RetryError::Retry(_))) {
|
match result {
|
||||||
break;
|
Ok(_) | Err(RetryError::Stop(_)) => break,
|
||||||
}
|
Err(RetryError::Retry(_)) => {
|
||||||
if !delay.is_zero() {
|
if !delay.is_zero() {
|
||||||
tokio::time::sleep(delay).await;
|
tokio::time::sleep(delay).await;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
result = operation(&mut state, index + 1).await;
|
result = operation(&mut state, index + 1).await;
|
||||||
}
|
}
|
||||||
result.map_err(RetryError::into_inner)
|
result.map_err(|error| match error {
|
||||||
|
RetryError::Retry(error) | RetryError::Stop(error) => error,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn retry_sync<T, E>(
|
pub fn retry_sync<T, E>(
|
||||||
@@ -91,39 +92,41 @@ pub fn retry_sync<T, E>(
|
|||||||
) -> Result<T, E> {
|
) -> Result<T, E> {
|
||||||
let mut result = operation(0);
|
let mut result = operation(0);
|
||||||
for (index, delay) in policy.delays().enumerate() {
|
for (index, delay) in policy.delays().enumerate() {
|
||||||
if !matches!(result, Err(RetryError::Retry(_))) {
|
match result {
|
||||||
break;
|
Ok(_) | Err(RetryError::Stop(_)) => break,
|
||||||
}
|
Err(RetryError::Retry(_)) => {
|
||||||
if !delay.is_zero() {
|
if !delay.is_zero() {
|
||||||
std::thread::sleep(delay);
|
std::thread::sleep(delay);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
result = operation(index + 1);
|
result = operation(index + 1);
|
||||||
}
|
}
|
||||||
result.map_err(RetryError::into_inner)
|
result.map_err(|error| match error {
|
||||||
|
RetryError::Retry(error) | RetryError::Stop(error) => error,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use std::future::ready;
|
|
||||||
|
|
||||||
#[tokio::test(start_paused = true)]
|
#[tokio::test]
|
||||||
async fn retries_stop_at_success_terminal_error_or_attempt_limit() {
|
async fn retries_stop_at_success_terminal_error_or_attempt_limit() {
|
||||||
let delay = Duration::from_millis(50);
|
let policy = RetryPolicy::fixed(NonZeroUsize::MIN.saturating_add(2), Duration::ZERO);
|
||||||
let policy = RetryPolicy::fixed(NonZeroUsize::MIN.saturating_add(2), delay);
|
|
||||||
let started = tokio::time::Instant::now();
|
|
||||||
let mut calls = 0;
|
let mut calls = 0;
|
||||||
let success = retry(policy, |attempt| {
|
let success = retry(policy, |attempt| {
|
||||||
calls += 1;
|
calls += 1;
|
||||||
ready(if attempt == 1 {
|
async move {
|
||||||
|
if attempt == 1 {
|
||||||
Ok(7)
|
Ok(7)
|
||||||
} else {
|
} else {
|
||||||
Err(RetryError::Retry(attempt))
|
Err(RetryError::Retry(attempt))
|
||||||
})
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.await;
|
.await;
|
||||||
assert_eq!((success, calls), (Ok(7), 2));
|
assert_eq!((success, calls), (Ok(7), 2));
|
||||||
assert_eq!(started.elapsed(), delay);
|
|
||||||
calls = 0;
|
calls = 0;
|
||||||
let stopped = retry(policy, |_| {
|
let stopped = retry(policy, |_| {
|
||||||
calls += 1;
|
calls += 1;
|
||||||
@@ -131,7 +134,6 @@ mod tests {
|
|||||||
})
|
})
|
||||||
.await;
|
.await;
|
||||||
assert_eq!((stopped, calls), (Err("terminal"), 1));
|
assert_eq!((stopped, calls), (Err("terminal"), 1));
|
||||||
assert_eq!(started.elapsed(), delay);
|
|
||||||
calls = 0;
|
calls = 0;
|
||||||
let exhausted = retry(policy, |attempt| {
|
let exhausted = retry(policy, |attempt| {
|
||||||
calls += 1;
|
calls += 1;
|
||||||
@@ -139,7 +141,6 @@ mod tests {
|
|||||||
})
|
})
|
||||||
.await;
|
.await;
|
||||||
assert_eq!((exhausted, calls), (Err(2), 3));
|
assert_eq!((exhausted, calls), (Err(2), 3));
|
||||||
assert_eq!(started.elapsed(), delay * 3);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -160,9 +161,11 @@ mod tests {
|
|||||||
let result = retry_with_state(policy, Vec::new(), |visited, attempt| {
|
let result = retry_with_state(policy, Vec::new(), |visited, attempt| {
|
||||||
Box::pin(async move {
|
Box::pin(async move {
|
||||||
visited.push(attempt);
|
visited.push(attempt);
|
||||||
(visited.len() == 3)
|
if visited.len() == 3 {
|
||||||
.then(|| visited.clone())
|
Ok(visited.clone())
|
||||||
.ok_or(RetryError::Retry(()))
|
} else {
|
||||||
|
Err(RetryError::Retry(()))
|
||||||
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.await;
|
.await;
|
||||||
@@ -52,7 +52,7 @@ pub async fn check_singleton() -> Result<SingletonDisposition> {
|
|||||||
.context("failed to initialize singleton lock")?;
|
.context("failed to initialize singleton lock")?;
|
||||||
if !try_lock_instance(&lock).context("failed to acquire singleton lock")? {
|
if !try_lock_instance(&lock).context("failed to acquire singleton lock")? {
|
||||||
let deadline = std::time::Instant::now() + Duration::from_secs(20);
|
let deadline = std::time::Instant::now() + Duration::from_secs(20);
|
||||||
use clash_verge_task::retry::{RetryError, RetryPolicy, retry};
|
use crate::utils::retry::{RetryError, RetryPolicy, retry};
|
||||||
let secondary = retry(
|
let secondary = retry(
|
||||||
RetryPolicy::fixed(
|
RetryPolicy::fixed(
|
||||||
std::num::NonZeroUsize::MIN.saturating_add(400),
|
std::num::NonZeroUsize::MIN.saturating_add(400),
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { useTheme } from '@mui/material/styles'
|
import { useTheme } from '@mui/material/styles'
|
||||||
import { useLocalStorage } from 'foxact/use-local-storage'
|
|
||||||
import {
|
import {
|
||||||
memo,
|
memo,
|
||||||
useCallback,
|
useCallback,
|
||||||
@@ -13,6 +12,8 @@ import {
|
|||||||
} from 'react'
|
} from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
|
|
||||||
|
import { useLocalStorage } from '@/hooks/use-local-storage'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ConnectionColumnManager,
|
ConnectionColumnManager,
|
||||||
type ConnectionColumnOption,
|
type ConnectionColumnOption,
|
||||||
@@ -62,6 +63,19 @@ type ColumnField =
|
|||||||
type ColumnSizingState = Record<string, number>
|
type ColumnSizingState = Record<string, number>
|
||||||
type VisibilityState = Record<string, boolean>
|
type VisibilityState = Record<string, boolean>
|
||||||
|
|
||||||
|
const EMPTY_RECORD = {}
|
||||||
|
const EMPTY_COLUMN_ORDER: string[] = []
|
||||||
|
|
||||||
|
const parseColumnVisibility = (value: string): VisibilityState => {
|
||||||
|
const parsed = JSON.parse(value)
|
||||||
|
return parsed && typeof parsed === 'object' ? parsed : EMPTY_RECORD
|
||||||
|
}
|
||||||
|
|
||||||
|
const parseColumnOrder = (value: string): string[] => {
|
||||||
|
const parsed = JSON.parse(value)
|
||||||
|
return Array.isArray(parsed) ? parsed : EMPTY_COLUMN_ORDER
|
||||||
|
}
|
||||||
|
|
||||||
interface BaseColumn {
|
interface BaseColumn {
|
||||||
field: ColumnField
|
field: ColumnField
|
||||||
headerName: string
|
headerName: string
|
||||||
@@ -368,42 +382,20 @@ export const ConnectionTable = (props: Props) => {
|
|||||||
const theme = useTheme()
|
const theme = useTheme()
|
||||||
const [columnWidths, setColumnWidths] = useLocalStorage<ColumnSizingState>(
|
const [columnWidths, setColumnWidths] = useLocalStorage<ColumnSizingState>(
|
||||||
'connection-table-widths',
|
'connection-table-widths',
|
||||||
{},
|
EMPTY_RECORD,
|
||||||
)
|
)
|
||||||
|
|
||||||
const [columnVisibilityModel, setColumnVisibilityModel] =
|
const [columnVisibilityModel, setColumnVisibilityModel] =
|
||||||
useLocalStorage<VisibilityState>(
|
useLocalStorage<VisibilityState>(
|
||||||
'connection-table-visibility',
|
'connection-table-visibility',
|
||||||
{},
|
EMPTY_RECORD,
|
||||||
{
|
parseColumnVisibility,
|
||||||
serializer: JSON.stringify,
|
|
||||||
deserializer: (value) => {
|
|
||||||
try {
|
|
||||||
const parsed = JSON.parse(value)
|
|
||||||
if (parsed && typeof parsed === 'object') return parsed
|
|
||||||
} catch (err) {
|
|
||||||
console.warn('Failed to parse connection-table-visibility', err)
|
|
||||||
}
|
|
||||||
return {}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const [columnOrder, setColumnOrder] = useLocalStorage<string[]>(
|
const [columnOrder, setColumnOrder] = useLocalStorage<string[]>(
|
||||||
'connection-table-order',
|
'connection-table-order',
|
||||||
[],
|
EMPTY_COLUMN_ORDER,
|
||||||
{
|
parseColumnOrder,
|
||||||
serializer: JSON.stringify,
|
|
||||||
deserializer: (value) => {
|
|
||||||
try {
|
|
||||||
const parsed = JSON.parse(value)
|
|
||||||
if (Array.isArray(parsed)) return parsed
|
|
||||||
} catch (err) {
|
|
||||||
console.warn('Failed to parse connection-table-order', err)
|
|
||||||
}
|
|
||||||
return []
|
|
||||||
},
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const baseColumns = useMemo<BaseColumn[]>(() => {
|
const baseColumns = useMemo<BaseColumn[]>(() => {
|
||||||
|
|||||||
@@ -14,20 +14,18 @@ import {
|
|||||||
Typography,
|
Typography,
|
||||||
} from '@mui/material'
|
} from '@mui/material'
|
||||||
import { getCurrentWebviewWindow } from '@tauri-apps/api/webviewWindow'
|
import { getCurrentWebviewWindow } from '@tauri-apps/api/webviewWindow'
|
||||||
import { useEffect } from 'foxact/use-abortable-effect'
|
|
||||||
import { useIntersection } from 'foxact/use-intersection'
|
|
||||||
import { useLocalStorage } from 'foxact/use-local-storage'
|
|
||||||
import type { XOR } from 'foxts/ts-xor'
|
|
||||||
import {
|
import {
|
||||||
forwardRef,
|
forwardRef,
|
||||||
memo,
|
memo,
|
||||||
useCallback,
|
useCallback,
|
||||||
|
useEffect,
|
||||||
useEffectEvent,
|
useEffectEvent,
|
||||||
useMemo,
|
useMemo,
|
||||||
useState,
|
useState,
|
||||||
} from 'react'
|
} from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
|
|
||||||
|
import { useLocalStorage } from '@/hooks/use-local-storage'
|
||||||
import { getIpInfo } from '@/services/api'
|
import { getIpInfo } from '@/services/api'
|
||||||
import { useQuery } from '@/services/query-client'
|
import { useQuery } from '@/services/query-client'
|
||||||
import getSystem from '@/utils/get-system'
|
import getSystem from '@/utils/get-system'
|
||||||
@@ -72,15 +70,14 @@ const getCountryFlag = (countryCode: string | undefined) => {
|
|||||||
return String.fromCodePoint(...codePoints)
|
return String.fromCodePoint(...codePoints)
|
||||||
}
|
}
|
||||||
|
|
||||||
type CountDownState = XOR<
|
type CountDownState =
|
||||||
{
|
| {
|
||||||
type: 'countdown'
|
type: 'countdown'
|
||||||
remainingSeconds: number
|
remainingSeconds: number
|
||||||
},
|
}
|
||||||
{
|
| {
|
||||||
type: 'revalidating'
|
type: 'revalidating'
|
||||||
}
|
}
|
||||||
>
|
|
||||||
|
|
||||||
const IPInfoCardContainer = forwardRef<HTMLElement, React.PropsWithChildren>(
|
const IPInfoCardContainer = forwardRef<HTMLElement, React.PropsWithChildren>(
|
||||||
({ children }, ref) => {
|
({ children }, ref) => {
|
||||||
@@ -114,10 +111,19 @@ export const IpInfoCard = () => {
|
|||||||
)
|
)
|
||||||
const appWindow = useMemo(() => getCurrentWebviewWindow(), [])
|
const appWindow = useMemo(() => getCurrentWebviewWindow(), [])
|
||||||
|
|
||||||
|
const [hasIntersected, setHasIntersected] = useState(false)
|
||||||
// Once intersected, the card stays eligible for refresh until unmount.
|
// Once intersected, the card stays eligible for refresh until unmount.
|
||||||
const [containerRef, hasIntersected, _resetIntersected] = useIntersection({
|
const containerRef = useCallback((element: HTMLElement | null) => {
|
||||||
rootMargin: '0px',
|
if (!element) return
|
||||||
|
const observer = new IntersectionObserver((entries) => {
|
||||||
|
if (entries.some((e) => e.isIntersecting || e.intersectionRatio > 0)) {
|
||||||
|
setHasIntersected(true)
|
||||||
|
observer.disconnect()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
observer.observe(element)
|
||||||
|
return () => observer.disconnect()
|
||||||
|
}, [])
|
||||||
|
|
||||||
const [countdown, setCountdown] = useState<CountDownState>({
|
const [countdown, setCountdown] = useState<CountDownState>({
|
||||||
type: 'countdown',
|
type: 'countdown',
|
||||||
|
|||||||
@@ -19,10 +19,6 @@ import {
|
|||||||
styled,
|
styled,
|
||||||
} from '@mui/material'
|
} from '@mui/material'
|
||||||
import { useLockFn } from 'ahooks'
|
import { useLockFn } from 'ahooks'
|
||||||
import {
|
|
||||||
cancelIdleCallback,
|
|
||||||
requestIdleCallback,
|
|
||||||
} from 'foxact/request-idle-callback'
|
|
||||||
import * as yaml from 'js-yaml'
|
import * as yaml from 'js-yaml'
|
||||||
import {
|
import {
|
||||||
startTransition,
|
startTransition,
|
||||||
@@ -350,10 +346,12 @@ export const GroupsEditorViewer = (props: Props) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const handle = requestIdleCallback(serialize)
|
if (typeof window.requestIdleCallback === 'function') {
|
||||||
return () => {
|
const handle = window.requestIdleCallback(serialize)
|
||||||
cancelIdleCallback(handle)
|
return () => window.cancelIdleCallback(handle)
|
||||||
}
|
}
|
||||||
|
const handle = window.setTimeout(serialize, 1)
|
||||||
|
return () => window.clearTimeout(handle)
|
||||||
}
|
}
|
||||||
}, [prependSeq, appendSeq, deleteSeq])
|
}, [prependSeq, appendSeq, deleteSeq])
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { useCallback, useEffect, useReducer } from 'react'
|
import { useCallback, useEffect, useState } from 'react'
|
||||||
|
|
||||||
|
import { useLocalStorage } from '@/hooks/use-local-storage'
|
||||||
import { useProfiles } from '@/hooks/use-profiles'
|
import { useProfiles } from '@/hooks/use-profiles'
|
||||||
|
|
||||||
import { ProxySortType } from './use-filter-sort'
|
import { ProxySortType } from './use-filter-sort'
|
||||||
@@ -16,9 +17,13 @@ export interface HeadState {
|
|||||||
testUrl: string
|
testUrl: string
|
||||||
}
|
}
|
||||||
|
|
||||||
type HeadStateStorage = Record<string, Record<string, HeadState>>
|
type ProfileHeadState = Record<string, HeadState>
|
||||||
|
type HeadStateStorage = Record<string, ProfileHeadState>
|
||||||
|
|
||||||
const HEAD_STATE_KEY = 'proxy-head-state'
|
const HEAD_STATE_KEY = 'proxy-head-state'
|
||||||
|
const EMPTY_STORAGE: HeadStateStorage = {}
|
||||||
|
const EMPTY_PROFILE: ProfileHeadState = {}
|
||||||
|
|
||||||
export const DEFAULT_STATE: HeadState = {
|
export const DEFAULT_STATE: HeadState = {
|
||||||
open: false,
|
open: false,
|
||||||
showType: true,
|
showType: true,
|
||||||
@@ -31,77 +36,65 @@ export const DEFAULT_STATE: HeadState = {
|
|||||||
testUrl: '',
|
testUrl: '',
|
||||||
}
|
}
|
||||||
|
|
||||||
type HeadStateAction =
|
const parseStorage = (raw: string): HeadStateStorage => {
|
||||||
| { type: 'reset' }
|
const value = JSON.parse(raw) as HeadStateStorage | null
|
||||||
| { type: 'replace'; payload: Record<string, HeadState> }
|
return value && typeof value === 'object' && !Array.isArray(value)
|
||||||
| { type: 'update'; groupName: string; patch: Partial<HeadState> }
|
? value
|
||||||
|
: EMPTY_STORAGE
|
||||||
|
}
|
||||||
|
|
||||||
function headStateReducer(
|
const getProfileState = (storage: HeadStateStorage, profile: string) => {
|
||||||
state: Record<string, HeadState>,
|
const state = storage[profile]
|
||||||
action: HeadStateAction,
|
return state && typeof state === 'object' && !Array.isArray(state)
|
||||||
): Record<string, HeadState> {
|
? state
|
||||||
switch (action.type) {
|
: EMPTY_PROFILE
|
||||||
case 'reset':
|
|
||||||
return {}
|
|
||||||
case 'replace':
|
|
||||||
return action.payload
|
|
||||||
case 'update': {
|
|
||||||
const prev = state[action.groupName] || DEFAULT_STATE
|
|
||||||
return { ...state, [action.groupName]: { ...prev, ...action.patch } }
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
return state
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useHeadStateNew() {
|
export function useHeadStateNew() {
|
||||||
const { profiles } = useProfiles()
|
const { profiles } = useProfiles()
|
||||||
const current = profiles?.current || ''
|
const current = profiles?.current || ''
|
||||||
|
|
||||||
const [state, dispatch] = useReducer(headStateReducer, {})
|
const [storage, setStorage] = useLocalStorage(
|
||||||
|
HEAD_STATE_KEY,
|
||||||
useEffect(() => {
|
EMPTY_STORAGE,
|
||||||
try {
|
parseStorage,
|
||||||
const data = JSON.parse(
|
)
|
||||||
localStorage.getItem(HEAD_STATE_KEY)!,
|
const saved = getProfileState(storage, current)
|
||||||
) as HeadStateStorage
|
// The active profile owns its live state even if persistence fails.
|
||||||
|
const [state, setState] = useState(() => ({
|
||||||
const value = data[current] || {}
|
profile: { id: current, initialGroups: saved },
|
||||||
|
groups: saved,
|
||||||
if (value && typeof value === 'object') {
|
}))
|
||||||
dispatch({ type: 'replace', payload: value })
|
const { profile, groups } = state
|
||||||
} else {
|
if (profile.id !== current) {
|
||||||
dispatch({ type: 'reset' })
|
setState({ profile: { id: current, initialGroups: saved }, groups: saved })
|
||||||
}
|
}
|
||||||
} catch {
|
|
||||||
dispatch({ type: 'reset' })
|
|
||||||
}
|
|
||||||
}, [current])
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (groups === profile.initialGroups) return
|
||||||
const timer = setTimeout(() => {
|
const timer = setTimeout(() => {
|
||||||
try {
|
setStorage((previous) => ({
|
||||||
const item = localStorage.getItem(HEAD_STATE_KEY)
|
...previous,
|
||||||
|
[profile.id]: groups,
|
||||||
let data = (item ? JSON.parse(item) : {}) as HeadStateStorage
|
}))
|
||||||
|
|
||||||
if (!data || typeof data !== 'object') data = {}
|
|
||||||
|
|
||||||
data[current] = state
|
|
||||||
|
|
||||||
localStorage.setItem(HEAD_STATE_KEY, JSON.stringify(data))
|
|
||||||
} catch {}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
return () => clearTimeout(timer)
|
return () => clearTimeout(timer)
|
||||||
}, [state, current])
|
}, [groups, profile, setStorage])
|
||||||
|
|
||||||
const setHeadState = useCallback(
|
const setHeadState = useCallback(
|
||||||
(groupName: string, obj: Partial<HeadState>) => {
|
(groupName: string, patch: Partial<HeadState>) => {
|
||||||
dispatch({ type: 'update', groupName, patch: obj })
|
setState((previous) => {
|
||||||
|
if (previous.profile !== profile) return previous
|
||||||
|
const group = previous.groups[groupName] ?? DEFAULT_STATE
|
||||||
|
return {
|
||||||
|
profile,
|
||||||
|
groups: { ...previous.groups, [groupName]: { ...group, ...patch } },
|
||||||
|
}
|
||||||
|
})
|
||||||
},
|
},
|
||||||
[],
|
[profile],
|
||||||
)
|
)
|
||||||
|
|
||||||
return [state, setHeadState] as const
|
return [groups, setHeadState] as const
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { useLocalStorage } from 'foxact/use-local-storage'
|
import { useLocalStorage } from './use-local-storage'
|
||||||
|
|
||||||
const defaultClashLog: IClashLog = {
|
const defaultClashLog: IClashLog = {
|
||||||
enable: true,
|
enable: true,
|
||||||
@@ -8,7 +8,4 @@ const defaultClashLog: IClashLog = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const useClashLog = () =>
|
export const useClashLog = () =>
|
||||||
useLocalStorage<IClashLog>('clash-log', defaultClashLog, {
|
useLocalStorage<IClashLog>('clash-log', defaultClashLog)
|
||||||
serializer: JSON.stringify,
|
|
||||||
deserializer: JSON.parse,
|
|
||||||
})
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { useLocalStorage } from 'foxact/use-local-storage'
|
import { useLocalStorage } from './use-local-storage'
|
||||||
|
|
||||||
const defaultConnectionSetting: IConnectionSetting = { layout: 'table' }
|
const defaultConnectionSetting: IConnectionSetting = { layout: 'table' }
|
||||||
|
|
||||||
@@ -6,8 +6,4 @@ export const useConnectionSetting = () =>
|
|||||||
useLocalStorage<IConnectionSetting>(
|
useLocalStorage<IConnectionSetting>(
|
||||||
'connections-setting',
|
'connections-setting',
|
||||||
defaultConnectionSetting,
|
defaultConnectionSetting,
|
||||||
{
|
|
||||||
serializer: JSON.stringify,
|
|
||||||
deserializer: JSON.parse,
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
/* eslint-disable @eslint-react/set-state-in-effect */
|
/* eslint-disable @eslint-react/set-state-in-effect */
|
||||||
import { useEffect } from 'foxact/use-abortable-effect'
|
import { useCallback, useEffect, useState } from 'react'
|
||||||
import { useCallback, useState } from 'react'
|
|
||||||
|
|
||||||
import { showNotice } from '@/services/notice-service'
|
import { showNotice } from '@/services/notice-service'
|
||||||
|
|
||||||
@@ -42,26 +41,28 @@ export const useEditorDocument = ({ open, load }: UseEditorDocumentOptions) => {
|
|||||||
}
|
}
|
||||||
}, [applyLoadedValue, load])
|
}, [applyLoadedValue, load])
|
||||||
|
|
||||||
useEffect(
|
useEffect(() => {
|
||||||
(signal) => {
|
let cancelled = false
|
||||||
resetDocumentState()
|
resetDocumentState()
|
||||||
|
|
||||||
if (!open) return
|
if (!open) return
|
||||||
|
|
||||||
load()
|
load()
|
||||||
.then((nextValue) => {
|
.then((nextValue) => {
|
||||||
if (signal.aborted) return
|
if (cancelled) return
|
||||||
applyLoadedValue(nextValue)
|
applyLoadedValue(nextValue)
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
if (!signal.aborted) showNotice.error(error)
|
if (!cancelled) showNotice.error(error)
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
if (!signal.aborted) setLoading(false)
|
if (!cancelled) setLoading(false)
|
||||||
})
|
})
|
||||||
},
|
|
||||||
[applyLoadedValue, load, open, resetDocumentState],
|
return () => {
|
||||||
)
|
cancelled = true
|
||||||
|
}
|
||||||
|
}, [applyLoadedValue, load, open, resetDocumentState])
|
||||||
|
|
||||||
const markSaved = useCallback((nextValue: string) => {
|
const markSaved = useCallback((nextValue: string) => {
|
||||||
setSavedValue(nextValue)
|
setSavedValue(nextValue)
|
||||||
|
|||||||
@@ -0,0 +1,148 @@
|
|||||||
|
import { useCallback, useMemo, useSyncExternalStore } from 'react'
|
||||||
|
|
||||||
|
interface StorageEntry {
|
||||||
|
listeners: Set<() => void>
|
||||||
|
raw: string | null
|
||||||
|
parsedRaw: string | null
|
||||||
|
parsed: unknown
|
||||||
|
deserializer?: (value: string) => unknown
|
||||||
|
}
|
||||||
|
|
||||||
|
const entries = new Map<string, StorageEntry>()
|
||||||
|
|
||||||
|
const readRaw = (key: string): string | null => {
|
||||||
|
try {
|
||||||
|
return window.localStorage.getItem(key)
|
||||||
|
} catch (error) {
|
||||||
|
console.warn(`[useLocalStorage] Failed to read "${key}"`, error)
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const getRaw = (key: string): string | null => {
|
||||||
|
const entry = entries.get(key)
|
||||||
|
return entry ? entry.raw : readRaw(key)
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleStorageEvent = (event: StorageEvent) => {
|
||||||
|
if (event.storageArea !== window.localStorage) return
|
||||||
|
|
||||||
|
if (event.key === null) {
|
||||||
|
entries.forEach((entry) => {
|
||||||
|
entry.raw = null
|
||||||
|
entry.parsedRaw = null
|
||||||
|
entry.parsed = undefined
|
||||||
|
entry.listeners.forEach((listener) => listener())
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const entry = entries.get(event.key)
|
||||||
|
if (!entry) return
|
||||||
|
entry.raw = event.newValue
|
||||||
|
entry.parsedRaw = null
|
||||||
|
entry.parsed = undefined
|
||||||
|
entry.listeners.forEach((listener) => listener())
|
||||||
|
}
|
||||||
|
|
||||||
|
const subscribeKey = (key: string, listener: () => void) => {
|
||||||
|
if (entries.size === 0) {
|
||||||
|
window.addEventListener('storage', handleStorageEvent)
|
||||||
|
}
|
||||||
|
|
||||||
|
let entry = entries.get(key)
|
||||||
|
if (!entry) {
|
||||||
|
entry = {
|
||||||
|
listeners: new Set(),
|
||||||
|
raw: readRaw(key),
|
||||||
|
parsedRaw: null,
|
||||||
|
parsed: undefined,
|
||||||
|
}
|
||||||
|
entries.set(key, entry)
|
||||||
|
}
|
||||||
|
entry.listeners.add(listener)
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
const current = entries.get(key)
|
||||||
|
if (current) {
|
||||||
|
current.listeners.delete(listener)
|
||||||
|
if (current.listeners.size === 0) entries.delete(key)
|
||||||
|
}
|
||||||
|
if (entries.size === 0) {
|
||||||
|
window.removeEventListener('storage', handleStorageEvent)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const parseRaw = <T>(
|
||||||
|
key: string,
|
||||||
|
raw: string | null,
|
||||||
|
defaultValue: T,
|
||||||
|
deserializer: (value: string) => T,
|
||||||
|
): T => {
|
||||||
|
if (raw === null) return defaultValue
|
||||||
|
const entry = entries.get(key)
|
||||||
|
if (entry && entry.parsedRaw === raw && entry.deserializer === deserializer) {
|
||||||
|
return entry.parsed as T
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const value = deserializer(raw)
|
||||||
|
if (entry) {
|
||||||
|
entry.parsedRaw = raw
|
||||||
|
entry.parsed = value
|
||||||
|
entry.deserializer = deserializer
|
||||||
|
}
|
||||||
|
return value
|
||||||
|
} catch (error) {
|
||||||
|
console.warn(`[useLocalStorage] Failed to deserialize "${key}"`, error)
|
||||||
|
return defaultValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const useLocalStorage = <T>(
|
||||||
|
key: string,
|
||||||
|
defaultValue: T,
|
||||||
|
deserializer: (value: string) => T = JSON.parse,
|
||||||
|
): [T, (value: T | ((prev: T) => T)) => void] => {
|
||||||
|
const subscribe = useCallback(
|
||||||
|
(listener: () => void) => subscribeKey(key, listener),
|
||||||
|
[key],
|
||||||
|
)
|
||||||
|
|
||||||
|
const raw = useSyncExternalStore(subscribe, () => getRaw(key))
|
||||||
|
|
||||||
|
const value = useMemo<T>(
|
||||||
|
() => parseRaw(key, raw, defaultValue, deserializer),
|
||||||
|
[key, raw, defaultValue, deserializer],
|
||||||
|
)
|
||||||
|
|
||||||
|
const setValue = useCallback(
|
||||||
|
(next: T | ((prev: T) => T)) => {
|
||||||
|
try {
|
||||||
|
const entry = entries.get(key)
|
||||||
|
const currentRaw = entry ? entry.raw : readRaw(key)
|
||||||
|
const resolved =
|
||||||
|
typeof next === 'function'
|
||||||
|
? (next as (prev: T) => T)(
|
||||||
|
parseRaw(key, currentRaw, defaultValue, deserializer),
|
||||||
|
)
|
||||||
|
: next
|
||||||
|
|
||||||
|
const serialized = JSON.stringify(resolved)
|
||||||
|
if (currentRaw === serialized) return
|
||||||
|
window.localStorage.setItem(key, serialized)
|
||||||
|
if (entry) {
|
||||||
|
entry.raw = serialized
|
||||||
|
entry.parsedRaw = null
|
||||||
|
entry.parsed = undefined
|
||||||
|
entry.listeners.forEach((listener) => listener())
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.warn(`[useLocalStorage] Failed to write "${key}"`, error)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[key, defaultValue, deserializer],
|
||||||
|
)
|
||||||
|
|
||||||
|
return [value, setValue]
|
||||||
|
}
|
||||||
+6
-9
@@ -1,7 +1,6 @@
|
|||||||
import './assets/styles/index.scss'
|
import './assets/styles/index.scss'
|
||||||
|
|
||||||
import { ResizeObserver } from '@juggle/resize-observer'
|
import { ResizeObserver } from '@juggle/resize-observer'
|
||||||
import { ComposeContextProvider } from 'foxact/compose-context-provider'
|
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { createRoot } from 'react-dom/client'
|
import { createRoot } from 'react-dom/client'
|
||||||
import { RouterProvider } from 'react-router'
|
import { RouterProvider } from 'react-router'
|
||||||
@@ -38,16 +37,12 @@ if (!container) {
|
|||||||
disableWebViewShortcuts()
|
disableWebViewShortcuts()
|
||||||
|
|
||||||
const initializeApp = (initialThemeMode: 'light' | 'dark') => {
|
const initializeApp = (initialThemeMode: 'light' | 'dark') => {
|
||||||
const contexts = [
|
|
||||||
<ThemeModeProvider key="theme" initialState={initialThemeMode} />,
|
|
||||||
<AppStoreProvider key="app-store" />,
|
|
||||||
<UpdateStateProvider key="update" />,
|
|
||||||
]
|
|
||||||
|
|
||||||
const root = createRoot(container)
|
const root = createRoot(container)
|
||||||
root.render(
|
root.render(
|
||||||
<React.StrictMode>
|
<React.StrictMode>
|
||||||
<ComposeContextProvider contexts={contexts}>
|
<ThemeModeProvider initialState={initialThemeMode}>
|
||||||
|
<AppStoreProvider>
|
||||||
|
<UpdateStateProvider>
|
||||||
<BaseErrorBoundary>
|
<BaseErrorBoundary>
|
||||||
<SWRConfig value={swrConfig}>
|
<SWRConfig value={swrConfig}>
|
||||||
<WindowProvider>
|
<WindowProvider>
|
||||||
@@ -57,7 +52,9 @@ const initializeApp = (initialThemeMode: 'light' | 'dark') => {
|
|||||||
</WindowProvider>
|
</WindowProvider>
|
||||||
</SWRConfig>
|
</SWRConfig>
|
||||||
</BaseErrorBoundary>
|
</BaseErrorBoundary>
|
||||||
</ComposeContextProvider>
|
</UpdateStateProvider>
|
||||||
|
</AppStoreProvider>
|
||||||
|
</ThemeModeProvider>
|
||||||
</React.StrictMode>,
|
</React.StrictMode>,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
+35
-19
@@ -1,8 +1,5 @@
|
|||||||
import { getName, getVersion } from '@tauri-apps/api/app'
|
import { getName, getVersion } from '@tauri-apps/api/app'
|
||||||
import { fetch } from '@tauri-apps/plugin-http'
|
import { fetch } from '@tauri-apps/plugin-http'
|
||||||
import { asyncRetry } from 'foxts/async-retry'
|
|
||||||
import { extractErrorMessage } from 'foxts/extract-error-message'
|
|
||||||
import { once } from 'foxts/once'
|
|
||||||
import i18n from 'i18next'
|
import i18n from 'i18next'
|
||||||
import { getBaseConfig } from 'tauri-plugin-mihomo-api'
|
import { getBaseConfig } from 'tauri-plugin-mihomo-api'
|
||||||
|
|
||||||
@@ -10,15 +7,42 @@ import { debugLog } from '@/utils/debug'
|
|||||||
|
|
||||||
import { getRuntimeConfig } from './cmds'
|
import { getRuntimeConfig } from './cmds'
|
||||||
|
|
||||||
const getUserAgentPromise = once(async () => {
|
let userAgentPromise: Promise<string> | null = null
|
||||||
try {
|
const getUserAgentPromise = () =>
|
||||||
const [name, version] = await Promise.all([getName(), getVersion()])
|
(userAgentPromise ??= Promise.all([getName(), getVersion()])
|
||||||
return `${name}/${version}`
|
.then(([name, version]) => `${name}/${version}`)
|
||||||
} catch (error) {
|
.catch((error) => {
|
||||||
console.debug('Failed to build User-Agent, fallback to default', error)
|
console.debug('Failed to build User-Agent, fallback to default', error)
|
||||||
return 'clash-verge-rev'
|
return 'clash-verge-rev'
|
||||||
|
}))
|
||||||
|
|
||||||
|
const extractErrorMessage = (error: unknown): string | null =>
|
||||||
|
error instanceof Error ? `${error.name}: ${error.message}`.trim() : null
|
||||||
|
|
||||||
|
const retryWithBackoff = async <T>(
|
||||||
|
fn: (bail: (error: unknown) => never) => Promise<T>,
|
||||||
|
retries: number,
|
||||||
|
): Promise<T> => {
|
||||||
|
let bailed = false
|
||||||
|
const bail = (error: unknown): never => {
|
||||||
|
bailed = true
|
||||||
|
throw error
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let attempt = 0; ; attempt++) {
|
||||||
|
try {
|
||||||
|
return await fn(bail)
|
||||||
|
} catch (error) {
|
||||||
|
if (bailed || attempt >= retries) throw error
|
||||||
|
|
||||||
|
const delay = Math.min(
|
||||||
|
Math.round((Math.random() + 1) * 1000 * 2 ** attempt),
|
||||||
|
4000,
|
||||||
|
)
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, delay))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
|
||||||
// Get current IP and geolocation information (refactored IP detection with service-specific mappings)
|
// Get current IP and geolocation information (refactored IP detection with service-specific mappings)
|
||||||
interface IpInfo {
|
interface IpInfo {
|
||||||
ip: string
|
ip: string
|
||||||
@@ -249,8 +273,7 @@ export const getIpInfo = async (): Promise<
|
|||||||
debugLog(`尝试IP检测服务: ${service.url}`)
|
debugLog(`尝试IP检测服务: ${service.url}`)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return await asyncRetry(
|
return await retryWithBackoff(async (bail) => {
|
||||||
async (bail) => {
|
|
||||||
console.debug('Fetching IP information:', service.url)
|
console.debug('Fetching IP information:', service.url)
|
||||||
|
|
||||||
const timeoutController = new AbortController()
|
const timeoutController = new AbortController()
|
||||||
@@ -296,14 +319,7 @@ export const getIpInfo = async (): Promise<
|
|||||||
} finally {
|
} finally {
|
||||||
clearTimeout(timeoutId)
|
clearTimeout(timeoutId)
|
||||||
}
|
}
|
||||||
},
|
}, maxRetries)
|
||||||
{
|
|
||||||
retries: maxRetries,
|
|
||||||
minTimeout: 1000,
|
|
||||||
maxTimeout: 4000,
|
|
||||||
randomize: true,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
debugLog(`IP检测服务失败: ${service.url}`, error)
|
debugLog(`IP检测服务失败: ${service.url}`, error)
|
||||||
lastError = error
|
lastError = error
|
||||||
|
|||||||
+47
-14
@@ -1,18 +1,51 @@
|
|||||||
import { createContextState } from 'foxact/create-context-state'
|
import {
|
||||||
|
createContext,
|
||||||
|
createElement,
|
||||||
|
use,
|
||||||
|
useState,
|
||||||
|
type Dispatch,
|
||||||
|
type ReactNode,
|
||||||
|
type SetStateAction,
|
||||||
|
} from 'react'
|
||||||
|
|
||||||
const [ThemeModeProvider, useThemeMode, useSetThemeMode] = createContextState<
|
import noop from '@/utils/noop'
|
||||||
'light' | 'dark'
|
|
||||||
>()
|
|
||||||
|
|
||||||
// save update state
|
type ThemeMode = 'light' | 'dark'
|
||||||
const [UpdateStateProvider, useUpdateState, useSetUpdateState] =
|
|
||||||
createContextState<boolean>(false)
|
|
||||||
|
|
||||||
export {
|
const ThemeModeContext = createContext<ThemeMode>('light')
|
||||||
ThemeModeProvider,
|
const SetThemeModeContext =
|
||||||
useThemeMode,
|
createContext<Dispatch<SetStateAction<ThemeMode>>>(noop)
|
||||||
useSetThemeMode,
|
|
||||||
UpdateStateProvider,
|
export const ThemeModeProvider = ({
|
||||||
useUpdateState,
|
initialState,
|
||||||
useSetUpdateState,
|
children,
|
||||||
|
}: {
|
||||||
|
initialState: ThemeMode
|
||||||
|
children?: ReactNode
|
||||||
|
}) => {
|
||||||
|
const [mode, setMode] = useState<ThemeMode>(initialState)
|
||||||
|
return createElement(
|
||||||
|
ThemeModeContext,
|
||||||
|
{ value: mode },
|
||||||
|
createElement(SetThemeModeContext, { value: setMode }, children),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const useThemeMode = () => use(ThemeModeContext)
|
||||||
|
export const useSetThemeMode = () => use(SetThemeModeContext)
|
||||||
|
|
||||||
|
const UpdateStateContext = createContext<boolean>(false)
|
||||||
|
const SetUpdateStateContext =
|
||||||
|
createContext<Dispatch<SetStateAction<boolean>>>(noop)
|
||||||
|
|
||||||
|
export const UpdateStateProvider = ({ children }: { children?: ReactNode }) => {
|
||||||
|
const [state, setState] = useState(false)
|
||||||
|
return createElement(
|
||||||
|
UpdateStateContext,
|
||||||
|
{ value: state },
|
||||||
|
createElement(SetUpdateStateContext, { value: setState }, children),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export const useUpdateState = () => use(UpdateStateContext)
|
||||||
|
export const useSetUpdateState = () => use(SetUpdateStateContext)
|
||||||
|
|||||||
Reference in New Issue
Block a user