mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-14 12:23:43 +00:00
Compare commits
175
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9504e33a44 | ||
|
|
941fda7d13 | ||
|
|
be0a395447 | ||
|
|
506f689992 | ||
|
|
38c2f1e8c2 | ||
|
|
0520fd2baf | ||
|
|
6f7fd056ef | ||
|
|
6cd95507fd | ||
|
|
89dfbe4c45 | ||
|
|
392ee36137 | ||
|
|
a34383a7e2 | ||
|
|
98879569f0 | ||
|
|
8ef3b63e8d | ||
|
|
d873cd411c | ||
|
|
9e9bcd4b01 | ||
|
|
5bd57608d2 | ||
|
|
ebfd113360 | ||
|
|
d69874e13e | ||
|
|
b0d45226d7 | ||
|
|
cd19772099 | ||
|
|
1e36599d52 | ||
|
|
fc0a1e0ef9 | ||
|
|
8719166dbf | ||
|
|
c0b70d319d | ||
|
|
e0951de270 | ||
|
|
be0fb05edd | ||
|
|
91edba9af6 | ||
|
|
7d423e2182 | ||
|
|
903c5c46c4 | ||
|
|
b8ff5ff97f | ||
|
|
c51c5b284d | ||
|
|
4d65948934 | ||
|
|
c275bc2e46 | ||
|
|
9aae13453a | ||
|
|
d125d4ab75 | ||
|
|
4214765d39 | ||
|
|
47cafb7575 | ||
|
|
de65149b29 | ||
|
|
5462b14705 | ||
|
|
eee39e012f | ||
|
|
12860bb207 | ||
|
|
b86c2c18e7 | ||
|
|
6f20790b17 | ||
|
|
fa622a4063 | ||
|
|
c6619794fc | ||
|
|
87a8f87b70 | ||
|
|
ba84a04a43 | ||
|
|
224b488087 | ||
|
|
7ce4fb7f0e | ||
|
|
8d1ae93b03 | ||
|
|
363153fa33 | ||
|
|
f0dab90e09 | ||
|
|
6e60889ce8 | ||
|
|
88d150b933 | ||
|
|
694b43e3f9 | ||
|
|
fe25ccab1d | ||
|
|
8301b1f9ce | ||
|
|
49aab4ea7c | ||
|
|
5d8267fa56 | ||
|
|
1ab452ced8 | ||
|
|
743f356567 | ||
|
|
b1dd46cc7c | ||
|
|
38750d8505 | ||
|
|
7c1447f659 | ||
|
|
21702d5d46 | ||
|
|
e99ef6c7f4 | ||
|
|
c667f097dc | ||
|
|
46c34f2e92 | ||
|
|
e47a20a1bd | ||
|
|
cee5f3336e | ||
|
|
a760290213 | ||
|
|
a29f4bb42a | ||
|
|
62e8ab3cef | ||
|
|
8fa9a1e902 | ||
|
|
46675f26af | ||
|
|
0d52b840a2 | ||
|
|
091e7b8936 | ||
|
|
ff8f61423e | ||
|
|
e5ac13cfdc | ||
|
|
073e1413ab | ||
|
|
04b9aa18ec | ||
|
|
08fe4eef4e | ||
|
|
8f9bac9e6b | ||
|
|
bb17c7d48a | ||
|
|
75ffe70a4d | ||
|
|
36f9f65384 | ||
|
|
5f89ae3516 | ||
|
|
0cc2b690f8 | ||
|
|
b991482617 | ||
|
|
1f8906f952 | ||
|
|
0efc85d3c0 | ||
|
|
481675107f | ||
|
|
6568498850 | ||
|
|
67814348dc | ||
|
|
53d13dfe28 | ||
|
|
d511e66d56 | ||
|
|
16f2d30476 | ||
|
|
aafd039205 | ||
|
|
647e161431 | ||
|
|
8f3cf35162 | ||
|
|
f2145de571 | ||
|
|
39cd9034cd | ||
|
|
177c225f16 | ||
|
|
3be8db664c | ||
|
|
9b704f6f14 | ||
|
|
f49e2510f5 | ||
|
|
c5c8bb2bf5 | ||
|
|
962ff4dc98 | ||
|
|
59f3aa7028 | ||
|
|
cfdf87c3b8 | ||
|
|
99924296ef | ||
|
|
9d3221ebbb | ||
|
|
7b7327ffb3 | ||
|
|
fdfc6902a7 | ||
|
|
9fb3758203 | ||
|
|
e2ac8ce64b | ||
|
|
c01d11305c | ||
|
|
def54f8998 | ||
|
|
a205c0b8d7 | ||
|
|
ae70dc240c | ||
|
|
d7f6c3b206 | ||
|
|
a83e38dac4 | ||
|
|
d46c06f08d | ||
|
|
a61cdbed67 | ||
|
|
daa8c39dad | ||
|
|
a5cd53f94c | ||
|
|
847e88881d | ||
|
|
3d20e818e5 | ||
|
|
09f7c88ed3 | ||
|
|
f7b26753c1 | ||
|
|
9704d4af27 | ||
|
|
1907f404ac | ||
|
|
72c5ba7d20 | ||
|
|
5b0254f7c0 | ||
|
|
d36b345f92 | ||
|
|
bc5c818eae | ||
|
|
98bd3305b7 | ||
|
|
3f38848051 | ||
|
|
82d7f8ec81 | ||
|
|
a6981d58e9 | ||
|
|
1b1631b41a | ||
|
|
3eb6df55df | ||
|
|
6de63c3f63 | ||
|
|
969615f353 | ||
|
|
5a88b98314 | ||
|
|
2674b1c39e | ||
|
|
4c90b38247 | ||
|
|
93088b22f1 | ||
|
|
fe90c1d261 | ||
|
|
640e798d70 | ||
|
|
ba2df0ecff | ||
|
|
d61da67456 | ||
|
|
7c696ee6e0 | ||
|
|
7b840b4261 | ||
|
|
a3c1f84c2c | ||
|
|
8d33e1a5b3 | ||
|
|
bad7f1d06c | ||
|
|
af1c8b2719 | ||
|
|
d90af0b9d1 | ||
|
|
6016ee1d24 | ||
|
|
e275fd58bd | ||
|
|
c9626cb389 | ||
|
|
f86a379f93 | ||
|
|
a9eee26be7 | ||
|
|
abd16d5326 | ||
|
|
6756d82ffa | ||
|
|
71c9e6947a | ||
|
|
24db9bb58b | ||
|
|
de0afb1481 | ||
|
|
cb6331c20d | ||
|
|
b0e133b554 | ||
|
|
dbe37befa3 | ||
|
|
0d5c4e8e7f | ||
|
|
5515a1c48c | ||
|
|
3abf6ed933 |
No files matched your search
@@ -0,0 +1,2 @@
|
|||||||
|
# Keep upstream plugin sources recognizable and collapsed in GitHub reviews.
|
||||||
|
ui/flutter/third_party/** linguist-vendored whitespace=-blank-at-eol,-blank-at-eof
|
||||||
+1
-1
@@ -12,4 +12,4 @@
|
|||||||
#custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
#custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
||||||
# github: monkeyWie
|
# github: monkeyWie
|
||||||
ko_fi: gopeed
|
ko_fi: gopeed
|
||||||
custom: https://docs.gopeed.com/donate.html
|
custom: https://gopeed.com/docs/donate
|
||||||
@@ -40,16 +40,24 @@ template: |
|
|||||||
<table>
|
<table>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td rowspan="2">🪟 Windows</td>
|
<td rowspan="4">🪟 Windows</td>
|
||||||
<td><code>EXE</code></td>
|
<td rowspan="2"><code>EXE</code></td>
|
||||||
<td>amd64</td>
|
<td>amd64</td>
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-v$NEXT_PATCH_VERSION-windows-amd64.zip">📥</a></td>
|
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-v$NEXT_PATCH_VERSION-windows-amd64.zip">📥</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code>Portable</code></td>
|
<td>arm64</td>
|
||||||
|
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-v$NEXT_PATCH_VERSION-windows-arm64.zip">📥</a></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td rowspan="2"><code>Portable</code></td>
|
||||||
<td>amd64</td>
|
<td>amd64</td>
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-v$NEXT_PATCH_VERSION-windows-amd64-portable.zip">📥</a></td>
|
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-v$NEXT_PATCH_VERSION-windows-amd64-portable.zip">📥</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>arm64</td>
|
||||||
|
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-v$NEXT_PATCH_VERSION-windows-arm64-portable.zip">📥</a></td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td rowspan="3">🍎 MacOS</td>
|
<td rowspan="3">🍎 MacOS</td>
|
||||||
<td rowspan="3"><code>DMG</code></td>
|
<td rowspan="3"><code>DMG</code></td>
|
||||||
|
|||||||
+134
-49
@@ -13,8 +13,10 @@ on:
|
|||||||
default: "false"
|
default: "false"
|
||||||
|
|
||||||
env:
|
env:
|
||||||
GO_VERSION: "1.24"
|
GO_VERSION: "1.26.11"
|
||||||
FLUTTER_VERSION: "3.24.5"
|
FLUTTER_VERSION: "3.41.6"
|
||||||
|
GA4_MEASUREMENT_ID: ${{ secrets.GA4_MEASUREMENT_ID }}
|
||||||
|
GA4_API_SECRET: ${{ secrets.GA4_API_SECRET }}
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
@@ -34,21 +36,64 @@ jobs:
|
|||||||
|
|
||||||
build-windows:
|
build-windows:
|
||||||
if: ${{ github.event.inputs.platform == 'all' || github.event.inputs.platform == 'windows' }}
|
if: ${{ github.event.inputs.platform == 'all' || github.event.inputs.platform == 'windows' }}
|
||||||
runs-on: windows-2022
|
|
||||||
needs: [get-release]
|
needs: [get-release]
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- arch: arm64
|
||||||
|
os: windows-11-arm
|
||||||
|
llvm_ver: "20251202" # Only ARM64
|
||||||
|
flutter_channel: "main"
|
||||||
|
flutter_version: "7e1c8868"
|
||||||
|
- arch: amd64
|
||||||
|
os: windows-2022
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-go@v4
|
- name: Enable long paths for flutter main branch checks
|
||||||
|
run: |
|
||||||
|
git config --global core.longpaths true
|
||||||
|
|
||||||
|
# Install LLVM environment only on ARM64
|
||||||
|
- name: Install llvm-mingw-ucrt-aarch64 (ARM64 only)
|
||||||
|
if: matrix.arch == 'arm64'
|
||||||
|
run: |
|
||||||
|
$ver = "${{ matrix.llvm_ver }}"
|
||||||
|
$url = "https://github.com/mstorsjo/llvm-mingw/releases/download/$ver/llvm-mingw-$ver-ucrt-aarch64.zip"
|
||||||
|
$zip = "$env:RUNNER_TEMP\\llvm.zip"
|
||||||
|
$extract = "$env:RUNNER_TEMP\\extract"
|
||||||
|
$target = "C:\\clangarm64"
|
||||||
|
|
||||||
|
curl -L $url -o $zip
|
||||||
|
rm -r -fo $extract,$target -ea Ignore
|
||||||
|
mkdir $extract | Out-Null
|
||||||
|
|
||||||
|
tar -xf $zip -C $extract
|
||||||
|
mv (Get-ChildItem $extract)[0].FullName $target
|
||||||
|
|
||||||
|
$b = "$target\\bin"
|
||||||
|
"CC=$b\\clang.exe" >> $env:GITHUB_ENV
|
||||||
|
"CXX=$b\\clang++.exe" >> $env:GITHUB_ENV
|
||||||
|
"CLANGARM64_BIN=$b" >> $env:GITHUB_ENV
|
||||||
|
"CGO_ENABLED=1" >> $env:GITHUB_ENV
|
||||||
|
"CLANGARM64_ROOT=$target" >> $env:GITHUB_ENV
|
||||||
|
$b >> $env:GITHUB_PATH
|
||||||
|
|
||||||
|
- uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: ${{ env.GO_VERSION }}
|
go-version: ${{ env.GO_VERSION }}
|
||||||
- uses: subosito/flutter-action@v2
|
- uses: subosito/flutter-action@v2
|
||||||
with:
|
with:
|
||||||
flutter-version: ${{ env.FLUTTER_VERSION }}
|
channel: ${{ matrix.flutter_channel || 'stable' }}
|
||||||
|
flutter-version: ${{ matrix.flutter_version || env.FLUTTER_VERSION }}
|
||||||
- name: Build
|
- name: Build
|
||||||
env:
|
env:
|
||||||
VERSION: ${{ needs.get-release.outputs.version }}
|
VERSION: ${{ needs.get-release.outputs.version }}
|
||||||
|
GOARCH: ${{ matrix.arch }}
|
||||||
run: |
|
run: |
|
||||||
Invoke-WebRequest -Uri "https://github.com/jrsoftware/issrc/raw/main/Files/Languages/Unofficial/ChineseSimplified.isl" -OutFile "ChineseSimplified.isl"
|
Invoke-WebRequest -Uri "https://github.com/jrsoftware/issrc/raw/main/Files/Languages/ChineseSimplified.isl" -OutFile "ChineseSimplified.isl"
|
||||||
mv ChineseSimplified.isl "C:\Program Files (x86)\Inno Setup 6\Languages\"
|
mv ChineseSimplified.isl "C:\Program Files (x86)\Inno Setup 6\Languages\"
|
||||||
|
|
||||||
go build -tags nosqlite -ldflags="-w -s -X github.com/GopeedLab/gopeed/pkg/base.Version=$env:VERSION" -buildmode=c-shared -o ui/flutter/windows/libgopeed.dll github.com/GopeedLab/gopeed/bind/desktop
|
go build -tags nosqlite -ldflags="-w -s -X github.com/GopeedLab/gopeed/pkg/base.Version=$env:VERSION" -buildmode=c-shared -o ui/flutter/windows/libgopeed.dll github.com/GopeedLab/gopeed/bind/desktop
|
||||||
@@ -56,21 +101,45 @@ jobs:
|
|||||||
go build -ldflags="-w -s" -o ui/flutter/assets/exec/updater.exe github.com/GopeedLab/gopeed/cmd/updater
|
go build -ldflags="-w -s" -o ui/flutter/assets/exec/updater.exe github.com/GopeedLab/gopeed/cmd/updater
|
||||||
cd ui/flutter
|
cd ui/flutter
|
||||||
$TAG = "v$env:VERSION"
|
$TAG = "v$env:VERSION"
|
||||||
flutter build windows --dart-define="UPDATE_CHANNEL=windowsPortable"
|
flutter build windows --dart-define="UPDATE_CHANNEL=windowsPortable" --dart-define="GA4_MEASUREMENT_ID=${{ env.GA4_MEASUREMENT_ID }}" --dart-define="GA4_API_SECRET=${{ env.GA4_API_SECRET }}"
|
||||||
$mingw = "C:\Program Files\Git\mingw64\bin"
|
|
||||||
$system = "C:\Windows\System32"
|
$system = "C:\Windows\System32"
|
||||||
|
if ("${{ matrix.arch }}" -eq "amd64") {
|
||||||
|
# for amd64
|
||||||
$release = "build\windows\x64\runner\Release\"
|
$release = "build\windows\x64\runner\Release\"
|
||||||
cp $mingw\libstdc++-6.dll $release
|
# Use the same toolchain as cgo instead of Git's bundled DLLs.
|
||||||
cp $mingw\libgcc_s_seh-1.dll $release
|
$cc = (Get-Command -Name (go env CC) -CommandType Application -ErrorAction Stop | Select-Object -First 1).Source
|
||||||
|
foreach ($dll in @("libstdc++-6.dll", "libgcc_s_seh-1.dll", "libwinpthread-1.dll")) {
|
||||||
|
$runtimePath = [string](& $cc "-print-file-name=$dll")
|
||||||
|
if ($LASTEXITCODE -ne 0 -or [string]::IsNullOrWhiteSpace($runtimePath)) {
|
||||||
|
throw "Failed to locate $dll using $cc"
|
||||||
|
}
|
||||||
|
$runtimePath = $runtimePath.Trim()
|
||||||
|
# Some MinGW distributions keep runtime DLLs beside gcc.exe.
|
||||||
|
if ($runtimePath -eq $dll) {
|
||||||
|
$runtimePath = Join-Path (Split-Path -Parent $cc) $dll
|
||||||
|
}
|
||||||
|
if (!(Test-Path -LiteralPath $runtimePath -PathType Leaf)) {
|
||||||
|
throw "MinGW runtime $dll was not found by $cc (reported path: $runtimePath)"
|
||||||
|
}
|
||||||
|
Write-Host "Copying MinGW runtime: $runtimePath"
|
||||||
|
Copy-Item -LiteralPath $runtimePath -Destination $release
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
# for ARM64
|
||||||
|
$release = "build\windows\arm64\runner\Release\"
|
||||||
|
$mingw = "$env:CLANGARM64_ROOT\aarch64-w64-mingw32\bin"
|
||||||
|
cp $mingw\libc++.dll $release
|
||||||
|
cp $mingw\libunwind.dll $release
|
||||||
cp $mingw\libwinpthread-1.dll $release
|
cp $mingw\libwinpthread-1.dll $release
|
||||||
|
}
|
||||||
cp $system\msvcp140.dll $release
|
cp $system\msvcp140.dll $release
|
||||||
cp $system\vcruntime140.dll $release
|
cp $system\vcruntime140.dll $release
|
||||||
cp $system\vcruntime140_1.dll $release
|
cp $system\vcruntime140_1.dll $release
|
||||||
|
|
||||||
New-Item -Path build\windows\Output -ItemType Directory
|
New-Item -Path build\windows\Output -ItemType Directory
|
||||||
Compress-Archive -Path "$release*" -DestinationPath "build\windows\Output\Gopeed-$TAG-windows-amd64-portable.zip"
|
Compress-Archive -Path "$release*" -DestinationPath "build\windows\Output\Gopeed-$TAG-windows-${{ matrix.arch }}-portable.zip"
|
||||||
|
|
||||||
flutter build windows --dart-define="UPDATE_CHANNEL=windowsInstaller"
|
flutter build windows --dart-define="UPDATE_CHANNEL=windowsInstaller" --dart-define="GA4_MEASUREMENT_ID=${{ env.GA4_MEASUREMENT_ID }}" --dart-define="GA4_API_SECRET=${{ env.GA4_API_SECRET }}"
|
||||||
cd build/windows
|
cd build/windows
|
||||||
echo @"
|
echo @"
|
||||||
; Script generated by the Inno Setup Script Wizard.
|
; Script generated by the Inno Setup Script Wizard.
|
||||||
@@ -116,7 +185,7 @@ jobs:
|
|||||||
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
|
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
|
||||||
|
|
||||||
[Files]
|
[Files]
|
||||||
Source: ".\x64\runner\Release\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs;
|
Source: ".\${{ matrix.arch == 'amd64' && 'x64' || 'arm64' }}\runner\Release\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs;
|
||||||
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
|
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
|
||||||
|
|
||||||
[UninstallDelete]
|
[UninstallDelete]
|
||||||
@@ -130,22 +199,21 @@ jobs:
|
|||||||
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
|
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
|
||||||
"@ > setup.iss
|
"@ > setup.iss
|
||||||
iscc.exe setup.iss
|
iscc.exe setup.iss
|
||||||
mv "Output\gopeed.exe" "Output\Gopeed-$TAG-windows-amd64.exe"
|
mv "Output\gopeed.exe" "Output\Gopeed-$TAG-windows-${{ matrix.arch }}.exe"
|
||||||
Compress-Archive -Path "Output\Gopeed-$TAG-windows-amd64.exe" -DestinationPath "Output\Gopeed-$TAG-windows-amd64.zip"
|
Compress-Archive -Path "Output\Gopeed-$TAG-windows-${{ matrix.arch }}.exe" -DestinationPath "Output\Gopeed-$TAG-windows-${{ matrix.arch }}.zip"
|
||||||
Remove-Item -Path "Output\Gopeed-$TAG-windows-amd64.exe"
|
|
||||||
- name: Upload
|
- name: Upload
|
||||||
uses: shogo82148/actions-upload-release-asset@v1
|
uses: shogo82148/actions-upload-release-asset@v1.9.2
|
||||||
with:
|
with:
|
||||||
upload_url: ${{ needs.get-release.outputs.upload_url }}
|
upload_url: ${{ needs.get-release.outputs.upload_url }}
|
||||||
asset_path: ui/flutter/build/windows/Output/*
|
asset_path: ui/flutter/build/windows/Output/*
|
||||||
overwrite: true
|
overwrite: true
|
||||||
build-macos-amd64-lib:
|
build-macos-amd64-lib:
|
||||||
if: ${{ github.event.inputs.platform == 'all' || github.event.inputs.platform == 'macos' }}
|
if: ${{ github.event.inputs.platform == 'all' || github.event.inputs.platform == 'macos' }}
|
||||||
runs-on: macos-13
|
runs-on: macos-15-intel
|
||||||
needs: [get-release]
|
needs: [get-release]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-go@v4
|
- uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: ${{ env.GO_VERSION }}
|
go-version: ${{ env.GO_VERSION }}
|
||||||
- name: Build
|
- name: Build
|
||||||
@@ -171,7 +239,7 @@ jobs:
|
|||||||
needs: [get-release, build-macos-amd64-lib]
|
needs: [get-release, build-macos-amd64-lib]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-go@v4
|
- uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: ${{ env.GO_VERSION }}
|
go-version: ${{ env.GO_VERSION }}
|
||||||
- uses: actions/setup-node@v3
|
- uses: actions/setup-node@v3
|
||||||
@@ -226,7 +294,7 @@ jobs:
|
|||||||
VERSION: ${{ needs.get-release.outputs.version }}
|
VERSION: ${{ needs.get-release.outputs.version }}
|
||||||
run: |
|
run: |
|
||||||
cd ui/flutter
|
cd ui/flutter
|
||||||
flutter build macos --dart-define="UPDATE_CHANNEL=macosDmg"
|
flutter build macos --dart-define="UPDATE_CHANNEL=macosDmg" --dart-define="GA4_MEASUREMENT_ID=${{ env.GA4_MEASUREMENT_ID }}" --dart-define="GA4_API_SECRET=${{ env.GA4_API_SECRET }}"
|
||||||
cd build/macos/Build/Products/Release
|
cd build/macos/Build/Products/Release
|
||||||
cat>appdmg.json<<EOF
|
cat>appdmg.json<<EOF
|
||||||
{
|
{
|
||||||
@@ -262,7 +330,7 @@ jobs:
|
|||||||
needs: [get-release]
|
needs: [get-release]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-go@v4
|
- uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: ${{ env.GO_VERSION }}
|
go-version: ${{ env.GO_VERSION }}
|
||||||
- uses: subosito/flutter-action@v2
|
- uses: subosito/flutter-action@v2
|
||||||
@@ -271,7 +339,7 @@ jobs:
|
|||||||
channel: master
|
channel: master
|
||||||
- run: |
|
- run: |
|
||||||
sudo apt update -y
|
sudo apt update -y
|
||||||
sudo apt install -y ninja-build libgtk-3-dev libayatana-appindicator3-1 libayatana-appindicator3-dev rpm patchelf libfuse2 locate imagemagick potrace
|
sudo apt install -y ninja-build libgtk-3-dev libwebkit2gtk-4.1-dev libayatana-appindicator3-1 libayatana-appindicator3-dev rpm patchelf libfuse2 locate libkeybinder-3.0-dev
|
||||||
arch=$(uname -m)
|
arch=$(uname -m)
|
||||||
wget -O appimagetool "https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-${arch}.AppImage"
|
wget -O appimagetool "https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-${arch}.AppImage"
|
||||||
chmod +x appimagetool
|
chmod +x appimagetool
|
||||||
@@ -286,18 +354,11 @@ jobs:
|
|||||||
|
|
||||||
cd ui/flutter
|
cd ui/flutter
|
||||||
|
|
||||||
ICON_PATH=$(find assets -name "logo.png" -o -name "icon.png" | head -n 1)
|
|
||||||
[ -z "$ICON_PATH" ] && ICON_PATH="assets/icon.png" && touch assets/icon.png
|
|
||||||
|
|
||||||
convert "$ICON_PATH" assets/icon.svg
|
|
||||||
ICON_PATH="assets/icon.svg"
|
|
||||||
|
|
||||||
RPM_ARCH=$(uname -m)
|
RPM_ARCH=$(uname -m)
|
||||||
|
|
||||||
mkdir -p linux/packaging/rpm
|
mkdir -p linux/packaging/rpm
|
||||||
cat << EOF > linux/packaging/rpm/make_config.yaml
|
cat << EOF > linux/packaging/rpm/make_config.yaml
|
||||||
display_name: Gopeed
|
display_name: Gopeed
|
||||||
icon: $ICON_PATH
|
icon: assets/icon/icon.svg
|
||||||
summary: High speed downloader.
|
summary: High speed downloader.
|
||||||
description: A high speed downloader that supports all platforms.
|
description: A high speed downloader that supports all platforms.
|
||||||
group: Applications/Internet
|
group: Applications/Internet
|
||||||
@@ -320,6 +381,8 @@ jobs:
|
|||||||
build_args:
|
build_args:
|
||||||
dart-define:
|
dart-define:
|
||||||
UPDATE_CHANNEL: linuxAppImage
|
UPDATE_CHANNEL: linuxAppImage
|
||||||
|
GA4_MEASUREMENT_ID: ${{ env.GA4_MEASUREMENT_ID }}
|
||||||
|
GA4_API_SECRET: ${{ env.GA4_API_SECRET }}
|
||||||
- name: deb
|
- name: deb
|
||||||
package:
|
package:
|
||||||
platform: linux
|
platform: linux
|
||||||
@@ -327,6 +390,8 @@ jobs:
|
|||||||
build_args:
|
build_args:
|
||||||
dart-define:
|
dart-define:
|
||||||
UPDATE_CHANNEL: linuxDeb
|
UPDATE_CHANNEL: linuxDeb
|
||||||
|
GA4_MEASUREMENT_ID: ${{ env.GA4_MEASUREMENT_ID }}
|
||||||
|
GA4_API_SECRET: ${{ env.GA4_API_SECRET }}
|
||||||
- name: rpm
|
- name: rpm
|
||||||
package:
|
package:
|
||||||
platform: linux
|
platform: linux
|
||||||
@@ -334,6 +399,8 @@ jobs:
|
|||||||
build_args:
|
build_args:
|
||||||
dart-define:
|
dart-define:
|
||||||
UPDATE_CHANNEL: linuxRpm
|
UPDATE_CHANNEL: linuxRpm
|
||||||
|
GA4_MEASUREMENT_ID: ${{ env.GA4_MEASUREMENT_ID }}
|
||||||
|
GA4_API_SECRET: ${{ env.GA4_API_SECRET }}
|
||||||
EOF
|
EOF
|
||||||
dart pub global activate -sgit https://github.com/GopeedLab/flutter_distributor.git --git-path packages/flutter_distributor
|
dart pub global activate -sgit https://github.com/GopeedLab/flutter_distributor.git --git-path packages/flutter_distributor
|
||||||
flutter_distributor release --name linux
|
flutter_distributor release --name linux
|
||||||
@@ -355,13 +422,17 @@ jobs:
|
|||||||
overwrite: true
|
overwrite: true
|
||||||
build-snap:
|
build-snap:
|
||||||
if: ${{ github.event.inputs.platform == 'all' || github.event.inputs.platform == 'snap' }}
|
if: ${{ github.event.inputs.platform == 'all' || github.event.inputs.platform == 'snap' }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-24.04
|
||||||
needs: [get-release]
|
needs: [get-release]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-go@v4
|
- uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: ${{ env.GO_VERSION }}
|
go-version: ${{ env.GO_VERSION }}
|
||||||
|
- name: Install Snap host build dependencies
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y --no-install-recommends pkg-config libgtk-3-dev libwebkit2gtk-4.1-dev
|
||||||
- name: Setup LXD
|
- name: Setup LXD
|
||||||
uses: canonical/[email protected]
|
uses: canonical/[email protected]
|
||||||
with:
|
with:
|
||||||
@@ -425,9 +496,13 @@ jobs:
|
|||||||
\$CRAFT_PART_INSTALL/usr/bin/flutter doctor
|
\$CRAFT_PART_INSTALL/usr/bin/flutter doctor
|
||||||
build-packages:
|
build-packages:
|
||||||
- clang
|
- clang
|
||||||
|
- llvm-18
|
||||||
|
- lld
|
||||||
- cmake
|
- cmake
|
||||||
- curl
|
- curl
|
||||||
- libgtk-3-dev
|
- libgtk-3-dev
|
||||||
|
- libwebkit2gtk-4.1-dev
|
||||||
|
- libkeybinder-3.0-dev
|
||||||
- ninja-build
|
- ninja-build
|
||||||
- unzip
|
- unzip
|
||||||
- xz-utils
|
- xz-utils
|
||||||
@@ -442,14 +517,19 @@ jobs:
|
|||||||
source: .
|
source: .
|
||||||
plugin: nil
|
plugin: nil
|
||||||
stage-packages:
|
stage-packages:
|
||||||
|
- libwebkit2gtk-4.1-0
|
||||||
- libgtk-3-dev
|
- libgtk-3-dev
|
||||||
|
- libkeybinder-3.0-dev
|
||||||
- libappindicator3-dev
|
- libappindicator3-dev
|
||||||
override-build: |
|
override-build: |
|
||||||
# work around pub get stack overflow # https://github.com/dart-lang/sdk/issues/51068#issuecomment-1396588253
|
# work around pub get stack overflow # https://github.com/dart-lang/sdk/issues/51068#issuecomment-1396588253
|
||||||
set +e
|
set +e
|
||||||
dart pub get
|
dart pub get
|
||||||
set -eux
|
set -eux
|
||||||
flutter build linux --dart-define="UPDATE_CHANNEL=linuxSnap"
|
llvm_bin_dir="\$(dirname "\$(readlink -f "\$(command -v clang)")")"
|
||||||
|
test -x "\$llvm_bin_dir/llvm-ar"
|
||||||
|
test -x "\$llvm_bin_dir/ld.lld"
|
||||||
|
flutter build linux --dart-define="UPDATE_CHANNEL=linuxSnap" --dart-define="GA4_MEASUREMENT_ID=$GA4_MEASUREMENT_ID" --dart-define="GA4_API_SECRET=$GA4_API_SECRET"
|
||||||
mkdir -p \$CRAFT_PART_INSTALL/bin/
|
mkdir -p \$CRAFT_PART_INSTALL/bin/
|
||||||
cp -r build/linux/*/release/bundle/* \$CRAFT_PART_INSTALL/bin/
|
cp -r build/linux/*/release/bundle/* \$CRAFT_PART_INSTALL/bin/
|
||||||
gpu-2404:
|
gpu-2404:
|
||||||
@@ -491,7 +571,7 @@ jobs:
|
|||||||
needs: [get-release]
|
needs: [get-release]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-go@v4
|
- uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: ${{ env.GO_VERSION }}
|
go-version: ${{ env.GO_VERSION }}
|
||||||
- uses: actions/setup-java@v3
|
- uses: actions/setup-java@v3
|
||||||
@@ -514,8 +594,8 @@ jobs:
|
|||||||
gomobile bind -tags nosqlite -ldflags="-w -s -checklinkname=0 -X github.com/GopeedLab/gopeed/pkg/base.Version=$VERSION" -o ui/flutter/android/app/libs/libgopeed.aar -target=android -androidapi 21 -javapkg=com.gopeed github.com/GopeedLab/gopeed/bind/mobile
|
gomobile bind -tags nosqlite -ldflags="-w -s -checklinkname=0 -X github.com/GopeedLab/gopeed/pkg/base.Version=$VERSION" -o ui/flutter/android/app/libs/libgopeed.aar -target=android -androidapi 21 -javapkg=com.gopeed github.com/GopeedLab/gopeed/bind/mobile
|
||||||
cd ui/flutter
|
cd ui/flutter
|
||||||
echo $APK_KEYSTORE | base64 -di > android/app/upload-keystore.jks
|
echo $APK_KEYSTORE | base64 -di > android/app/upload-keystore.jks
|
||||||
flutter build apk --dart-define="UPDATE_CHANNEL=androidApk"
|
flutter build apk --dart-define="UPDATE_CHANNEL=androidApk" --dart-define="GA4_MEASUREMENT_ID=${{ env.GA4_MEASUREMENT_ID }}" --dart-define="GA4_API_SECRET=${{ env.GA4_API_SECRET }}"
|
||||||
flutter build apk --split-per-abi --dart-define="UPDATE_CHANNEL=androidApk"
|
flutter build apk --split-per-abi --dart-define="UPDATE_CHANNEL=androidApk" --dart-define="GA4_MEASUREMENT_ID=${{ env.GA4_MEASUREMENT_ID }}" --dart-define="GA4_API_SECRET=${{ env.GA4_API_SECRET }}"
|
||||||
mkdir dist
|
mkdir dist
|
||||||
cp build/app/outputs/flutter-apk/app-release.apk dist/Gopeed-v$VERSION-android.apk
|
cp build/app/outputs/flutter-apk/app-release.apk dist/Gopeed-v$VERSION-android.apk
|
||||||
cp build/app/outputs/flutter-apk/app-armeabi-v7a-release.apk dist/Gopeed-v$VERSION-android-armeabi-v7a.apk
|
cp build/app/outputs/flutter-apk/app-armeabi-v7a-release.apk dist/Gopeed-v$VERSION-android-armeabi-v7a.apk
|
||||||
@@ -529,11 +609,11 @@ jobs:
|
|||||||
overwrite: true
|
overwrite: true
|
||||||
build-ios:
|
build-ios:
|
||||||
if: ${{ github.event.inputs.platform == 'all' || github.event.inputs.platform == 'ios' }}
|
if: ${{ github.event.inputs.platform == 'all' || github.event.inputs.platform == 'ios' }}
|
||||||
runs-on: macos-14
|
runs-on: macos-26
|
||||||
needs: [get-release]
|
needs: [get-release]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-go@v4
|
- uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: ${{ env.GO_VERSION }}
|
go-version: ${{ env.GO_VERSION }}
|
||||||
- uses: subosito/flutter-action@v2
|
- uses: subosito/flutter-action@v2
|
||||||
@@ -548,7 +628,7 @@ jobs:
|
|||||||
gomobile init
|
gomobile init
|
||||||
gomobile bind -tags nosqlite -ldflags="-w -s -X github.com/GopeedLab/gopeed/pkg/base.Version=$VERSION" -o ui/flutter/ios/Frameworks/Libgopeed.xcframework -target=ios github.com/GopeedLab/gopeed/bind/mobile
|
gomobile bind -tags nosqlite -ldflags="-w -s -X github.com/GopeedLab/gopeed/pkg/base.Version=$VERSION" -o ui/flutter/ios/Frameworks/Libgopeed.xcframework -target=ios github.com/GopeedLab/gopeed/bind/mobile
|
||||||
cd ui/flutter
|
cd ui/flutter
|
||||||
flutter build ios --no-codesign --dart-define="UPDATE_CHANNEL=iosIpa"
|
flutter build ios --no-codesign --dart-define="UPDATE_CHANNEL=iosIpa" --dart-define="GA4_MEASUREMENT_ID=${{ env.GA4_MEASUREMENT_ID }}" --dart-define="GA4_API_SECRET=${{ env.GA4_API_SECRET }}"
|
||||||
mkdir Payload
|
mkdir Payload
|
||||||
cp -r build/ios/iphoneos/Runner.app Payload
|
cp -r build/ios/iphoneos/Runner.app Payload
|
||||||
zip -r -y Payload.zip Payload/Runner.app
|
zip -r -y Payload.zip Payload/Runner.app
|
||||||
@@ -566,7 +646,7 @@ jobs:
|
|||||||
needs: [get-release]
|
needs: [get-release]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-go@v4
|
- uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: ${{ env.GO_VERSION }}
|
go-version: ${{ env.GO_VERSION }}
|
||||||
- uses: subosito/flutter-action@v2
|
- uses: subosito/flutter-action@v2
|
||||||
@@ -577,7 +657,8 @@ jobs:
|
|||||||
VERSION: ${{ needs.get-release.outputs.version }}
|
VERSION: ${{ needs.get-release.outputs.version }}
|
||||||
run: |
|
run: |
|
||||||
cd ui/flutter
|
cd ui/flutter
|
||||||
flutter build web --no-web-resources-cdn
|
flutter build web --no-web-resources-cdn --dart-define="GA4_MEASUREMENT_ID=${{ env.GA4_MEASUREMENT_ID }}" --dart-define="GA4_API_SECRET=${{ env.GA4_API_SECRET }}"
|
||||||
|
dart ../../.github/workflows/scripts/flutter_local_font.dart
|
||||||
cd ../../
|
cd ../../
|
||||||
cp -r ui/flutter/build/web cmd/web/dist
|
cp -r ui/flutter/build/web cmd/web/dist
|
||||||
mkdir -p dist/zip
|
mkdir -p dist/zip
|
||||||
@@ -630,12 +711,15 @@ jobs:
|
|||||||
VERSION: ${{ needs.get-release.outputs.version }}
|
VERSION: ${{ needs.get-release.outputs.version }}
|
||||||
run: |
|
run: |
|
||||||
sudo apt update -y
|
sudo apt update -y
|
||||||
sudo apt install -y pv bsdmainutils
|
qdk_version=2.5.3
|
||||||
wget -O qdk2_0.32.bionic_amd64.deb "https://github.com/qnap-dev/qdk2/releases/download/v0.32/qdk2_0.32.bionic_amd64.deb"
|
qdk_package="qdk_${qdk_version}_amd64.deb"
|
||||||
dpkg -X qdk2_0.32.bionic_amd64.deb qdk2 # Direct installs will fail due to missing dependencies!
|
curl --fail --location --retry 3 --retry-all-errors \
|
||||||
[[ -d qdk2 ]] || exit 1
|
--output "${qdk_package}" \
|
||||||
|
"https://github.com/qnap-dev/QDK/releases/download/v${qdk_version}/${qdk_package}"
|
||||||
|
echo "17b3841b7d4590a4ee025844ba583304b5e3c497d9fa8934d5175131d3908022 ${qdk_package}" | sha256sum --check --strict
|
||||||
|
sudo apt-get install -y "./${qdk_package}"
|
||||||
|
command -v qbuild
|
||||||
|
|
||||||
export PATH=$(pwd)/qdk2/usr/bin:$(pwd)/qdk2/usr/share/qdk2/QDK/bin:${PATH}
|
|
||||||
wget -O Gopeed.template.tar.gz "https://github.com/GopeedLab/QpkgBuild/raw/refs/heads/master/template/Gopeed.template.tar.gz"
|
wget -O Gopeed.template.tar.gz "https://github.com/GopeedLab/QpkgBuild/raw/refs/heads/master/template/Gopeed.template.tar.gz"
|
||||||
tar -zxf Gopeed.template.tar.gz
|
tar -zxf Gopeed.template.tar.gz
|
||||||
[[ -d Gopeed ]] || exit 1
|
[[ -d Gopeed ]] || exit 1
|
||||||
@@ -693,7 +777,8 @@ jobs:
|
|||||||
- name: Build flutter web
|
- name: Build flutter web
|
||||||
run: |
|
run: |
|
||||||
cd ui/flutter
|
cd ui/flutter
|
||||||
flutter build web --no-web-resources-cdn --dart-define="UPDATE_CHANNEL=docker"
|
flutter build web --no-web-resources-cdn --dart-define="UPDATE_CHANNEL=docker" --dart-define="GA4_MEASUREMENT_ID=${{ env.GA4_MEASUREMENT_ID }}" --dart-define="GA4_API_SECRET=${{ env.GA4_API_SECRET }}"
|
||||||
|
dart ../../.github/workflows/scripts/flutter_local_font.dart
|
||||||
cd ../../
|
cd ../../
|
||||||
rm -rf cmd/web/dist
|
rm -rf cmd/web/dist
|
||||||
cp -r ui/flutter/build/web cmd/web/dist
|
cp -r ui/flutter/build/web cmd/web/dist
|
||||||
@@ -713,5 +798,5 @@ jobs:
|
|||||||
linux/arm64
|
linux/arm64
|
||||||
linux/arm/v7
|
linux/arm/v7
|
||||||
tags: |
|
tags: |
|
||||||
liwei2633/gopeed:latest
|
${{ !contains(env.VERSION, 'beta') && 'liwei2633/gopeed:latest' || '' }}
|
||||||
liwei2633/gopeed:v${{ env.VERSION }}
|
liwei2633/gopeed:v${{ env.VERSION }}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
name: l10n
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
paths:
|
||||||
|
- "ui/flutter/lib/l10n/**"
|
||||||
|
- "ui/flutter/l10n.yaml"
|
||||||
|
- ".github/workflows/scripts/check_l10n.dart"
|
||||||
|
- ".github/workflows/l10n.yml"
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
paths:
|
||||||
|
- "ui/flutter/lib/l10n/**"
|
||||||
|
- "ui/flutter/l10n.yaml"
|
||||||
|
- ".github/workflows/scripts/check_l10n.dart"
|
||||||
|
- ".github/workflows/l10n.yml"
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: l10n-${{ github.event.pull_request.number || github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
env:
|
||||||
|
FLUTTER_VERSION: "3.41.6"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
validate:
|
||||||
|
name: Validate Flutter translations
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
working-directory: ui/flutter
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: subosito/flutter-action@v2
|
||||||
|
with:
|
||||||
|
flutter-version: ${{ env.FLUTTER_VERSION }}
|
||||||
|
- run: flutter pub get
|
||||||
|
- name: Validate ARB catalogs
|
||||||
|
run: dart run ../../.github/workflows/scripts/check_l10n.dart
|
||||||
|
- name: Generate localizations
|
||||||
|
run: flutter gen-l10n
|
||||||
|
- name: Analyze generated localization integration
|
||||||
|
run: flutter analyze
|
||||||
@@ -17,7 +17,7 @@ on:
|
|||||||
- "Dockerfile"
|
- "Dockerfile"
|
||||||
|
|
||||||
env:
|
env:
|
||||||
GO_VERSION: "1.24"
|
GO_VERSION: "1.26.11"
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
@@ -31,7 +31,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-go@v4
|
- uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: ${{ env.GO_VERSION }}
|
go-version: ${{ env.GO_VERSION }}
|
||||||
- uses: release-drafter/release-drafter@v5
|
- uses: release-drafter/release-drafter@v5
|
||||||
|
|||||||
@@ -0,0 +1,107 @@
|
|||||||
|
// Validate Flutter ARB translation catalogs before localization code generation.
|
||||||
|
//
|
||||||
|
// Usage (from ui/flutter):
|
||||||
|
// dart run ../../.github/workflows/scripts/check_l10n.dart
|
||||||
|
//
|
||||||
|
// What it checks:
|
||||||
|
// - Every ARB file uses the repository's canonical two-space JSON formatting.
|
||||||
|
// - Every app_<locale>.arb file declares the matching @@locale value.
|
||||||
|
// - Message values are not empty (warning only).
|
||||||
|
// - Every locale has the same message keys as app_en.arb (warning only).
|
||||||
|
// - Every translation preserves the placeholder variables used by app_en.arb
|
||||||
|
// (warning only).
|
||||||
|
//
|
||||||
|
// Notes:
|
||||||
|
// - This script does not judge translation quality.
|
||||||
|
// - It does not generate localization code or fully parse ICU MessageFormat.
|
||||||
|
// `flutter gen-l10n` runs immediately afterwards in CI to validate ICU syntax
|
||||||
|
// and generate app_localizations*.dart.
|
||||||
|
// - The script exits with a failure only for malformed JSON, invalid ARB
|
||||||
|
// formatting, or a mismatched @@locale value. Translation completeness is
|
||||||
|
// reported as warnings; generation and analysis remain the compile-time gate.
|
||||||
|
|
||||||
|
import 'dart:convert';
|
||||||
|
import 'dart:io';
|
||||||
|
|
||||||
|
/// Runs repository-specific checks that `flutter gen-l10n` does not enforce.
|
||||||
|
void main() {
|
||||||
|
final directory = Directory('lib/l10n');
|
||||||
|
final templateFile = File('${directory.path}/app_en.arb');
|
||||||
|
final template = _readArb(templateFile);
|
||||||
|
final templateKeys = _messageKeys(template);
|
||||||
|
var failed = false;
|
||||||
|
|
||||||
|
for (final file in directory.listSync().whereType<File>().where(
|
||||||
|
(file) => file.path.endsWith('.arb'),
|
||||||
|
)) {
|
||||||
|
final messages = _readArb(file);
|
||||||
|
if (!_hasCanonicalFormat(file, messages)) {
|
||||||
|
stderr.writeln(
|
||||||
|
'${file.path}: ARB formatting is not canonical (use two-space JSON indentation and a trailing newline)',
|
||||||
|
);
|
||||||
|
failed = true;
|
||||||
|
}
|
||||||
|
final expectedLocale = file.uri.pathSegments.last
|
||||||
|
.replaceFirst('app_', '')
|
||||||
|
.replaceFirst('.arb', '');
|
||||||
|
if (messages['@@locale'] != expectedLocale) {
|
||||||
|
stderr.writeln('${file.path}: @@locale must be $expectedLocale');
|
||||||
|
failed = true;
|
||||||
|
}
|
||||||
|
final keys = _messageKeys(messages);
|
||||||
|
final empty =
|
||||||
|
keys.where((key) => (messages[key] as String).trim().isEmpty).toList()
|
||||||
|
..sort();
|
||||||
|
if (empty.isNotEmpty) {
|
||||||
|
_warning('${file.path}: empty messages $empty');
|
||||||
|
}
|
||||||
|
if (file.path == templateFile.path) continue;
|
||||||
|
final missing = templateKeys.difference(keys);
|
||||||
|
final extra = keys.difference(templateKeys);
|
||||||
|
if (missing.isNotEmpty || extra.isNotEmpty) {
|
||||||
|
_warning(
|
||||||
|
'${file.path}: missing ${missing.toList()..sort()}, extra ${extra.toList()..sort()}',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (final key in templateKeys.intersection(keys)) {
|
||||||
|
final expected = _placeholders(template[key] as String);
|
||||||
|
final actual = _placeholders(messages[key] as String);
|
||||||
|
if (!_sameSet(expected, actual)) {
|
||||||
|
_warning(
|
||||||
|
'${file.path}: $key placeholders $actual do not match $expected',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (failed) exitCode = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Reads one ARB file as its top-level JSON object.
|
||||||
|
Map<String, Object?> _readArb(File file) =>
|
||||||
|
jsonDecode(file.readAsStringSync()) as Map<String, Object?>;
|
||||||
|
|
||||||
|
/// Checks the exact JSON layout so whitespace-only formatting drift fails CI.
|
||||||
|
bool _hasCanonicalFormat(File file, Map<String, Object?> arb) {
|
||||||
|
const encoder = JsonEncoder.withIndent(' ');
|
||||||
|
return file.readAsStringSync() == '${encoder.convert(arb)}\n';
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns user-facing message keys and excludes ARB metadata keys (`@`/`@@`).
|
||||||
|
Set<String> _messageKeys(Map<String, Object?> arb) =>
|
||||||
|
arb.keys.where((key) => !key.startsWith('@')).toSet();
|
||||||
|
|
||||||
|
/// Extracts both simple placeholders (`{name}`) and ICU selector variables.
|
||||||
|
///
|
||||||
|
/// For example, this returns `count` from
|
||||||
|
/// `{count, plural, =1{1 file} other{{count} files}}`.
|
||||||
|
Set<String> _placeholders(String message) => RegExp(
|
||||||
|
r'\{([A-Za-z_][A-Za-z0-9_]*)(?=\s*(?:\}|,\s*(?:plural|select|selectordinal)\s*,))',
|
||||||
|
).allMatches(message).map((match) => match.group(1)!).toSet();
|
||||||
|
|
||||||
|
/// Compares sets without depending on iteration order.
|
||||||
|
bool _sameSet(Set<String> left, Set<String> right) =>
|
||||||
|
left.length == right.length && left.containsAll(right);
|
||||||
|
|
||||||
|
void _warning(String message) => stderr.writeln('warning: $message');
|
||||||
@@ -0,0 +1,413 @@
|
|||||||
|
// Localize external Google Fonts (fonts.gstatic.com) references in Flutter Web build output.
|
||||||
|
//
|
||||||
|
// Usage (post-build):
|
||||||
|
// # Run AFTER: flutter build web --no-web-resources-cdn
|
||||||
|
// dart ../../.github/workflows/scripts/flutter_local_font.dart
|
||||||
|
//
|
||||||
|
// What it does:
|
||||||
|
// In main.dart.js:
|
||||||
|
// - Find any referenced resources under: https://fonts.gstatic.com/s/
|
||||||
|
// (including the common pattern where Flutter concatenates the base URL with a relative path)
|
||||||
|
// - Download them into: build/web/assets/gstatic/<path>
|
||||||
|
// - Rewrite "https://fonts.gstatic.com/s/" -> "assets/gstatic/" so runtime loads locally
|
||||||
|
// - Only download font subsets needed by supported locales (parsed from lib/l10n/*.arb)
|
||||||
|
//
|
||||||
|
// Notes:
|
||||||
|
// - This script DOES NOT call `flutter build web`. It only patches the output.
|
||||||
|
// - This is a best-effort post-process. Always verify in browser devtools.
|
||||||
|
|
||||||
|
import 'dart:async';
|
||||||
|
import 'dart:io';
|
||||||
|
|
||||||
|
/// Get font families required for a specific locale based on language/script.
|
||||||
|
/// Uses language code prefix to automatically detect the script system.
|
||||||
|
/// Returns empty set if base fonts (Latin/Cyrillic/Greek) are sufficient.
|
||||||
|
Set<String> _getFontFamiliesForLocale(String locale) {
|
||||||
|
final normalizedLocale = locale.toLowerCase().replaceAll('-', '_');
|
||||||
|
final lang = normalizedLocale.split('_').first;
|
||||||
|
|
||||||
|
// CJK languages - need specific large font files
|
||||||
|
if (lang == 'zh') {
|
||||||
|
// Simplified vs Traditional Chinese
|
||||||
|
if (normalizedLocale.contains('_tw') ||
|
||||||
|
normalizedLocale.contains('_hk') ||
|
||||||
|
normalizedLocale.contains('_mo')) {
|
||||||
|
return {'notosanstc', 'notosanshk'}; // Traditional Chinese (TW, HK, MO)
|
||||||
|
}
|
||||||
|
return {'notosanssc'}; // Simplified Chinese, including generic zh
|
||||||
|
}
|
||||||
|
if (lang == 'ja') return {'notosansjp'}; // Japanese
|
||||||
|
if (lang == 'ko') return {'notosanskr'}; // Korean
|
||||||
|
|
||||||
|
// Arabic script languages
|
||||||
|
if (lang == 'ar') return {'notosansarabic'}; // Arabic
|
||||||
|
if (lang == 'fa') return {'notosansarabic'}; // Persian/Farsi
|
||||||
|
if (lang == 'ur') return {'notosansarabic'}; // Urdu
|
||||||
|
if (lang == 'ps') return {'notosansarabic'}; // Pashto
|
||||||
|
if (lang == 'ku') return {'notosansarabic'}; // Kurdish (Arabic script)
|
||||||
|
|
||||||
|
// Hebrew script
|
||||||
|
if (lang == 'he' || lang == 'yi') return {'notosanshebrew'};
|
||||||
|
|
||||||
|
// South Asian scripts
|
||||||
|
if (lang == 'hi' || lang == 'mr' || lang == 'ne' || lang == 'sa') {
|
||||||
|
return {'notosansdevanagari'}; // Hindi, Marathi, Nepali, Sanskrit
|
||||||
|
}
|
||||||
|
if (lang == 'bn' || lang == 'as')
|
||||||
|
return {'notosansbengali'}; // Bengali, Assamese
|
||||||
|
if (lang == 'ta')
|
||||||
|
return {'notosanstamil', 'notosanstamilsupplement'}; // Tamil
|
||||||
|
if (lang == 'te') return {'notosanstelugu'}; // Telugu
|
||||||
|
if (lang == 'kn') return {'notosanskannada'}; // Kannada
|
||||||
|
if (lang == 'ml') return {'notosansmalayalam'}; // Malayalam
|
||||||
|
if (lang == 'gu') return {'notosansgujarati'}; // Gujarati
|
||||||
|
if (lang == 'pa') return {'notosansgurmukhi'}; // Punjabi (Gurmukhi)
|
||||||
|
if (lang == 'or') return {'notosansoriya'}; // Odia/Oriya
|
||||||
|
if (lang == 'si') return {'notosanssinhala'}; // Sinhala
|
||||||
|
|
||||||
|
// Southeast Asian scripts
|
||||||
|
if (lang == 'th') return {'notosansthai'}; // Thai
|
||||||
|
if (lang == 'lo') return {'notosanslao'}; // Lao
|
||||||
|
if (lang == 'my') return {'notosansmyanmar'}; // Myanmar/Burmese
|
||||||
|
if (lang == 'km') return {'notosanskhmer'}; // Khmer/Cambodian
|
||||||
|
if (lang == 'jv') return {'notosansjavanese'}; // Javanese
|
||||||
|
|
||||||
|
// Other scripts
|
||||||
|
if (lang == 'ka') return {'notosansgeorgian'}; // Georgian
|
||||||
|
if (lang == 'hy') return {'notosansarmenian'}; // Armenian
|
||||||
|
if (lang == 'am' || lang == 'ti')
|
||||||
|
return {'notosansethiopic'}; // Amharic, Tigrinya
|
||||||
|
if (lang == 'mn') return {'notosansmongolian'}; // Mongolian
|
||||||
|
|
||||||
|
// Latin/Cyrillic/Greek based languages - base notosans is sufficient
|
||||||
|
// Includes: English, German, French, Spanish, Italian, Portuguese,
|
||||||
|
// Russian, Ukrainian, Polish, Turkish, Vietnamese, Greek, etc.
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Base font families that are always included regardless of locale.
|
||||||
|
/// These provide core functionality and are relatively small.
|
||||||
|
const _baseFontFamilies = <String>{
|
||||||
|
'notosans', // Base Latin/Cyrillic/Greek/Vietnamese
|
||||||
|
'roboto', // Material Design default font
|
||||||
|
'notosanssymbols', // Common symbols
|
||||||
|
'notosanssymbols2', // Additional symbols
|
||||||
|
'notosansmath', // Math symbols
|
||||||
|
'notomusic', // Music notation symbols
|
||||||
|
// Note: notocoloremoji (~24MB) and notoemoji (~860KB) are excluded
|
||||||
|
// to reduce bundle size. Add them back if emoji support is needed.
|
||||||
|
};
|
||||||
|
|
||||||
|
/// Parse supported locales from Flutter gen-l10n ARB filenames.
|
||||||
|
/// Filenames follow app_<locale>.arb, for example app_zh_CN.arb or app_en.arb.
|
||||||
|
Set<String> _parseSupportedLocales(Directory l10nDirectory) {
|
||||||
|
final locales = <String>{};
|
||||||
|
|
||||||
|
if (!l10nDirectory.existsSync()) {
|
||||||
|
_fail('Localization directory not found: ${l10nDirectory.path}');
|
||||||
|
}
|
||||||
|
|
||||||
|
final arbName = RegExp(r'^app_(.+)\.arb$');
|
||||||
|
for (final entity in l10nDirectory.listSync()) {
|
||||||
|
if (entity is! File) continue;
|
||||||
|
final filename = entity.uri.pathSegments.last;
|
||||||
|
final locale = arbName.firstMatch(filename)?.group(1);
|
||||||
|
if (locale != null && locale.isNotEmpty) locales.add(locale);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (locales.isEmpty) {
|
||||||
|
_fail('No app_<locale>.arb files found in ${l10nDirectory.path}');
|
||||||
|
}
|
||||||
|
|
||||||
|
return locales;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get required font families for the given locales.
|
||||||
|
/// Returns a set of font family names that should be included.
|
||||||
|
/// Automatically detects required fonts based on language code prefix.
|
||||||
|
Set<String> _getRequiredFontFamilies(Set<String> locales) {
|
||||||
|
final families = <String>{..._baseFontFamilies};
|
||||||
|
for (final locale in locales) {
|
||||||
|
final localeFamilies = _getFontFamiliesForLocale(locale);
|
||||||
|
families.addAll(localeFamilies);
|
||||||
|
}
|
||||||
|
return families;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Check if a font file path should be included based on required font families.
|
||||||
|
/// Font paths have the format: "fontfamily/version/filename.ext"
|
||||||
|
/// Example: "notosanssc/v36/xxx.ttf" -> font family is "notosanssc"
|
||||||
|
bool _fontMatchesRequiredFamilies(
|
||||||
|
String fontPath,
|
||||||
|
Set<String> requiredFamilies,
|
||||||
|
) {
|
||||||
|
// Extract font family from path (first segment before '/')
|
||||||
|
final slashIndex = fontPath.indexOf('/');
|
||||||
|
if (slashIndex == -1) {
|
||||||
|
// No slash found, include by default (unusual path format)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
final fontFamily = fontPath.substring(0, slashIndex).toLowerCase();
|
||||||
|
return requiredFamilies.contains(fontFamily);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> main(List<String> args) async {
|
||||||
|
try {
|
||||||
|
// This script is intentionally argument-free for CI convenience.
|
||||||
|
// It assumes it is executed from the Flutter project directory (ui/flutter),
|
||||||
|
// but will also try to locate pubspec.yaml by walking up.
|
||||||
|
final flutterDir = _findFlutterProjectRoot(Directory.current);
|
||||||
|
|
||||||
|
// Parse supported locales from Flutter gen-l10n ARB files.
|
||||||
|
final l10nDirectory = Directory(_join(flutterDir.path, 'lib', 'l10n'));
|
||||||
|
final supportedLocales = _parseSupportedLocales(l10nDirectory);
|
||||||
|
stdout.writeln('Supported locales: ${supportedLocales.join(', ')}');
|
||||||
|
|
||||||
|
// Get required font families based on supported locales
|
||||||
|
final requiredFamilies = _getRequiredFontFamilies(supportedLocales);
|
||||||
|
stdout.writeln('Required font families: ${requiredFamilies.join(', ')}');
|
||||||
|
|
||||||
|
final webDir = Directory(_join(flutterDir.path, 'build', 'web'));
|
||||||
|
if (!webDir.existsSync()) {
|
||||||
|
_fail(
|
||||||
|
'Web build directory not found: ${webDir.path}\n'
|
||||||
|
'Did you run: flutter build web --no-web-resources-cdn ?',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
final mainJs = File(_join(webDir.path, 'main.dart.js'));
|
||||||
|
if (!mainJs.existsSync()) {
|
||||||
|
_fail('main.dart.js not found at: ${mainJs.path}');
|
||||||
|
}
|
||||||
|
|
||||||
|
final gstaticRoot = Directory(_join(webDir.path, 'assets', 'gstatic'));
|
||||||
|
if (!gstaticRoot.existsSync()) gstaticRoot.createSync(recursive: true);
|
||||||
|
|
||||||
|
const gstaticSPrefix = 'https://fonts.gstatic.com/s/';
|
||||||
|
final original = mainJs.readAsStringSync();
|
||||||
|
|
||||||
|
// Relative font asset paths which Flutter's loader typically concatenates with:
|
||||||
|
// https://fonts.gstatic.com/s/
|
||||||
|
// Keep this as a best-effort heuristic to cover the common concatenation pattern.
|
||||||
|
// Some gstatic assets include extra dot segments like: notocoloremoji/v32/Yq6P-KqIXTD0t4D9z1ESnKM3-HpFabsE4tq3luCC7p-aXxcn.0.woff2
|
||||||
|
// Allow dots in the path, while still restricting to font-like extensions.
|
||||||
|
final relAssetRegex = RegExp(
|
||||||
|
r"""["']([a-zA-Z0-9/_\.-]+\.(?:woff2|woff|ttf|otf|eot|svg))["']""",
|
||||||
|
caseSensitive: false,
|
||||||
|
);
|
||||||
|
final relAssetsUnderS = <String>{};
|
||||||
|
for (final m in relAssetRegex.allMatches(original)) {
|
||||||
|
final p = m.group(1);
|
||||||
|
if (p == null || p.isEmpty) continue;
|
||||||
|
if (p.contains('://') || p.startsWith('data:')) continue;
|
||||||
|
if (p.startsWith('/') ||
|
||||||
|
p.startsWith('assets/') ||
|
||||||
|
p.startsWith('packages/'))
|
||||||
|
continue;
|
||||||
|
if (p.contains('..')) continue;
|
||||||
|
relAssetsUnderS.add(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (relAssetsUnderS.isEmpty) {
|
||||||
|
_fail('No fonts.gstatic.com assets found in main.dart.js.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build a download plan: dest relative path (under assets/gstatic/) -> URL.
|
||||||
|
// Filter fonts based on required font families to reduce package size.
|
||||||
|
final downloads = <String, Uri>{};
|
||||||
|
final skippedFonts = <String, Set<String>>{};
|
||||||
|
|
||||||
|
for (final rel in relAssetsUnderS) {
|
||||||
|
if (_fontMatchesRequiredFamilies(rel, requiredFamilies)) {
|
||||||
|
downloads[rel] = Uri.parse('$gstaticSPrefix$rel');
|
||||||
|
} else {
|
||||||
|
// Track skipped fonts and their paths for fallback generation
|
||||||
|
final slashIndex = rel.indexOf('/');
|
||||||
|
final family = slashIndex > 0 ? rel.substring(0, slashIndex) : rel;
|
||||||
|
skippedFonts.putIfAbsent(family, () => <String>{}).add(rel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (skippedFonts.isNotEmpty) {
|
||||||
|
stdout.writeln(
|
||||||
|
'Skipped ${skippedFonts.length} font families not required by supported locales:',
|
||||||
|
);
|
||||||
|
stdout.writeln(' ${skippedFonts.keys.join(', ')}');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (downloads.isNotEmpty) {
|
||||||
|
stdout.writeln(
|
||||||
|
'Found ${downloads.length} fonts.gstatic.com assets to download...',
|
||||||
|
);
|
||||||
|
|
||||||
|
// Reuse a single HttpClient to avoid creating hundreds of short-lived
|
||||||
|
// connections (can be flaky on some environments).
|
||||||
|
final httpClient = HttpClient()
|
||||||
|
..connectionTimeout = const Duration(seconds: 30)
|
||||||
|
..idleTimeout = const Duration(seconds: 30)
|
||||||
|
..maxConnectionsPerHost = 6;
|
||||||
|
try {
|
||||||
|
for (final entry in downloads.entries) {
|
||||||
|
final relPath = entry.key;
|
||||||
|
final url = entry.value;
|
||||||
|
final destPath = relPath.replaceAll('/', Platform.pathSeparator);
|
||||||
|
final dest = File(_join(gstaticRoot.path, destPath));
|
||||||
|
await _downloadIfMissing(httpClient, url, dest);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
httpClient.close(force: true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate empty fallback font files for skipped fonts to prevent infinite loading
|
||||||
|
// Empty files will cause browsers to fail fast instead of retrying indefinitely
|
||||||
|
if (skippedFonts.isNotEmpty) {
|
||||||
|
var fallbackCount = 0;
|
||||||
|
for (final entry in skippedFonts.entries) {
|
||||||
|
for (final relPath in entry.value) {
|
||||||
|
final destPath = relPath.replaceAll('/', Platform.pathSeparator);
|
||||||
|
final dest = File(_join(gstaticRoot.path, destPath));
|
||||||
|
if (!dest.existsSync()) {
|
||||||
|
dest.parent.createSync(recursive: true);
|
||||||
|
// Create an empty file - browsers will recognize it as invalid and skip
|
||||||
|
dest.writeAsBytesSync([]);
|
||||||
|
fallbackCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (fallbackCount > 0) {
|
||||||
|
stdout.writeln(
|
||||||
|
'Generated $fallbackCount empty fallback font files to prevent infinite loading',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rewrite remote prefix so requests become:
|
||||||
|
// <origin>/assets/gstatic/<...>.woff2
|
||||||
|
final replacedGstatic = original.replaceAll(
|
||||||
|
gstaticSPrefix,
|
||||||
|
'assets/gstatic/',
|
||||||
|
);
|
||||||
|
|
||||||
|
if (replacedGstatic == original && downloads.isEmpty) {
|
||||||
|
stdout.writeln(
|
||||||
|
'No changes applied (no fonts.gstatic.com references found).',
|
||||||
|
);
|
||||||
|
exitCode = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mainJs.writeAsStringSync(replacedGstatic);
|
||||||
|
|
||||||
|
stdout.writeln('Patched: ${mainJs.path}');
|
||||||
|
if (downloads.isNotEmpty) {
|
||||||
|
stdout.writeln(
|
||||||
|
' - downloaded ${downloads.length} files into: ${gstaticRoot.path}',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
stdout.writeln(' - fonts.gstatic.com rewritten -> assets/gstatic/');
|
||||||
|
} catch (e, st) {
|
||||||
|
stderr.writeln('ERROR: $e');
|
||||||
|
stderr.writeln(st);
|
||||||
|
exitCode = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _downloadIfMissing(HttpClient client, Uri url, File dest) async {
|
||||||
|
if (dest.existsSync() && dest.lengthSync() > 0) return;
|
||||||
|
|
||||||
|
dest.parent.createSync(recursive: true);
|
||||||
|
|
||||||
|
// Network can be flaky in CI. Retry a few times on transient errors.
|
||||||
|
const maxAttempts = 4;
|
||||||
|
|
||||||
|
for (var attempt = 1; attempt <= maxAttempts; attempt++) {
|
||||||
|
final tmp = File('${dest.path}.tmp');
|
||||||
|
try {
|
||||||
|
try {
|
||||||
|
final req = await client.getUrl(url);
|
||||||
|
|
||||||
|
final resp = await req.close().timeout(const Duration(seconds: 60));
|
||||||
|
if (resp.statusCode != 200) {
|
||||||
|
// 404 is not transient in practice - fail fast with a clear message.
|
||||||
|
if (resp.statusCode == 404) {
|
||||||
|
_fail('Missing gstatic asset (404): $url');
|
||||||
|
}
|
||||||
|
throw HttpException('HTTP ${resp.statusCode}', uri: url);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stream to temp file first, then rename to avoid leaving partial files.
|
||||||
|
if (tmp.existsSync()) tmp.deleteSync();
|
||||||
|
final sink = tmp.openWrite();
|
||||||
|
await resp.pipe(sink).timeout(const Duration(seconds: 120));
|
||||||
|
|
||||||
|
if (!tmp.existsSync() || tmp.lengthSync() == 0) {
|
||||||
|
throw const FormatException('Downloaded asset is empty');
|
||||||
|
}
|
||||||
|
if (dest.existsSync()) dest.deleteSync();
|
||||||
|
tmp.renameSync(dest.path);
|
||||||
|
return;
|
||||||
|
} finally {
|
||||||
|
// no-op: HttpClient lifecycle managed by the caller
|
||||||
|
}
|
||||||
|
} on TimeoutException {
|
||||||
|
if (tmp.existsSync()) tmp.deleteSync();
|
||||||
|
if (attempt == maxAttempts) {
|
||||||
|
_fail('Timeout downloading asset: $url');
|
||||||
|
}
|
||||||
|
} on SocketException catch (e) {
|
||||||
|
if (tmp.existsSync()) tmp.deleteSync();
|
||||||
|
if (attempt == maxAttempts) {
|
||||||
|
_fail('Socket error downloading asset: $url ($e)');
|
||||||
|
}
|
||||||
|
} on HttpException catch (e) {
|
||||||
|
if (tmp.existsSync()) tmp.deleteSync();
|
||||||
|
if (attempt == maxAttempts) {
|
||||||
|
_fail('HTTP error downloading asset: $url ($e)');
|
||||||
|
}
|
||||||
|
} on FileSystemException catch (e) {
|
||||||
|
if (tmp.existsSync()) tmp.deleteSync();
|
||||||
|
_fail('File write error downloading asset: $url ($e)');
|
||||||
|
} catch (e) {
|
||||||
|
if (tmp.existsSync()) tmp.deleteSync();
|
||||||
|
if (attempt == maxAttempts) {
|
||||||
|
_fail('Unexpected error downloading asset: $url ($e)');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Backoff before retrying.
|
||||||
|
final backoffSeconds = 1 << (attempt - 1);
|
||||||
|
stdout.writeln(
|
||||||
|
'Retrying (${attempt + 1}/$maxAttempts) for: $url (wait ${backoffSeconds}s)',
|
||||||
|
);
|
||||||
|
await Future.delayed(Duration(seconds: backoffSeconds));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Directory _findFlutterProjectRoot(Directory start) {
|
||||||
|
var dir = start;
|
||||||
|
for (var i = 0; i < 10; i++) {
|
||||||
|
final pubspec = File(_join(dir.path, 'pubspec.yaml'));
|
||||||
|
if (pubspec.existsSync()) return dir;
|
||||||
|
final parent = dir.parent;
|
||||||
|
if (parent.path == dir.path) break;
|
||||||
|
dir = parent;
|
||||||
|
}
|
||||||
|
// Fallback: use current directory, error messages will explain what is missing.
|
||||||
|
return start;
|
||||||
|
}
|
||||||
|
|
||||||
|
Never _fail(String msg) {
|
||||||
|
throw FormatException(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
String _join(String a, [String? b, String? c, String? d]) {
|
||||||
|
final parts = <String>[
|
||||||
|
a,
|
||||||
|
if (b != null) b,
|
||||||
|
if (c != null) c,
|
||||||
|
if (d != null) d,
|
||||||
|
];
|
||||||
|
return parts.join(Platform.pathSeparator);
|
||||||
|
}
|
||||||
+192
-16
@@ -25,10 +25,11 @@ on:
|
|||||||
- ".github/workflows/test.yml"
|
- ".github/workflows/test.yml"
|
||||||
- "go.mod"
|
- "go.mod"
|
||||||
- "go.sum"
|
- "go.sum"
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
env:
|
env:
|
||||||
GO_VERSION: "1.24"
|
GO_VERSION: "1.26.11"
|
||||||
FLUTTER_VERSION: "3.24.5"
|
FLUTTER_VERSION: "3.41.6"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
# lint:
|
# lint:
|
||||||
@@ -49,14 +50,18 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-go@v4
|
- uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: ${{ env.GO_VERSION }}
|
go-version: ${{ env.GO_VERSION }}
|
||||||
|
- name: Install webview dependencies
|
||||||
|
run: |
|
||||||
|
sudo apt-get update -y
|
||||||
|
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev xvfb
|
||||||
- name: Run Unit tests.
|
- name: Run Unit tests.
|
||||||
run: |
|
run: |
|
||||||
# Get packages for testing and coverage (including cmd/web for flags_test.go)
|
# Get packages for testing and coverage (including cmd/web for flags_test.go)
|
||||||
PACKAGES=$(go list ./... | grep -v /bind/ | grep -v -E '/cmd/(?!web)')
|
PACKAGES=$(go list ./... | awk '!/\/bind\// && (!/\/cmd\// || /\/cmd\/web$/)')
|
||||||
go test -v -coverpkg=$(echo "$PACKAGES" | paste -sd "," -) -covermode=count -coverprofile=coverage.txt $PACKAGES
|
env CGO_ENABLED=1 xvfb-run -a go test -tags webview -v -coverpkg=$(echo "$PACKAGES" | paste -sd "," -) -covermode=count -coverprofile=coverage.txt $PACKAGES
|
||||||
# Filter out main.go from coverage report to avoid lowering coverage percentage
|
# Filter out main.go from coverage report to avoid lowering coverage percentage
|
||||||
grep -v "main.go" coverage.txt > coverage_filtered.txt || true
|
grep -v "main.go" coverage.txt > coverage_filtered.txt || true
|
||||||
mv coverage_filtered.txt coverage.txt
|
mv coverage_filtered.txt coverage.txt
|
||||||
@@ -64,22 +69,192 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
files: ./coverage.txt
|
files: ./coverage.txt
|
||||||
token: ${{ secrets.CODECOV_UPLOAD_TOKEN }}
|
token: ${{ secrets.CODECOV_UPLOAD_TOKEN }}
|
||||||
build-desktop:
|
test-flutter-category:
|
||||||
name: Build desktop check
|
# The settings editor and the backend have to read an extension list the
|
||||||
|
# same way, so both sides run the shared rule table. The Go side is covered
|
||||||
|
# by the test job above, this runs the ui side of it.
|
||||||
|
name: Test shared category rules
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: subosito/flutter-action@v2
|
||||||
|
with:
|
||||||
|
flutter-version: ${{ env.FLUTTER_VERSION }}
|
||||||
|
- name: Run the shared category rule table on the ui side
|
||||||
|
working-directory: ui/flutter
|
||||||
|
run: |
|
||||||
|
flutter pub get
|
||||||
|
flutter gen-l10n
|
||||||
|
flutter test test/api/downloader_config_test.dart
|
||||||
|
test-flutter-task-context-menu:
|
||||||
|
name: Test task context menus and text inputs
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 20
|
||||||
|
env:
|
||||||
|
CHROME_EXECUTABLE: /usr/bin/google-chrome
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: subosito/flutter-action@v2
|
||||||
|
with:
|
||||||
|
flutter-version: ${{ env.FLUTTER_VERSION }}
|
||||||
|
- name: Prepare Flutter tests
|
||||||
|
working-directory: ui/flutter
|
||||||
|
run: |
|
||||||
|
flutter pub get
|
||||||
|
flutter gen-l10n
|
||||||
|
- name: Test task menu actions and native input policy
|
||||||
|
working-directory: ui/flutter
|
||||||
|
run: |
|
||||||
|
flutter test --no-pub test/features/tasks/presentation/widgets/task_context_menu_test.dart test/shared/widgets/app_text_field_test.dart
|
||||||
|
flutter test --no-pub test/widget_test.dart --plain-name 'task context menu exposes'
|
||||||
|
- name: Test browser menu cancellation and input policy
|
||||||
|
working-directory: ui/flutter
|
||||||
|
run: |
|
||||||
|
"$CHROME_EXECUTABLE" --version
|
||||||
|
flutter test --no-pub --platform chrome test/features/tasks/presentation/widgets/task_context_menu_test.dart test/shared/widgets/app_text_field_test.dart
|
||||||
|
test-webview-integration:
|
||||||
|
name: Test webview integration (${{ matrix.name }})
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- name: Windows
|
||||||
|
os: windows-latest
|
||||||
|
- name: Linux
|
||||||
|
os: ubuntu-latest
|
||||||
|
- name: macOS
|
||||||
|
os: macos-latest
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: ${{ env.GO_VERSION }}
|
||||||
|
- uses: subosito/flutter-action@v2
|
||||||
|
if: runner.os == 'macOS'
|
||||||
|
with:
|
||||||
|
flutter-version: ${{ env.FLUTTER_VERSION }}
|
||||||
|
- name: Test Windows FFmpeg memory and stream lifecycle
|
||||||
|
if: runner.os == 'Windows'
|
||||||
|
run: go test -v -count=1 -timeout 180s ./pkg/download/engine/ffmpeg ./pkg/download/engine/inject/stream ./pkg/download/engine
|
||||||
|
- name: Install Linux WebView dependencies
|
||||||
|
if: runner.os == 'Linux'
|
||||||
|
run: |
|
||||||
|
sudo apt-get update -y
|
||||||
|
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev xvfb
|
||||||
|
- name: Test webview
|
||||||
|
if: runner.os == 'Linux'
|
||||||
|
# Match the full suite's coverage instrumentation and repeat on the same
|
||||||
|
# GTK event loop to catch queued callbacks after engine destruction.
|
||||||
|
run: |
|
||||||
|
PACKAGES=$(go list ./... | awk '!/\/bind\// && (!/\/cmd\// || /\/cmd\/web$/)')
|
||||||
|
go test -c -tags webview -coverpkg=$(echo "$PACKAGES" | paste -sd "," -) -covermode=count -o "$RUNNER_TEMP/goprovider.test" ./internal/webview/goprovider
|
||||||
|
xvfb-run -a "$RUNNER_TEMP/goprovider.test" -test.v -test.count=5 -test.timeout=300s -test.coverprofile="$RUNNER_TEMP/webview-coverage.out"
|
||||||
|
env:
|
||||||
|
CGO_ENABLED: 1
|
||||||
|
- name: Test webview
|
||||||
|
if: runner.os == 'Windows'
|
||||||
|
# Repeat close/reopen coverage to catch browser shutdown races.
|
||||||
|
run: go test -tags webview -v -count=3 -timeout 300s ./internal/webview/goprovider/
|
||||||
|
env:
|
||||||
|
CGO_ENABLED: 1
|
||||||
|
- name: Test webview
|
||||||
|
if: runner.os == 'macOS'
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
SOCKET_PATH="$HOME/Library/Application Support/com.gopeed.gopeed/gopeed_webview.sock"
|
||||||
|
LOG_PATH="$RUNNER_TEMP/gopeed-webview-rpc.log"
|
||||||
|
rm -f "$SOCKET_PATH"
|
||||||
|
|
||||||
|
go build -tags nosqlite -ldflags="-w -s" -buildmode=c-shared -o ui/flutter/macos/Frameworks/libgopeed.dylib github.com/GopeedLab/gopeed/bind/desktop
|
||||||
|
|
||||||
|
cd ui/flutter
|
||||||
|
flutter pub get
|
||||||
|
flutter run --machine -d macos >"$LOG_PATH" 2>&1 &
|
||||||
|
FLUTTER_PID=$!
|
||||||
|
cd ../..
|
||||||
|
|
||||||
|
cleanup() {
|
||||||
|
kill "$FLUTTER_PID" >/dev/null 2>&1 || true
|
||||||
|
}
|
||||||
|
trap cleanup EXIT
|
||||||
|
|
||||||
|
FLUTTER_STARTED=false
|
||||||
|
for _ in $(seq 1 600); do
|
||||||
|
if grep -Eq '"event"[[:space:]]*:[[:space:]]*"app\.started"' "$LOG_PATH"; then
|
||||||
|
FLUTTER_STARTED=true
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
if ! kill -0 "$FLUTTER_PID" >/dev/null 2>&1; then
|
||||||
|
echo "Flutter exited before reporting app.started"
|
||||||
|
cat "$LOG_PATH"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
if [[ "$FLUTTER_STARTED" != true ]]; then
|
||||||
|
echo "Timed out waiting for Flutter to report app.started"
|
||||||
|
cat "$LOG_PATH"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! go test -tags webview -v -count=1 -timeout 600s ./internal/webview/rpcprovider/ -args -webview-rpc-network unix -webview-rpc-address "$SOCKET_PATH"; then
|
||||||
|
cat "$LOG_PATH"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
build-desktop:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [windows-2022, macos-latest, ubuntu-22.04, ubuntu-22.04-arm]
|
include:
|
||||||
|
- os: windows-2022
|
||||||
|
- os: windows-11-arm
|
||||||
|
llvm_ver: "20251202" # Only ARM64
|
||||||
|
flutter_channel: "main"
|
||||||
|
flutter_version: "7e1c8868"
|
||||||
|
- os: macos-latest
|
||||||
|
- os: ubuntu-22.04
|
||||||
|
- os: ubuntu-22.04-arm
|
||||||
|
flutter_channel: "main"
|
||||||
|
name: Build desktop check (${{ matrix.os }})
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
needs: [ test ]
|
needs: [ test ]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-go@v4
|
- name: Enable long paths for flutter main branch checks
|
||||||
|
run: |
|
||||||
|
git config --global core.longpaths true
|
||||||
|
- name: Install llvm-mingw-ucrt-aarch64 (ARM64 only)
|
||||||
|
if: matrix.os == 'windows-11-arm'
|
||||||
|
run: |
|
||||||
|
$ver = "${{ matrix.llvm_ver }}"
|
||||||
|
$url = "https://github.com/mstorsjo/llvm-mingw/releases/download/$ver/llvm-mingw-$ver-ucrt-aarch64.zip"
|
||||||
|
$zip = "$env:RUNNER_TEMP\\llvm.zip"
|
||||||
|
$extract = "$env:RUNNER_TEMP\\extract"
|
||||||
|
$target = "C:\\clangarm64"
|
||||||
|
|
||||||
|
curl -L $url -o $zip
|
||||||
|
rm -r -fo $extract,$target -ea Ignore
|
||||||
|
mkdir $extract | Out-Null
|
||||||
|
|
||||||
|
tar -xf $zip -C $extract
|
||||||
|
mv (Get-ChildItem $extract)[0].FullName $target
|
||||||
|
|
||||||
|
$b = "$target\\bin"
|
||||||
|
"CC=$b\\clang.exe" >> $env:GITHUB_ENV
|
||||||
|
"CXX=$b\\clang++.exe" >> $env:GITHUB_ENV
|
||||||
|
"CLANGARM64_BIN=$b" >> $env:GITHUB_ENV
|
||||||
|
"CGO_ENABLED=1" >> $env:GITHUB_ENV
|
||||||
|
"CLANGARM64_ROOT=$target" >> $env:GITHUB_ENV
|
||||||
|
$b >> $env:GITHUB_PATH
|
||||||
|
- uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: ${{ env.GO_VERSION }}
|
go-version: ${{ env.GO_VERSION }}
|
||||||
- uses: subosito/flutter-action@v2
|
- uses: subosito/flutter-action@v2
|
||||||
with:
|
with:
|
||||||
flutter-version: ${{ env.FLUTTER_VERSION }}
|
channel: ${{ matrix.flutter_channel || 'stable' }}
|
||||||
channel: master
|
flutter-version: ${{ matrix.flutter_version || env.FLUTTER_VERSION }}
|
||||||
- if: runner.os == 'Windows'
|
- if: runner.os == 'Windows'
|
||||||
run: |
|
run: |
|
||||||
go build -tags nosqlite -ldflags="-w -s" -buildmode=c-shared -o ui/flutter/windows/libgopeed.dll github.com/GopeedLab/gopeed/bind/desktop
|
go build -tags nosqlite -ldflags="-w -s" -buildmode=c-shared -o ui/flutter/windows/libgopeed.dll github.com/GopeedLab/gopeed/bind/desktop
|
||||||
@@ -93,7 +268,7 @@ jobs:
|
|||||||
- if: runner.os == 'Linux'
|
- if: runner.os == 'Linux'
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get update -y
|
sudo apt-get update -y
|
||||||
sudo apt-get install -y ninja-build libgtk-3-dev libayatana-appindicator3-dev
|
sudo apt-get install -y ninja-build libgtk-3-dev libwebkit2gtk-4.1-dev libayatana-appindicator3-dev libkeybinder-3.0-dev
|
||||||
go build -tags nosqlite -ldflags="-w -s" -buildmode=c-shared -o ui/flutter/linux/bundle/lib/libgopeed.so github.com/GopeedLab/gopeed/bind/desktop
|
go build -tags nosqlite -ldflags="-w -s" -buildmode=c-shared -o ui/flutter/linux/bundle/lib/libgopeed.so github.com/GopeedLab/gopeed/bind/desktop
|
||||||
cd ui/flutter
|
cd ui/flutter
|
||||||
flutter build linux
|
flutter build linux
|
||||||
@@ -102,11 +277,11 @@ jobs:
|
|||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-14, ubuntu-latest]
|
os: [ macos-26, ubuntu-latest ]
|
||||||
needs: [ test ]
|
needs: [ test ]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-go@v4
|
- uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: ${{ env.GO_VERSION }}
|
go-version: ${{ env.GO_VERSION }}
|
||||||
- uses: subosito/flutter-action@v2
|
- uses: subosito/flutter-action@v2
|
||||||
@@ -138,7 +313,7 @@ jobs:
|
|||||||
needs: [ test ]
|
needs: [ test ]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-go@v4
|
- uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: ${{ env.GO_VERSION }}
|
go-version: ${{ env.GO_VERSION }}
|
||||||
- uses: subosito/flutter-action@v2
|
- uses: subosito/flutter-action@v2
|
||||||
@@ -148,6 +323,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
cd ui/flutter
|
cd ui/flutter
|
||||||
flutter build web --no-web-resources-cdn
|
flutter build web --no-web-resources-cdn
|
||||||
|
dart ../../.github/workflows/scripts/flutter_local_font.dart
|
||||||
cd ../../
|
cd ../../
|
||||||
rm -rf cmd/web/dist
|
rm -rf cmd/web/dist
|
||||||
cp -r ui/flutter/build/web cmd/web/dist
|
cp -r ui/flutter/build/web cmd/web/dist
|
||||||
@@ -158,7 +334,7 @@ jobs:
|
|||||||
needs: [ test ]
|
needs: [ test ]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-go@v4
|
- uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: ${{ env.GO_VERSION }}
|
go-version: ${{ env.GO_VERSION }}
|
||||||
- uses: subosito/flutter-action@v2
|
- uses: subosito/flutter-action@v2
|
||||||
|
|||||||
+53
-4
@@ -17,11 +17,60 @@ start the front-end flutter project in `debug` mode to run.
|
|||||||
|
|
||||||
## Translation
|
## Translation
|
||||||
|
|
||||||
The internationalization files of Gopeed are located in the `ui/flutter/lib/i18n/langs` directory.
|
Flutter translations are ARB files in `ui/flutter/lib/l10n`. Use `app_en.arb` as the source template,
|
||||||
You only need to add the corresponding language file in this directory.
|
then edit or add `app_<locale>.arb` (for example, `app_de.arb` or `app_zh_TW.arb`). Every locale must
|
||||||
|
contain the same message keys as the English template.
|
||||||
|
|
||||||
Please refer to `en_us.dart` for translation.
|
Translate message values only, and do not rename variables inside braces such as `{count}` and `{name}`.
|
||||||
words prefixed with `@` are not meant to be translated.
|
Do not translate metadata keys prefixed with `@`. Submit only the ARB source files you changed; do not generate or commit
|
||||||
|
`app_localizations*.dart`. The pull-request CI automatically validates the catalogs, generates the
|
||||||
|
localization code, and checks its integration.
|
||||||
|
|
||||||
|
The following examples show both the ARB definition and the text users see after the app supplies values.
|
||||||
|
|
||||||
|
1. Insert a variable into a message
|
||||||
|
|
||||||
|
ARB definition:
|
||||||
|
|
||||||
|
```json
|
||||||
|
"welcomeUser": "Hola, {name}"
|
||||||
|
```
|
||||||
|
|
||||||
|
Rendered result: when `name = Ana`, users see “Hola, Ana”. You may reorder the sentence, but keep `{name}`.
|
||||||
|
|
||||||
|
2. Display different text for different quantities
|
||||||
|
|
||||||
|
ARB definition:
|
||||||
|
|
||||||
|
```json
|
||||||
|
"fileCount": "{count, plural, =0{No hay archivos} =1{1 archivo} other{{count} archivos}}"
|
||||||
|
```
|
||||||
|
|
||||||
|
Rendered results:
|
||||||
|
|
||||||
|
- `count = 0` → “No hay archivos”
|
||||||
|
- `count = 1` → “1 archivo”
|
||||||
|
- `count = 3` → “3 archivos”
|
||||||
|
|
||||||
|
`=0`, `=1`, and `other` mean zero, one, and every other quantity. Translate only the user-visible text
|
||||||
|
inside each branch.
|
||||||
|
|
||||||
|
3. Display different text for different values
|
||||||
|
|
||||||
|
ARB definition:
|
||||||
|
|
||||||
|
```json
|
||||||
|
"taskState": "{state, select, running{En curso} paused{En pausa} other{Desconocido}}"
|
||||||
|
```
|
||||||
|
|
||||||
|
Rendered results:
|
||||||
|
|
||||||
|
- `state = running` → “En curso”
|
||||||
|
- `state = paused` → “En pausa”
|
||||||
|
- Any other value → “Desconocido”
|
||||||
|
|
||||||
|
`running`, `paused`, and `other` are values supplied by the app. Do not translate them; translate only
|
||||||
|
the display text inside the following braces.
|
||||||
|
|
||||||
## flutter development
|
## flutter development
|
||||||
|
|
||||||
|
|||||||
+51
-3
@@ -17,10 +17,58 @@
|
|||||||
|
|
||||||
## 翻訳
|
## 翻訳
|
||||||
|
|
||||||
Gopeed の国際化ファイルは `ui/flutter/lib/i18n/langs` ディレクトリにあります。
|
Flutter の翻訳ファイルは `ui/flutter/lib/l10n` にあります。`app_en.arb` を原文テンプレートとして、
|
||||||
このディレクトリに対応する言語ファイルを追加するだけでよいです。
|
`app_<locale>.arb`(例: `app_de.arb`、`app_zh_TW.arb`)を編集または追加してください。すべての言語で
|
||||||
|
英語テンプレートと同じメッセージ key が必要です。
|
||||||
|
|
||||||
翻訳については `en_us.dart` を参照してください。
|
翻訳するのはメッセージ値だけです。`{count}` や `{name}` など、中括弧内の変数名は変更しないでください。
|
||||||
|
`@` で始まるメタデータ key は翻訳しません。変更した ARB ソースファイルだけをコミットし、
|
||||||
|
`app_localizations*.dart` は生成もコミットも不要です。PR の CI が全言語を検証し、国際化コードを生成して
|
||||||
|
統合結果を確認します。
|
||||||
|
|
||||||
|
以下の例では、ARB に記述する定義と、アプリが値を渡した後にユーザーが実際に見る表示を示します。
|
||||||
|
|
||||||
|
1. メッセージに変数を挿入する
|
||||||
|
|
||||||
|
ARB 定義:
|
||||||
|
|
||||||
|
```json
|
||||||
|
"welcomeUser": "こんにちは、{name}"
|
||||||
|
```
|
||||||
|
|
||||||
|
最終表示:`name = 太郎` の場合は「こんにちは、太郎」と表示されます。語順は変更できますが、`{name}` は残します。
|
||||||
|
|
||||||
|
2. 数量に応じて表示を切り替える
|
||||||
|
|
||||||
|
ARB 定義:
|
||||||
|
|
||||||
|
```json
|
||||||
|
"fileCount": "{count, plural, =0{ファイルなし} =1{1 個のファイル} other{{count} 個のファイル}}"
|
||||||
|
```
|
||||||
|
|
||||||
|
最終表示:
|
||||||
|
|
||||||
|
- `count = 0` →「ファイルなし」
|
||||||
|
- `count = 1` →「1 個のファイル」
|
||||||
|
- `count = 3` →「3 個のファイル」
|
||||||
|
|
||||||
|
`=0`、`=1`、`other` はそれぞれ 0、1、その他の数量を表します。各分岐の中で画面に表示される文字だけを翻訳します。
|
||||||
|
|
||||||
|
3. 変数の値に応じて表示を切り替える
|
||||||
|
|
||||||
|
ARB 定義:
|
||||||
|
|
||||||
|
```json
|
||||||
|
"taskState": "{state, select, running{実行中} paused{一時停止} other{不明}}"
|
||||||
|
```
|
||||||
|
|
||||||
|
最終表示:
|
||||||
|
|
||||||
|
- `state = running` →「実行中」
|
||||||
|
- `state = paused` →「一時停止」
|
||||||
|
- その他の値 →「不明」
|
||||||
|
|
||||||
|
`running`、`paused`、`other` はアプリが渡す分岐値なので翻訳せず、その後の中括弧内にある表示文字だけを翻訳します。
|
||||||
|
|
||||||
## flutter での開発
|
## flutter での開発
|
||||||
|
|
||||||
|
|||||||
+53
-3
@@ -17,10 +17,60 @@ khởi động dự án flutter frontend trong chế độ `debug` để chạy.
|
|||||||
|
|
||||||
## Dịch thuật
|
## Dịch thuật
|
||||||
|
|
||||||
Các tệp quốc tế hóa của Gopeed được đặt trong thư mục `ui/flutter/lib/i18n/langs`.
|
Các bản dịch Flutter là tệp ARB trong `ui/flutter/lib/l10n`. Hãy dùng `app_en.arb` làm mẫu nguồn,
|
||||||
Bạn chỉ cần thêm tệp ngôn ngữ tương ứng trong thư mục này.
|
sau đó sửa hoặc thêm `app_<locale>.arb` (ví dụ `app_de.arb` hoặc `app_zh_TW.arb`). Mỗi ngôn ngữ phải
|
||||||
|
có cùng các khóa thông điệp như mẫu tiếng Anh.
|
||||||
|
|
||||||
Vui lòng tham khảo `en_us.dart` để biết cách dịch thuật.
|
Chỉ dịch giá trị thông điệp; không đổi tên biến trong dấu ngoặc nhọn như `{count}` và `{name}`. Không dịch khóa
|
||||||
|
siêu dữ liệu bắt đầu bằng `@`. Chỉ commit các tệp nguồn ARB đã thay đổi; không cần tạo hoặc commit
|
||||||
|
`app_localizations*.dart`. CI của pull request sẽ tự động
|
||||||
|
kiểm tra tất cả ngôn ngữ, tạo mã bản địa hóa và xác minh việc tích hợp.
|
||||||
|
|
||||||
|
Các ví dụ sau hiển thị cả định nghĩa trong ARB và nội dung người dùng thực sự thấy sau khi ứng dụng truyền giá trị.
|
||||||
|
|
||||||
|
1. Chèn biến vào thông điệp
|
||||||
|
|
||||||
|
Định nghĩa ARB:
|
||||||
|
|
||||||
|
```json
|
||||||
|
"welcomeUser": "Xin chào, {name}"
|
||||||
|
```
|
||||||
|
|
||||||
|
Kết quả hiển thị: khi `name = An`, người dùng thấy “Xin chào, An”. Có thể đổi trật tự câu nhưng phải giữ `{name}`.
|
||||||
|
|
||||||
|
2. Hiển thị nội dung khác nhau theo số lượng
|
||||||
|
|
||||||
|
Định nghĩa ARB:
|
||||||
|
|
||||||
|
```json
|
||||||
|
"fileCount": "{count, plural, =0{Không có tệp} =1{1 tệp} other{{count} tệp}}"
|
||||||
|
```
|
||||||
|
|
||||||
|
Kết quả hiển thị:
|
||||||
|
|
||||||
|
- `count = 0` → “Không có tệp”
|
||||||
|
- `count = 1` → “1 tệp”
|
||||||
|
- `count = 3` → “3 tệp”
|
||||||
|
|
||||||
|
`=0`, `=1` và `other` lần lượt biểu thị số lượng bằng 0, bằng 1 và các số lượng còn lại. Chỉ dịch phần chữ
|
||||||
|
hiển thị cho người dùng bên trong mỗi nhánh.
|
||||||
|
|
||||||
|
3. Hiển thị nội dung khác nhau theo giá trị biến
|
||||||
|
|
||||||
|
Định nghĩa ARB:
|
||||||
|
|
||||||
|
```json
|
||||||
|
"taskState": "{state, select, running{Đang chạy} paused{Đã tạm dừng} other{Không xác định}}"
|
||||||
|
```
|
||||||
|
|
||||||
|
Kết quả hiển thị:
|
||||||
|
|
||||||
|
- `state = running` → “Đang chạy”
|
||||||
|
- `state = paused` → “Đã tạm dừng”
|
||||||
|
- Giá trị khác → “Không xác định”
|
||||||
|
|
||||||
|
`running`, `paused` và `other` là các giá trị do ứng dụng truyền vào nên không được dịch; chỉ dịch phần chữ
|
||||||
|
hiển thị trong dấu ngoặc theo sau chúng.
|
||||||
|
|
||||||
## Phát triển flutter
|
## Phát triển flutter
|
||||||
|
|
||||||
|
|||||||
+49
-3
@@ -14,9 +14,56 @@ flutter 项目即可运行。
|
|||||||
|
|
||||||
## 翻译
|
## 翻译
|
||||||
|
|
||||||
Gopeed 的国际化文件位于 `ui/flutter/lib/i18n/langs` 目录下,只需要在该目录下添加对应的语言文件即可。
|
Flutter 国际化文件位于 `ui/flutter/lib/l10n`,请以 `app_en.arb` 为源模板,修改或新增
|
||||||
|
`app_<locale>.arb`(例如 `app_de.arb` 或 `app_zh_TW.arb`)。每个语种必须与英文模板包含相同的文案 key。
|
||||||
|
|
||||||
请注意以 `en_us.dart` 为参照进行翻译。
|
只翻译文案值,不要修改 `{count}`、`{name}` 等花括号中的变量名。以 `@` 开头的元数据 key 不需要翻译。
|
||||||
|
提交时只包含修改过的 ARB 源文件,不需要生成或提交 `app_localizations*.dart`。PR 的 CI 会自动校验所有语种、
|
||||||
|
生成国际化代码并检查集成结果。
|
||||||
|
|
||||||
|
下面的例子同时给出 ARB 中填写的文案定义,以及程序传值后用户最终看到的内容。
|
||||||
|
|
||||||
|
1. 在文案中插入变量
|
||||||
|
|
||||||
|
ARB 定义:
|
||||||
|
|
||||||
|
```json
|
||||||
|
"welcomeUser": "你好,{name}"
|
||||||
|
```
|
||||||
|
|
||||||
|
最终显示:当 `name = 小明` 时,显示“你好,小明”。翻译时可以调整整句话,但必须保留 `{name}`。
|
||||||
|
|
||||||
|
2. 根据数量显示不同文案
|
||||||
|
|
||||||
|
ARB 定义:
|
||||||
|
|
||||||
|
```json
|
||||||
|
"fileCount": "{count, plural, =0{没有文件} =1{1 个文件} other{{count} 个文件}}"
|
||||||
|
```
|
||||||
|
|
||||||
|
最终显示:
|
||||||
|
|
||||||
|
- `count = 0` → “没有文件”
|
||||||
|
- `count = 1` → “1 个文件”
|
||||||
|
- `count = 3` → “3 个文件”
|
||||||
|
|
||||||
|
`=0`、`=1`、`other` 分别表示数量为 0、数量为 1 和其他数量。只翻译每个分支花括号内显示给用户的文字。
|
||||||
|
|
||||||
|
3. 根据变量值显示不同文案
|
||||||
|
|
||||||
|
ARB 定义:
|
||||||
|
|
||||||
|
```json
|
||||||
|
"taskState": "{state, select, running{运行中} paused{已暂停} other{未知状态}}"
|
||||||
|
```
|
||||||
|
|
||||||
|
最终显示:
|
||||||
|
|
||||||
|
- `state = running` → “运行中”
|
||||||
|
- `state = paused` → “已暂停”
|
||||||
|
- 其他值 → “未知状态”
|
||||||
|
|
||||||
|
`running`、`paused`、`other` 是程序传入的分支值,不能翻译;只翻译它们后面花括号内的显示文字。
|
||||||
|
|
||||||
## flutter开发
|
## flutter开发
|
||||||
|
|
||||||
@@ -27,4 +74,3 @@ Gopeed 的国际化文件位于 `ui/flutter/lib/i18n/langs` 目录下,只需
|
|||||||
```
|
```
|
||||||
flutter pub run build_runner watch
|
flutter pub run build_runner watch
|
||||||
```
|
```
|
||||||
|
|
||||||
+48
-2
@@ -12,10 +12,56 @@
|
|||||||
|
|
||||||
## 翻譯
|
## 翻譯
|
||||||
|
|
||||||
Gopeed 的翻譯文件位於 `ui/flutter/lib/i18n/langs` 目錄中,只需要修改或新建翻譯文件即可。
|
Flutter 翻譯檔位於 `ui/flutter/lib/l10n`,請以 `app_en.arb` 為來源範本,修改或新增
|
||||||
|
`app_<locale>.arb`(例如 `app_de.arb` 或 `app_zh_TW.arb`)。每個語言都必須與英文範本包含相同的訊息 key。
|
||||||
|
|
||||||
|
只翻譯訊息值,不要修改 `{count}`、`{name}` 等大括號中的變數名稱。以 `@` 開頭的中繼資料 key 不需要翻譯。
|
||||||
|
提交時只需包含修改過的 ARB 來源檔,不需要產生或提交 `app_localizations*.dart`。PR 的 CI
|
||||||
|
會自動驗證所有語言、產生國際化程式碼並檢查整合結果。
|
||||||
|
|
||||||
請以 `en_us.dart` 作為參照。
|
以下範例同時列出 ARB 中填寫的訊息定義,以及程式傳值後使用者最終看到的內容。
|
||||||
|
|
||||||
|
1. 在訊息中插入變數
|
||||||
|
|
||||||
|
ARB 定義:
|
||||||
|
|
||||||
|
```json
|
||||||
|
"welcomeUser": "你好,{name}"
|
||||||
|
```
|
||||||
|
|
||||||
|
最終顯示:當 `name = 小明` 時,顯示「你好,小明」。翻譯時可以調整整句話,但必須保留 `{name}`。
|
||||||
|
|
||||||
|
2. 依數量顯示不同訊息
|
||||||
|
|
||||||
|
ARB 定義:
|
||||||
|
|
||||||
|
```json
|
||||||
|
"fileCount": "{count, plural, =0{沒有檔案} =1{1 個檔案} other{{count} 個檔案}}"
|
||||||
|
```
|
||||||
|
|
||||||
|
最終顯示:
|
||||||
|
|
||||||
|
- `count = 0` →「沒有檔案」
|
||||||
|
- `count = 1` →「1 個檔案」
|
||||||
|
- `count = 3` →「3 個檔案」
|
||||||
|
|
||||||
|
`=0`、`=1`、`other` 分別代表數量為 0、數量為 1 和其他數量。只翻譯各分支大括號內顯示給使用者的文字。
|
||||||
|
|
||||||
|
3. 依變數值顯示不同訊息
|
||||||
|
|
||||||
|
ARB 定義:
|
||||||
|
|
||||||
|
```json
|
||||||
|
"taskState": "{state, select, running{執行中} paused{已暫停} other{未知狀態}}"
|
||||||
|
```
|
||||||
|
|
||||||
|
最終顯示:
|
||||||
|
|
||||||
|
- `state = running` →「執行中」
|
||||||
|
- `state = paused` →「已暫停」
|
||||||
|
- 其他值 →「未知狀態」
|
||||||
|
|
||||||
|
`running`、`paused`、`other` 是程式傳入的分支值,不能翻譯;只翻譯其後大括號內的顯示文字。
|
||||||
|
|
||||||
## flutter開發
|
## flutter開發
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
FROM golang:1.23.3 AS go
|
FROM golang:1.26.11-alpine3.23 AS go
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY ./go.mod ./go.sum ./
|
COPY ./go.mod ./go.sum ./
|
||||||
RUN go mod download
|
RUN go mod download
|
||||||
@@ -8,7 +8,7 @@ RUN CGO_ENABLED=0 go build -tags nosqlite,web \
|
|||||||
-ldflags="-s -w -X github.com/GopeedLab/gopeed/pkg/base.Version=$VERSION -X github.com/GopeedLab/gopeed/pkg/base.InDocker=true" \
|
-ldflags="-s -w -X github.com/GopeedLab/gopeed/pkg/base.Version=$VERSION -X github.com/GopeedLab/gopeed/pkg/base.InDocker=true" \
|
||||||
-o dist/gopeed github.com/GopeedLab/gopeed/cmd/web
|
-o dist/gopeed github.com/GopeedLab/gopeed/cmd/web
|
||||||
|
|
||||||
FROM alpine:3.18
|
FROM alpine:3.23
|
||||||
LABEL maintainer="monkeyWie"
|
LABEL maintainer="monkeyWie"
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY --from=go /app/dist/gopeed ./
|
COPY --from=go /app/dist/gopeed ./
|
||||||
|
|||||||
@@ -1,167 +1,80 @@
|
|||||||
# [](https://gopeed.com)
|
# [](https://gopeed.com)
|
||||||
|
|
||||||
[](https://github.com/GopeedLab/gopeed/actions?query=workflow%3Atest)
|
[](https://github.com/GopeedLab/gopeed/actions?query=workflow%3Atest)
|
||||||
[](https://codecov.io/gh/GopeedLab/gopeed)
|
[](https://codecov.io/gh/GopeedLab/gopeed)
|
||||||
[](https://github.com/GopeedLab/gopeed/releases)
|
[](https://github.com/GopeedLab/gopeed/releases)
|
||||||
[](https://github.com/GopeedLab/gopeed/releases)
|
[](https://github.com/GopeedLab/gopeed/releases)
|
||||||
[](https://docs.gopeed.com/donate.html)
|
[](https://gopeed.com/docs/donate)
|
||||||
[](https://raw.githubusercontent.com/GopeedLab/gopeed/main/_docs/img/weixin.png)
|
[](https://raw.githubusercontent.com/GopeedLab/gopeed/main/_docs/img/weixin.png)
|
||||||
[](https://discord.gg/ZUJqJrwCGB)
|
[](https://discord.gg/ZUJqJrwCGB)
|
||||||
|
|
||||||
<a href="https://trendshift.io/repositories/7953" target="_blank"><img src="https://trendshift.io/api/badge/repositories/7953" alt="GopeedLab%2Fgopeed | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
|
<a href="https://trendshift.io/repositories/7953" target="_blank"><img src="https://trendshift.io/api/badge/repositories/7953" alt="GopeedLab%2Fgopeed | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
|
||||||
|
|
||||||
[](https://ko-fi.com/R6R6IJGN6)
|
|
||||||
|
|
||||||
[English](/README.md) | [中文](/README_zh-CN.md) | [日本語](/README_ja-JP.md) | [正體中文](/README_zh-TW.md) | [Tiếng Việt](/README_vi-VN.md)
|
[English](/README.md) | [中文](/README_zh-CN.md) | [日本語](/README_ja-JP.md) | [正體中文](/README_zh-TW.md) | [Tiếng Việt](/README_vi-VN.md)
|
||||||
|
|
||||||
## 🚀 Introduction
|
## 🚀 Introduction
|
||||||
|
|
||||||
Gopeed (full name Go Speed), a high-speed downloader developed by `Golang` + `Flutter`, supports (HTTP, BitTorrent, Magnet) protocol, and supports all platforms. In addition to basic download functions, Gopeed is also a highly customizable downloader that supports implementing more features through integration with [APIs](https://docs.gopeed.com/dev-api.html) or installation and development of [extensions](https://docs.gopeed.com/dev-extension.html).
|
Gopeed (short for **Go Speed**) is a fast, modern, free, and open-source download manager built with Go and Flutter. It supports HTTP, HTTPS, BitTorrent, magnet links, and ed2k on desktop, mobile, and the web.
|
||||||
|
|
||||||
Visit ✈ [Official Website](https://gopeed.com) | 📖 [Official Docs](https://docs.gopeed.com)
|
Beyond core download management, Gopeed offers browser integration, JavaScript extensions, a REST API, a CLI, and a self-hosted web UI for customization and automation.
|
||||||
|
|
||||||
|
Visit ✈ [Official Website](https://gopeed.com)
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## ✨ Features
|
||||||
|
|
||||||
|
- ⚡ **High-speed downloads** — combine concurrent tasks, multi-connection HTTP transfers, and peer-to-peer BitTorrent downloads to make the most of your bandwidth.
|
||||||
|
- 🧲 **Multiple protocols** — download HTTP/HTTPS files, torrents, magnet links, and ed2k resources from a single app.
|
||||||
|
- 🌱 **Full-featured BitTorrent** — use DHT peer discovery, uTP transport, Web Seeds, selective file downloads, tracker management, peer and piece statistics, and ratio- or time-based seeding limits.
|
||||||
|
- 📋 **Flexible task management** — pause, resume, retry, run batch operations, search, filter by status, organize with categories, and recover tasks after a restart.
|
||||||
|
- 🪶 **Lightweight native experience** — the main interface is rendered natively with Flutter. No Electron. No WebView shell. Enjoy a smaller footprint, lower overhead, and responsive performance.
|
||||||
|
- 💻 **Cross-platform** — available for Windows, macOS, Linux, Android, iOS, and the web, with Docker and QNAP deployment options.
|
||||||
|
- 🎨 **Customizable appearance** — follow your system theme or choose light or dark mode, with eight accent colors.
|
||||||
|
- 📐 **Responsive interface** — task lists, navigation, settings, and detail views adapt to phones, tablets, and resizable desktop windows.
|
||||||
|
- 🗣️ **Available in 20+ languages** — including English, Simplified and Traditional Chinese, Japanese, Korean, and many more.
|
||||||
|
- 🌐 **Browser integration** — send downloads from Chrome, Edge, Firefox, and other compatible browsers directly to Gopeed.
|
||||||
|
- 🧩 **JavaScript extensions** — add support for video platforms, AI model hubs, cloud storage services, and other download sources.
|
||||||
|
- 🤖 **AI integration** — use Gopeed's MCP endpoint to connect compatible AI agents and create, inspect, or manage downloads with natural language.
|
||||||
|
- 🔌 **Automation-ready** — integrate with Gopeed through its REST API, CLI, authenticated web UI, webhooks, and post-download scripts.
|
||||||
|
- 🛠️ **Built-in essentials** — customize headers and the User-Agent, use proxies and GitHub mirrors, receive notifications, and extract archives automatically.
|
||||||
|
|
||||||
|
## 🤖 AI Integration
|
||||||
|
|
||||||
|
Connect Gopeed to an AI agent and manage downloads with natural language. For example, you can say:
|
||||||
|
|
||||||
|
> Download the latest Gopeed client for Windows.
|
||||||
|
|
||||||
|
| Tool | Description |
|
||||||
|
| --- | --- |
|
||||||
|
| `resolve_task` | Resolve a download URL or URI and return its resource metadata and files before creating a task. |
|
||||||
|
| `create_task` | Create and start a task from a resolved resource ID or a direct download request. |
|
||||||
|
| `list_tasks` | List tasks, optionally filtering them by ID or status. |
|
||||||
|
| `get_task` | Get the request, resource, options, and current progress for one task. |
|
||||||
|
| `get_task_status` | Get lightweight runtime status and per-file progress for one task. |
|
||||||
|
| `get_task_stats` | Get protocol-specific statistics, including HTTP connections or BitTorrent peers and seeding data. |
|
||||||
|
| `pause_task` | Pause a task. |
|
||||||
|
| `continue_task` | Continue a paused or failed task. |
|
||||||
|
| `delete_task` | Delete a task, optionally deleting its downloaded files. |
|
||||||
|
|
||||||
## ⬇️ Download
|
## ⬇️ Download
|
||||||
|
|
||||||
<table>
|
### 🧪 Gopeed 2.0.0 Beta
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td rowspan="2">🪟 Windows</td>
|
|
||||||
<td><code>EXE</code></td>
|
|
||||||
<td>amd64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-windows-amd64.zip">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><code>Portable</code></td>
|
|
||||||
<td>amd64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-windows-amd64-portable.zip">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td rowspan="3">🍎 MacOS</td>
|
|
||||||
<td rowspan="3"><code>DMG</code></td>
|
|
||||||
<td>universal</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-macos.dmg">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>amd64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-macos-amd64.dmg">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>arm64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-macos-arm64.dmg">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td rowspan="6">🐧 Linux</td>
|
|
||||||
<td><code>Flathub</code></td>
|
|
||||||
<td>amd64</td>
|
|
||||||
<td><a href="https://flathub.org/apps/com.gopeed.Gopeed">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><code>SNAP</code></td>
|
|
||||||
<td>amd64</td>
|
|
||||||
<td><a href="https://snapcraft.io/gopeed">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td rowspan="2"><code>DEB</code></td>
|
|
||||||
<td>amd64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-linux-amd64.deb">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>arm64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-linux-arm64.deb">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td rowspan="2"><code>AppImage</code></td>
|
|
||||||
<td>amd64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-linux-amd64.AppImage">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>arm64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-linux-arm64.AppImage">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td rowspan="4">🤖 Android</td>
|
|
||||||
<td rowspan="4"><code>APK</code></td>
|
|
||||||
<td>universal</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-android.apk">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>armeabi-v7a</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-android-armeabi-v7a.apk">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>arm64-v8a</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-android-arm64-v8a.apk">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>x86_64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-android-x86_64.apk">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>📱 iOS</td>
|
|
||||||
<td><code>IPA</code></td>
|
|
||||||
<td>universal</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-ios.ipa">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>🐳 Docker</td>
|
|
||||||
<td>-</td>
|
|
||||||
<td>universal</td>
|
|
||||||
<td><a href="https://hub.docker.com/r/liwei2633/gopeed">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td rowspan="2">💾 Qnap</td>
|
|
||||||
<td rowspan="2"><code>QPKG</code></td>
|
|
||||||
<td>amd64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=gopeed-$version-qnap-amd64.qpkg">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>arm64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=gopeed-$version-qnap-arm64.qpkg">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td rowspan="8">🌐 Web</td>
|
|
||||||
<td rowspan="3"><code>Windows</code></td>
|
|
||||||
<td>amd64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=gopeed-web-$version-windows-amd64.zip">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>arm64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=gopeed-web-$version-windows-arm64.zip">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>386</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=gopeed-web-$version-windows-386.zip">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td rowspan="2"><code>MacOS</code></td>
|
|
||||||
<td>amd64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=gopeed-web-$version-macos-amd64.zip">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>arm64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=gopeed-web-$version-macos-arm64.zip">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td rowspan="3"><code>Linux</code></td>
|
|
||||||
<td>amd64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=gopeed-web-$version-linux-amd64.zip">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>arm64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=gopeed-web-$version-linux-arm64.zip">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>386</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=gopeed-web-$version-linux-386.zip">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
More about installation, please refer to [Installation](https://docs.gopeed.com/install.html)
|
Gopeed 2.0.0 is currently in public beta, introducing a redesigned interface, a native communication architecture that connects desktop and mobile clients directly to the Go core through FFI, a more consistent cross-platform experience, improved task management, more flexible API support, and MCP-based AI agent integration. Some features may still be incomplete or unstable, so please try it and report any issues you encounter.
|
||||||
|
|
||||||
### 🛠️ Command tool
|
- [Download Gopeed 2.0.0 Beta 3](https://github.com/GopeedLab/gopeed/releases/tag/v2.0.0-beta.3)
|
||||||
|
|
||||||
use `go install`:
|
Once the features and stability meet our release standards, we will publish the official Gopeed 2.0.0 release. Beta users will be able to upgrade directly to the final release, while existing stable users will not be automatically moved onto the beta channel.
|
||||||
|
|
||||||
|
### Stable release
|
||||||
|
|
||||||
|
- [Official Download](https://gopeed.com)
|
||||||
|
- [GitHub Releases](https://github.com/GopeedLab/gopeed/releases/latest)
|
||||||
|
|
||||||
|
### 🛠️ Command-line tool
|
||||||
|
|
||||||
|
Install the CLI with `go install`:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
go install github.com/GopeedLab/gopeed/cmd/gopeed@latest
|
go install github.com/GopeedLab/gopeed/cmd/gopeed@latest
|
||||||
@@ -169,32 +82,28 @@ go install github.com/GopeedLab/gopeed/cmd/gopeed@latest
|
|||||||
|
|
||||||
## 🔌 Browser Extension
|
## 🔌 Browser Extension
|
||||||
|
|
||||||
Gopeed also provides a browser extension to take over browser downloads, supporting browsers such as Chrome, Edge, Firefox, etc., please refer to: [https://github.com/GopeedLab/browser-extension](https://github.com/GopeedLab/browser-extension)
|
Use the Gopeed browser extension to send downloads from Chrome, Edge, Firefox, and other compatible browsers directly to Gopeed: [GopeedLab/browser-extension](https://github.com/GopeedLab/browser-extension)
|
||||||
|
|
||||||
## 📱 WeChat Official Account
|
## 📱 WeChat Official Account
|
||||||
|
|
||||||
Follow our WeChat Official Account to get the latest updates and news.
|
Follow Gopeed's official WeChat account for updates and news.
|
||||||
|
|
||||||
<img src="_docs/img/weixin.png" width="200" />
|
<img src="_docs/img/weixin.png" width="200" />
|
||||||
|
|
||||||
## 💝 Donate
|
## 💝 Donate
|
||||||
|
|
||||||
If you like this project, please consider [donating](https://docs.gopeed.com/donate.html) to support the development of this project, thank you!
|
If Gopeed is useful to you, please consider [supporting its development](https://gopeed.com/docs/donate). Thank you!
|
||||||
|
|
||||||
## 🖼️ Showcase
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## 👨💻 Development
|
## 👨💻 Development
|
||||||
|
|
||||||
This project is divided into two parts, the front end uses `flutter`, the back end uses `Golang`, and the two sides communicate through the `http` protocol. On the unix system, `unix socket` is used, and on the windows system, `tcp` protocol is used.
|
Gopeed consists of a Flutter front end and a Go back end. They communicate over HTTP, using Unix sockets on Unix-like systems and TCP on Windows.
|
||||||
|
|
||||||
> The front code is located in the `ui/flutter` directory.
|
> The front-end source is located in the `ui/flutter` directory.
|
||||||
|
|
||||||
### 🌍 Environment
|
### 🌍 Environment
|
||||||
|
|
||||||
1. Golang 1.23+
|
1. Go 1.25+
|
||||||
2. Flutter 3.24+
|
2. Flutter 3.41+
|
||||||
|
|
||||||
### 📋 Clone
|
### 📋 Clone
|
||||||
|
|
||||||
@@ -204,17 +113,17 @@ git clone [email protected]:GopeedLab/gopeed.git
|
|||||||
|
|
||||||
### 🤝 Contributing
|
### 🤝 Contributing
|
||||||
|
|
||||||
Please refer to [CONTRIBUTING.md](/CONTRIBUTING.md)
|
See [CONTRIBUTING.md](/CONTRIBUTING.md).
|
||||||
|
|
||||||
### 🏗️ Build
|
### 🏗️ Build
|
||||||
|
|
||||||
#### Desktop
|
#### Desktop
|
||||||
|
|
||||||
First, you need to configure the environment according to the official [Flutter desktop website documention](https://docs.flutter.dev/development/platform-integration/desktop), then you will need to ensure the cgo environment is set up accordingly. For detailed instructions on setting up the cgo environment, please refer to relevant resources available online.
|
Set up Flutter desktop development using the official [Flutter desktop guide](https://docs.flutter.dev/development/platform-integration/desktop), and make sure a working C toolchain is available for cgo. Then run the commands for your platform.
|
||||||
|
|
||||||
command:
|
Commands:
|
||||||
|
|
||||||
- windows
|
- Windows
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
go build -tags nosqlite -ldflags="-w -s" -buildmode=c-shared -o ui/flutter/windows/libgopeed.dll github.com/GopeedLab/gopeed/bind/desktop
|
go build -tags nosqlite -ldflags="-w -s" -buildmode=c-shared -o ui/flutter/windows/libgopeed.dll github.com/GopeedLab/gopeed/bind/desktop
|
||||||
@@ -222,7 +131,7 @@ cd ui/flutter
|
|||||||
flutter build windows
|
flutter build windows
|
||||||
```
|
```
|
||||||
|
|
||||||
- macos
|
- macOS
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
go build -tags nosqlite -ldflags="-w -s" -buildmode=c-shared -o ui/flutter/macos/Frameworks/libgopeed.dylib github.com/GopeedLab/gopeed/bind/desktop
|
go build -tags nosqlite -ldflags="-w -s" -buildmode=c-shared -o ui/flutter/macos/Frameworks/libgopeed.dylib github.com/GopeedLab/gopeed/bind/desktop
|
||||||
@@ -230,7 +139,7 @@ cd ui/flutter
|
|||||||
flutter build macos
|
flutter build macos
|
||||||
```
|
```
|
||||||
|
|
||||||
- linux
|
- Linux
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
go build -tags nosqlite -ldflags="-w -s" -buildmode=c-shared -o ui/flutter/linux/bundle/lib/libgopeed.so github.com/GopeedLab/gopeed/bind/desktop
|
go build -tags nosqlite -ldflags="-w -s" -buildmode=c-shared -o ui/flutter/linux/bundle/lib/libgopeed.so github.com/GopeedLab/gopeed/bind/desktop
|
||||||
@@ -240,7 +149,7 @@ flutter build linux
|
|||||||
|
|
||||||
#### Mobile
|
#### Mobile
|
||||||
|
|
||||||
Same as before, you also need to prepare the `cgo` environment, and then install `gomobile`:
|
Mobile builds also require a working cgo toolchain. Install and initialize `gomobile`:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
go install golang.org/x/mobile/cmd/gomobile@latest
|
go install golang.org/x/mobile/cmd/gomobile@latest
|
||||||
@@ -248,9 +157,9 @@ go get golang.org/x/mobile/bind
|
|||||||
gomobile init
|
gomobile init
|
||||||
```
|
```
|
||||||
|
|
||||||
command:
|
Commands:
|
||||||
|
|
||||||
- android
|
- Android
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
gomobile bind -tags nosqlite -ldflags="-w -s -checklinkname=0" -o ui/flutter/android/app/libs/libgopeed.aar -target=android -androidapi 21 -javapkg="com.gopeed" github.com/GopeedLab/gopeed/bind/mobile
|
gomobile bind -tags nosqlite -ldflags="-w -s -checklinkname=0" -o ui/flutter/android/app/libs/libgopeed.aar -target=android -androidapi 21 -javapkg="com.gopeed" github.com/GopeedLab/gopeed/bind/mobile
|
||||||
@@ -258,7 +167,7 @@ cd ui/flutter
|
|||||||
flutter build apk
|
flutter build apk
|
||||||
```
|
```
|
||||||
|
|
||||||
- ios
|
- iOS
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
gomobile bind -tags nosqlite -ldflags="-w -s" -o ui/flutter/ios/Frameworks/Libgopeed.xcframework -target=ios github.com/GopeedLab/gopeed/bind/mobile
|
gomobile bind -tags nosqlite -ldflags="-w -s" -o ui/flutter/ios/Frameworks/Libgopeed.xcframework -target=ios github.com/GopeedLab/gopeed/bind/mobile
|
||||||
@@ -268,7 +177,7 @@ flutter build ios --no-codesign
|
|||||||
|
|
||||||
#### Web
|
#### Web
|
||||||
|
|
||||||
command:
|
Build the web app and server:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd ui/flutter
|
cd ui/flutter
|
||||||
|
|||||||
+58
-148
@@ -1,162 +1,76 @@
|
|||||||
# [](https://gopeed.com)
|
# [](https://gopeed.com)
|
||||||
|
|
||||||
[](https://github.com/GopeedLab/gopeed/actions?query=workflow%3Atest)
|
[](https://github.com/GopeedLab/gopeed/actions?query=workflow%3Atest)
|
||||||
[](https://codecov.io/gh/GopeedLab/gopeed)
|
[](https://codecov.io/gh/GopeedLab/gopeed)
|
||||||
[](https://github.com/GopeedLab/gopeed/releases)
|
[](https://github.com/GopeedLab/gopeed/releases)
|
||||||
[](https://github.com/GopeedLab/gopeed/releases)
|
[](https://github.com/GopeedLab/gopeed/releases)
|
||||||
[](https://docs.gopeed.com/donate.html)
|
[](https://gopeed.com/docs/donate)
|
||||||
[](https://raw.githubusercontent.com/GopeedLab/gopeed/main/_docs/img/weixin.png)
|
[](https://raw.githubusercontent.com/GopeedLab/gopeed/main/_docs/img/weixin.png)
|
||||||
[](https://discord.gg/ZUJqJrwCGB)
|
[](https://discord.gg/ZUJqJrwCGB)
|
||||||
|
|
||||||
<a href="https://trendshift.io/repositories/7953" target="_blank"><img src="https://trendshift.io/api/badge/repositories/7953" alt="GopeedLab%2Fgopeed | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
|
<a href="https://trendshift.io/repositories/7953" target="_blank"><img src="https://trendshift.io/api/badge/repositories/7953" alt="GopeedLab%2Fgopeed | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
|
||||||
|
|
||||||
[](https://ko-fi.com/R6R6IJGN6)
|
|
||||||
|
|
||||||
[English](/README.md) | [中文](/README_zh-CN.md) | [日本語](/README_ja-JP.md) | [正體中文](/README_zh-TW.md) | [Tiếng Việt](/README_vi-VN.md)
|
[English](/README.md) | [中文](/README_zh-CN.md) | [日本語](/README_ja-JP.md) | [正體中文](/README_zh-TW.md) | [Tiếng Việt](/README_vi-VN.md)
|
||||||
|
|
||||||
## 🚀 はじめに
|
## 🚀 はじめに
|
||||||
|
|
||||||
Gopeed (正式名 Go Speed) は `Golang` + `Flutter` によって開発された高速ダウンローダーで、(HTTP、BitTorrent、Magnet) プロトコルをサポートし、すべてのプラットフォームをサポートします。基本的なダウンロード機能に加え、[APIs](https://docs.gopeed.com/dev-api.html)との連動や[拡張機能](https://docs.gopeed.com/dev-extension.html)のインストール・開発による追加機能にも対応した、カスタマイズ性の高いダウンローダーです。
|
Gopeed(**Go Speed** の略)は、Go と Flutter で開発された高速でモダンな無料オープンソース・ダウンロードマネージャーです。HTTP、HTTPS、BitTorrent、Magnet、ed2k に対応し、デスクトップ、モバイル、Web で利用できます。
|
||||||
|
|
||||||
見て下さい ✈ [公式ウェブサイト](https://gopeed.com) | 📖 [開発ドキュメント](https://docs.gopeed.com)
|
ブラウザー連携、JavaScript 拡張、REST API、CLI、セルフホスト可能な Web UI により、日常利用から高度な自動化まで幅広く対応します。
|
||||||
|
|
||||||
|
✈ [公式サイト](https://gopeed.com)
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## ✨ 主な機能
|
||||||
|
|
||||||
|
- ⚡ **高速ダウンロード** — 複数タスク、HTTP のマルチ接続分割転送、BitTorrent の P2P ダウンロードで帯域を最大限に活用します。
|
||||||
|
- 🧲 **マルチプロトコル** — HTTP、HTTPS、BitTorrent、Magnet、ed2k を一つの画面で管理します。
|
||||||
|
- 🌱 **充実した BT 機能** — DHT によるピア検出、uTP 転送、Web Seed、ファイル選択、Tracker 管理、Peer/ピース統計、共有率または時間によるシード制御。
|
||||||
|
- 📋 **タスク管理** — 一時停止、再開、再試行、一括操作、検索、状態フィルター、カテゴリ、起動時復元。
|
||||||
|
- 🪶 **軽量なネイティブ体験** — メイン UI は Flutter でネイティブ描画。Electron 非採用。WebView ラッパーでもありません。パッケージサイズと実行時オーバーヘッドを抑え、軽快な応答性を実現します。
|
||||||
|
- 💻 **クロスプラットフォーム** — Windows、macOS、Linux、Android、iOS、Web、Docker、QNAP に対応。
|
||||||
|
- 🎨 **カスタマイズ可能なテーマ** — システム連動、ライト、ダークの各モードと 8 色のアクセントカラーに対応。
|
||||||
|
- 📐 **レスポンシブ UI** — タスクリスト、ナビゲーション、設定、詳細画面がスマートフォン、タブレット、サイズ変更可能なデスクトップウィンドウに適応。
|
||||||
|
- 🗣️ **20 以上の UI 言語** — 日本語、英語、簡体字・繁体字中国語、韓国語など多くの言語に対応。
|
||||||
|
- 🌐 **ブラウザー連携** — Chrome、Edge、Firefox などのダウンロードを Gopeed に送信できます。
|
||||||
|
- 🧩 **JavaScript 拡張** — 動画サイト、AI モデルハブ、クラウドストレージなどのダウンロード元を追加できます。
|
||||||
|
- 🤖 **AI 連携** — MCP インターフェースを通じて対応する AI Agent と連携し、自然言語でダウンロードタスクを作成・確認・管理できます。
|
||||||
|
- 🔌 **オープンなインターフェース** — REST API、CLI、認証付き Web UI、Webhook、完了後スクリプトに対応。
|
||||||
|
- 🛠️ **便利な内蔵機能** — カスタム Header/User-Agent、Proxy、GitHub ミラー、通知、自動展開。
|
||||||
|
|
||||||
|
## 🤖 AI 連携
|
||||||
|
|
||||||
|
Gopeed を AI Agent と連携すると、自然言語でダウンロードを管理できます。たとえば、AI Agent に次のように依頼できます:
|
||||||
|
|
||||||
|
> 最新の Gopeed Windows クライアントをダウンロードして
|
||||||
|
|
||||||
|
| Tool | 説明 |
|
||||||
|
| --- | --- |
|
||||||
|
| `resolve_task` | ダウンロード URL または URI を解析し、タスク作成前にリソース情報とファイル一覧を返します。 |
|
||||||
|
| `create_task` | 解析済みのリソース ID または直接のダウンロードリクエストからタスクを作成して開始します。 |
|
||||||
|
| `list_tasks` | タスクを一覧表示し、必要に応じて ID または状態で絞り込みます。 |
|
||||||
|
| `get_task` | 一つのタスクについて、リクエスト、リソース、オプション、現在の進捗を取得します。 |
|
||||||
|
| `get_task_status` | 一つのタスクの簡易的な実行状態とファイル別の進捗を取得します。 |
|
||||||
|
| `get_task_stats` | HTTP 接続数や BitTorrent の Peer・シード情報など、プロトコル固有の統計を取得します。 |
|
||||||
|
| `pause_task` | タスクを一時停止します。 |
|
||||||
|
| `continue_task` | 一時停止または失敗したタスクを再開します。 |
|
||||||
|
| `delete_task` | タスクを削除し、必要に応じてダウンロード済みファイルも削除します。 |
|
||||||
|
|
||||||
## ⬇️ インストール
|
## ⬇️ インストール
|
||||||
|
|
||||||
<table>
|
### 🧪 Gopeed 2.0.0 Beta
|
||||||
<tbody>
|
|
||||||
<tr>
|
Gopeed 2.0.0 は現在パブリックベータ版です。刷新されたインターフェース、デスクトップおよびモバイルから FFI で Go コアへ直接接続するネイティブ通信アーキテクチャ、より統一されたクロスプラットフォーム体験、強化されたタスク管理、より柔軟な API、MCP による AI Agent 連携機能を導入しています。一部の機能はまだ不完全または不安定な場合がありますので、ぜひお試しいただき、問題があればフィードバックをお寄せください。
|
||||||
<td rowspan="2">🪟 Windows</td>
|
|
||||||
<td><code>EXE</code></td>
|
- [Gopeed 2.0.0 Beta 3 をダウンロード](https://github.com/GopeedLab/gopeed/releases/tag/v2.0.0-beta.3)
|
||||||
<td>amd64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-windows-amd64.zip">📥</a></td>
|
機能と安定性が正式リリースの基準に達した時点で、Gopeed 2.0.0 正式版を公開します。ベータ版のユーザーは正式版へ直接アップデートできます。既存の安定版ユーザーが自動的にベータチャンネルへ移行することはありません。
|
||||||
</tr>
|
|
||||||
<tr>
|
### 安定版
|
||||||
<td><code>Portable</code></td>
|
|
||||||
<td>amd64</td>
|
- [公式サイトからダウンロード](https://gopeed.com)
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-windows-amd64-portable.zip">📥</a></td>
|
- [GitHub Releases](https://github.com/GopeedLab/gopeed/releases/latest)
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td rowspan="3">🍎 MacOS</td>
|
|
||||||
<td rowspan="3"><code>DMG</code></td>
|
|
||||||
<td>universal</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-macos.dmg">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>amd64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-macos-amd64.dmg">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>arm64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-macos-arm64.dmg">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td rowspan="6">🐧 Linux</td>
|
|
||||||
<td><code>Flathub</code></td>
|
|
||||||
<td>amd64</td>
|
|
||||||
<td><a href="https://flathub.org/apps/com.gopeed.Gopeed">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><code>SNAP</code></td>
|
|
||||||
<td>amd64</td>
|
|
||||||
<td><a href="https://snapcraft.io/gopeed">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td rowspan="2"><code>DEB</code></td>
|
|
||||||
<td>amd64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-linux-amd64.deb">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>arm64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-linux-arm64.deb">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td rowspan="2"><code>AppImage</code></td>
|
|
||||||
<td>amd64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-linux-amd64.AppImage">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>arm64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-linux-arm64.AppImage">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td rowspan="4">🤖 Android</td>
|
|
||||||
<td rowspan="4"><code>APK</code></td>
|
|
||||||
<td>universal</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-android.apk">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>armeabi-v7a</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-android-armeabi-v7a.apk">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>arm64-v8a</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-android-arm64-v8a.apk">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>x86_64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-android-x86_64.apk">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>📱 iOS</td>
|
|
||||||
<td><code>IPA</code></td>
|
|
||||||
<td>universal</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-ios.ipa">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>🐳 Docker</td>
|
|
||||||
<td>-</td>
|
|
||||||
<td>universal</td>
|
|
||||||
<td><a href="https://hub.docker.com/r/liwei2633/gopeed">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td rowspan="2">💾 Qnap</td>
|
|
||||||
<td rowspan="2"><code>QPKG</code></td>
|
|
||||||
<td>amd64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=gopeed-$version-qnap-amd64.qpkg">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>arm64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=gopeed-$version-qnap-arm64.qpkg">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td rowspan="8">🌐 Web</td>
|
|
||||||
<td rowspan="3"><code>Windows</code></td>
|
|
||||||
<td>amd64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=gopeed-web-$version-windows-amd64.zip">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>arm64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=gopeed-web-$version-windows-arm64.zip">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>386</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=gopeed-web-$version-windows-386.zip">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td rowspan="2"><code>MacOS</code></td>
|
|
||||||
<td>amd64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=gopeed-web-$version-macos-amd64.zip">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>arm64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=gopeed-web-$version-macos-arm64.zip">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td rowspan="3"><code>Linux</code></td>
|
|
||||||
<td>amd64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=gopeed-web-$version-linux-amd64.zip">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>arm64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=gopeed-web-$version-linux-arm64.zip">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>386</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=gopeed-web-$version-linux-386.zip">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
インストールについての詳細は、[インストール](https://docs.gopeed.com/install.html)を参照してください。
|
|
||||||
|
|
||||||
### 🛠️ コマンドツール
|
### 🛠️ コマンドツール
|
||||||
|
|
||||||
@@ -168,11 +82,7 @@ Gopeed (正式名 Go Speed) は `Golang` + `Flutter` によって開発された
|
|||||||
|
|
||||||
## 💝 寄付
|
## 💝 寄付
|
||||||
|
|
||||||
もしこのプロジェクトがお気に召しましたら、このプロジェクトの発展を支援するために[寄付](https://docs.gopeed.com/donate.html)をご検討ください!
|
もしこのプロジェクトがお気に召しましたら、このプロジェクトの発展を支援するために[寄付](https://gopeed.com/docs/donate)をご検討ください!
|
||||||
|
|
||||||
## 🖼️ ショーケース
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## 👨💻 開発
|
## 👨💻 開発
|
||||||
|
|
||||||
@@ -182,8 +92,8 @@ Gopeed (正式名 Go Speed) は `Golang` + `Flutter` によって開発された
|
|||||||
|
|
||||||
### 🌍 環境
|
### 🌍 環境
|
||||||
|
|
||||||
1. Go 言語 1.23+
|
1. Go 言語 1.25+
|
||||||
2. Flutter 3.24+
|
2. Flutter 3.41+
|
||||||
|
|
||||||
### 📋 クローン
|
### 📋 クローン
|
||||||
|
|
||||||
|
|||||||
+58
-148
@@ -1,162 +1,76 @@
|
|||||||
# [](https://gopeed.com)
|
# [](https://gopeed.com)
|
||||||
|
|
||||||
[](https://github.com/GopeedLab/gopeed/actions?query=workflow%3Atest)
|
[](https://github.com/GopeedLab/gopeed/actions?query=workflow%3Atest)
|
||||||
[](https://codecov.io/gh/GopeedLab/gopeed)
|
[](https://codecov.io/gh/GopeedLab/gopeed)
|
||||||
[](https://github.com/GopeedLab/gopeed/releases)
|
[](https://github.com/GopeedLab/gopeed/releases)
|
||||||
[](https://github.com/GopeedLab/gopeed/releases)
|
[](https://github.com/GopeedLab/gopeed/releases)
|
||||||
[](https://docs.gopeed.com/donate.html)
|
[](https://gopeed.com/docs/donate)
|
||||||
[](https://raw.githubusercontent.com/GopeedLab/gopeed/main/_docs/img/weixin.png)
|
[](https://raw.githubusercontent.com/GopeedLab/gopeed/main/_docs/img/weixin.png)
|
||||||
[](https://discord.gg/ZUJqJrwCGB)
|
[](https://discord.gg/ZUJqJrwCGB)
|
||||||
|
|
||||||
<a href="https://trendshift.io/repositories/7953" target="_blank"><img src="https://trendshift.io/api/badge/repositories/7953" alt="GopeedLab%2Fgopeed | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
|
<a href="https://trendshift.io/repositories/7953" target="_blank"><img src="https://trendshift.io/api/badge/repositories/7953" alt="GopeedLab%2Fgopeed | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
|
||||||
|
|
||||||
[](https://ko-fi.com/R6R6IJGN6)
|
|
||||||
|
|
||||||
[English](/README.md) | [中文](/README_zh-CN.md) | [日本語](/README_ja-JP.md) | [正體中文](/README_zh-TW.md) | [Tiếng Việt](/README_vi-VN.md)
|
[English](/README.md) | [中文](/README_zh-CN.md) | [日本語](/README_ja-JP.md) | [正體中文](/README_zh-TW.md) | [Tiếng Việt](/README_vi-VN.md)
|
||||||
|
|
||||||
## 🚀 Giới thiệu
|
## 🚀 Giới thiệu
|
||||||
|
|
||||||
Gopeed (tên đầy đủ Go Speed), một công cụ tải xuống tốc độ cao được phát triển bởi `Golang` + `Flutter`, hỗ trợ giao thức (HTTP, BitTorrent, Magnet) và hỗ trợ tất cả các nền tảng. Ngoài các chức năng tải xuống cơ bản, Gopeed còn là một công cụ tải xuống có thể tùy chỉnh cao cho phép triển khai thêm tính năng thông qua việc tích hợp với [APIs](https://docs.gopeed.com/dev-api.html) hoặc cài đặt và phát triển các [tiện ích mở rộng](https://docs.gopeed.com/dev-extension.html).
|
Gopeed (viết tắt của **Go Speed**) là trình quản lý tải xuống nhanh, hiện đại, miễn phí và mã nguồn mở, được xây dựng bằng Go và Flutter. Gopeed hỗ trợ HTTP, HTTPS, BitTorrent, Magnet và ed2k trên máy tính, thiết bị di động và Web.
|
||||||
|
|
||||||
Truy cập ✈ [Trang web chính thức](https://gopeed.com) | 📖 [Tài liệu chính thức](https://docs.gopeed.com)
|
Ngoài việc quản lý tải xuống hằng ngày, Gopeed còn hỗ trợ tích hợp trình duyệt, tiện ích JavaScript, REST API, CLI và Web UI có thể tự lưu trữ để mở rộng và tự động hóa quy trình.
|
||||||
|
|
||||||
|
Truy cập ✈ [Trang web chính thức](https://gopeed.com)
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## ✨ Tính năng chính
|
||||||
|
|
||||||
|
- ⚡ **Tải xuống tốc độ cao** — kết hợp nhiều tác vụ, truyền HTTP phân đoạn qua nhiều kết nối và tải BitTorrent P2P để tận dụng tối đa băng thông.
|
||||||
|
- 🧲 **Đa giao thức** — quản lý HTTP, HTTPS, BitTorrent, Magnet và ed2k trong một giao diện.
|
||||||
|
- 🌱 **Bộ công cụ BT đầy đủ** — hỗ trợ khám phá Peer qua DHT, truyền tải uTP, Web Seed, chọn tệp, quản lý Tracker, xem Peer/mảnh và kiểm soát seed theo tỷ lệ hoặc thời gian.
|
||||||
|
- 📋 **Quản lý tác vụ thực tế** — tạm dừng, tiếp tục, thử lại, thao tác hàng loạt, tìm kiếm, bộ lọc, danh mục và khôi phục khi khởi động.
|
||||||
|
- 🪶 **Trải nghiệm native gọn nhẹ** — giao diện chính được Flutter kết xuất native. Không Electron. Không vỏ bọc WebView. Kích thước nhỏ hơn, ít tốn tài nguyên hơn và phản hồi nhanh hơn.
|
||||||
|
- 💻 **Đa nền tảng** — Windows, macOS, Linux, Android, iOS, Web, Docker và QNAP.
|
||||||
|
- 🎨 **Giao diện tùy biến** — hỗ trợ chế độ theo hệ thống, sáng, tối và 8 màu nhấn.
|
||||||
|
- 📐 **Bố cục thích ứng** — danh sách tác vụ, điều hướng, cài đặt và màn hình chi tiết tự điều chỉnh cho điện thoại, máy tính bảng và cửa sổ desktop có thể thay đổi kích thước.
|
||||||
|
- 🗣️ **Hơn 20 ngôn ngữ giao diện** — gồm tiếng Việt, tiếng Anh, tiếng Trung giản thể và phồn thể, tiếng Nhật, tiếng Hàn cùng nhiều ngôn ngữ khác.
|
||||||
|
- 🌐 **Tích hợp trình duyệt** — gửi tải xuống từ Chrome, Edge, Firefox và các trình duyệt tương thích sang Gopeed.
|
||||||
|
- 🧩 **Tiện ích JavaScript** — thêm nguồn tải từ nền tảng video, kho mô hình AI, lưu trữ đám mây và nhiều dịch vụ khác.
|
||||||
|
- 🤖 **Tích hợp AI** — cung cấp giao diện MCP để kết nối với các AI Agent tương thích và tạo, kiểm tra hoặc quản lý tác vụ tải xuống bằng ngôn ngữ tự nhiên.
|
||||||
|
- 🔌 **Giao diện mở** — REST API, CLI, Web UI có xác thực, webhook và script sau khi tải.
|
||||||
|
- 🛠️ **Công cụ tích hợp** — Header/User-Agent tùy chỉnh, proxy, mirror GitHub, thông báo và tự động giải nén.
|
||||||
|
|
||||||
|
## 🤖 Tích hợp AI
|
||||||
|
|
||||||
|
Sau khi kết nối Gopeed với AI Agent, bạn có thể quản lý tải xuống bằng ngôn ngữ tự nhiên. Ví dụ, hãy nói với AI Agent:
|
||||||
|
|
||||||
|
> Hãy tải xuống phiên bản Gopeed mới nhất dành cho Windows
|
||||||
|
|
||||||
|
| Tool | Mô tả |
|
||||||
|
| --- | --- |
|
||||||
|
| `resolve_task` | Phân tích URL hoặc URI tải xuống và trả về thông tin tài nguyên cùng danh sách tệp trước khi tạo tác vụ. |
|
||||||
|
| `create_task` | Tạo và bắt đầu tác vụ từ ID tài nguyên đã phân tích hoặc từ yêu cầu tải xuống trực tiếp. |
|
||||||
|
| `list_tasks` | Liệt kê tác vụ và có thể lọc theo ID hoặc trạng thái. |
|
||||||
|
| `get_task` | Lấy yêu cầu, tài nguyên, tùy chọn và tiến độ hiện tại của một tác vụ. |
|
||||||
|
| `get_task_status` | Lấy trạng thái chạy rút gọn và tiến độ của từng tệp trong một tác vụ. |
|
||||||
|
| `get_task_stats` | Lấy số liệu thống kê theo giao thức, gồm kết nối HTTP hoặc Peer và dữ liệu seed của BitTorrent. |
|
||||||
|
| `pause_task` | Tạm dừng tác vụ. |
|
||||||
|
| `continue_task` | Tiếp tục tác vụ đã tạm dừng hoặc bị lỗi. |
|
||||||
|
| `delete_task` | Xóa tác vụ và có thể xóa cả các tệp đã tải xuống. |
|
||||||
|
|
||||||
## ⬇️ Tải về
|
## ⬇️ Tải về
|
||||||
|
|
||||||
<table>
|
### 🧪 Gopeed 2.0.0 Beta
|
||||||
<tbody>
|
|
||||||
<tr>
|
Gopeed 2.0.0 hiện đang trong giai đoạn beta công khai, với giao diện được thiết kế lại, kiến trúc giao tiếp native kết nối trực tiếp ứng dụng desktop và di động với lõi Go qua FFI, trải nghiệm đa nền tảng nhất quán hơn, khả năng quản lý tác vụ được cải thiện, API linh hoạt hơn và khả năng tích hợp AI Agent qua MCP. Một số tính năng có thể vẫn chưa hoàn thiện hoặc chưa ổn định, vì vậy hãy dùng thử và gửi phản hồi nếu bạn gặp vấn đề.
|
||||||
<td rowspan="2">🪟 Windows</td>
|
|
||||||
<td><code>EXE</code></td>
|
- [Tải Gopeed 2.0.0 Beta 3](https://github.com/GopeedLab/gopeed/releases/tag/v2.0.0-beta.3)
|
||||||
<td>amd64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-windows-amd64.zip">📥</a></td>
|
Khi các tính năng và độ ổn định đáp ứng tiêu chuẩn phát hành, chúng tôi sẽ phát hành Gopeed 2.0.0 chính thức. Người dùng bản beta có thể nâng cấp trực tiếp lên bản chính thức, trong khi người dùng bản ổn định hiện tại sẽ không tự động được chuyển sang kênh beta.
|
||||||
</tr>
|
|
||||||
<tr>
|
### Bản ổn định
|
||||||
<td><code>Portable</code></td>
|
|
||||||
<td>amd64</td>
|
- [Tải xuống từ trang web chính thức](https://gopeed.com)
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-windows-amd64-portable.zip">📥</a></td>
|
- [GitHub Releases](https://github.com/GopeedLab/gopeed/releases/latest)
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td rowspan="3">🍎 MacOS</td>
|
|
||||||
<td rowspan="3"><code>DMG</code></td>
|
|
||||||
<td>universal</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-macos.dmg">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>amd64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-macos-amd64.dmg">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>arm64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-macos-arm64.dmg">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td rowspan="6">🐧 Linux</td>
|
|
||||||
<td><code>Flathub</code></td>
|
|
||||||
<td>amd64</td>
|
|
||||||
<td><a href="https://flathub.org/apps/com.gopeed.Gopeed">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><code>SNAP</code></td>
|
|
||||||
<td>amd64</td>
|
|
||||||
<td><a href="https://snapcraft.io/gopeed">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td rowspan="2"><code>DEB</code></td>
|
|
||||||
<td>amd64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-linux-amd64.deb">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>arm64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-linux-arm64.deb">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td rowspan="2"><code>AppImage</code></td>
|
|
||||||
<td>amd64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-linux-amd64.AppImage">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>arm64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-linux-arm64.AppImage">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td rowspan="4">🤖 Android</td>
|
|
||||||
<td rowspan="4"><code>APK</code></td>
|
|
||||||
<td>universal</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-android.apk">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>armeabi-v7a</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-android-armeabi-v7a.apk">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>arm64-v8a</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-android-arm64-v8a.apk">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>x86_64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-android-x86_64.apk">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>📱 iOS</td>
|
|
||||||
<td><code>IPA</code></td>
|
|
||||||
<td>universal</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-ios.ipa">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>🐳 Docker</td>
|
|
||||||
<td>-</td>
|
|
||||||
<td>universal</td>
|
|
||||||
<td><a href="https://hub.docker.com/r/liwei2633/gopeed">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td rowspan="2">💾 Qnap</td>
|
|
||||||
<td rowspan="2"><code>QPKG</code></td>
|
|
||||||
<td>amd64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=gopeed-$version-qnap-amd64.qpkg">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>arm64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=gopeed-$version-qnap-arm64.qpkg">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td rowspan="8">🌐 Web</td>
|
|
||||||
<td rowspan="3"><code>Windows</code></td>
|
|
||||||
<td>amd64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=gopeed-web-$version-windows-amd64.zip">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>arm64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=gopeed-web-$version-windows-arm64.zip">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>386</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=gopeed-web-$version-windows-386.zip">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td rowspan="2"><code>MacOS</code></td>
|
|
||||||
<td>amd64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=gopeed-web-$version-macos-amd64.zip">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>arm64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=gopeed-web-$version-macos-arm64.zip">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td rowspan="3"><code>Linux</code></td>
|
|
||||||
<td>amd64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=gopeed-web-$version-linux-amd64.zip">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>arm64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=gopeed-web-$version-linux-arm64.zip">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>386</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=gopeed-web-$version-linux-386.zip">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
Thêm thông tin về cài đặt, vui lòng tham khảo [Cài đặt](https://docs.gopeed.com/install.html)
|
|
||||||
|
|
||||||
### 🛠️ Công cụ lệnh
|
### 🛠️ Công cụ lệnh
|
||||||
|
|
||||||
@@ -174,11 +88,7 @@ Theo dõi tài khoản chính thức để nhận các cập nhật và tin tứ
|
|||||||
|
|
||||||
## 💝 Quyên góp
|
## 💝 Quyên góp
|
||||||
|
|
||||||
Nếu bạn thích dự án này, xin vui lòng xem xét [quyên góp](https://docs.gopeed.com/donate.html) để hỗ trợ phát triển dự án này, cảm ơn bạn!
|
Nếu bạn thích dự án này, xin vui lòng xem xét [quyên góp](https://gopeed.com/docs/donate) để hỗ trợ phát triển dự án này, cảm ơn bạn!
|
||||||
|
|
||||||
## 🖼️ Trưng bày
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## 👨💻 Development
|
## 👨💻 Development
|
||||||
|
|
||||||
@@ -188,8 +98,8 @@ Dự án này được chia thành hai phần, phần giao diện sử dụng `f
|
|||||||
|
|
||||||
### 🌍 Environment
|
### 🌍 Environment
|
||||||
|
|
||||||
1. Golang 1.23+
|
1. Golang 1.25+
|
||||||
2. Flutter 3.24+
|
2. Flutter 3.41+
|
||||||
|
|
||||||
### 📋 Clone
|
### 📋 Clone
|
||||||
|
|
||||||
|
|||||||
+58
-148
@@ -1,162 +1,76 @@
|
|||||||
# [](https://gopeed.com)
|
# [](https://gopeed.com)
|
||||||
|
|
||||||
[](https://github.com/GopeedLab/gopeed/actions?query=workflow%3Atest)
|
[](https://github.com/GopeedLab/gopeed/actions?query=workflow%3Atest)
|
||||||
[](https://codecov.io/gh/GopeedLab/gopeed)
|
[](https://codecov.io/gh/GopeedLab/gopeed)
|
||||||
[](https://github.com/GopeedLab/gopeed/releases)
|
[](https://github.com/GopeedLab/gopeed/releases)
|
||||||
[](https://github.com/GopeedLab/gopeed/releases)
|
[](https://github.com/GopeedLab/gopeed/releases)
|
||||||
[](https://docs.gopeed.com/zh/donate.html)
|
[](https://gopeed.com/docs/donate)
|
||||||
[](https://raw.githubusercontent.com/GopeedLab/gopeed/main/_docs/img/weixin.png)
|
[](https://raw.githubusercontent.com/GopeedLab/gopeed/main/_docs/img/weixin.png)
|
||||||
[](https://discord.gg/ZUJqJrwCGB)
|
[](https://discord.gg/ZUJqJrwCGB)
|
||||||
|
|
||||||
<a href="https://trendshift.io/repositories/7953" target="_blank"><img src="https://trendshift.io/api/badge/repositories/7953" alt="GopeedLab%2Fgopeed | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
|
<a href="https://trendshift.io/repositories/7953" target="_blank"><img src="https://trendshift.io/api/badge/repositories/7953" alt="GopeedLab%2Fgopeed | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
|
||||||
|
|
||||||
[](https://ko-fi.com/R6R6IJGN6)
|
|
||||||
|
|
||||||
[English](/README.md) | [中文](/README_zh-CN.md) | [日本語](/README_ja-JP.md) | [正體中文](/README_zh-TW.md) | [Tiếng Việt](/README_vi-VN.md)
|
[English](/README.md) | [中文](/README_zh-CN.md) | [日本語](/README_ja-JP.md) | [正體中文](/README_zh-TW.md) | [Tiếng Việt](/README_vi-VN.md)
|
||||||
|
|
||||||
## 🚀 介绍
|
## 🚀 介绍
|
||||||
|
|
||||||
Gopeed(全称 Go Speed),直译过来中文名叫做`够快下载器`(不是狗屁下载器!),是一款由`Golang`+`Flutter`开发的高速下载器,支持(HTTP、BitTorrent、Magnet)协议下载,并且支持全平台使用。除了基本的下载功能外,Gopeed 还是一款高度可定制化的下载器,支持通过对接[APIs](https://docs.gopeed.com/zh/dev-api.html)或者安装和开发[扩展](https://docs.gopeed.com/zh/dev-extension.html)来实现更多的功能。
|
Gopeed(全称 **Go Speed**,也叫“够快下载器”)是一款使用 Go 和 Flutter 开发的高速、现代、免费开源下载器,支持 HTTP、HTTPS、BitTorrent、磁力链接和 ed2k,并覆盖桌面端、移动端与 Web。
|
||||||
|
|
||||||
访问 ✈ [官方网站](https://gopeed.com/zh-CN) | 📖 [官方文档](https://docs.gopeed.com/zh/)
|
除了日常下载任务管理,Gopeed 还提供浏览器接管、JavaScript 扩展、REST API、命令行工具和可自托管 Web UI,方便高级用户扩展和自动化自己的下载流程。
|
||||||
|
|
||||||
|
访问 ✈ [官方网站](https://gopeed.com)
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## ✨ 主要特性
|
||||||
|
|
||||||
|
- ⚡ **高速下载** — 多任务并发、HTTP 多连接分段传输和 BitTorrent P2P 下载,充分利用可用带宽。
|
||||||
|
- 🧲 **多协议支持** — 在同一个界面管理 HTTP、HTTPS、BitTorrent、磁力链接和 ed2k。
|
||||||
|
- 🌱 **完整 BT 能力** — 支持 DHT 节点发现、uTP 传输、Web Seed、按文件选择下载、Tracker 管理、Peer/分片统计,以及按分享率或时间控制做种。
|
||||||
|
- 📋 **实用任务管理** — 暂停、续传、重试、批量操作、搜索、状态筛选、下载分类和启动恢复。
|
||||||
|
- 🪶 **轻量原生体验** — 主界面使用 Flutter 原生渲染,非 Electron,非 WebView 的套壳,安装包更轻量、运行开销更低、响应更流畅。
|
||||||
|
- 💻 **全平台覆盖** — 支持 Windows、macOS、Linux、Android、iOS 和 Web,并提供 Docker、QNAP 部署方式。
|
||||||
|
- 🎨 **个性化主题** — 支持跟随系统、浅色、深色三种模式,以及 8 种主题强调色。
|
||||||
|
- 📐 **响应式界面** — 任务列表、导航、设置和详情视图会针对手机、平板及可调整大小的桌面窗口自动布局。
|
||||||
|
- 🗣️ **20+ 种界面语言** — 支持简体中文、繁体中文、英语、日语、韩语等多种语言。
|
||||||
|
- 🌐 **浏览器接管** — 支持 Chrome、Edge、Firefox 等兼容浏览器,将下载任务直接发送到 Gopeed。
|
||||||
|
- 🧩 **JavaScript 扩展** — 扩展视频网站、AI 模型站、网盘等更多下载源。
|
||||||
|
- 🤖 **AI 接入** — 开放 MCP 接口,可接入 AI Agent,通过自然语言创建、查询和管理下载任务。
|
||||||
|
- 🔌 **开放接口** — 通过 REST API、CLI、带身份认证的 Web UI、Webhook 和下载后脚本进行自动化。
|
||||||
|
- 🛠️ **常用内置能力** — 自定义 Header 与 User-Agent、代理、GitHub 镜像、通知和自动解压。
|
||||||
|
|
||||||
|
## 🤖 AI 接入
|
||||||
|
|
||||||
|
将 Gopeed 接入 AI Agent 后,即可通过自然语言管理下载。例如,直接对 AI Agent 说:
|
||||||
|
|
||||||
|
> 帮我下载最新的 Gopeed Windows 客户端
|
||||||
|
|
||||||
|
| Tool | 功能说明 |
|
||||||
|
| --- | --- |
|
||||||
|
| `resolve_task` | 解析下载 URL 或 URI,在创建任务前返回资源信息及文件列表。 |
|
||||||
|
| `create_task` | 使用已解析的资源 ID 或直接下载请求创建并启动任务。 |
|
||||||
|
| `list_tasks` | 查询任务列表,并可按任务 ID 或状态筛选。 |
|
||||||
|
| `get_task` | 获取单个任务的请求、资源、选项及当前进度等完整信息。 |
|
||||||
|
| `get_task_status` | 获取单个任务的轻量运行状态和各文件下载进度。 |
|
||||||
|
| `get_task_stats` | 获取协议相关统计信息,包括 HTTP 连接或 BitTorrent Peer 与做种数据。 |
|
||||||
|
| `pause_task` | 暂停任务。 |
|
||||||
|
| `continue_task` | 继续已暂停或失败的任务。 |
|
||||||
|
| `delete_task` | 删除任务,并可选择同时删除已下载文件。 |
|
||||||
|
|
||||||
## ⬇️ 下载
|
## ⬇️ 下载
|
||||||
|
|
||||||
<table>
|
### 🧪 Gopeed 2.0.0 Beta
|
||||||
<tbody>
|
|
||||||
<tr>
|
Gopeed 2.0.0 目前处于公开 Beta 测试阶段,引入了全新界面、通过 FFI 直连 Go 核心的原生通信架构、更一致的跨平台体验、更完善的任务管理、更灵活的 API,以及用于 AI Agent 接入的 MCP 能力。部分功能仍可能不够完善或稳定,欢迎提前体验并向我们反馈问题。
|
||||||
<td rowspan="2">🪟 Windows</td>
|
|
||||||
<td><code>EXE</code></td>
|
- [下载 Gopeed 2.0.0 Beta 3](https://github.com/GopeedLab/gopeed/releases/tag/v2.0.0-beta.3)
|
||||||
<td>amd64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-windows-amd64.zip">📥</a></td>
|
当功能完整度和稳定性达到正式发布标准后,我们会发布 Gopeed 2.0.0 正式版。已安装 Beta 版本的用户可以直接升级到最终正式版,现有稳定版用户则不会被自动切换到 Beta 渠道。
|
||||||
</tr>
|
|
||||||
<tr>
|
### 正式稳定版
|
||||||
<td><code>Portable</code></td>
|
|
||||||
<td>amd64</td>
|
- [官方网站下载](https://gopeed.com)
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-windows-amd64-portable.zip">📥</a></td>
|
- [GitHub Releases](https://github.com/GopeedLab/gopeed/releases/latest)
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td rowspan="3">🍎 MacOS</td>
|
|
||||||
<td rowspan="3"><code>DMG</code></td>
|
|
||||||
<td>universal</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-macos.dmg">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>amd64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-macos-amd64.dmg">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>arm64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-macos-arm64.dmg">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td rowspan="6">🐧 Linux</td>
|
|
||||||
<td><code>Flathub</code></td>
|
|
||||||
<td>amd64</td>
|
|
||||||
<td><a href="https://flathub.org/apps/com.gopeed.Gopeed">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><code>SNAP</code></td>
|
|
||||||
<td>amd64</td>
|
|
||||||
<td><a href="https://snapcraft.io/gopeed">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td rowspan="2"><code>DEB</code></td>
|
|
||||||
<td>amd64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-linux-amd64.deb">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>arm64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-linux-arm64.deb">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td rowspan="2"><code>AppImage</code></td>
|
|
||||||
<td>amd64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-linux-amd64.AppImage">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>arm64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-linux-arm64.AppImage">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td rowspan="4">🤖 Android</td>
|
|
||||||
<td rowspan="4"><code>APK</code></td>
|
|
||||||
<td>universal</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-android.apk">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>armeabi-v7a</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-android-armeabi-v7a.apk">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>arm64-v8a</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-android-arm64-v8a.apk">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>x86_64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-android-x86_64.apk">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>📱 iOS</td>
|
|
||||||
<td><code>IPA</code></td>
|
|
||||||
<td>universal</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-ios.ipa">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>🐳 Docker</td>
|
|
||||||
<td>-</td>
|
|
||||||
<td>universal</td>
|
|
||||||
<td><a href="https://hub.docker.com/r/liwei2633/gopeed">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td rowspan="2">💾 Qnap</td>
|
|
||||||
<td rowspan="2"><code>QPKG</code></td>
|
|
||||||
<td>amd64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=gopeed-$version-qnap-amd64.qpkg">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>arm64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=gopeed-$version-qnap-arm64.qpkg">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td rowspan="8">🌐 Web</td>
|
|
||||||
<td rowspan="3"><code>Windows</code></td>
|
|
||||||
<td>amd64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=gopeed-web-$version-windows-amd64.zip">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>arm64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=gopeed-web-$version-windows-arm64.zip">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>386</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=gopeed-web-$version-windows-386.zip">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td rowspan="2"><code>MacOS</code></td>
|
|
||||||
<td>amd64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=gopeed-web-$version-macos-amd64.zip">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>arm64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=gopeed-web-$version-macos-arm64.zip">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td rowspan="3"><code>Linux</code></td>
|
|
||||||
<td>amd64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=gopeed-web-$version-linux-amd64.zip">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>arm64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=gopeed-web-$version-linux-arm64.zip">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>386</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=gopeed-web-$version-linux-386.zip">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
更多关于安装的内容请参考[安装文档](https://docs.gopeed.com/zh/install.html)
|
|
||||||
|
|
||||||
### 🛠️ 命令行工具
|
### 🛠️ 命令行工具
|
||||||
|
|
||||||
@@ -178,11 +92,7 @@ Gopeed 还提供了浏览器扩展用于接管浏览器下载,支持 Chrome、
|
|||||||
|
|
||||||
## 💝 赞助
|
## 💝 赞助
|
||||||
|
|
||||||
如果觉得项目对你有帮助,请考虑[赞助](https://docs.gopeed.com/zh/donate)以支持这个项目的发展,非常感谢!
|
如果觉得项目对你有帮助,请考虑[赞助](https://gopeed.com/docs/donate)以支持这个项目的发展,非常感谢!
|
||||||
|
|
||||||
## 🖼️ 界面展示
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## 👨💻 开发
|
## 👨💻 开发
|
||||||
|
|
||||||
@@ -192,8 +102,8 @@ Gopeed 还提供了浏览器扩展用于接管浏览器下载,支持 Chrome、
|
|||||||
|
|
||||||
### 🌍 环境要求
|
### 🌍 环境要求
|
||||||
|
|
||||||
1. Golang 1.23+
|
1. Golang 1.25+
|
||||||
2. Flutter 3.24+
|
2. Flutter 3.41+
|
||||||
|
|
||||||
### 📋 克隆项目
|
### 📋 克隆项目
|
||||||
|
|
||||||
|
|||||||
+57
-148
@@ -1,163 +1,76 @@
|
|||||||
# [](https://gopeed.com)
|
# [](https://gopeed.com)
|
||||||
|
|
||||||
[](https://github.com/GopeedLab/gopeed/actions?query=workflow%3Atest)
|
[](https://github.com/GopeedLab/gopeed/actions?query=workflow%3Atest)
|
||||||
[](https://codecov.io/gh/GopeedLab/gopeed)
|
[](https://codecov.io/gh/GopeedLab/gopeed)
|
||||||
[](https://github.com/GopeedLab/gopeed/releases)
|
[](https://github.com/GopeedLab/gopeed/releases)
|
||||||
[](https://github.com/GopeedLab/gopeed/releases)
|
[](https://github.com/GopeedLab/gopeed/releases)
|
||||||
[](https://docs.gopeed.com/donate.html)
|
[](https://gopeed.com/docs/donate)
|
||||||
[](https://raw.githubusercontent.com/GopeedLab/gopeed/main/_docs/img/weixin.png)
|
[](https://raw.githubusercontent.com/GopeedLab/gopeed/main/_docs/img/weixin.png)
|
||||||
[](https://discord.gg/ZUJqJrwCGB)
|
[](https://discord.gg/ZUJqJrwCGB)
|
||||||
|
|
||||||
<a href="https://trendshift.io/repositories/7953" target="_blank"><img src="https://trendshift.io/api/badge/repositories/7953" alt="GopeedLab%2Fgopeed | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
|
<a href="https://trendshift.io/repositories/7953" target="_blank"><img src="https://trendshift.io/api/badge/repositories/7953" alt="GopeedLab%2Fgopeed | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
|
||||||
|
|
||||||
[](https://ko-fi.com/R6R6IJGN6)
|
|
||||||
|
|
||||||
[English](/README.md) | [中文](/README_zh-CN.md) | [日本語](/README_ja-JP.md) | [正體中文](/README_zh-TW.md) | [Tiếng Việt](/README_vi-VN.md)
|
[English](/README.md) | [中文](/README_zh-CN.md) | [日本語](/README_ja-JP.md) | [正體中文](/README_zh-TW.md) | [Tiếng Việt](/README_vi-VN.md)
|
||||||
|
|
||||||
## 🚀 簡介
|
## 🚀 簡介
|
||||||
|
|
||||||
Gopeed(全稱 Go Speed),是一款使用`Golang`+`Flutter`編寫的高速下載軟體,支援(HTTP、BitTorrent、Magnet)協定,同時支援所有的平台。
|
Gopeed(**Go Speed** 的縮寫)是一款以 Go 與 Flutter 開發的高速、現代化、免費開源下載器,支援 HTTP、HTTPS、BitTorrent、磁力連結與 ed2k,並涵蓋桌面、行動裝置及 Web。
|
||||||
|
|
||||||
前往 ✈ [主頁](https://gopeed.com/zh-CN) | 📖 [文檔](https://docs.gopeed.com/zh/)
|
除了日常任務管理,Gopeed 也提供瀏覽器整合、JavaScript 擴充、REST API、命令列工具及可自行託管的 Web UI,方便進階使用者擴充與自動化下載流程。
|
||||||
|
|
||||||
|
瀏覽 ✈ [官方網站](https://gopeed.com)
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## ✨ 主要功能
|
||||||
|
|
||||||
|
- ⚡ **高速下載** — 多任務並行、HTTP 多連線分段傳輸與 BitTorrent P2P 下載,充分利用可用頻寬。
|
||||||
|
- 🧲 **多協定支援** — 在同一介面管理 HTTP、HTTPS、BitTorrent、磁力連結與 ed2k。
|
||||||
|
- 🌱 **完整 BT 功能** — 支援 DHT 節點探索、uTP 傳輸、Web Seed、逐檔選擇、Tracker 管理、Peer/分片統計,以及依分享率或時間控制做種。
|
||||||
|
- 📋 **實用任務管理** — 暫停、續傳、重試、批次操作、搜尋、狀態篩選、分類及啟動恢復。
|
||||||
|
- 🪶 **輕量原生體驗** — 主介面使用 Flutter 原生渲染,非 Electron,非 WebView 套殼,安裝包更輕量、執行開銷更低、操作回應更流暢。
|
||||||
|
- 💻 **跨平台** — 支援 Windows、macOS、Linux、Android、iOS、Web、Docker 與 QNAP。
|
||||||
|
- 🎨 **個人化主題** — 支援跟隨系統、淺色、深色模式及 8 種主題強調色。
|
||||||
|
- 📐 **響應式介面** — 任務列表、導覽、設定與詳細資訊會配合手機、平板及可調整大小的桌面視窗自動配置。
|
||||||
|
- 🗣️ **20+ 種介面語言** — 支援繁體中文、簡體中文、英文、日文、韓文等多種語言。
|
||||||
|
- 🌐 **瀏覽器整合** — 可接管 Chrome、Edge、Firefox 等相容瀏覽器的下載。
|
||||||
|
- 🧩 **JavaScript 擴充** — 新增影音網站、AI 模型平台、雲端儲存等下載來源。
|
||||||
|
- 🤖 **AI 整合** — 提供 MCP 介面,可串接相容的 AI Agent,以自然語言建立、查詢及管理下載任務。
|
||||||
|
- 🔌 **開放介面** — 支援 REST API、CLI、認證 Web UI、Webhook 及下載後腳本。
|
||||||
|
- 🛠️ **實用內建能力** — 自訂 Header/User-Agent、Proxy、GitHub 鏡像、通知及自動解壓縮。
|
||||||
|
|
||||||
|
## 🤖 AI 整合
|
||||||
|
|
||||||
|
將 Gopeed 與 AI Agent 串接後,即可透過自然語言管理下載。例如,直接對 AI Agent 說:
|
||||||
|
|
||||||
|
> 幫我下載最新的 Gopeed Windows 用戶端
|
||||||
|
|
||||||
|
| Tool | 功能說明 |
|
||||||
|
| --- | --- |
|
||||||
|
| `resolve_task` | 解析下載 URL 或 URI,在建立任務前回傳資源資訊及檔案清單。 |
|
||||||
|
| `create_task` | 使用已解析的資源 ID 或直接下載請求建立並啟動任務。 |
|
||||||
|
| `list_tasks` | 查詢任務清單,並可依任務 ID 或狀態篩選。 |
|
||||||
|
| `get_task` | 取得單一任務的請求、資源、選項及目前進度等完整資訊。 |
|
||||||
|
| `get_task_status` | 取得單一任務的簡要執行狀態及各檔案下載進度。 |
|
||||||
|
| `get_task_stats` | 取得協定相關統計資訊,包括 HTTP 連線或 BitTorrent Peer 與做種資料。 |
|
||||||
|
| `pause_task` | 暫停任務。 |
|
||||||
|
| `continue_task` | 繼續已暫停或失敗的任務。 |
|
||||||
|
| `delete_task` | 刪除任務,並可選擇同時刪除已下載檔案。 |
|
||||||
|
|
||||||
## ⬇️ 下載
|
## ⬇️ 下載
|
||||||
|
|
||||||
<table>
|
### 🧪 Gopeed 2.0.0 Beta
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td rowspan="2">🪟 Windows</td>
|
|
||||||
<td><code>EXE</code></td>
|
|
||||||
<td>amd64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-windows-amd64.zip">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><code>Portable</code></td>
|
|
||||||
<td>amd64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-windows-amd64-portable.zip">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td rowspan="3">🍎 MacOS</td>
|
|
||||||
<td rowspan="3"><code>DMG</code></td>
|
|
||||||
<td>universal</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-macos.dmg">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>amd64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-macos-amd64.dmg">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>arm64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-macos-arm64.dmg">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td rowspan="6">🐧 Linux</td>
|
|
||||||
<td><code>Flathub</code></td>
|
|
||||||
<td>amd64</td>
|
|
||||||
<td><a href="https://flathub.org/apps/com.gopeed.Gopeed">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><code>SNAP</code></td>
|
|
||||||
<td>amd64</td>
|
|
||||||
<td><a href="https://snapcraft.io/gopeed">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td rowspan="2"><code>DEB</code></td>
|
|
||||||
<td>amd64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-linux-amd64.deb">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>arm64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-linux-arm64.deb">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td rowspan="2"><code>AppImage</code></td>
|
|
||||||
<td>amd64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-linux-amd64.AppImage">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>arm64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-linux-arm64.AppImage">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td rowspan="4">🤖 Android</td>
|
|
||||||
<td rowspan="4"><code>APK</code></td>
|
|
||||||
<td>universal</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-android.apk">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>armeabi-v7a</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-android-armeabi-v7a.apk">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>arm64-v8a</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-android-arm64-v8a.apk">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>x86_64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-android-x86_64.apk">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>📱 iOS</td>
|
|
||||||
<td><code>IPA</code></td>
|
|
||||||
<td>universal</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=Gopeed-$version-ios.ipa">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>🐳 Docker</td>
|
|
||||||
<td>-</td>
|
|
||||||
<td>universal</td>
|
|
||||||
<td><a href="https://hub.docker.com/r/liwei2633/gopeed">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td rowspan="2">💾 Qnap</td>
|
|
||||||
<td rowspan="2"><code>QPKG</code></td>
|
|
||||||
<td>amd64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=gopeed-$version-qnap-amd64.qpkg">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>arm64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=gopeed-$version-qnap-arm64.qpkg">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td rowspan="8">🌐 Web</td>
|
|
||||||
<td rowspan="3"><code>Windows</code></td>
|
|
||||||
<td>amd64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=gopeed-web-$version-windows-amd64.zip">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>arm64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=gopeed-web-$version-windows-arm64.zip">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>386</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=gopeed-web-$version-windows-386.zip">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td rowspan="2"><code>MacOS</code></td>
|
|
||||||
<td>amd64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=gopeed-web-$version-macos-amd64.zip">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>arm64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=gopeed-web-$version-macos-arm64.zip">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td rowspan="3"><code>Linux</code></td>
|
|
||||||
<td>amd64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=gopeed-web-$version-linux-amd64.zip">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>arm64</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=gopeed-web-$version-linux-arm64.zip">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>386</td>
|
|
||||||
<td><a href="https://gopeed.com/api/download?tpl=gopeed-web-$version-linux-386.zip">📥</a></td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
更多關於安裝的內容請參考[安裝文檔](https://docs.gopeed.com/zh/install.html)
|
Gopeed 2.0.0 目前處於公開 Beta 測試階段,引入了全新介面、透過 FFI 直連 Go 核心的原生通訊架構、更一致的跨平台體驗、更完善的任務管理、更靈活的 API,以及透過 MCP 串接 AI Agent 的能力。部分功能仍可能不夠完善或穩定,歡迎搶先體驗並向我們回報問題。
|
||||||
|
|
||||||
|
- [下載 Gopeed 2.0.0 Beta 3](https://github.com/GopeedLab/gopeed/releases/tag/v2.0.0-beta.3)
|
||||||
|
|
||||||
|
當功能完整度與穩定性達到正式發布標準後,我們會發布 Gopeed 2.0.0 正式版。已安裝 Beta 版本的使用者可以直接升級至最終正式版,現有穩定版使用者則不會被自動切換至 Beta 頻道。
|
||||||
|
|
||||||
|
### 正式穩定版
|
||||||
|
|
||||||
|
- [官方網站下載](https://gopeed.com)
|
||||||
|
- [GitHub Releases](https://github.com/GopeedLab/gopeed/releases/latest)
|
||||||
|
|
||||||
### 🛠️ 使用 CLI 安裝
|
### 🛠️ 使用 CLI 安裝
|
||||||
|
|
||||||
@@ -175,11 +88,7 @@ go install github.com/GopeedLab/gopeed/cmd/gopeed@latest
|
|||||||
|
|
||||||
## 💝 贊助
|
## 💝 贊助
|
||||||
|
|
||||||
如果你認為該項目對你有所幫助,請考慮[贊助](https://docs.gopeed.com/zh/donate)以支持該項目的持續發展,謝謝!
|
如果你認為該項目對你有所幫助,請考慮[贊助](https://gopeed.com/docs/donate)以支持該項目的持續發展,謝謝!
|
||||||
|
|
||||||
## 🖼️ 軟體介面
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## 👨💻 開發
|
## 👨💻 開發
|
||||||
|
|
||||||
@@ -189,8 +98,8 @@ go install github.com/GopeedLab/gopeed/cmd/gopeed@latest
|
|||||||
|
|
||||||
### 🌍 開發環境
|
### 🌍 開發環境
|
||||||
|
|
||||||
1. Golang 1.23+
|
1. Golang 1.25+
|
||||||
2. Flutter 3.24+
|
2. Flutter 3.41+
|
||||||
|
|
||||||
### 📋 克隆項目
|
### 📋 克隆項目
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 51 KiB |
@@ -0,0 +1,54 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 400" width="1200" height="400">
|
||||||
|
<rect width="1200" height="400" fill="#040605"/>
|
||||||
|
<g fill="#5dc76c">
|
||||||
|
<rect x="-100" y="50" width="150" height="2" opacity="0.6">
|
||||||
|
<animate attributeName="x" from="-200" to="1300" dur="0.8s" repeatCount="indefinite"/>
|
||||||
|
</rect>
|
||||||
|
<rect x="-200" y="150" width="200" height="1" opacity="0.4">
|
||||||
|
<animate attributeName="x" from="-300" to="1300" dur="1.2s" repeatCount="indefinite"/>
|
||||||
|
</rect>
|
||||||
|
<rect x="-50" y="250" width="180" height="3" opacity="0.8">
|
||||||
|
<animate attributeName="x" from="-200" to="1300" dur="0.6s" repeatCount="indefinite"/>
|
||||||
|
</rect>
|
||||||
|
<rect x="-150" y="350" width="220" height="2" opacity="0.5">
|
||||||
|
<animate attributeName="x" from="-300" to="1300" dur="1s" repeatCount="indefinite"/>
|
||||||
|
</rect>
|
||||||
|
<rect x="-100" y="100" width="100" height="1" opacity="0.7">
|
||||||
|
<animate attributeName="x" from="-150" to="1300" dur="0.9s" repeatCount="indefinite"/>
|
||||||
|
</rect>
|
||||||
|
<rect x="-250" y="300" width="250" height="2" opacity="0.3">
|
||||||
|
<animate attributeName="x" from="-400" to="1300" dur="1.5s" repeatCount="indefinite"/>
|
||||||
|
</rect>
|
||||||
|
</g>
|
||||||
|
<defs>
|
||||||
|
<filter id="logoGlow" x="-50%" y="-50%" width="200%" height="200%">
|
||||||
|
<feGaussianBlur stdDeviation="12" result="blur" />
|
||||||
|
<feComposite in="SourceGraphic" in2="blur" operator="over" />
|
||||||
|
</filter>
|
||||||
|
</defs>
|
||||||
|
<g transform="translate(600, 160)">
|
||||||
|
<!-- Floating animation -->
|
||||||
|
<g>
|
||||||
|
<animateTransform attributeName="transform" type="translate" values="0,-8; 0,8; 0,-8" dur="3s" repeatCount="indefinite" />
|
||||||
|
|
||||||
|
<!-- Pulsing glow behind logo -->
|
||||||
|
<circle cx="0" cy="0" r="45" fill="#5dc76c" filter="url(#logoGlow)" opacity="0.3">
|
||||||
|
<animate attributeName="opacity" values="0.1; 0.6; 0.1" dur="2s" repeatCount="indefinite" />
|
||||||
|
<animate attributeName="r" values="40; 65; 40" dur="2s" repeatCount="indefinite" />
|
||||||
|
</circle>
|
||||||
|
|
||||||
|
<!-- Breathing scale animation -->
|
||||||
|
<g>
|
||||||
|
<animateTransform attributeName="transform" type="scale" values="0.95; 1.05; 0.95" dur="2s" repeatCount="indefinite" />
|
||||||
|
<g transform="scale(0.12) translate(-512, -512)">
|
||||||
|
<path style="opacity:0.998" fill="#5dc76c" d="M 951.5,763.5 C 940.739,755.276 929.405,747.776 917.5,741C 908.477,736.319 899.143,732.485 889.5,729.5C 885.844,625.779 840.844,545.613 754.5,489C 674.802,441.453 590.135,430.12 500.5,455C 419.755,480.605 359.588,530.771 320,605.5C 278.585,565.816 230.752,555.649 176.5,575C 131.948,594.935 106.448,629.102 100,677.5C 99.3333,685.833 99.3333,694.167 100,702.5C 102.081,714.824 105.081,726.824 109,738.5C 95.4882,745.492 82.9882,753.826 71.5,763.5C 37.7121,705.639 16.5454,643.306 8,576.5C -9.41698,416.759 35.9164,278.093 144,160.5C 244.661,58.2827 367.161,5.94939 511.5,3.5C 678.975,7.48829 814.142,74.8216 917,205.5C 1011.33,336.426 1040,480.759 1003,638.5C 991.564,682.671 974.397,724.337 951.5,763.5 Z"/>
|
||||||
|
<path style="opacity:0.999" fill="#fefefe" d="M 951.5,763.5 C 949.28,768.272 946.78,772.938 944,777.5C 938.305,786.913 932.138,795.913 925.5,804.5C 915.954,796.888 905.288,791.055 893.5,787C 878.282,782.958 863.115,778.791 848,774.5C 854.013,716.891 841.346,663.891 810,615.5C 768.341,553.228 711.174,512.395 638.5,493C 560.311,479.566 490.311,497.566 428.5,547C 411.963,560.536 397.13,575.703 384,592.5C 366.745,616.923 348.911,640.923 330.5,664.5C 310.135,651.302 290.469,637.135 271.5,622C 238.448,602.307 206.782,604.307 176.5,628C 159.375,642.752 148.875,661.252 145,683.5C 143.968,692.716 144.968,701.716 148,710.5C 154.334,725.339 160.167,740.339 165.5,755.5C 138.118,764.688 114.451,779.688 94.5,800.5C 85.653,788.968 77.9863,776.635 71.5,763.5C 82.9882,753.826 95.4882,745.492 109,738.5C 105.081,726.824 102.081,714.824 100,702.5C 99.3333,694.167 99.3333,685.833 100,677.5C 106.448,629.102 131.948,594.935 176.5,575C 230.752,555.649 278.585,565.816 320,605.5C 359.588,530.771 419.755,480.605 500.5,455C 590.135,430.12 674.802,441.453 754.5,489C 840.844,545.613 885.844,625.779 889.5,729.5C 899.143,732.485 908.477,736.319 917.5,741C 929.405,747.776 940.739,755.276 951.5,763.5 Z"/>
|
||||||
|
<path style="opacity:0.998" fill="#5dc76c" d="M 925.5,804.5 C 850.791,908.608 750.791,975.775 625.5,1006C 609.308,1009.7 592.975,1012.53 576.5,1014.5C 615.708,969.938 655.042,925.438 694.5,881C 664.168,880.5 633.835,880.333 603.5,880.5C 603.5,811.167 603.5,741.833 603.5,672.5C 542.167,672.5 480.833,672.5 419.5,672.5C 419.5,741.5 419.5,810.5 419.5,879.5C 388.493,879.167 357.493,879.5 326.5,880.5C 326.624,881.107 326.957,881.44 327.5,881.5C 366.805,925.808 406.138,970.141 445.5,1014.5C 318.63,996.317 212.796,939.651 128,844.5C 115.85,830.525 104.683,815.859 94.5,800.5C 114.451,779.688 138.118,764.688 165.5,755.5C 160.167,740.339 154.334,725.339 148,710.5C 144.968,701.716 143.968,692.716 145,683.5C 148.875,661.252 159.375,642.752 176.5,628C 206.782,604.307 238.448,602.307 271.5,622C 290.469,637.135 310.135,651.302 330.5,664.5C 348.911,640.923 366.745,616.923 384,592.5C 397.13,575.703 411.963,560.536 428.5,547C 490.311,497.566 560.311,479.566 638.5,493C 711.174,512.395 768.341,553.228 810,615.5C 841.346,663.891 854.013,716.891 848,774.5C 863.115,778.791 878.282,782.958 893.5,787C 905.288,791.055 915.954,796.888 925.5,804.5 Z"/>
|
||||||
|
<path style="opacity:0.999" fill="#fefefe" d="M 576.5,1014.5 C 532.836,1019.82 489.169,1019.82 445.5,1014.5C 406.138,970.141 366.805,925.808 327.5,881.5C 358.167,880.833 388.833,880.167 419.5,879.5C 419.5,810.5 419.5,741.5 419.5,672.5C 480.833,672.5 542.167,672.5 603.5,672.5C 603.5,741.833 603.5,811.167 603.5,880.5C 633.835,880.333 664.168,880.5 694.5,881C 655.042,925.438 615.708,969.938 576.5,1014.5 Z"/>
|
||||||
|
<path style="opacity:1" fill="#ade2b5" d="M 419.5,879.5 C 388.833,880.167 358.167,880.833 327.5,881.5C 326.957,881.44 326.624,881.107 326.5,880.5C 357.493,879.5 388.493,879.167 419.5,879.5 Z"/>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<text x="600" y="300" font-family="sans-serif" font-size="72" font-style="italic" font-weight="900" text-anchor="middle" fill="#fff" letter-spacing="8">GOPEED</text>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 6.0 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 792 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 787 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 309 KiB After Width: | Height: | Size: 1.2 MiB |
@@ -0,0 +1,52 @@
|
|||||||
|
# Batch task creation
|
||||||
|
|
||||||
|
`POST /api/v1/tasks/batch` accepts ordinary and grouped batches:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"group": true,
|
||||||
|
"groupName": "album",
|
||||||
|
"opts": {"path": "/downloads"},
|
||||||
|
"reqs": [
|
||||||
|
{"rid": "resolved-resource-id", "opts": {"selectFiles": [1]}},
|
||||||
|
{"req": {"url": "https://example.com/cover.jpg"}}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Each member accepts `rid` or `req`. A nonempty `rid` takes priority and creates a
|
||||||
|
task from the cached resolve result. A member's `opts`, when present, replaces
|
||||||
|
batch `opts` as a whole; omitted fields do not inherit individual batch values.
|
||||||
|
Members without `opts` use batch `opts`. BT file selections use the indexes from
|
||||||
|
the resolve result. Requests without `rid` continue to work.
|
||||||
|
|
||||||
|
For groups, batch `opts.path` selects the parent directory. Members inheriting
|
||||||
|
batch options, or with an empty path, use the reserved group directory. Explicit
|
||||||
|
relative member paths are resolved under that directory; do not prefix them with
|
||||||
|
the batch parent path. For example, parent `downloads` and member path `nested`
|
||||||
|
place the member in `downloads/<group name>/nested`. Absolute paths under the
|
||||||
|
parent directory preserve their relative structure within the group. In ordinary
|
||||||
|
batches, an empty member path uses the configured default download directory.
|
||||||
|
|
||||||
|
All members are attempted. If at least one task is persisted, the response is
|
||||||
|
successful and contains the created task IDs. A task that fails to start after
|
||||||
|
being persisted is included; use the existing task controls to retry it.
|
||||||
|
Successful tasks are kept when other members fail. If every member fails, the
|
||||||
|
API returns an error and removes any newly reserved empty group and directory.
|
||||||
|
|
||||||
|
Both ordinary and grouped batches now return an object in `data`:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{"code": 0, "msg": "", "data": {"taskIds": ["task-1", "task-2"], "parentId": "group-id"}}
|
||||||
|
```
|
||||||
|
|
||||||
|
Ordinary batches omit `parentId`. **This replaces the former array response for
|
||||||
|
ordinary batches.** The outer `code`/`msg`/`data` envelope is unchanged. Clients
|
||||||
|
must read `data.taskIds`; there are no per-member results. A successful response
|
||||||
|
completes the batch, including partial success, so clients must not automatically
|
||||||
|
resubmit missing members.
|
||||||
|
|
||||||
|
With `group: true`, the server generates the group ID and reserves its directory.
|
||||||
|
Creation does not accept a client group ID or append to an existing group. Group
|
||||||
|
metadata remains available through the existing task list and detail responses;
|
||||||
|
`parentId` identifies membership for group operations.
|
||||||
+111
-1
@@ -1,8 +1,28 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
|
/*
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
typedef void (*TaskEventCallback)(char* payload);
|
||||||
|
|
||||||
|
typedef void (*InvokeResultCallback)(uint64_t request_id, int success, char* payload);
|
||||||
|
|
||||||
|
static void callTaskEventCallback(uintptr_t callback, char* payload) {
|
||||||
|
((TaskEventCallback)callback)(payload);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void callInvokeResultCallback(uintptr_t callback, uint64_t request_id, int success, char* payload) {
|
||||||
|
((InvokeResultCallback)callback)(request_id, success, payload);
|
||||||
|
}
|
||||||
|
*/
|
||||||
import "C"
|
import "C"
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"unsafe"
|
||||||
|
|
||||||
|
nativebridge "github.com/GopeedLab/gopeed/bind/native"
|
||||||
"github.com/GopeedLab/gopeed/pkg/rest"
|
"github.com/GopeedLab/gopeed/pkg/rest"
|
||||||
"github.com/GopeedLab/gopeed/pkg/rest/model"
|
"github.com/GopeedLab/gopeed/pkg/rest/model"
|
||||||
)
|
)
|
||||||
@@ -16,14 +36,104 @@ func Start(cfg *C.char) (int, *C.char) {
|
|||||||
return 0, C.CString(err.Error())
|
return 0, C.CString(err.Error())
|
||||||
}
|
}
|
||||||
config.ProductionMode = true
|
config.ProductionMode = true
|
||||||
|
config.NativeMode = true
|
||||||
|
applyWebViewProvider(&config)
|
||||||
realPort, err := rest.Start(&config)
|
realPort, err := rest.Start(&config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, C.CString(err.Error())
|
return 0, C.CString(err.Error())
|
||||||
}
|
}
|
||||||
|
nativebridge.ResumeInvokes()
|
||||||
return realPort, nil
|
return realPort, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//export Stop
|
//export Stop
|
||||||
func Stop() {
|
func Stop() {
|
||||||
rest.Stop()
|
nativebridge.Stop()
|
||||||
|
}
|
||||||
|
|
||||||
|
//export GetAPIServerState
|
||||||
|
func GetAPIServerState() *C.char {
|
||||||
|
return C.CString(apiServerResult(rest.GetAPIServerState()))
|
||||||
|
}
|
||||||
|
|
||||||
|
//export StartAPIServer
|
||||||
|
func StartAPIServer() *C.char {
|
||||||
|
return C.CString(apiServerResult(rest.StartAPIServer()))
|
||||||
|
}
|
||||||
|
|
||||||
|
//export StopAPIServer
|
||||||
|
func StopAPIServer() *C.char {
|
||||||
|
return C.CString(apiServerResult(rest.StopAPIServer()))
|
||||||
|
}
|
||||||
|
|
||||||
|
//export RestartAPIServer
|
||||||
|
func RestartAPIServer() *C.char {
|
||||||
|
return C.CString(apiServerResult(rest.RestartAPIServer()))
|
||||||
|
}
|
||||||
|
|
||||||
|
func apiServerResult(state *model.APIServerState, err error) string {
|
||||||
|
result := &model.APIServerOperationResult{State: state}
|
||||||
|
if err != nil {
|
||||||
|
result.Error = err.Error()
|
||||||
|
}
|
||||||
|
data, marshalErr := json.Marshal(result)
|
||||||
|
if marshalErr != nil {
|
||||||
|
return fmt.Sprintf(`{"state":null,"error":%q}`, marshalErr.Error())
|
||||||
|
}
|
||||||
|
return string(data)
|
||||||
|
}
|
||||||
|
|
||||||
|
//export InvokeAsync
|
||||||
|
func InvokeAsync(
|
||||||
|
method *C.char,
|
||||||
|
path *C.char,
|
||||||
|
query *C.char,
|
||||||
|
body *C.char,
|
||||||
|
requestID C.ulonglong,
|
||||||
|
callback C.uintptr_t,
|
||||||
|
) {
|
||||||
|
if callback == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
complete := func(result string, err error) {
|
||||||
|
success := C.int(1)
|
||||||
|
payload := result
|
||||||
|
if err != nil {
|
||||||
|
success = 0
|
||||||
|
payload = err.Error()
|
||||||
|
}
|
||||||
|
C.callInvokeResultCallback(
|
||||||
|
callback,
|
||||||
|
C.uint64_t(requestID),
|
||||||
|
success,
|
||||||
|
C.CString(payload),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
nativebridge.InvokeAsync(
|
||||||
|
C.GoString(method),
|
||||||
|
C.GoString(path),
|
||||||
|
C.GoString(query),
|
||||||
|
C.GoString(body),
|
||||||
|
complete,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
//export SubscribeTaskEvents
|
||||||
|
func SubscribeTaskEvents(mask C.ulonglong, callback C.uintptr_t) {
|
||||||
|
if mask == 0 || callback == 0 {
|
||||||
|
rest.SubscribeTaskEvents(0, nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
rest.SubscribeTaskEvents(uint64(mask), func(payload string) {
|
||||||
|
// Ownership crosses the asynchronous Dart callback boundary. Dart frees
|
||||||
|
// this string with FreeCString after decoding it.
|
||||||
|
C.callTaskEventCallback(callback, C.CString(payload))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
//export FreeCString
|
||||||
|
func FreeCString(value *C.char) {
|
||||||
|
if value != nil {
|
||||||
|
C.free(unsafe.Pointer(value))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
//go:build darwin
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/GopeedLab/gopeed/internal/webview/rpcprovider"
|
||||||
|
enginewebview "github.com/GopeedLab/gopeed/pkg/download/engine/webview"
|
||||||
|
"github.com/GopeedLab/gopeed/pkg/rest/model"
|
||||||
|
)
|
||||||
|
|
||||||
|
func applyWebViewProvider(config *model.StartConfig) {
|
||||||
|
if config == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
config.WebViewProvider = newDesktopWebViewProvider(config.WebViewRPCConfig)
|
||||||
|
}
|
||||||
|
|
||||||
|
func newDesktopWebViewProvider(rpcCfg *enginewebview.RPCConfig) enginewebview.Provider {
|
||||||
|
if rpcCfg != nil && rpcCfg.Enabled() {
|
||||||
|
return rpcprovider.New(*rpcCfg)
|
||||||
|
}
|
||||||
|
return enginewebview.NewUnavailableProvider()
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
//go:build !darwin
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/GopeedLab/gopeed/internal/webview/goprovider"
|
||||||
|
"github.com/GopeedLab/gopeed/pkg/rest/model"
|
||||||
|
)
|
||||||
|
|
||||||
|
func applyWebViewProvider(config *model.StartConfig) {
|
||||||
|
if config == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
config.WebViewProvider = goprovider.New()
|
||||||
|
}
|
||||||
+84
-2
@@ -4,6 +4,10 @@ package libgopeed
|
|||||||
import "C"
|
import "C"
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
|
nativebridge "github.com/GopeedLab/gopeed/bind/native"
|
||||||
|
"github.com/GopeedLab/gopeed/internal/webview/rpcprovider"
|
||||||
|
goapi "github.com/GopeedLab/gopeed/pkg/api"
|
||||||
"github.com/GopeedLab/gopeed/pkg/rest"
|
"github.com/GopeedLab/gopeed/pkg/rest"
|
||||||
"github.com/GopeedLab/gopeed/pkg/rest/model"
|
"github.com/GopeedLab/gopeed/pkg/rest/model"
|
||||||
)
|
)
|
||||||
@@ -14,9 +18,87 @@ func Start(cfg string) (int, error) {
|
|||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
config.ProductionMode = true
|
config.ProductionMode = true
|
||||||
return rest.Start(&config)
|
config.NativeMode = true
|
||||||
|
applyWebViewProvider(&config)
|
||||||
|
port, err := rest.Start(&config)
|
||||||
|
if err == nil {
|
||||||
|
nativebridge.ResumeInvokes()
|
||||||
|
}
|
||||||
|
return port, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func Stop() {
|
func Stop() {
|
||||||
rest.Stop()
|
nativebridge.Stop()
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetAPIServerState() string {
|
||||||
|
return apiServerResult(rest.GetAPIServerState())
|
||||||
|
}
|
||||||
|
|
||||||
|
func StartAPIServer() string {
|
||||||
|
return apiServerResult(rest.StartAPIServer())
|
||||||
|
}
|
||||||
|
|
||||||
|
func StopAPIServer() string {
|
||||||
|
return apiServerResult(rest.StopAPIServer())
|
||||||
|
}
|
||||||
|
|
||||||
|
func RestartAPIServer() string {
|
||||||
|
return apiServerResult(rest.RestartAPIServer())
|
||||||
|
}
|
||||||
|
|
||||||
|
func apiServerResult(state *model.APIServerState, err error) string {
|
||||||
|
result := &model.APIServerOperationResult{State: state}
|
||||||
|
if err != nil {
|
||||||
|
result.Error = err.Error()
|
||||||
|
}
|
||||||
|
data, _ := json.Marshal(result)
|
||||||
|
return string(data)
|
||||||
|
}
|
||||||
|
|
||||||
|
type InvokeResultListener interface {
|
||||||
|
OnResult(requestID int64, success bool, payload string)
|
||||||
|
}
|
||||||
|
|
||||||
|
func InvokeAsync(method, path, query, body string, requestID int64, listener InvokeResultListener) {
|
||||||
|
if listener == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
nativebridge.InvokeAsync(method, path, query, body, func(result string, err error) {
|
||||||
|
if err != nil {
|
||||||
|
listener.OnResult(requestID, false, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
listener.OnResult(requestID, true, result)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
type TaskEventListener interface {
|
||||||
|
OnTaskEvent(payload string)
|
||||||
|
}
|
||||||
|
|
||||||
|
func SubscribeTaskEvents(mask int64, listener TaskEventListener) {
|
||||||
|
if mask == 0 || listener == nil {
|
||||||
|
rest.SubscribeTaskEvents(0, nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
rest.SubscribeTaskEvents(uint64(mask), listener.OnTaskEvent)
|
||||||
|
}
|
||||||
|
|
||||||
|
func applyWebViewProvider(config *model.StartConfig) {
|
||||||
|
if config == nil || config.WebViewRPCConfig == nil || !config.WebViewRPCConfig.Enabled() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
config.WebViewProvider = rpcprovider.New(*config.WebViewRPCConfig)
|
||||||
|
}
|
||||||
|
|
||||||
|
func LiveActivityTaskEventMask() int64 {
|
||||||
|
return int64(
|
||||||
|
goapi.TaskEventDone |
|
||||||
|
goapi.TaskEventError |
|
||||||
|
goapi.TaskEventStart |
|
||||||
|
goapi.TaskEventProgress |
|
||||||
|
goapi.TaskEventPause |
|
||||||
|
goapi.TaskEventDelete,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,240 @@
|
|||||||
|
// Package nativebridge contains transport-neutral behavior shared by the
|
||||||
|
// Desktop C FFI and gomobile bridge adapters.
|
||||||
|
package nativebridge
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"sync"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/GopeedLab/gopeed/pkg/rest"
|
||||||
|
)
|
||||||
|
|
||||||
|
// StopTimeout bounds native shutdown even when an in-process request never returns.
|
||||||
|
const StopTimeout = 3 * time.Second
|
||||||
|
|
||||||
|
var errNativeBridgeStopping = errors.New("native bridge is stopping")
|
||||||
|
|
||||||
|
type invokeRequest struct {
|
||||||
|
method string
|
||||||
|
path string
|
||||||
|
query string
|
||||||
|
body string
|
||||||
|
}
|
||||||
|
|
||||||
|
type invokeTask struct {
|
||||||
|
id uint64
|
||||||
|
request invokeRequest
|
||||||
|
complete func(result string, err error)
|
||||||
|
once sync.Once
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *invokeTask) finish(result string, err error) {
|
||||||
|
t.once.Do(func() {
|
||||||
|
completeCallback(t.complete, result, err)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// InvokeAsync starts an in-process API request and completes it through the
|
||||||
|
// supplied callback. Desktop and mobile adapters share this executor.
|
||||||
|
func InvokeAsync(method, path, query, body string, callback func(result string, err error)) {
|
||||||
|
if callback == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
task := invokeTask{
|
||||||
|
request: invokeRequest{
|
||||||
|
method: method,
|
||||||
|
path: path,
|
||||||
|
query: query,
|
||||||
|
body: body,
|
||||||
|
},
|
||||||
|
complete: callback,
|
||||||
|
}
|
||||||
|
if !getInvokeExecutor().submit(task) {
|
||||||
|
completeCallback(callback, "", errNativeBridgeStopping)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ResumeInvokes enables request submission after the native runtime starts.
|
||||||
|
func ResumeInvokes() {
|
||||||
|
getInvokeExecutor().resume()
|
||||||
|
}
|
||||||
|
|
||||||
|
// PauseInvokesAndWait prevents new submissions and gives running requests a
|
||||||
|
// bounded opportunity to finish before a native runtime is stopped.
|
||||||
|
// Requests still pending after StopTimeout are failed and detached so shutdown
|
||||||
|
// can continue without invoking their callbacks a second time.
|
||||||
|
func PauseInvokesAndWait() bool {
|
||||||
|
return getInvokeExecutor().pauseAndWait(StopTimeout)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stop pauses native requests and shuts down the shared runtime, but never
|
||||||
|
// keeps the host application waiting longer than StopTimeout. Cleanup that
|
||||||
|
// cannot finish within the deadline is allowed to continue in the background.
|
||||||
|
func Stop() {
|
||||||
|
stopWithin(getInvokeExecutor(), rest.Stop, StopTimeout)
|
||||||
|
}
|
||||||
|
|
||||||
|
func stopWithin(executor *invokeExecutor, cleanup func(), timeout time.Duration) {
|
||||||
|
deadline := time.Now().Add(timeout)
|
||||||
|
executor.pauseAndWait(time.Until(deadline))
|
||||||
|
|
||||||
|
stopped := make(chan struct{})
|
||||||
|
go func() {
|
||||||
|
defer close(stopped)
|
||||||
|
cleanup()
|
||||||
|
}()
|
||||||
|
|
||||||
|
remaining := time.Until(deadline)
|
||||||
|
if remaining <= 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
timer := time.NewTimer(remaining)
|
||||||
|
defer timer.Stop()
|
||||||
|
select {
|
||||||
|
case <-stopped:
|
||||||
|
case <-timer.C:
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
invokeExecutorOnce sync.Once
|
||||||
|
sharedInvoker *invokeExecutor
|
||||||
|
)
|
||||||
|
|
||||||
|
func getInvokeExecutor() *invokeExecutor {
|
||||||
|
invokeExecutorOnce.Do(func() {
|
||||||
|
sharedInvoker = newInvokeExecutor(func(request invokeRequest) string {
|
||||||
|
return rest.Dispatch(request.method, request.path, request.query, request.body)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
return sharedInvoker
|
||||||
|
}
|
||||||
|
|
||||||
|
// invokeExecutor starts every native API request in its own goroutine, matching
|
||||||
|
// net/http's request concurrency. It only tracks them to support bounded drain
|
||||||
|
// during shutdown; one stuck request must never prevent another from starting.
|
||||||
|
type invokeExecutor struct {
|
||||||
|
mu sync.Mutex
|
||||||
|
closed bool
|
||||||
|
accepting bool
|
||||||
|
nextID uint64
|
||||||
|
pending map[uint64]*invokeTask
|
||||||
|
drained chan struct{}
|
||||||
|
running sync.WaitGroup
|
||||||
|
handler func(invokeRequest) string
|
||||||
|
}
|
||||||
|
|
||||||
|
func newInvokeExecutor(handler func(invokeRequest) string) *invokeExecutor {
|
||||||
|
drained := make(chan struct{})
|
||||||
|
close(drained)
|
||||||
|
return &invokeExecutor{
|
||||||
|
handler: handler,
|
||||||
|
accepting: true,
|
||||||
|
pending: make(map[uint64]*invokeTask),
|
||||||
|
drained: drained,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *invokeExecutor) submit(task invokeTask) bool {
|
||||||
|
e.mu.Lock()
|
||||||
|
if e.closed || !e.accepting {
|
||||||
|
e.mu.Unlock()
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if len(e.pending) == 0 {
|
||||||
|
e.drained = make(chan struct{})
|
||||||
|
}
|
||||||
|
taskID := e.nextID
|
||||||
|
e.nextID++
|
||||||
|
task.id = taskID
|
||||||
|
taskPtr := &task
|
||||||
|
e.pending[taskID] = taskPtr
|
||||||
|
e.running.Add(1)
|
||||||
|
e.mu.Unlock()
|
||||||
|
|
||||||
|
go e.run(taskPtr)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *invokeExecutor) resume() {
|
||||||
|
e.mu.Lock()
|
||||||
|
e.accepting = true
|
||||||
|
e.mu.Unlock()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *invokeExecutor) pauseAndWait(timeout time.Duration) bool {
|
||||||
|
e.mu.Lock()
|
||||||
|
e.accepting = false
|
||||||
|
if len(e.pending) == 0 {
|
||||||
|
e.mu.Unlock()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
drained := e.drained
|
||||||
|
e.mu.Unlock()
|
||||||
|
|
||||||
|
timer := time.NewTimer(timeout)
|
||||||
|
defer timer.Stop()
|
||||||
|
select {
|
||||||
|
case <-drained:
|
||||||
|
return true
|
||||||
|
case <-timer.C:
|
||||||
|
}
|
||||||
|
|
||||||
|
e.mu.Lock()
|
||||||
|
if len(e.pending) == 0 {
|
||||||
|
e.mu.Unlock()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
pending := make([]*invokeTask, 0, len(e.pending))
|
||||||
|
for _, task := range e.pending {
|
||||||
|
pending = append(pending, task)
|
||||||
|
}
|
||||||
|
e.pending = make(map[uint64]*invokeTask)
|
||||||
|
close(e.drained)
|
||||||
|
e.mu.Unlock()
|
||||||
|
|
||||||
|
for _, task := range pending {
|
||||||
|
task.finish("", errNativeBridgeStopping)
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *invokeExecutor) close() {
|
||||||
|
e.mu.Lock()
|
||||||
|
e.closed = true
|
||||||
|
e.accepting = false
|
||||||
|
e.mu.Unlock()
|
||||||
|
e.running.Wait()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *invokeExecutor) run(task *invokeTask) {
|
||||||
|
defer e.running.Done()
|
||||||
|
result, err := e.execute(task.request)
|
||||||
|
task.finish(result, err)
|
||||||
|
e.mu.Lock()
|
||||||
|
if _, exists := e.pending[task.id]; exists {
|
||||||
|
delete(e.pending, task.id)
|
||||||
|
if len(e.pending) == 0 {
|
||||||
|
close(e.drained)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
e.mu.Unlock()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *invokeExecutor) execute(request invokeRequest) (result string, err error) {
|
||||||
|
defer func() {
|
||||||
|
if recovered := recover(); recovered != nil {
|
||||||
|
err = fmt.Errorf("invoke panic: %v", recovered)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
return e.handler(request), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func completeCallback(callback func(string, error), result string, err error) {
|
||||||
|
defer func() {
|
||||||
|
_ = recover()
|
||||||
|
}()
|
||||||
|
callback(result, err)
|
||||||
|
}
|
||||||
@@ -0,0 +1,258 @@
|
|||||||
|
package nativebridge
|
||||||
|
|
||||||
|
import (
|
||||||
|
"runtime"
|
||||||
|
"strconv"
|
||||||
|
"sync"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestInvokeExecutorStartsEveryRequestIndependently(t *testing.T) {
|
||||||
|
const taskCount = 64
|
||||||
|
release := make(chan struct{})
|
||||||
|
started := make(chan struct{}, taskCount)
|
||||||
|
executor := newInvokeExecutor(func(request invokeRequest) string {
|
||||||
|
started <- struct{}{}
|
||||||
|
<-release
|
||||||
|
return request.path
|
||||||
|
})
|
||||||
|
|
||||||
|
var completed sync.WaitGroup
|
||||||
|
completed.Add(taskCount)
|
||||||
|
for i := range taskCount {
|
||||||
|
accepted := executor.submit(invokeTask{
|
||||||
|
request: invokeRequest{path: strconv.Itoa(i)},
|
||||||
|
complete: func(string, error) {
|
||||||
|
completed.Done()
|
||||||
|
},
|
||||||
|
})
|
||||||
|
if !accepted {
|
||||||
|
t.Fatalf("request %d was rejected", i)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Every handler must start before any of them is released. A worker pool
|
||||||
|
// would stall here once all of its workers were occupied.
|
||||||
|
for range taskCount {
|
||||||
|
select {
|
||||||
|
case <-started:
|
||||||
|
case <-time.After(time.Second):
|
||||||
|
t.Fatal("a request waited behind other blocked requests")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
close(release)
|
||||||
|
completed.Wait()
|
||||||
|
executor.close()
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestInvokeExecutorConvertsPanicsToErrors(t *testing.T) {
|
||||||
|
executor := newInvokeExecutor(func(invokeRequest) string {
|
||||||
|
panic("boom")
|
||||||
|
})
|
||||||
|
completed := make(chan error, 1)
|
||||||
|
executor.submit(invokeTask{complete: func(_ string, err error) {
|
||||||
|
completed <- err
|
||||||
|
}})
|
||||||
|
select {
|
||||||
|
case err := <-completed:
|
||||||
|
if err == nil || err.Error() != "invoke panic: boom" {
|
||||||
|
t.Fatalf("unexpected error: %v", err)
|
||||||
|
}
|
||||||
|
case <-time.After(time.Second):
|
||||||
|
t.Fatal("panic result was not completed")
|
||||||
|
}
|
||||||
|
executor.close()
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestInvokeExecutorSurvivesCallbackPanic(t *testing.T) {
|
||||||
|
executor := newInvokeExecutor(func(request invokeRequest) string {
|
||||||
|
return request.path
|
||||||
|
})
|
||||||
|
executor.submit(invokeTask{complete: func(string, error) {
|
||||||
|
panic("callback failed")
|
||||||
|
}})
|
||||||
|
|
||||||
|
completed := make(chan string, 1)
|
||||||
|
executor.submit(invokeTask{
|
||||||
|
request: invokeRequest{path: "next"},
|
||||||
|
complete: func(result string, _ error) {
|
||||||
|
completed <- result
|
||||||
|
},
|
||||||
|
})
|
||||||
|
select {
|
||||||
|
case result := <-completed:
|
||||||
|
if result != "next" {
|
||||||
|
t.Fatalf("unexpected result: %q", result)
|
||||||
|
}
|
||||||
|
case <-time.After(time.Second):
|
||||||
|
t.Fatal("worker stopped after callback panic")
|
||||||
|
}
|
||||||
|
executor.close()
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestInvokeExecutorPausesAndDrains(t *testing.T) {
|
||||||
|
release := make(chan struct{})
|
||||||
|
started := make(chan struct{})
|
||||||
|
executor := newInvokeExecutor(func(request invokeRequest) string {
|
||||||
|
if request.path == "running" {
|
||||||
|
close(started)
|
||||||
|
<-release
|
||||||
|
}
|
||||||
|
return request.path
|
||||||
|
})
|
||||||
|
completed := make(chan struct{})
|
||||||
|
if !executor.submit(invokeTask{
|
||||||
|
request: invokeRequest{path: "running"},
|
||||||
|
complete: func(string, error) {
|
||||||
|
close(completed)
|
||||||
|
},
|
||||||
|
}) {
|
||||||
|
t.Fatal("initial task was rejected")
|
||||||
|
}
|
||||||
|
<-started
|
||||||
|
|
||||||
|
drained := make(chan struct{})
|
||||||
|
go func() {
|
||||||
|
executor.pauseAndWait(time.Second)
|
||||||
|
close(drained)
|
||||||
|
}()
|
||||||
|
deadline := time.Now().Add(time.Second)
|
||||||
|
for {
|
||||||
|
executor.mu.Lock()
|
||||||
|
paused := !executor.accepting
|
||||||
|
executor.mu.Unlock()
|
||||||
|
if paused {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if time.Now().After(deadline) {
|
||||||
|
t.Fatal("executor did not pause")
|
||||||
|
}
|
||||||
|
runtime.Gosched()
|
||||||
|
}
|
||||||
|
select {
|
||||||
|
case <-drained:
|
||||||
|
t.Fatal("pause returned before the running request completed")
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
if executor.submit(invokeTask{}) {
|
||||||
|
t.Fatal("paused executor accepted a new request")
|
||||||
|
}
|
||||||
|
|
||||||
|
close(release)
|
||||||
|
<-completed
|
||||||
|
select {
|
||||||
|
case <-drained:
|
||||||
|
case <-time.After(time.Second):
|
||||||
|
t.Fatal("pause did not return after pending requests drained")
|
||||||
|
}
|
||||||
|
|
||||||
|
executor.resume()
|
||||||
|
resumed := make(chan struct{})
|
||||||
|
if !executor.submit(invokeTask{complete: func(string, error) {
|
||||||
|
close(resumed)
|
||||||
|
}}) {
|
||||||
|
t.Fatal("resumed executor rejected a request")
|
||||||
|
}
|
||||||
|
<-resumed
|
||||||
|
executor.close()
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestInvokeExecutorPauseTimesOutAndFailsPendingRequests(t *testing.T) {
|
||||||
|
release := make(chan struct{})
|
||||||
|
started := make(chan struct{})
|
||||||
|
executor := newInvokeExecutor(func(request invokeRequest) string {
|
||||||
|
started <- struct{}{}
|
||||||
|
<-release
|
||||||
|
return request.path
|
||||||
|
})
|
||||||
|
|
||||||
|
errors := make(chan error, 2)
|
||||||
|
for _, path := range []string{"first", "second"} {
|
||||||
|
if !executor.submit(invokeTask{
|
||||||
|
request: invokeRequest{path: path},
|
||||||
|
complete: func(_ string, err error) {
|
||||||
|
errors <- err
|
||||||
|
},
|
||||||
|
}) {
|
||||||
|
t.Fatalf("request %q was rejected", path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for range 2 {
|
||||||
|
<-started
|
||||||
|
}
|
||||||
|
|
||||||
|
const timeout = 30 * time.Millisecond
|
||||||
|
startedAt := time.Now()
|
||||||
|
if executor.pauseAndWait(timeout) {
|
||||||
|
t.Fatal("pause unexpectedly reported a complete drain")
|
||||||
|
}
|
||||||
|
if elapsed := time.Since(startedAt); elapsed < timeout || elapsed > 10*timeout {
|
||||||
|
t.Fatalf("pause returned after %s, want close to %s", elapsed, timeout)
|
||||||
|
}
|
||||||
|
for range 2 {
|
||||||
|
select {
|
||||||
|
case err := <-errors:
|
||||||
|
if err == nil || err.Error() != errNativeBridgeStopping.Error() {
|
||||||
|
t.Fatalf("unexpected timeout error: %v", err)
|
||||||
|
}
|
||||||
|
case <-time.After(time.Second):
|
||||||
|
t.Fatal("pending request was not failed after the timeout")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
close(release)
|
||||||
|
executor.close()
|
||||||
|
select {
|
||||||
|
case err := <-errors:
|
||||||
|
t.Fatalf("request callback ran more than once: %v", err)
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestStopWithinUsesOneDeadlineForRequestsAndCleanup(t *testing.T) {
|
||||||
|
releaseRequest := make(chan struct{})
|
||||||
|
requestStarted := make(chan struct{})
|
||||||
|
executor := newInvokeExecutor(func(invokeRequest) string {
|
||||||
|
close(requestStarted)
|
||||||
|
<-releaseRequest
|
||||||
|
return "done"
|
||||||
|
})
|
||||||
|
requestResult := make(chan error, 1)
|
||||||
|
executor.submit(invokeTask{complete: func(_ string, err error) {
|
||||||
|
requestResult <- err
|
||||||
|
}})
|
||||||
|
<-requestStarted
|
||||||
|
|
||||||
|
releaseCleanup := make(chan struct{})
|
||||||
|
cleanupStarted := make(chan struct{})
|
||||||
|
cleanup := func() {
|
||||||
|
close(cleanupStarted)
|
||||||
|
<-releaseCleanup
|
||||||
|
}
|
||||||
|
|
||||||
|
const timeout = 40 * time.Millisecond
|
||||||
|
startedAt := time.Now()
|
||||||
|
stopWithin(executor, cleanup, timeout)
|
||||||
|
if elapsed := time.Since(startedAt); elapsed < timeout || elapsed > 10*timeout {
|
||||||
|
t.Fatalf("stop returned after %s, want close to %s", elapsed, timeout)
|
||||||
|
}
|
||||||
|
select {
|
||||||
|
case <-cleanupStarted:
|
||||||
|
case <-time.After(time.Second):
|
||||||
|
t.Fatal("cleanup was not started after the request deadline")
|
||||||
|
}
|
||||||
|
select {
|
||||||
|
case err := <-requestResult:
|
||||||
|
if err == nil || err.Error() != errNativeBridgeStopping.Error() {
|
||||||
|
t.Fatalf("unexpected request result: %v", err)
|
||||||
|
}
|
||||||
|
case <-time.After(time.Second):
|
||||||
|
t.Fatal("timed-out request was not failed")
|
||||||
|
}
|
||||||
|
|
||||||
|
close(releaseRequest)
|
||||||
|
close(releaseCleanup)
|
||||||
|
executor.close()
|
||||||
|
}
|
||||||
+7
-1
@@ -1,6 +1,9 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/GopeedLab/gopeed/cmd"
|
"github.com/GopeedLab/gopeed/cmd"
|
||||||
"github.com/GopeedLab/gopeed/pkg/rest/model"
|
"github.com/GopeedLab/gopeed/pkg/rest/model"
|
||||||
)
|
)
|
||||||
@@ -13,5 +16,8 @@ func main() {
|
|||||||
Storage: model.StorageBolt,
|
Storage: model.StorageBolt,
|
||||||
WebEnable: true,
|
WebEnable: true,
|
||||||
}
|
}
|
||||||
cmd.Start(cfg)
|
if err := cmd.Start(cfg); err != nil {
|
||||||
|
fmt.Fprintln(os.Stderr, err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -10,6 +10,8 @@ type args struct {
|
|||||||
url string
|
url string
|
||||||
connections *int
|
connections *int
|
||||||
dir *string
|
dir *string
|
||||||
|
checksum *string
|
||||||
|
checksumAlgo *string
|
||||||
}
|
}
|
||||||
|
|
||||||
func parse() *args {
|
func parse() *args {
|
||||||
@@ -20,6 +22,8 @@ func parse() *args {
|
|||||||
var args args
|
var args args
|
||||||
args.connections = flag.Int("C", 16, "Concurrent connections.")
|
args.connections = flag.Int("C", 16, "Concurrent connections.")
|
||||||
args.dir = flag.String("D", dir, "Store directory.")
|
args.dir = flag.String("D", dir, "Store directory.")
|
||||||
|
args.checksum = flag.String("checksum", "", "Expected checksum hash (hex encoded).")
|
||||||
|
args.checksumAlgo = flag.String("checksum-algo", "md5", "Checksum algorithm: md5, sha1, or sha256.")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
t := flag.Args()
|
t := flag.Args()
|
||||||
if len(t) > 0 {
|
if len(t) > 0 {
|
||||||
|
|||||||
+19
-3
@@ -2,13 +2,14 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"github.com/GopeedLab/gopeed/internal/fetcher"
|
"github.com/GopeedLab/gopeed/internal/fetcher"
|
||||||
"github.com/GopeedLab/gopeed/pkg/base"
|
"github.com/GopeedLab/gopeed/pkg/base"
|
||||||
"github.com/GopeedLab/gopeed/pkg/download"
|
"github.com/GopeedLab/gopeed/pkg/download"
|
||||||
"github.com/GopeedLab/gopeed/pkg/protocol/http"
|
"github.com/GopeedLab/gopeed/pkg/protocol/http"
|
||||||
"github.com/GopeedLab/gopeed/pkg/util"
|
"github.com/GopeedLab/gopeed/pkg/util"
|
||||||
"strings"
|
|
||||||
"sync"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const progressWidth = 20
|
const progressWidth = 20
|
||||||
@@ -18,6 +19,18 @@ func main() {
|
|||||||
|
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
|
var checksumOpt *http.ChecksumOption
|
||||||
|
if args.checksum != nil && *args.checksum != "" {
|
||||||
|
algo := "md5"
|
||||||
|
if args.checksumAlgo != nil && *args.checksumAlgo != "" {
|
||||||
|
algo = *args.checksumAlgo
|
||||||
|
}
|
||||||
|
checksumOpt = &http.ChecksumOption{
|
||||||
|
Algorithm: algo,
|
||||||
|
Expected: *args.checksum,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_, err := download.Boot().
|
_, err := download.Boot().
|
||||||
URL(args.url).
|
URL(args.url).
|
||||||
Listener(func(event *download.Event) {
|
Listener(func(event *download.Event) {
|
||||||
@@ -43,7 +56,10 @@ func main() {
|
|||||||
}).
|
}).
|
||||||
Create(&base.Options{
|
Create(&base.Options{
|
||||||
Path: *args.dir,
|
Path: *args.dir,
|
||||||
Extra: http.OptsExtra{Connections: *args.connections},
|
Extra: http.OptsExtra{
|
||||||
|
Connections: *args.connections,
|
||||||
|
Checksum: checksumOpt,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
|||||||
+58
-20
@@ -60,43 +60,82 @@ func wakeup(hidden bool) error {
|
|||||||
return fmt.Errorf("start gopeed failed")
|
return fmt.Errorf("start gopeed failed")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// postToFlutter sends a POST request to Flutter RPC server
|
||||||
|
func postToFlutter(path string, body []byte, headers map[string]string, timeout time.Duration) (*http.Response, error) {
|
||||||
|
client := &http.Client{
|
||||||
|
Transport: &http.Transport{
|
||||||
|
DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) {
|
||||||
|
return Dial()
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Timeout: timeout,
|
||||||
|
}
|
||||||
|
req, err := http.NewRequest("POST", "http://127.0.0.1"+path, bytes.NewBuffer(body))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
req.Header.Set("Content-Type", "application/json")
|
||||||
|
for k, v := range headers {
|
||||||
|
req.Header.Set(k, v)
|
||||||
|
}
|
||||||
|
return client.Do(req)
|
||||||
|
}
|
||||||
|
|
||||||
var apiMap = map[string]func(message *Message) (data any, err error){
|
var apiMap = map[string]func(message *Message) (data any, err error){
|
||||||
"ping": func(message *Message) (data any, err error) {
|
"ping": func(message *Message) (data any, err error) {
|
||||||
return check()
|
return check()
|
||||||
},
|
},
|
||||||
|
"wakeup": func(message *Message) (data any, err error) {
|
||||||
|
silent := false
|
||||||
|
if v, ok := message.Meta["silent"]; ok {
|
||||||
|
silent, _ = v.(bool)
|
||||||
|
}
|
||||||
|
err = wakeup(silent)
|
||||||
|
return
|
||||||
|
},
|
||||||
"create": func(message *Message) (data any, err error) {
|
"create": func(message *Message) (data any, err error) {
|
||||||
buf, err := message.Params.MarshalJSON()
|
buf, err := message.Params.MarshalJSON()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
silent := false
|
// Task creation owns its presentation: silent requests stay in the
|
||||||
if v, ok := message.Meta["silent"]; ok {
|
// background, while non-silent requests open a dedicated create window.
|
||||||
silent, _ = v.(bool)
|
// Always bootstrap the main process hidden so it never flashes first.
|
||||||
}
|
if err := wakeup(true); err != nil {
|
||||||
|
|
||||||
if err := wakeup(silent); err != nil {
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
client := &http.Client{
|
headers := make(map[string]string)
|
||||||
Transport: &http.Transport{
|
if message.Meta != nil {
|
||||||
DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) {
|
metaJson, _ := json.Marshal(message.Meta)
|
||||||
return Dial()
|
headers["X-Gopeed-Host-Meta"] = string(metaJson)
|
||||||
},
|
|
||||||
},
|
|
||||||
Timeout: 10 * time.Second,
|
|
||||||
}
|
}
|
||||||
req, err := http.NewRequest("POST", "http://127.0.0.1/create", bytes.NewBuffer(buf))
|
_, err = postToFlutter("/create", buf, headers, 10*time.Second)
|
||||||
|
return
|
||||||
|
},
|
||||||
|
"forward": func(message *Message) (data any, err error) {
|
||||||
|
buf, err := message.Params.MarshalJSON()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if message.Meta != nil {
|
|
||||||
metaJson, _ := json.Marshal(message.Meta)
|
resp, err := postToFlutter("/forward", buf, nil, 60*time.Second)
|
||||||
req.Header.Set("X-Gopeed-Host-Meta", string(metaJson))
|
if err != nil {
|
||||||
}
|
|
||||||
_, err = client.Do(req)
|
|
||||||
return
|
return
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
respBody, err := io.ReadAll(resp.Body)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var respData map[string]json.RawMessage
|
||||||
|
if err := json.Unmarshal(respBody, &respData); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return respData, nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,7 +147,6 @@ func main() {
|
|||||||
var length uint32
|
var length uint32
|
||||||
if err := binary.Read(os.Stdin, binary.NativeEndian, &length); err != nil {
|
if err := binary.Read(os.Stdin, binary.NativeEndian, &length); err != nil {
|
||||||
if err == io.EOF {
|
if err == io.EOF {
|
||||||
// Connection closed by Chrome
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
sendError("Failed to read message length: " + err.Error())
|
sendError("Failed to read message length: " + err.Error())
|
||||||
|
|||||||
+14
-6
@@ -16,17 +16,18 @@ import (
|
|||||||
//go:embed banner.txt
|
//go:embed banner.txt
|
||||||
var banner string
|
var banner string
|
||||||
|
|
||||||
func Start(cfg *model.StartConfig) {
|
func Start(cfg *model.StartConfig) error {
|
||||||
fmt.Println(banner)
|
|
||||||
srv, listener, err := rest.BuildServer(cfg)
|
srv, listener, err := rest.BuildServer(cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
return err
|
||||||
}
|
}
|
||||||
|
fmt.Println(banner)
|
||||||
downloadCfg, err := rest.Downloader.GetConfig()
|
downloadCfg, err := rest.Downloader.GetConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
listener.Close()
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
if downloadCfg.FirstLoad {
|
if rest.Downloader.IsFirstLoad() {
|
||||||
// Set default download config
|
// Set default download config
|
||||||
if cfg.DownloadConfig != nil {
|
if cfg.DownloadConfig != nil {
|
||||||
cfg.DownloadConfig.Merge(downloadCfg)
|
cfg.DownloadConfig.Merge(downloadCfg)
|
||||||
@@ -51,13 +52,20 @@ func Start(cfg *model.StartConfig) {
|
|||||||
rest.Downloader.PutConfig(downloadCfg)
|
rest.Downloader.PutConfig(downloadCfg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The default download dir is resolved only after the core starts, so
|
||||||
|
// seed the built-in categories now that the dir is known. Init is
|
||||||
|
// idempotent and leaves an existing category list untouched.
|
||||||
|
downloadCfg.Init()
|
||||||
|
rest.Downloader.PutConfig(downloadCfg)
|
||||||
}
|
}
|
||||||
watchExit()
|
watchExit()
|
||||||
|
|
||||||
fmt.Printf("Server start success on http://%s\n", listener.Addr().String())
|
fmt.Printf("Server start success on http://%s\n", listener.Addr().String())
|
||||||
if err := srv.Serve(listener); err != nil && err != http.ErrServerClosed {
|
if err := srv.Serve(listener); err != nil && err != http.ErrServerClosed {
|
||||||
panic(err)
|
return err
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func watchExit() {
|
func watchExit() {
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package cmd
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/GopeedLab/gopeed/pkg/rest/model"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestStartInvalidWebAPITokenReturnsError(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
webAuth *model.WebAuth
|
||||||
|
}{
|
||||||
|
{name: "no credentials"},
|
||||||
|
{name: "missing username", webAuth: &model.WebAuth{Password: "secret"}},
|
||||||
|
{name: "missing password", webAuth: &model.WebAuth{Username: "gopeed"}},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
err := Start(&model.StartConfig{
|
||||||
|
WebEnable: true,
|
||||||
|
ApiToken: "test-token",
|
||||||
|
WebAuth: tt.webAuth,
|
||||||
|
})
|
||||||
|
if err == nil {
|
||||||
|
t.Fatal("Start() error = nil, want web authentication validation error")
|
||||||
|
}
|
||||||
|
if !strings.Contains(err.Error(), "web authentication username and password are required") {
|
||||||
|
t.Fatalf("Start() error = %q, want missing web authentication credentials", err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -37,15 +37,17 @@ func installByInstaller(killSignalChan chan<- any, packagePath, destDir string)
|
|||||||
}
|
}
|
||||||
defer reader.Close()
|
defer reader.Close()
|
||||||
|
|
||||||
// Find the installer file
|
|
||||||
var installerPath string
|
var installerPath string
|
||||||
for _, file := range reader.File {
|
for _, file := range reader.File {
|
||||||
|
cleanName := filepath.Clean(file.Name)
|
||||||
|
if strings.HasPrefix(cleanName, "..") || filepath.IsAbs(cleanName) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
if file.FileInfo().IsDir() {
|
if file.FileInfo().IsDir() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract file
|
path := filepath.Join(tempDir, cleanName)
|
||||||
path := filepath.Join(tempDir, file.Name)
|
|
||||||
|
|
||||||
if err := os.MkdirAll(filepath.Dir(path), os.ModePerm); err != nil {
|
if err := os.MkdirAll(filepath.Dir(path), os.ModePerm); err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -101,7 +103,11 @@ func installByPortable(killSignalChan chan<- any, packagePath, destDir string) e
|
|||||||
defer reader.Close()
|
defer reader.Close()
|
||||||
|
|
||||||
for _, file := range reader.File {
|
for _, file := range reader.File {
|
||||||
path := filepath.Join(destDir, file.Name)
|
cleanName := filepath.Clean(file.Name)
|
||||||
|
if strings.HasPrefix(cleanName, "..") || filepath.IsAbs(cleanName) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
path := filepath.Join(destDir, cleanName)
|
||||||
|
|
||||||
if file.FileInfo().IsDir() {
|
if file.FileInfo().IsDir() {
|
||||||
os.MkdirAll(path, file.Mode())
|
os.MkdirAll(path, file.Mode())
|
||||||
|
|||||||
+32
-10
@@ -13,11 +13,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type args struct {
|
type args struct {
|
||||||
|
TempDir *string `json:"tempDir"`
|
||||||
Address *string `json:"address"`
|
Address *string `json:"address"`
|
||||||
Port *int `json:"port"`
|
Port *int `json:"port"`
|
||||||
Username *string `json:"username"`
|
Username *string `json:"username"`
|
||||||
Password *string `json:"password"`
|
Password *string `json:"password"`
|
||||||
ApiToken *string `json:"apiToken"`
|
ApiToken *string `json:"apiToken"`
|
||||||
|
MCPEnable bool `json:"mcpEnable"`
|
||||||
StorageDir *string `json:"storageDir"`
|
StorageDir *string `json:"storageDir"`
|
||||||
WhiteDownloadDirs []string `json:"whiteDownloadDirs"`
|
WhiteDownloadDirs []string `json:"whiteDownloadDirs"`
|
||||||
// DownloadConfig when the first time to start the server, it will be configured as initial value
|
// DownloadConfig when the first time to start the server, it will be configured as initial value
|
||||||
@@ -43,13 +45,22 @@ func parse() *args {
|
|||||||
func loadCliArgs() *args {
|
func loadCliArgs() *args {
|
||||||
cfg := &args{}
|
cfg := &args{}
|
||||||
cfg.Address = flag.String("A", "0.0.0.0", "Bind Address")
|
cfg.Address = flag.String("A", "0.0.0.0", "Bind Address")
|
||||||
|
flag.StringVar(cfg.Address, "address", "0.0.0.0", "Bind Address")
|
||||||
cfg.Port = flag.Int("P", 9999, "Bind Port")
|
cfg.Port = flag.Int("P", 9999, "Bind Port")
|
||||||
|
flag.IntVar(cfg.Port, "port", 9999, "Bind Port")
|
||||||
cfg.Username = flag.String("u", "gopeed", "Web Authentication Username")
|
cfg.Username = flag.String("u", "gopeed", "Web Authentication Username")
|
||||||
|
flag.StringVar(cfg.Username, "username", "gopeed", "Web Authentication Username")
|
||||||
cfg.Password = flag.String("p", "", "Web Authentication Password, if no password is set, web authentication will not be enabled")
|
cfg.Password = flag.String("p", "", "Web Authentication Password, if no password is set, web authentication will not be enabled")
|
||||||
cfg.ApiToken = flag.String("T", "", "API token, it must be configured when using HTTP API in the case of enabling web authentication")
|
flag.StringVar(cfg.Password, "password", "", "Web Authentication Password, if no password is set, web authentication will not be enabled")
|
||||||
|
cfg.ApiToken = flag.String("T", "", "API token (requires web authentication with username and password)")
|
||||||
|
flag.StringVar(cfg.ApiToken, "api-token", "", "API token (requires web authentication with username and password)")
|
||||||
|
flag.BoolVar(&cfg.MCPEnable, "mcp-enable", false, "Enable MCP endpoint")
|
||||||
|
cfg.TempDir = flag.String("temp-dir", "", "Temporary directory (defaults to the OS temporary directory)")
|
||||||
cfg.StorageDir = flag.String("d", "", "Storage directory")
|
cfg.StorageDir = flag.String("d", "", "Storage directory")
|
||||||
whiteDownloadDirs := flag.String("w", "", "White download directories, comma-separated")
|
flag.StringVar(cfg.StorageDir, "storage-dir", "", "Storage directory")
|
||||||
|
whiteDownloadDirs := flag.String("white-download-dirs", "", "White download directories, comma-separated")
|
||||||
cfg.configPath = flag.String("c", "./config.json", "Config file path")
|
cfg.configPath = flag.String("c", "./config.json", "Config file path")
|
||||||
|
flag.StringVar(cfg.configPath, "config", "./config.json", "Config file path")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
// Parse white download directories from comma-separated string
|
// Parse white download directories from comma-separated string
|
||||||
@@ -68,21 +79,25 @@ func loadCliArgs() *args {
|
|||||||
func overrideWithCliArgs(cfg *args, cliConfig *args) {
|
func overrideWithCliArgs(cfg *args, cliConfig *args) {
|
||||||
flag.Visit(func(f *flag.Flag) {
|
flag.Visit(func(f *flag.Flag) {
|
||||||
switch f.Name {
|
switch f.Name {
|
||||||
case "A":
|
case "A", "address":
|
||||||
cfg.Address = cliConfig.Address
|
cfg.Address = cliConfig.Address
|
||||||
case "P":
|
case "P", "port":
|
||||||
cfg.Port = cliConfig.Port
|
cfg.Port = cliConfig.Port
|
||||||
case "u":
|
case "u", "username":
|
||||||
cfg.Username = cliConfig.Username
|
cfg.Username = cliConfig.Username
|
||||||
case "p":
|
case "p", "password":
|
||||||
cfg.Password = cliConfig.Password
|
cfg.Password = cliConfig.Password
|
||||||
case "T":
|
case "T", "api-token":
|
||||||
cfg.ApiToken = cliConfig.ApiToken
|
cfg.ApiToken = cliConfig.ApiToken
|
||||||
case "d":
|
case "mcp-enable":
|
||||||
|
cfg.MCPEnable = cliConfig.MCPEnable
|
||||||
|
case "temp-dir":
|
||||||
|
cfg.TempDir = cliConfig.TempDir
|
||||||
|
case "d", "storage-dir":
|
||||||
cfg.StorageDir = cliConfig.StorageDir
|
cfg.StorageDir = cliConfig.StorageDir
|
||||||
case "w":
|
case "white-download-dirs":
|
||||||
cfg.WhiteDownloadDirs = cliConfig.WhiteDownloadDirs
|
cfg.WhiteDownloadDirs = cliConfig.WhiteDownloadDirs
|
||||||
case "c":
|
case "c", "config":
|
||||||
cfg.configPath = cliConfig.configPath
|
cfg.configPath = cliConfig.configPath
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -90,6 +105,9 @@ func overrideWithCliArgs(cfg *args, cliConfig *args) {
|
|||||||
|
|
||||||
// setDefaults sets default values for any unset configuration fields
|
// setDefaults sets default values for any unset configuration fields
|
||||||
func setDefaults(cfg *args, cliConfig *args) {
|
func setDefaults(cfg *args, cliConfig *args) {
|
||||||
|
if cfg.TempDir == nil {
|
||||||
|
cfg.TempDir = cliConfig.TempDir
|
||||||
|
}
|
||||||
if cfg.Address == nil {
|
if cfg.Address == nil {
|
||||||
cfg.Address = cliConfig.Address
|
cfg.Address = cliConfig.Address
|
||||||
}
|
}
|
||||||
@@ -194,6 +212,10 @@ func loadEnvVars(cfg *args) {
|
|||||||
}
|
}
|
||||||
field.Set(reflect.ValueOf(dirs))
|
field.Set(reflect.ValueOf(dirs))
|
||||||
}
|
}
|
||||||
|
} else if field.Kind() == reflect.Bool {
|
||||||
|
if boolVal, err := strconv.ParseBool(envValue); err == nil {
|
||||||
|
field.SetBool(boolVal)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+85
-18
@@ -1,7 +1,9 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
@@ -10,6 +12,50 @@ import (
|
|||||||
"github.com/GopeedLab/gopeed/pkg/base"
|
"github.com/GopeedLab/gopeed/pkg/base"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func TestLoadCliArgsLongNames(t *testing.T) {
|
||||||
|
originalCommandLine := flag.CommandLine
|
||||||
|
originalArgs := os.Args
|
||||||
|
t.Cleanup(func() {
|
||||||
|
flag.CommandLine = originalCommandLine
|
||||||
|
os.Args = originalArgs
|
||||||
|
})
|
||||||
|
|
||||||
|
flags := flag.NewFlagSet("gopeed-web-test", flag.ContinueOnError)
|
||||||
|
flags.SetOutput(io.Discard)
|
||||||
|
flag.CommandLine = flags
|
||||||
|
os.Args = []string{
|
||||||
|
"gopeed-web",
|
||||||
|
"--address", "127.0.0.2",
|
||||||
|
"--port", "8080",
|
||||||
|
"--username", "admin",
|
||||||
|
"--password", "password",
|
||||||
|
"--api-token", "token",
|
||||||
|
"--mcp-enable",
|
||||||
|
"--storage-dir", "/tmp/gopeed",
|
||||||
|
"--white-download-dirs", "/tmp/one,/tmp/two",
|
||||||
|
"--config", "/tmp/gopeed.json",
|
||||||
|
}
|
||||||
|
|
||||||
|
cfg := loadCliArgs()
|
||||||
|
if *cfg.Address != "127.0.0.2" || *cfg.Port != 8080 || *cfg.Username != "admin" ||
|
||||||
|
*cfg.Password != "password" || *cfg.ApiToken != "token" || !cfg.MCPEnable ||
|
||||||
|
*cfg.StorageDir != "/tmp/gopeed" || !reflect.DeepEqual(cfg.WhiteDownloadDirs, []string{"/tmp/one", "/tmp/two"}) ||
|
||||||
|
*cfg.configPath != "/tmp/gopeed.json" {
|
||||||
|
t.Fatalf("unexpected long-name CLI config: %+v", cfg)
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, name := range []string{"A", "P", "u", "p", "T", "d", "c"} {
|
||||||
|
if flags.Lookup(name) == nil {
|
||||||
|
t.Errorf("legacy short flag %q is missing", name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, name := range []string{"M", "w"} {
|
||||||
|
if flags.Lookup(name) != nil {
|
||||||
|
t.Errorf("new option unexpectedly has short flag %q", name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestSetDefaults(t *testing.T) {
|
func TestSetDefaults(t *testing.T) {
|
||||||
// Create mock CLI configuration with command line default values
|
// Create mock CLI configuration with command line default values
|
||||||
cliDefaults := &args{
|
cliDefaults := &args{
|
||||||
@@ -165,14 +211,15 @@ func TestOverrideWithCliArgs(t *testing.T) {
|
|||||||
t.Run("flag override documentation", func(t *testing.T) {
|
t.Run("flag override documentation", func(t *testing.T) {
|
||||||
// Document the expected behavior for each flag:
|
// Document the expected behavior for each flag:
|
||||||
flagBehaviors := map[string]string{
|
flagBehaviors := map[string]string{
|
||||||
"A": "Should override cfg.Address with cliConfig.Address",
|
"A/address": "Should override cfg.Address with cliConfig.Address",
|
||||||
"P": "Should override cfg.Port with cliConfig.Port",
|
"P/port": "Should override cfg.Port with cliConfig.Port",
|
||||||
"u": "Should override cfg.Username with cliConfig.Username",
|
"u/username": "Should override cfg.Username with cliConfig.Username",
|
||||||
"p": "Should override cfg.Password with cliConfig.Password",
|
"p/password": "Should override cfg.Password with cliConfig.Password",
|
||||||
"T": "Should override cfg.ApiToken with cliConfig.ApiToken",
|
"T/api-token": "Should override cfg.ApiToken with cliConfig.ApiToken",
|
||||||
"d": "Should override cfg.StorageDir with cliConfig.StorageDir",
|
"mcp-enable": "Should override cfg.MCPEnable with cliConfig.MCPEnable",
|
||||||
"w": "Should override cfg.WhiteDownloadDirs with cliConfig.WhiteDownloadDirs",
|
"d/storage-dir": "Should override cfg.StorageDir with cliConfig.StorageDir",
|
||||||
"c": "Should override cfg.configPath with cliConfig.configPath",
|
"white-download-dirs": "Should override cfg.WhiteDownloadDirs with cliConfig.WhiteDownloadDirs",
|
||||||
|
"c/config": "Should override cfg.configPath with cliConfig.configPath",
|
||||||
}
|
}
|
||||||
|
|
||||||
t.Log("Expected flag override behaviors:")
|
t.Log("Expected flag override behaviors:")
|
||||||
@@ -187,21 +234,23 @@ func TestOverrideWithCliArgs(t *testing.T) {
|
|||||||
mockFlagVisit := func(config *args, cliConfig *args, flagName string) {
|
mockFlagVisit := func(config *args, cliConfig *args, flagName string) {
|
||||||
// Simulate the switch statement in overrideWithCliArgs
|
// Simulate the switch statement in overrideWithCliArgs
|
||||||
switch flagName {
|
switch flagName {
|
||||||
case "A":
|
case "A", "address":
|
||||||
config.Address = cliConfig.Address
|
config.Address = cliConfig.Address
|
||||||
case "P":
|
case "P", "port":
|
||||||
config.Port = cliConfig.Port
|
config.Port = cliConfig.Port
|
||||||
case "u":
|
case "u", "username":
|
||||||
config.Username = cliConfig.Username
|
config.Username = cliConfig.Username
|
||||||
case "p":
|
case "p", "password":
|
||||||
config.Password = cliConfig.Password
|
config.Password = cliConfig.Password
|
||||||
case "T":
|
case "T", "api-token":
|
||||||
config.ApiToken = cliConfig.ApiToken
|
config.ApiToken = cliConfig.ApiToken
|
||||||
case "d":
|
case "mcp-enable":
|
||||||
|
config.MCPEnable = cliConfig.MCPEnable
|
||||||
|
case "d", "storage-dir":
|
||||||
config.StorageDir = cliConfig.StorageDir
|
config.StorageDir = cliConfig.StorageDir
|
||||||
case "w":
|
case "white-download-dirs":
|
||||||
config.WhiteDownloadDirs = cliConfig.WhiteDownloadDirs
|
config.WhiteDownloadDirs = cliConfig.WhiteDownloadDirs
|
||||||
case "c":
|
case "c", "config":
|
||||||
config.configPath = cliConfig.configPath
|
config.configPath = cliConfig.configPath
|
||||||
default:
|
default:
|
||||||
t.Errorf("Unknown flag: %s", flagName)
|
t.Errorf("Unknown flag: %s", flagName)
|
||||||
@@ -285,6 +334,20 @@ func TestOverrideWithCliArgs(t *testing.T) {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
flagName: "mcp-enable",
|
||||||
|
setupConfig: func() *args {
|
||||||
|
return &args{MCPEnable: false}
|
||||||
|
},
|
||||||
|
setupCliConfig: func() *args {
|
||||||
|
return &args{MCPEnable: true}
|
||||||
|
},
|
||||||
|
verify: func(t *testing.T, cfg *args) {
|
||||||
|
if !cfg.MCPEnable {
|
||||||
|
t.Error("MCPEnable flag override failed: got false, want true")
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
flagName: "d",
|
flagName: "d",
|
||||||
setupConfig: func() *args {
|
setupConfig: func() *args {
|
||||||
@@ -300,7 +363,7 @@ func TestOverrideWithCliArgs(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
flagName: "w",
|
flagName: "white-download-dirs",
|
||||||
setupConfig: func() *args {
|
setupConfig: func() *args {
|
||||||
return &args{WhiteDownloadDirs: []string{"/original/dir1", "/original/dir2"}}
|
return &args{WhiteDownloadDirs: []string{"/original/dir1", "/original/dir2"}}
|
||||||
},
|
},
|
||||||
@@ -402,6 +465,7 @@ func TestLoadConfigFile(t *testing.T) {
|
|||||||
"username": "testuser",
|
"username": "testuser",
|
||||||
"password": "testpass",
|
"password": "testpass",
|
||||||
"apiToken": "testtoken",
|
"apiToken": "testtoken",
|
||||||
|
"mcpEnable": true,
|
||||||
"storageDir": "/test/storage",
|
"storageDir": "/test/storage",
|
||||||
"downloadConfig": {
|
"downloadConfig": {
|
||||||
"downloadDir": "/test/downloads",
|
"downloadDir": "/test/downloads",
|
||||||
@@ -415,6 +479,7 @@ func TestLoadConfigFile(t *testing.T) {
|
|||||||
Username: stringPtr("testuser"),
|
Username: stringPtr("testuser"),
|
||||||
Password: stringPtr("testpass"),
|
Password: stringPtr("testpass"),
|
||||||
ApiToken: stringPtr("testtoken"),
|
ApiToken: stringPtr("testtoken"),
|
||||||
|
MCPEnable: true,
|
||||||
StorageDir: stringPtr("/test/storage"),
|
StorageDir: stringPtr("/test/storage"),
|
||||||
DownloadConfig: &base.DownloaderStoreConfig{
|
DownloadConfig: &base.DownloaderStoreConfig{
|
||||||
DownloadDir: "/test/downloads",
|
DownloadDir: "/test/downloads",
|
||||||
@@ -476,7 +541,7 @@ func TestLoadEnvVars(t *testing.T) {
|
|||||||
originalEnv := make(map[string]string)
|
originalEnv := make(map[string]string)
|
||||||
envKeys := []string{
|
envKeys := []string{
|
||||||
"GOPEED_ADDRESS", "GOPEED_PORT", "GOPEED_USERNAME",
|
"GOPEED_ADDRESS", "GOPEED_PORT", "GOPEED_USERNAME",
|
||||||
"GOPEED_PASSWORD", "GOPEED_APITOKEN", "GOPEED_STORAGEDIR",
|
"GOPEED_PASSWORD", "GOPEED_APITOKEN", "GOPEED_MCPENABLE", "GOPEED_STORAGEDIR",
|
||||||
"GOPEED_DOWNLOADCONFIG", "GOPEED_WHITEDOWNLOADDIRS",
|
"GOPEED_DOWNLOADCONFIG", "GOPEED_WHITEDOWNLOADDIRS",
|
||||||
}
|
}
|
||||||
for _, key := range envKeys {
|
for _, key := range envKeys {
|
||||||
@@ -508,6 +573,7 @@ func TestLoadEnvVars(t *testing.T) {
|
|||||||
"GOPEED_USERNAME": "envuser",
|
"GOPEED_USERNAME": "envuser",
|
||||||
"GOPEED_PASSWORD": "envpass",
|
"GOPEED_PASSWORD": "envpass",
|
||||||
"GOPEED_APITOKEN": "envtoken",
|
"GOPEED_APITOKEN": "envtoken",
|
||||||
|
"GOPEED_MCPENABLE": "true",
|
||||||
"GOPEED_STORAGEDIR": "/env/storage",
|
"GOPEED_STORAGEDIR": "/env/storage",
|
||||||
},
|
},
|
||||||
expected: &args{
|
expected: &args{
|
||||||
@@ -516,6 +582,7 @@ func TestLoadEnvVars(t *testing.T) {
|
|||||||
Username: stringPtr("envuser"),
|
Username: stringPtr("envuser"),
|
||||||
Password: stringPtr("envpass"),
|
Password: stringPtr("envpass"),
|
||||||
ApiToken: stringPtr("envtoken"),
|
ApiToken: stringPtr("envtoken"),
|
||||||
|
MCPEnable: true,
|
||||||
StorageDir: stringPtr("/env/storage"),
|
StorageDir: stringPtr("/env/storage"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
+10
-1
@@ -43,20 +43,29 @@ func main() {
|
|||||||
storageDir = filepath.Join(filepath.Dir(exe), "storage")
|
storageDir = filepath.Join(filepath.Dir(exe), "storage")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tempDir := ""
|
||||||
|
if args.TempDir != nil {
|
||||||
|
tempDir = *args.TempDir
|
||||||
|
}
|
||||||
cfg := &model.StartConfig{
|
cfg := &model.StartConfig{
|
||||||
Network: "tcp",
|
Network: "tcp",
|
||||||
Address: fmt.Sprintf("%s:%d", *args.Address, *args.Port),
|
Address: fmt.Sprintf("%s:%d", *args.Address, *args.Port),
|
||||||
Storage: model.StorageBolt,
|
Storage: model.StorageBolt,
|
||||||
StorageDir: storageDir,
|
StorageDir: storageDir,
|
||||||
|
TempDir: tempDir,
|
||||||
WhiteDownloadDirs: args.WhiteDownloadDirs,
|
WhiteDownloadDirs: args.WhiteDownloadDirs,
|
||||||
ApiToken: *args.ApiToken,
|
ApiToken: *args.ApiToken,
|
||||||
|
MCPEnable: args.MCPEnable,
|
||||||
DownloadConfig: args.DownloadConfig,
|
DownloadConfig: args.DownloadConfig,
|
||||||
ProductionMode: true,
|
ProductionMode: true,
|
||||||
WebEnable: true,
|
WebEnable: true,
|
||||||
WebFS: sub,
|
WebFS: sub,
|
||||||
WebAuth: webAuth,
|
WebAuth: webAuth,
|
||||||
}
|
}
|
||||||
cmd.Start(cfg)
|
if err := cmd.Start(cfg); err != nil {
|
||||||
|
fmt.Fprintln(os.Stderr, err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func isNotBlank(str *string) bool {
|
func isNotBlank(str *string) bool {
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
/testdata/extensions/
|
||||||
|
/bin/
|
||||||
|
__pycache__/
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
# moejs 实验评估
|
||||||
|
|
||||||
|
目标按顺序判断:**先能跑通 Gopeed 的真实扩展,再判断收益是否足够大,最后才考虑正式替换。**
|
||||||
|
|
||||||
|
这是独立 Go module。生产引擎、根目录依赖和默认构建不变。结论、实测数据及限制见 [REPORT.md](REPORT.md)。
|
||||||
|
|
||||||
|
## 复现
|
||||||
|
|
||||||
|
从本目录运行,需要 Git、Python 3 和 Go 1.26.0:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
python3 fetch_sources.py
|
||||||
|
go test -v -timeout 3m
|
||||||
|
# 可选:向 Bilibili / YouTube / Twitter 等公开接口发请求;不需要账户 Cookie。
|
||||||
|
GOPEED_MOEJS_LIVE=1 go test -run TestLiveResolve -v -timeout 4m
|
||||||
|
# 单独执行,期间避免其他构建/测试负载。
|
||||||
|
GOMAXPROCS=1 go test -pgo=off -run '^$' -bench . -benchmem -benchtime=500ms -count=5 -timeout 8m > results/bench.txt
|
||||||
|
python3 summarize.py
|
||||||
|
python3 measure_size.py
|
||||||
|
# macOS/Linux:独立进程的 CPU、峰值 RSS、存活堆和关闭后内存。默认 5 轮。
|
||||||
|
python3 measure_resources.py > results/resources-run.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
`fetch_sources.py` 只取固定提交的原始 `dist/index.js`,校验已记录的 SHA-256,不执行 npm 安装或构建。下载文件和二进制不入库。`results/sources.json` 是来源清单。
|
||||||
|
|
||||||
|
## 实验范围
|
||||||
|
|
||||||
|
- goja 基线调用真实的 `pkg/download/engine.NewEngine`。
|
||||||
|
- moejs 原型使用其 eventloop、Web API,加载 Gopeed 现有的 polyfill 和 XHR JS;保留 mutable builtins,与 goja 的默认语义接近。
|
||||||
|
- 三个完整扩展包执行 `onResolve`,两端逐字比较资源输出和请求路径;B 站包含 SDK/WBI 签名逻辑,YouTube 包含 YouTube.js 的元数据解析。
|
||||||
|
- `replay.js` 用固定的合成 HTTP 响应隔离网络波动;没有把 SDK 函数替换成假函数。YouTube 的 session/config 请求固定返回 503,走库的本地 session fallback,再提供 player JSON。
|
||||||
|
- Blob 注册、FFmpeg 和 WebView 为模拟宿主。FFmpeg 的 mock 会拒绝真正合并;WebView 只接受 UA 查询。`onStart/onError` 只验证 mock 宿主下的回调流程,**不代表下载或 SABR/PoToken 已验证**。
|
||||||
|
- `TestMoeResolveWriteback` 演示显式的 Go request 拷入、JS resource 拷出,并验证 Gopeed `Resource.Validate()`。真实任务的可变对象/方法还需专门移植。
|
||||||
|
- `TestAsyncHTTP` 使用本地 HTTP server,验证异步 JSON 和 AbortController 请求取消。
|
||||||
|
- `BenchmarkBufferedTransport` 在两个引擎中使用同一段 JS 的 buffered Response,检查速度差是否主要来自原生 Response/Stream 实现。
|
||||||
|
- `BenchmarkExtension/*/cold` 包含建引擎、polyfill、编译和加载完整 bundle、一次 resolve 及关闭;`warm` 复用已加载的 runtime。冷启动更接近当前 `doTrigger` 路径。
|
||||||
|
- `measure_resources.py` 为每个样本启动独立 worker,交替引擎顺序,以进程 user+system CPU 时间比较相同工作量;另测保留 1/8 个 runtime 的内存。解释与结果见 [RESOURCES.md](RESOURCES.md)。两个引擎都链接在同一个测量程序中,RSS 是原型 worker 的占用,不是最终 Gopeed 应用占用。
|
||||||
|
- `measure_size.py` 实测独立解释器程序和真实 CLI 的双引擎共存成本;没有伪造“已经完全替换”的安装包大小。CLI 构建可能临时补充本实验 module 的依赖,最后执行 tidy。
|
||||||
|
|
||||||
|
测试只覆盖本报告所列路径。未指定 `GOPEED_MOEJS_LIVE=1` 时,扩展回放不访问外网;固定 bundle 需要事先下载。
|
||||||
@@ -0,0 +1,128 @@
|
|||||||
|
# moejs 替换 goja 的实验评估
|
||||||
|
|
||||||
|
日期:2026-11-14。目标顺序:**真实扩展先跑通 → 判断实际收益 → 再决定是否正式替换**。
|
||||||
|
|
||||||
|
## 判断
|
||||||
|
|
||||||
|
**CPU/内存补测后,建议维持 goja,暂不投入完整替换。**
|
||||||
|
|
||||||
|
新增的 [CPU 与内存测量](RESOURCES.md) 表明:当前冷路径 B 站/YouTube 的实际 CPU 时间只降低约 12% / 15%,驻留内存没有一致改善,连续解析的进程峰值 RSS 还更高。结合迁移成本和包体结果,收益不足以推进替换。
|
||||||
|
|
||||||
|
三个真实扩展的完整 bundle 已在 moejs 中跑通离线解析和公开网站联网解析,结果与 goja 相同。热运行 CPU 收益明显;当前 Gopeed 的事件路径每次新建引擎、编译并加载 bundle,冷启动的收益远小于热运行倍数。压缩体积基本没有显著收益。
|
||||||
|
|
||||||
|
“扩展解析可运行”已验证。“真实下载、FFmpeg 合并、YouTube SABR/PoToken、WebView 和 Go 任务生命周期完整可用”尚未验证,不能把本实验当成这些路径已经兼容。
|
||||||
|
|
||||||
|
## 版本与方法
|
||||||
|
|
||||||
|
- Gopeed 基线:`be0a395447d788419e83acdfd693e48a1a1706bf`,分支基于该版 main。
|
||||||
|
- goja:`v0.0.0-20260106131823-651366fbe6e3`,沿用项目依赖。
|
||||||
|
- moejs:`v0.0.0-20261113160646-b2c7fed9c42d`,固定上游提交;纯 Go,当前主模块的 Go 1.26.0 足够。
|
||||||
|
- Apple M1、8 GiB RAM、macOS 14.6.1、Go 1.26.0;性能测试 `GOMAXPROCS=1`、`-pgo=off`、每项 500 ms、5 次重复,报告中位数。没有套用上游的 PGO 或上游插件跑分。
|
||||||
|
- 最终性能测量单独执行,未与本次构建或联网测试并发。记录在 [toolchain.txt](results/toolchain.txt)、[bench.txt](results/bench.txt)。`ns_min/ns_max` 见 [bench-summary.json](results/bench-summary.json)。这不是多机器统计结论。
|
||||||
|
- goja 使用生产 `engine.NewEngine`;moejs 使用其 eventloop/webapi 加 Gopeed 的 polyfill/XHR。两侧都运行未经改写的发布 bundle。moejs 使用 `MutableIntrinsics: true`,保留 goja 的可写 builtin 语义。
|
||||||
|
- 冷运行包含建引擎、宿主 JS 初始化、编译/加载 bundle、一次解析及关闭;热运行复用已加载 runtime。宿主初始化能力不完全对等:goja 含完整生产注入,moejs 尚未移植 File/VM/FFmpeg 等原生桥。**冷运行数字是两个现有原型的对比,不是完成生产移植后的承诺。**
|
||||||
|
- 回放提供合成 HTTP 响应,不替换 Bilibili SDK、YouTube.js 或 Twitter SDK。YouTube session/config 固定返回 503,验证本地 session fallback 与 player JSON 解析;未覆盖成功 config、真实 player decipher 或媒体流。
|
||||||
|
- 基准中 Gopeed namespace/task/Blob 等由相同 JS mock 提供,结果以 JSON 字符串导出用于比较;不包含完整 Go 对象桥接及持久化的成本,原型的 Resource 拷出另有功能验证,未纳入时延表。
|
||||||
|
- 每次结果包含文件名、URL、labels、请求路径,两端比较相同输出。额外使用相同 JS 的 buffered Response 再测热运行,降低原生 Response/Stream 差异的影响。
|
||||||
|
|
||||||
|
## 真实扩展验证
|
||||||
|
|
||||||
|
| 扩展 | 固定发布包提交 | bundle 大小 | 回放 / 联网解析 | 已验证的范围 |
|
||||||
|
| --- | --- | ---: | --- | --- |
|
||||||
|
| Bilibili | [`b91db1e`](https://github.com/monkeyWie/gopeed-extension-bilibili/tree/b91db1ea52e975d8de9823f01a7af5f9ea83792f) | 920,556 B | 两个引擎均成功,输出相同 | 真实 SDK/WBI 请求签名、3 分 P、画质选择、资源组装 |
|
||||||
|
| YouTube | [`eeb78d1`](https://github.com/monkeyWie/gopeed-extension-youtube/tree/eeb78d168e053e9a2aad1dbaa309fc11f6992f7c) | 3,409,614 B | 两个引擎均成功,输出相同 | 完整 YouTube.js bundle 初始化、公开视频 metadata/title、下载任务描述 |
|
||||||
|
| Twitter | [`a963428`](https://github.com/monkeyWie/gopeed-extension-twitter/tree/a963428bbfdbee9510bf224b00b384e37514ce77) | 66,243 B | 两个引擎均成功,输出相同 | guest token/GraphQL SDK 路径、图片和最高码率视频筛选 |
|
||||||
|
|
||||||
|
联网输入:B 站 `BV1BJ4m1e7g8?p=1-3`、YouTube `dQw4w9WgXcQ`、Twitter `1734145541599383880`。未使用账户 Cookie。B 站实际返回了 480p fallback,两个引擎一致。联网不是固定延迟源,不用单次耗时推导速度倍数。
|
||||||
|
|
||||||
|
`onStart/onError` 在同一个实验 runtime 的模拟 task/blob/webview 宿主下跑通;B 站 CDN 切换和 YouTube 重试注册能返回相同结果。**这不包含真正调用 Blob opener 或读取/合并媒体。** WebView 只模拟 `navigator.userAgent`,FFmpeg mock 遇到真实 merge 会报错,不会伪造下载成功。
|
||||||
|
|
||||||
|
另有两个直接宿主检查:moejs 的显式 Go request 拷入、resource 拷出经过 `base.Resource.Validate()`;本地 HTTP server 的异步 JSON 和取消请求在两侧均可完成。取消后 HTTP server 的请求 context 均结束。但原生产 goja fetch 的取消 catch 路径因 `DOMException` 未定义而返回 `ReferenceError`,moejs 返回传入的取消原因;这个已有宿主差异被单独记录,不能视为错误语义已完全兼容,详见 [http.txt](results/http.txt)。
|
||||||
|
|
||||||
|
原始证据:[compatibility.txt](results/compatibility.txt)、[live.txt](results/live.txt)、[sources.json](results/sources.json)。
|
||||||
|
|
||||||
|
## 性能实测
|
||||||
|
|
||||||
|
### 热解析与冷解析
|
||||||
|
|
||||||
|
| 扩展 | 热 goja / moejs (ms) | 热速度倍数 | 冷 goja / moejs (ms) | 冷耗时下降 |
|
||||||
|
| --- | ---: | ---: | ---: | ---: |
|
||||||
|
| bilibili | 21.188 / 3.389 | 6.25× | 118.861 / 104.827 | 11.8% |
|
||||||
|
| youtube | 3.193 / 0.277 | 11.54× | 283.412 / 239.646 | 15.4% |
|
||||||
|
| twitter | 3.575 / 0.505 | 7.08× | 17.239 / 11.849 | 31.3% |
|
||||||
|
|
||||||
|
### 相同 JS buffered Response 的对照
|
||||||
|
|
||||||
|
| 扩展 | goja (ms) | moejs (ms) | 速度倍数 | 每次分配 goja / moejs (KiB) |
|
||||||
|
| --- | ---: | ---: | ---: | ---: |
|
||||||
|
| bilibili | 22.076 | 3.528 | 6.26× | 8036.0 / 1267.2 |
|
||||||
|
| youtube | 2.895 | 0.290 | 10.00× | 1071.1 / 151.3 |
|
||||||
|
| twitter | 3.450 | 0.491 | 7.03× | 1527.4 / 238.3 |
|
||||||
|
|
||||||
|
更换为相同的 JS Response 后仍有 6–10 倍差距,说明收益并不只来自 moejs 的原生 Response/Stream。但 URL/Headers 等底层实现仍不同,因此它仍是完整运行时对照,不能宣称是严格隔离的解释器指令效率。
|
||||||
|
|
||||||
|
### 空 runtime 加一次 `1+1` 的对照
|
||||||
|
|
||||||
|
| 配置 | 耗时 (µs) | 每次分配 (KiB) |
|
||||||
|
| --- | ---: | ---: |
|
||||||
|
| goja | 2.85 | 5.1 |
|
||||||
|
| moejs-mutable | 48.42 | 103.6 |
|
||||||
|
| moejs-shared | 3.86 | 5.2 |
|
||||||
|
|
||||||
|
moejs 的 mutable runtime 创建在本机反而明显更贵。shared frozen 模式能降低这部分成本,但改变 builtin 的可变性;本报告没有把这项不同合同的优化算入默认迁移收益。上述项也包含编译小脚本,并非只测构造函数。
|
||||||
|
|
||||||
|
|
||||||
|
热运行的明显收益不能直接解释成“下载快了数倍”。本次固定 JSON 较小,没有大 playlist、真实 YouTube player JS、PoToken、SABR、账号登录或 FFmpeg 媒体吞吐的测量。`B/op` 是每次调用累计分配量,**不是常驻内存、峰值 RSS 或每个 runtime 的存活内存**。
|
||||||
|
|
||||||
|
当前 [`doTrigger`](../../pkg/download/extension.go) 在匹配每个事件后调用 `newExtensionEngine` 并执行 bundle;[`engineSession`](../../pkg/download/extension_engine_session.go) 为 Blob/WebView 保活,未提供已编译 bundle 的通用缓存。因此首个事件更接近 cold 项。即使热运行快很多,也不能套用同样倍数预测首次解析。未来可以单独比较“两引擎均缓存编译产物”,避免把缓存改进归因于换引擎。
|
||||||
|
|
||||||
|
## 构建体积
|
||||||
|
|
||||||
|
`CGO_ENABLED=0`、`-trimpath -pgo=off -ldflags='-s -w'`。gzip 使用 Python 默认 level 9、`mtime=0`。gzip 只是相同压缩算法的代理,不是 Flutter installer、APK、IPA 或最终 zip 的测量。
|
||||||
|
|
||||||
|
### 独立解释器程序
|
||||||
|
|
||||||
|
| 目标 | goja (MiB) | moejs (MiB) | 未压缩减少 (MiB) | gzip 减少 (KiB) |
|
||||||
|
| --- | ---: | ---: | ---: | ---: |
|
||||||
|
| darwin/arm64 | 8.86 | 7.74 | 1.12 | 36.0 |
|
||||||
|
| linux/amd64 | 9.14 | 8.06 | 1.07 | 13.0 |
|
||||||
|
| windows/amd64 | 9.36 | 8.30 | 1.07 | 9.9 |
|
||||||
|
| android/arm64 | 9.56 | 8.44 | 1.12 | 37.3 |
|
||||||
|
|
||||||
|
### 真实 Gopeed CLI(`nosqlite`)的双引擎过渡成本
|
||||||
|
|
||||||
|
| 目标 | 原生产 CLI (MiB) | 加入 moejs/webapi (MiB) | 未压缩增加 (MiB) | gzip 增加 (MiB) |
|
||||||
|
| --- | ---: | ---: | ---: | ---: |
|
||||||
|
| darwin/arm64 | 49.63 | 56.06 | 6.43 | 2.50 |
|
||||||
|
| linux/amd64 | 51.25 | 57.92 | 6.68 | 2.69 |
|
||||||
|
| windows/amd64 | 52.42 | 59.23 | 6.81 | 2.73 |
|
||||||
|
|
||||||
|
|
||||||
|
独立解释器程序支持从命令行传入任意 JS,避免 linker 把执行功能全部裁掉;它不含完整宿主能力。真实 CLI 的第二项通过构建 overlay 额外链接 moejs、eventloop、webapi,**仍然保留生产 goja,默认扩展执行仍走 goja**。这测的是双引擎过渡阶段成本,没有伪装成完整替换的成品。
|
||||||
|
|
||||||
|
结论:独立引擎未压缩可以少约 1.1 MiB,但压缩后只省十几到几十 KiB;没有证据表明换引擎能让最终安装包大幅变小。双引擎灰度还会增大包。完全移除 goja 后的 CLI、桌面 c-shared、Android/iOS 库和 Flutter 安装包必须等完整桥接完成后再测。本次 Android 只交叉编译独立解释器,不代表 APK/FFI 已验证。
|
||||||
|
|
||||||
|
原始证据:[size.json](results/size.json)、[size-build.txt](results/size-build.txt),构建脚本 [measure_size.py](measure_size.py)。
|
||||||
|
|
||||||
|
## 迁移阻塞与工作量
|
||||||
|
|
||||||
|
| 接入点 | 实测或代码事实 | 正式替换需要完成 |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| Go struct / map 语义 | goja 对 `ctx.res`、`ctx.req.url` 的修改写回 Go;moejs `FromGo` 是 JS 快照,Go 值不变;Go 方法也不会自动映射 | 显式对象/方法包装及写回策略,覆盖 req/task/meta/extra/settings/storage,验证引用与持久化语义 |
|
||||||
|
| 数字 labels | B 站给 labels 写数字;goja 自动转成 `map[string]string`,直接 JSON 拷出会报类型错 | 原型已做 string 规范化;生产要定义完整转换和错误策略 |
|
||||||
|
| 事件循环和取消 | `goja_nodejs` 与现有 `Post`、Promise/事件超时直接绑定;moejs 有不同的 loop/API | 对齐并发归属、超时、Close、pending Promise、回调错误、后台任务生命周期,迁移现有 cancellation 测试 |
|
||||||
|
| fetch/XHR/streams | XHR JS 可复用;本次 fetch 使用 moejs webapi;本地取消请求已验证 | 保留代理、默认 UA、headers、Cookie、stream backpressure、body ownership 和 session cleanup;跑现有 Fetch WPT/流测试于新宿主 |
|
||||||
|
| Blob/FFmpeg/WebView | 生产注入层大量引用 goja `Value`、`Object`、`FunctionCall` | 移植 Blob opener/reader、FFmpeg WASM、WebView 回调与函数源码序列化,验证取消/恢复/重试 |
|
||||||
|
| File/VM/MessageError/logging | 现有 Go 方法/错误和值导出不是 moejs 的直接替代 API | 建原生函数包装,保留 `MessageError` 分类、日志格式、File 行为与子 VM 隔离 |
|
||||||
|
| 可写 builtins | 三个回放也能在 frozen 模式运行,但修改 `Array.prototype` 会失败 | 默认保持 mutable;除非扩展能力合同允许冻结,不能把共享 builtin 的启动/内存优势直接作为默认收益 |
|
||||||
|
|
||||||
|
上游 [Go values in](https://github.com/MoeForge/moejs/blob/b2c7fed9c42dd1ba8ce5ea844850cba6a1a95fb3/docs/guide.md#go-values-in) 说明快照/方法转换规则;[runtime.go](https://github.com/MoeForge/moejs/blob/b2c7fed9c42dd1ba8ce5ea844850cba6a1a95fb3/runtime.go) 说明共享冻结 builtin 和 goroutine 约束;[README](https://github.com/MoeForge/moejs/blob/b2c7fed9c42dd1ba8ce5ea844850cba6a1a95fb3/README.md#status) 仍将项目标为 alpha、API 可能变化。要固定提交,不能把上游语言测试通过数当成 Gopeed 宿主兼容证明。分发需要随带上游 [THIRD_PARTY_NOTICES](https://github.com/MoeForge/moejs/blob/b2c7fed9c42dd1ba8ce5ea844850cba6a1a95fb3/THIRD_PARTY_NOTICES)。
|
||||||
|
|
||||||
|
## 后续替换门槛
|
||||||
|
|
||||||
|
1. 在实验构建中跑完整 Downloader → extension → Go task/resource → Blob/FFmpeg/WebView 路径,实测 B 站与 YouTube 下载输出文件、取消、断点恢复、重试;不再依赖本次模拟宿主。
|
||||||
|
2. 新引擎跑现有扩展、Fetch/Stream、WebView、FFmpeg、事件取消测试;验证无 pending promise、session 泄漏及并发访问错误。
|
||||||
|
3. 在实际每事件新建 runtime 的方式下比较总耗时、CPU、峰值/常驻内存和最终安装包;增加至少一台 Windows、一台 Android/iOS 目标以及真实大型 player/playlist。
|
||||||
|
4. 再决定冷路径与实际解析体验的提升是否足以抵消桥接成本。新增资源测量不支持在当前架构下继续完整移植;未来若有真实的长时间计算/环境复用场景,再重新评估。**最终包体和完整下载性能目前没有“大幅提升”的证据**。
|
||||||
|
|
||||||
|
本 PR 仅交付可复现的调研/原型,不切换默认引擎。生产 engine 原有测试通过,记录在 [production-engine-tests.txt](results/production-engine-tests.txt)。复现命令见 [README.md](README.md)。
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
# CPU 与内存补充测量
|
||||||
|
|
||||||
|
日期:2026-11-14。沿用 [主报告](REPORT.md) 的引擎版本、三个固定扩展包、回放输入和 M1 / Go 1.26.0 环境。
|
||||||
|
|
||||||
|
**建议维持 goja,暂不投入完整替换。** 在当前每次事件新建引擎、重新编译加载的方式下,B 站/YouTube 的 CPU 只减少约 12% / 15%,没有一致的内存优势;连续解析时峰值 RSS 更高。Twitter 的 CPU 降幅较大,但每次只省约 5 ms。这些收益不足以抵消完整宿主桥接、兼容性和维护成本。
|
||||||
|
|
||||||
|
## 测量方式
|
||||||
|
|
||||||
|
- 每个样本使用新的独立 OS 进程,两个引擎交替先后顺序,5 轮重复,报告中位数;最终数据共 120 个进程样本。测量时未与本次其他构建或测试并发。
|
||||||
|
- `GOMAXPROCS=1 GOGC=100 GOMEMLIMIT=off`,不使用 PGO。CPU 是 `getrusage(RUSAGE_SELF)` 的 **user + system 时间**,除以完成次数;包含 GC 和编译开销,不使用瞬时 CPU 占用百分比,也不把墙钟耗时直接当 CPU 时间。
|
||||||
|
- `cold`:一次进程内先预热一次全局初始化,再连续完成 20 次“新建环境、克隆 bundle 输入字符串、编译加载、解析、关闭”。接近当前反复触发扩展事件的方式。每次使用独立 bundle 字符串,模拟生产文件读取后的输入所有权。
|
||||||
|
- `warm`:环境已加载,连续解析 200 次。仅用于确认复用环境时的 CPU 上限;当前生产事件路径没有这样复用。
|
||||||
|
- 内存组不预建引擎,从相同测量程序基线开始,分别建立并保留 1 / 8 个完整环境,每个环境执行一次解析后保持存活。8 个环境是同时保留,不是同时并行执行;不模拟实际 Blob/FFmpeg 媒体数据。
|
||||||
|
- 存活堆:`runtime.MemStats.HeapAlloc` 相对建引擎前的增量。连续 GC 并给异步清理调度机会,至少 3 轮、最多 8 轮,直到相邻值差异小于 64 KiB;不稳定则测量失败。保留源字符串并用 `runtime.KeepAlive` 保证环境仍存活,避免编译器提前释放。
|
||||||
|
- RSS:通过 `ps` 记录当前物理驻留快照,通过 `getrusage` 记录进程历史峰值;macOS 的峰值单位为字节,Linux 转换为字节。`ps`、稳定 GC 和内存快照都在计时区间外,`RUSAGE_SELF` 不包括 sampler 子进程 CPU。
|
||||||
|
- 两个引擎链接在相同测量 worker 中,RSS 含公共 Go/测试框架/代码页和 allocator 保留页,**不是完整 Gopeed 应用或最终单引擎产品的内存预测**。存活堆增量用来区分扩展保留对象和进程历史峰值。
|
||||||
|
- 全部输出按 SHA-256 比较一致,没有通过减少文件或请求处理量获得更好的数字。宿主 mock、HTTP fixture、未移植能力及真实下载尚未验证等限制与主报告相同。
|
||||||
|
|
||||||
|
## 冷路径 CPU 与连续解析峰值
|
||||||
|
|
||||||
|
| 扩展 | goja CPU (ms/次) | moejs CPU (ms/次) | CPU 减少 | goja 峰值 RSS (MiB) | moejs 峰值 RSS (MiB) |
|
||||||
|
| --- | ---: | ---: | ---: | ---: | ---: |
|
||||||
|
| bilibili | 118.962 | 104.081 | 12.5% | 154.7 | 172.3 |
|
||||||
|
| youtube | 278.476 | 237.330 | 14.8% | 283.8 | 358.9 |
|
||||||
|
| twitter | 15.555 | 10.594 | 31.9% | 79.7 | 96.8 |
|
||||||
|
|
||||||
|
|
||||||
|
峰值是连续 20 次冷解析期间**整个 worker 的进程峰值**,不是单个 runtime 的堆大小。峰值会受 Go GC/allocator 与异步清理时机影响;不能将它当作关闭后仍存活的对象。原始数据保留每轮值,汇总文件也提供 min/max。
|
||||||
|
|
||||||
|
| 扩展 | goja 累计分配 (MiB/次) | moejs 累计分配 (MiB/次) | 分配减少 |
|
||||||
|
| --- | ---: | ---: | ---: |
|
||||||
|
| bilibili | 73.69 | 60.17 | 18.3% |
|
||||||
|
| youtube | 159.91 | 146.82 | 8.2% |
|
||||||
|
| twitter | 10.96 | 7.73 | 29.5% |
|
||||||
|
|
||||||
|
|
||||||
|
moejs 的累计分配量确实较少,但这没有转化为更低的连续解析峰值 RSS。`B/op`、GC 后存活堆、RSS 是不同指标,不能互相替代。
|
||||||
|
|
||||||
|
## 保留环境时的内存
|
||||||
|
|
||||||
|
| 扩展 | 保留环境数 | goja 存活堆增量 (MiB) | moejs 存活堆增量 (MiB) | goja RSS 快照 (MiB) | moejs RSS 快照 (MiB) |
|
||||||
|
| --- | ---: | ---: | ---: | ---: | ---: |
|
||||||
|
| bilibili | 1 | 15.87 | 15.66 | 114.2 | 111.2 |
|
||||||
|
| bilibili | 8 | 126.72 | 120.60 | 362.0 | 302.6 |
|
||||||
|
| youtube | 1 | 32.48 | 41.22 | 203.7 | 192.2 |
|
||||||
|
| youtube | 8 | 259.64 | 320.54 | 627.8 | 680.1 |
|
||||||
|
| twitter | 1 | 2.53 | 2.63 | 75.6 | 74.7 |
|
||||||
|
| twitter | 8 | 20.06 | 19.48 | 106.9 | 93.5 |
|
||||||
|
|
||||||
|
|
||||||
|
B 站一个环境的存活堆几乎没有变化;YouTube 反而更高。多环境情况下也没有稳定、普遍的显著节省。RSS 快照包含 allocator 页面,因此与存活堆的变化比例不同。
|
||||||
|
|
||||||
|
最初单次 GC 的 YouTube 堆快照约为 32.5 → 42.2 MiB。考虑 moejs 异步清理编译缓存后,已重测驻留组,表中使用稳定 GC 的结果,不能将初始 42.2 MiB 当成最终驻留值。CPU 和冷路径峰值取自第一次进程资源测量;这些计时和峰值发生在强制 GC 之前,不受驻留测量修正影响。
|
||||||
|
|
||||||
|
关闭全部环境并等稳定 GC 后,额外存活 Go 堆回落到 goja 约 0.03–0.05 MiB、moejs 约 0.18–0.97 MiB。这包含一次性进程缓存;本实验没有据此认定泄漏。RSS 不一定同步回落,不能只看关闭后的 RSS 判断对象是否已释放。
|
||||||
|
|
||||||
|
## 热路径 CPU
|
||||||
|
|
||||||
|
| 扩展 | goja CPU (ms/次) | moejs CPU (ms/次) | CPU 减少 |
|
||||||
|
| --- | ---: | ---: | ---: |
|
||||||
|
| bilibili | 19.688 | 3.173 | 83.9% |
|
||||||
|
| youtube | 2.905 | 0.215 | 92.6% |
|
||||||
|
| twitter | 3.265 | 0.453 | 86.1% |
|
||||||
|
|
||||||
|
|
||||||
|
热路径的大幅 CPU 节省再次成立。但它要求持有并复用已加载的环境;对当前每个事件重建环境的实现,应该采用上面的 cold 结果评估迁移。
|
||||||
|
|
||||||
|
## 决策
|
||||||
|
|
||||||
|
按当前扩展和架构,CPU/内存补测没有提供足够的替换依据。尤其 B 站和 YouTube 的 CPU 节省有限,内存没有一致改善,加上主报告里压缩体积几乎不变,应先维持 goja,把本 PR 留作调研记录。
|
||||||
|
|
||||||
|
未来若出现长时间执行计算、反复复用环境的真实扩展,再重新评估;若独立研究编译缓存或环境复用,必须同时在 goja 和 moejs 上比较收益,不能把架构优化全部归给引擎替换。
|
||||||
|
|
||||||
|
## 复现和证据
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cd experiments/moejs
|
||||||
|
python3 fetch_sources.py
|
||||||
|
python3 measure_resources.py > results/resources-run.txt
|
||||||
|
# 只重新汇总已保存的原始样本,不启动新测量
|
||||||
|
python3 measure_resources.py --summarize-only
|
||||||
|
# 必要时只重测驻留组,保留之前的 CPU 样本
|
||||||
|
python3 measure_resources.py --memory-only > results/resources-memory-run.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
原始样本:[resources.json](results/resources.json);汇总:[resources-summary.json](results/resources-summary.json)。首次资源运行日志:[resources-run.txt](results/resources-run.txt);稳定 GC 后重测驻留组日志:[resources-memory-run.txt](results/resources-memory-run.txt)。首次日志中的驻留组已被后者替代。当前 worker:[resource_worker_test.go](resource_worker_test.go);驱动:[measure_resources.py](measure_resources.py);功能检查:[resources-tests.txt](results/resources-tests.txt)。CPU/warm 组中单次 GC 的快照保留作原始记录,内存结论只使用重新测得的 `retained` 组。
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
package evaluation
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/GopeedLab/gopeed/pkg/base"
|
||||||
|
"github.com/MoeForge/moejs"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Demonstrate an explicit copy-in/copy-out resolve bridge, since FromGo does
|
||||||
|
// not provide goja's live Go-struct wrappers. Existing task wrappers still need
|
||||||
|
// native methods and lifecycle ownership before this can ship.
|
||||||
|
func TestMoeResolveWriteback(t *testing.T) {
|
||||||
|
r := setup(t, "moejs", "bilibili").(*Moe)
|
||||||
|
req := &base.Request{URL: "https://www.bilibili.com/video/BV1BJ4m1e7g8?p=2"}
|
||||||
|
done := make(chan error, 1)
|
||||||
|
if !r.loop.RunOnLoop(func(rt *moejs.Runtime) { done <- rt.SetGlobal("hostContext", map[string]any{"req": req}) }) {
|
||||||
|
t.Fatal("loop stopped")
|
||||||
|
}
|
||||||
|
if e := <-done; e != nil {
|
||||||
|
t.Fatal(e)
|
||||||
|
}
|
||||||
|
v, e := r.Eval(`(async()=>{await handlers.onResolve(hostContext);
|
||||||
|
// Goja coerces numeric JS label values into map[string]string. JSON does not.
|
||||||
|
for (const f of hostContext.res.files) {
|
||||||
|
if (f.req.labels) f.req.labels = Object.fromEntries(Object.entries(f.req.labels).map(([k,v])=>[k,String(v)]));
|
||||||
|
}
|
||||||
|
return JSON.stringify(hostContext.res)})()`)
|
||||||
|
if e != nil {
|
||||||
|
t.Fatal(e)
|
||||||
|
}
|
||||||
|
var res base.Resource
|
||||||
|
if e = json.Unmarshal([]byte(fmt.Sprint(v)), &res); e != nil {
|
||||||
|
t.Fatal(e)
|
||||||
|
}
|
||||||
|
if e = res.Validate(); e != nil {
|
||||||
|
t.Fatal(e)
|
||||||
|
}
|
||||||
|
if len(res.Files) != 1 || res.Files[0].Name != "BV1BJ4m1e7g8.真实扩展 Replay 测试(P2).1080p.mp4" {
|
||||||
|
t.Fatalf("unexpected resource: %+v", res)
|
||||||
|
}
|
||||||
|
t.Logf("Go Resource.Validate passed, name=%s", res.Files[0].Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestBufferedReplay(t *testing.T) {
|
||||||
|
for _, name := range []string{"bilibili", "youtube", "twitter"} {
|
||||||
|
t.Run(name, func(t *testing.T) {
|
||||||
|
var want any
|
||||||
|
for _, engine := range []string{"goja", "moejs"} {
|
||||||
|
t.Run(engine, func(t *testing.T) {
|
||||||
|
r := setup(t, engine, name)
|
||||||
|
v, e := r.Eval("Response = BufferedResponse; resolveOnce()")
|
||||||
|
if e != nil {
|
||||||
|
t.Fatal(e)
|
||||||
|
}
|
||||||
|
if engine == "goja" {
|
||||||
|
want = v
|
||||||
|
} else if v != want {
|
||||||
|
t.Fatalf("output differs: %v / %v", want, v)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
//go:build !moejs
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"github.com/dop251/goja"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
source := "1+1"
|
||||||
|
if len(os.Args) > 1 {
|
||||||
|
source = os.Args[1]
|
||||||
|
}
|
||||||
|
rt := goja.New()
|
||||||
|
v, e := rt.RunString(source)
|
||||||
|
if e != nil {
|
||||||
|
panic(e)
|
||||||
|
}
|
||||||
|
fmt.Println(v.Export())
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
//go:build moejs
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"github.com/MoeForge/moejs"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
source := "1+1"
|
||||||
|
if len(os.Args) > 1 {
|
||||||
|
source = os.Args[1]
|
||||||
|
}
|
||||||
|
rt := moejs.NewRuntime(moejs.Options{MutableIntrinsics: true})
|
||||||
|
script, e := moejs.CompileScript("size", source)
|
||||||
|
if e != nil {
|
||||||
|
panic(e)
|
||||||
|
}
|
||||||
|
v, e := rt.RunScript(script)
|
||||||
|
if e != nil {
|
||||||
|
panic(e)
|
||||||
|
}
|
||||||
|
out, e := rt.ToGo(v)
|
||||||
|
if e != nil {
|
||||||
|
panic(e)
|
||||||
|
}
|
||||||
|
fmt.Println(out)
|
||||||
|
}
|
||||||
Loaded 50 of 1240 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user