Compare commits

...

55 Commits

Author SHA1 Message Date
157c97ab56 fix(deps): update module github.com/meilisearch/meilisearch-go to v0.28.0 2024-08-21 17:09:51 +00:00
e21edf98e2 revert: 34b6785fab 2024-08-21 17:08:03 +00:00
d2514d236f feat(drivers): add kodbox storage (#7059 close #7058)
- kodbox: https://github.com/kalcaddle/kodbox
2024-08-22 00:46:38 +08:00
34b6785fab fix(deps): update module github.com/meilisearch/meilisearch-go to v0.28.0 (#7061)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-08-22 00:45:31 +08:00
48f50a2ceb fix(search): BuildIndex concurrency error (#7035) 2024-08-22 00:44:55 +08:00
74887922b4 fix(offline_download): os.create failure while the name of downloaded file is empty (#7041) 2024-08-22 00:44:23 +08:00
bcb24d61ea fix(deps): update module github.com/go-resty/resty/v2 to v2.14.0 (#6981)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-08-22 00:43:35 +08:00
db1494455d fix(deps): update module github.com/charmbracelet/bubbles to v0.19.0 (#7048)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-08-22 00:43:11 +08:00
d9a1809313 fix(deps): update module github.com/charmbracelet/lipgloss to v0.13.0 (#7049)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-08-22 00:42:50 +08:00
0715198c7f chore: fix log format typo (#7056)
Signed-off-by: cuishuang <imcusg@gmail.com>
2024-08-22 00:42:19 +08:00
ef5e192c3b fix(pikpak): webdav upload issue (#7050) 2024-08-22 00:35:52 +08:00
489b28bdf7 fix(pikpak_share): add captcha_token generation function (#7045) 2024-08-22 00:35:14 +08:00
18176c659c ci: add beta tag to newest docker image 2024-08-20 21:36:36 +08:00
4c48a816bf fix(deps): update module github.com/charmbracelet/bubbletea to v0.27.0 (#7025)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-08-19 23:30:26 +08:00
9af7aaab59 fix(deps): update github.com/city404/v6-public-rpc-proto/go digest to 90f8e24 (#7028)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-08-19 23:30:08 +08:00
a54a09314f fix(deps): update module github.com/aws/aws-sdk-go to v1.55.5 (#6813)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-08-19 23:29:45 +08:00
e2fcd73720 fix(deps): update module github.com/go-webauthn/webauthn to v0.11.1 (#6901)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-08-19 23:29:24 +08:00
e238b90836 fix(pikpak): modify the processing logic of CaptchaToken (#7024) 2024-08-18 23:26:29 +08:00
69e5b66b50 ci: use changelogithub to generate changelog 2024-08-18 13:57:44 +08:00
e8e6d71c41 ci: only one beta release action concurrency [skip ci] 2024-08-18 00:38:27 +08:00
4ba476e25c ci: build beta release 2024-08-18 00:25:16 +08:00
e5fe9ea5f6 ci: set changelog for beta release 2024-08-17 23:03:49 +08:00
e1906c9312 ci: only release on tag with v prefix 2024-08-17 22:08:29 +08:00
51c95ee117 fix: decode body if enable gzip (#7003) 2024-08-15 22:25:53 +08:00
Mmx
1f652e2e7d ci(docker): using docker build args instead of extra dockerfile for ffmpeg (#6989)
* build: using docker build arg to determine install ffmpeg or not

* ci: pass build-args to ffmpeg image build step
2024-08-15 21:48:48 +08:00
8e6c1aa78d fix(pikpak): refresh_token cannot be obtained (#7017) 2024-08-15 21:46:55 +08:00
6bff5b6107 fix(deps): update module golang.org/x/image to v0.19.0 (#6982)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-08-14 19:35:33 +08:00
Mmx
94937db491 feat(s3): using internal download method in proxy (#6988) 2024-08-14 19:34:48 +08:00
3dc250cc37 feat(115): update qrcode source list (#6996)
* remove mac, linux, window (disabled)
* add alipaymini, wechatmini, qandroid
2024-08-14 19:34:11 +08:00
9560799175 fix(189pc): InvalidSessionKey (#6994 close #6992) 2024-08-14 19:33:15 +08:00
8f3c5b1587 fix(deps): update module github.com/meilisearch/meilisearch-go to v0.27.2 (#6907)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-08-11 11:40:47 +08:00
285125d06a fix(deps): update module github.com/larksuite/oapi-sdk-go/v3 to v3.3.1 (#6978)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-08-11 11:40:26 +08:00
a26185fe05 fix(deps): update github.com/xhofe/go-cache digest to b1a7192 (#6939)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-08-11 11:40:05 +08:00
a7efa3a676 fix(deps): update golang.org/x/exp digest to 0cdaa3a (#6977)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-08-11 11:39:13 +08:00
d596ef5c38 fix(deps): update module github.com/blevesearch/bleve/v2 to v2.4.2 (#6892)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-08-11 11:38:56 +08:00
34e34ef564 fix(deps): update module golang.org/x/time to v0.6.0 (#6944)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-08-11 11:38:32 +08:00
8032d0afb6 fix(deps): update module golang.org/x/oauth2 to v0.22.0 (#6943)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-08-10 21:01:41 +08:00
d3bc8993ee fix(deps): update module github.com/dlclark/regexp2 to v1.11.4 (#6958)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-08-10 21:01:05 +08:00
62ed169a39 feat: add support for quark tv driver and uc tv driver (#6959) 2024-08-10 21:00:43 +08:00
979d0cfeee fix(chaoxing): upload to ChaoxingxingGroupCloud failed (#6953)
change the data type on deserializing json
2024-08-10 20:59:49 +08:00
29165d8e60 feat(115): add offline download tool (close #6888 in #6954) 2024-08-10 20:59:07 +08:00
2d77db6bc2 fix(halalcloud): fix the timeout issue when logging in (#6960) 2024-08-10 20:58:10 +08:00
74f8295960 feat: persistant Task (#6925 close #5313) 2024-08-07 12:16:21 +08:00
f2727095d9 fix(thunder_browser): fix space parameter not handled correctly in some cases & update some parameters (#6952) 2024-08-06 22:14:36 +08:00
d4285b7c6c fix(halalcloud): fix some custom fields not taking effect & update appID and appSecret (#6938) 2024-08-04 19:03:24 +08:00
2e4265a778 feat: deleting folders is not allowed (close #6933) 2024-08-04 18:28:35 +08:00
81258d3e8a feat: invalidate token on logout (#6923 close #6792) 2024-08-04 12:32:39 +08:00
a6bead90d7 feat: add support for lenovonas_share driver (#6921) 2024-08-04 12:28:19 +08:00
87caaf2459 fix: out of order when database is not sqlite3 (#6560) 2024-08-03 13:11:09 +08:00
af9c6afd25 feat: update alist-org/gofakes3 to v0.0.7 to support create folder in PutObject (#6880) 2024-07-27 20:06:05 +08:00
8b5727a0aa fix(deps): update golang.org/x/exp digest to 8a7402a (#6801)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-07-26 14:27:56 +08:00
aeae47c9bf fix(deps): update module github.com/larksuite/oapi-sdk-go/v3 to v3.3.0 (#6812)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-07-25 20:13:01 +08:00
1aff758688 fix(deps): update github.com/alist-org/times digest to efa0c7d (#6840)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-07-25 20:11:12 +08:00
4a42bc5083 fix(lanzou): not find file page param (#6862 close #6857)
* fix(lanzou):not find file page param

* fix(labzou): change lanzouo.com to lanzoui.com
2024-07-25 20:09:48 +08:00
5fa70e4010 perf(123pan): optimize rate limiting (#6859)
- eliminating fixed 200 ms delay in getFiles to prevent thread starvation
- allowing cancellation via context to mitigate potential DoS attacks by immediately cancelling excessive requests
2024-07-25 20:08:59 +08:00
87 changed files with 3051 additions and 736 deletions

88
.github/workflows/beta_release.yml vendored Normal file
View File

@ -0,0 +1,88 @@
name: beta release
on:
push:
branches: [ 'main' ]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
changelog:
strategy:
matrix:
platform: [ ubuntu-latest ]
go-version: [ '1.21' ]
name: Beta Release Changelog
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: changelog # or changelogithub@0.12 if ensure the stable result
id: changelog
run: |
git tag -l
npx changelogithub --output CHANGELOG.md
# npx changelogen@latest --output CHANGELOG.md
- name: Upload assets
uses: softprops/action-gh-release@v2
with:
body_path: CHANGELOG.md
files: CHANGELOG.md
prerelease: true
tag_name: beta
release:
needs:
- changelog
strategy:
matrix:
include:
- target: '!(*musl*|*windows-arm64*|*android*)' # xgo
hash: "md5"
- target: 'linux-*-musl*' #musl
hash: "md5-linux-musl"
- target: 'windows-arm64' #win-arm64
hash: "md5-windows-arm64"
- target: 'android-*' #android
hash: "md5-android"
name: Beta Release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.22'
- name: Setup web
run: bash build.sh dev web
- name: Build
id: test-action
uses: go-cross/cgo-actions@v1
with:
targets: ${{ matrix.target }}
musl-target-format: $os-$musl-$arch
out-dir: build
- name: Compress
run: |
bash build.sh zip ${{ matrix.hash }}
- name: Upload assets
uses: softprops/action-gh-release@v2
with:
files: build/compress/*
prerelease: true
tag_name: beta

View File

@ -23,6 +23,12 @@ jobs:
uses: docker/metadata-action@v5
with:
images: xhofe/alist
tags: |
type=schedule
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=raw,value=beta,enable={{is_default_branch}}
- name: Docker meta with ffmpeg
id: meta-ffmpeg
@ -30,7 +36,13 @@ jobs:
with:
images: xhofe/alist
flavor: |
suffix=-ffmpeg,onlatest=true
suffix=-ffmpeg
tags: |
type=schedule
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=raw,value=beta,enable={{is_default_branch}}
- uses: actions/setup-go@v5
with:
@ -74,19 +86,16 @@ jobs:
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/386,linux/arm/v6,linux/s390x
- name: Replace dockerfile tag
run: |
sed -i -e "s/latest/main/g" Dockerfile.ffmpeg
- name: Build and push with ffmpeg
id: docker_build_ffmpeg
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile.ffmpeg
file: Dockerfile.ci
push: ${{ github.event_name == 'push' }}
tags: ${{ steps.meta-ffmpeg.outputs.tags }}
labels: ${{ steps.meta-ffmpeg.outputs.labels }}
build-args: INSTALL_FFMPEG=true
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/386,linux/arm/v6,linux/s390x
build_docker_with_aria2:

View File

@ -3,7 +3,7 @@ name: auto changelog
on:
push:
tags:
- '*'
- 'v*'
jobs:
changelog:
@ -14,6 +14,7 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
- run: npx changelogithub # or changelogithub@0.12 if ensure the stable result
env:
GITHUB_TOKEN: ${{secrets.MY_TOKEN}}

View File

@ -3,7 +3,7 @@ name: release_docker
on:
push:
tags:
- '*'
- 'v*'
jobs:
release_docker:
@ -74,10 +74,11 @@ jobs:
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile.ffmpeg
file: Dockerfile.ci
push: true
tags: ${{ steps.meta-ffmpeg.outputs.tags }}
labels: ${{ steps.meta-ffmpeg.outputs.labels }}
build-args: INSTALL_FFMPEG=true
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/386,linux/arm/v6,linux/s390x
release_docker_with_aria2:

View File

@ -8,16 +8,23 @@ COPY ./ ./
RUN bash build.sh release docker
FROM alpine:edge
ARG INSTALL_FFMPEG=false
LABEL MAINTAINER="i@nn.ci"
VOLUME /opt/alist/data/
WORKDIR /opt/alist/
COPY --from=builder /app/bin/alist ./
COPY entrypoint.sh /entrypoint.sh
RUN apk update && \
apk upgrade --no-cache && \
apk add --no-cache bash ca-certificates su-exec tzdata; \
chmod +x /entrypoint.sh && \
[ "$INSTALL_FFMPEG" = "true" ] && apk add --no-cache ffmpeg; \
rm -rf /var/cache/apk/*
COPY --from=builder /app/bin/alist ./
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh && /entrypoint.sh version
ENV PUID=0 PGID=0 UMASK=022
VOLUME /opt/alist/data/
EXPOSE 5244 5245
CMD [ "/entrypoint.sh" ]

View File

@ -1,16 +1,22 @@
FROM alpine:edge
ARG TARGETPLATFORM
ARG INSTALL_FFMPEG=false
LABEL MAINTAINER="i@nn.ci"
VOLUME /opt/alist/data/
WORKDIR /opt/alist/
COPY /build/${TARGETPLATFORM}/alist ./
COPY entrypoint.sh /entrypoint.sh
RUN apk update && \
apk upgrade --no-cache && \
apk add --no-cache bash ca-certificates su-exec tzdata; \
chmod +x /entrypoint.sh && \
rm -rf /var/cache/apk/* && \
/entrypoint.sh version
[ "$INSTALL_FFMPEG" = "true" ] && apk add --no-cache ffmpeg; \
rm -rf /var/cache/apk/*
COPY /build/${TARGETPLATFORM}/alist ./
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh && /entrypoint.sh version
ENV PUID=0 PGID=0 UMASK=022
VOLUME /opt/alist/data/
EXPOSE 5244 5245
CMD [ "/entrypoint.sh" ]

View File

@ -1,4 +0,0 @@
FROM xhofe/alist:latest
RUN apk update && \
apk add --no-cache ffmpeg \
rm -rf /var/cache/apk/*

View File

@ -267,6 +267,8 @@ if [ "$1" = "dev" ]; then
BuildDocker
elif [ "$2" = "docker-multiplatform" ]; then
BuildDockerMultiplatform
elif [ "$2" = "web" ]; then
echo "web only"
else
BuildDev
fi
@ -285,6 +287,8 @@ elif [ "$1" = "release" ]; then
elif [ "$2" = "android" ]; then
BuildReleaseAndroid
MakeRelease "md5-android.txt"
elif [ "$2" = "web" ]; then
echo "web only"
else
BuildRelease
MakeRelease "md5.txt"
@ -293,6 +297,8 @@ elif [ "$1" = "prepare" ]; then
if [ "$2" = "docker-multiplatform" ]; then
PrepareBuildDockerMusl
fi
elif [ "$1" = "zip" ]; then
MakeRelease "$2".txt
else
echo -e "Parameter error"
fi

View File

@ -139,7 +139,7 @@ var LangCmd = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) {
err := os.MkdirAll("lang", 0777)
if err != nil {
utils.Log.Fatal("failed create folder: %s", err.Error())
utils.Log.Fatalf("failed create folder: %s", err.Error())
}
generateDriversJson()
generateSettingsJson()

View File

@ -63,7 +63,7 @@ func (d *Pan115) Link(ctx context.Context, file model.Obj, args model.LinkArgs)
if err := d.WaitLimit(ctx); err != nil {
return nil, err
}
var userAgent = args.Header.Get("User-Agent")
userAgent := args.Header.Get("User-Agent")
downloadInfo, err := d.
DownloadWithUA(file.(*FileObj).PickCode, userAgent)
if err != nil {
@ -179,7 +179,22 @@ func (d *Pan115) Put(ctx context.Context, dstDir model.Obj, stream model.FileStr
}
// 分片上传
return d.UploadByMultipart(&fastInfo.UploadOSSParams, stream.GetSize(), stream, dirID)
}
func (d *Pan115) OfflineList(ctx context.Context) ([]*driver115.OfflineTask, error) {
resp, err := d.client.ListOfflineTask(0)
if err != nil {
return nil, err
}
return resp.Tasks, nil
}
func (d *Pan115) OfflineDownload(ctx context.Context, uris []string, dstDir model.Obj) ([]string, error) {
return d.client.AddOfflineTaskURIs(uris, dstDir.GetID())
}
func (d *Pan115) DeleteOfflineTasks(ctx context.Context, hashes []string, deleteFiles bool) error {
return d.client.DeleteOfflineTasks(hashes, deleteFiles)
}
var _ driver.Driver = (*Pan115)(nil)

View File

@ -8,7 +8,7 @@ import (
type Addition struct {
Cookie string `json:"cookie" type:"text" help:"one of QR code token and cookie required"`
QRCodeToken string `json:"qrcode_token" type:"text" help:"one of QR code token and cookie required"`
QRCodeSource string `json:"qrcode_source" type:"select" options:"web,android,ios,linux,mac,windows,tv" default:"linux" help:"select the QR code device, default linux"`
QRCodeSource string `json:"qrcode_source" type:"select" options:"web,android,ios,tv,alipaymini,wechatmini,qandroid" default:"linux" help:"select the QR code device, default linux"`
PageSize int64 `json:"page_size" type:"number" default:"56" help:"list api per page size of 115 driver"`
LimitRate float64 `json:"limit_rate" type:"number" default:"2" help:"limit all api request rate (1r/[limit_rate]s)"`
driver.RootID
@ -17,9 +17,9 @@ type Addition struct {
var config = driver.Config{
Name: "115 Cloud",
DefaultRoot: "0",
//OnlyProxy: true,
//OnlyLocal: true,
//NoOverwriteUpload: true,
// OnlyProxy: true,
// OnlyLocal: true,
// NoOverwriteUpload: true,
}
func init() {

View File

@ -38,17 +38,17 @@ func (d *Pan115) login() error {
}
d.client = driver115.New(opts...)
cr := &driver115.Credential{}
if d.Addition.QRCodeToken != "" {
if d.QRCodeToken != "" {
s := &driver115.QRCodeSession{
UID: d.Addition.QRCodeToken,
UID: d.QRCodeToken,
}
if cr, err = d.client.QRCodeLoginWithApp(s, driver115.LoginApp(d.QRCodeSource)); err != nil {
return errors.Wrap(err, "failed to login by qrcode")
}
d.Addition.Cookie = fmt.Sprintf("UID=%s;CID=%s;SEID=%s", cr.UID, cr.CID, cr.SEID)
d.Addition.QRCodeToken = ""
} else if d.Addition.Cookie != "" {
if err = cr.FromCookie(d.Addition.Cookie); err != nil {
d.Cookie = fmt.Sprintf("UID=%s;CID=%s;SEID=%s", cr.UID, cr.CID, cr.SEID)
d.QRCodeToken = ""
} else if d.Cookie != "" {
if err = cr.FromCookie(d.Cookie); err != nil {
return errors.Wrap(err, "failed to login by cookies")
}
d.client.ImportCredential(cr)
@ -370,11 +370,13 @@ LOOP:
}
return d.checkUploadStatus(dirID, params.SHA1)
}
func chunksProducer(ch chan oss.FileChunk, chunks []oss.FileChunk) {
for _, chunk := range chunks {
ch <- chunk
}
}
func (d *Pan115) checkUploadStatus(dirID, sha1 string) error {
// 验证上传是否成功
req := d.client.NewRequest().ForceContentType("application/json;charset=UTF-8")
@ -431,8 +433,8 @@ func SplitFileByPartNum(fileSize int64, chunkNum int) ([]oss.FileChunk, error) {
}
var chunks []oss.FileChunk
var chunk = oss.FileChunk{}
var chunkN = (int64)(chunkNum)
chunk := oss.FileChunk{}
chunkN := (int64)(chunkNum)
for i := int64(0); i < chunkN; i++ {
chunk.Number = int(i + 1)
chunk.Offset = i * (fileSize / chunkN)
@ -454,13 +456,13 @@ func SplitFileByPartSize(fileSize int64, chunkSize int64) ([]oss.FileChunk, erro
return nil, errors.New("chunkSize invalid")
}
var chunkN = fileSize / chunkSize
chunkN := fileSize / chunkSize
if chunkN >= 10000 {
return nil, errors.New("Too many parts, please increase part size")
}
var chunks []oss.FileChunk
var chunk = oss.FileChunk{}
chunk := oss.FileChunk{}
for i := int64(0); i < chunkN; i++ {
chunk.Number = int(i + 1)
chunk.Offset = i * chunkSize

View File

@ -8,7 +8,7 @@ import (
type Addition struct {
Cookie string `json:"cookie" type:"text" help:"one of QR code token and cookie required"`
QRCodeToken string `json:"qrcode_token" type:"text" help:"one of QR code token and cookie required"`
QRCodeSource string `json:"qrcode_source" type:"select" options:"web,android,ios,linux,mac,windows,tv" default:"linux" help:"select the QR code device, default linux"`
QRCodeSource string `json:"qrcode_source" type:"select" options:"web,android,ios,tv,alipaymini,wechatmini,qandroid" default:"linux" help:"select the QR code device, default linux"`
PageSize int64 `json:"page_size" type:"number" default:"20" help:"list api per page size of 115 driver"`
LimitRate float64 `json:"limit_rate" type:"number" default:"2" help:"limit all api request rate (1r/[limit_rate]s)"`
ShareCode string `json:"share_code" type:"text" required:"true" help:"share code of 115 share link"`

View File

@ -53,7 +53,7 @@ func (d *Pan123) Drop(ctx context.Context) error {
}
func (d *Pan123) List(ctx context.Context, dir model.Obj, args model.ListArgs) ([]model.Obj, error) {
files, err := d.getFiles(dir.GetID(), dir.GetName())
files, err := d.getFiles(ctx, dir.GetID(), dir.GetName())
if err != nil {
return nil, err
}
@ -247,9 +247,6 @@ func (d *Pan123) Put(ctx context.Context, dstDir model.Obj, stream model.FileStr
}
_, err = uploader.UploadWithContext(ctx, input)
}
if err != nil {
return err
}
_, err = d.request(UploadComplete, http.MethodPost, func(req *resty.Request) {
req.SetBody(base.Json{
"fileId": resp.Data.FileId,
@ -258,11 +255,12 @@ func (d *Pan123) Put(ctx context.Context, dstDir model.Obj, stream model.FileStr
return err
}
func (d *Pan123) APIRateLimit(api string) bool {
limiter, _ := d.apiRateLimit.LoadOrStore(api,
rate.NewLimiter(rate.Every(time.Millisecond*700), 1))
ins := limiter.(*rate.Limiter)
return ins.Allow()
func (d *Pan123) APIRateLimit(ctx context.Context, api string) error {
value, _ := d.apiRateLimit.LoadOrStore(api,
rate.NewLimiter(rate.Every(700*time.Millisecond), 1))
limiter := value.(*rate.Limiter)
return limiter.Wait(ctx)
}
var _ driver.Driver = (*Pan123)(nil)

View File

@ -1,6 +1,7 @@
package _123
import (
"context"
"errors"
"fmt"
"hash/crc32"
@ -14,7 +15,7 @@ import (
"github.com/alist-org/alist/v3/drivers/base"
"github.com/alist-org/alist/v3/pkg/utils"
resty "github.com/go-resty/resty/v2"
"github.com/go-resty/resty/v2"
jsoniter "github.com/json-iterator/go"
log "github.com/sirupsen/logrus"
)
@ -233,15 +234,14 @@ func (d *Pan123) request(url string, method string, callback base.ReqCallback, r
return body, nil
}
func (d *Pan123) getFiles(parentId string, name string) ([]File, error) {
func (d *Pan123) getFiles(ctx context.Context, parentId string, name string) ([]File, error) {
page := 1
total := 0
res := make([]File, 0)
// 2024-02-06 fix concurrency by 123pan
for {
if !d.APIRateLimit(FileList) {
time.Sleep(time.Millisecond * 200)
continue
if err := d.APIRateLimit(ctx, FileList); err != nil {
return nil, err
}
var resp Files
query := map[string]string{

View File

@ -45,7 +45,7 @@ func (d *Pan123Share) Drop(ctx context.Context) error {
func (d *Pan123Share) List(ctx context.Context, dir model.Obj, args model.ListArgs) ([]model.Obj, error) {
// TODO return the files list, required
files, err := d.getFiles(dir.GetID())
files, err := d.getFiles(ctx, dir.GetID())
if err != nil {
return nil, err
}
@ -150,11 +150,12 @@ func (d *Pan123Share) Put(ctx context.Context, dstDir model.Obj, stream model.Fi
// return nil, errs.NotSupport
//}
func (d *Pan123Share) APIRateLimit(api string) bool {
limiter, _ := d.apiRateLimit.LoadOrStore(api,
rate.NewLimiter(rate.Every(time.Millisecond*700), 1))
ins := limiter.(*rate.Limiter)
return ins.Allow()
func (d *Pan123Share) APIRateLimit(ctx context.Context, api string) error {
value, _ := d.apiRateLimit.LoadOrStore(api,
rate.NewLimiter(rate.Every(700*time.Millisecond), 1))
limiter := value.(*rate.Limiter)
return limiter.Wait(ctx)
}
var _ driver.Driver = (*Pan123Share)(nil)

View File

@ -1,6 +1,7 @@
package _123Share
import (
"context"
"errors"
"fmt"
"hash/crc32"
@ -80,13 +81,12 @@ func (d *Pan123Share) request(url string, method string, callback base.ReqCallba
return body, nil
}
func (d *Pan123Share) getFiles(parentId string) ([]File, error) {
func (d *Pan123Share) getFiles(ctx context.Context, parentId string) ([]File, error) {
page := 1
res := make([]File, 0)
for {
if !d.APIRateLimit(FileList) {
time.Sleep(time.Millisecond * 200)
continue
if err := d.APIRateLimit(ctx, FileList); err != nil {
return nil, err
}
var resp Files
query := map[string]string{

View File

@ -114,17 +114,19 @@ func (y *Cloud189PC) request(url, method string, callback base.ReqCallback, para
if err = y.refreshSession(); err != nil {
return nil, err
}
return y.request(url, method, callback, params, resp)
return y.request(url, method, callback, params, resp, isFamily...)
}
// if erron.ErrorCode == "InvalidSessionKey" || erron.Code == "InvalidSessionKey" {
if strings.Contains(res.String(), "InvalidSessionKey") {
if err = y.refreshSession(); err != nil {
return nil, err
}
return y.request(url, method, callback, params, resp, isFamily...)
}
// 处理错误
if erron.HasError() {
if erron.ErrorCode == "InvalidSessionKey" {
if err = y.refreshSession(); err != nil {
return nil, err
}
return y.request(url, method, callback, params, resp)
}
return nil, &erron
}
return res.Body(), nil

View File

@ -28,7 +28,9 @@ import (
_ "github.com/alist-org/alist/v3/drivers/halalcloud"
_ "github.com/alist-org/alist/v3/drivers/ilanzou"
_ "github.com/alist-org/alist/v3/drivers/ipfs_api"
_ "github.com/alist-org/alist/v3/drivers/kodbox"
_ "github.com/alist-org/alist/v3/drivers/lanzou"
_ "github.com/alist-org/alist/v3/drivers/lenovonas_share"
_ "github.com/alist-org/alist/v3/drivers/local"
_ "github.com/alist-org/alist/v3/drivers/mediatrack"
_ "github.com/alist-org/alist/v3/drivers/mega"
@ -40,6 +42,7 @@ import (
_ "github.com/alist-org/alist/v3/drivers/pikpak"
_ "github.com/alist-org/alist/v3/drivers/pikpak_share"
_ "github.com/alist-org/alist/v3/drivers/quark_uc"
_ "github.com/alist-org/alist/v3/drivers/quark_uc_tv"
_ "github.com/alist-org/alist/v3/drivers/quqi"
_ "github.com/alist-org/alist/v3/drivers/s3"
_ "github.com/alist-org/alist/v3/drivers/seafile"

View File

@ -191,33 +191,33 @@ type UploadFileDataRsp struct {
Resid int64 `json:"resid"`
Puid int `json:"puid"`
Data struct {
DisableOpt bool `json:"disableOpt"`
Resid int64 `json:"resid"`
Crc string `json:"crc"`
Puid int `json:"puid"`
Isfile bool `json:"isfile"`
Pantype string `json:"pantype"`
Size int `json:"size"`
Name string `json:"name"`
ObjectID string `json:"objectId"`
Restype string `json:"restype"`
UploadDate time.Time `json:"uploadDate"`
ModifyDate time.Time `json:"modifyDate"`
UploadDateFormat string `json:"uploadDateFormat"`
Residstr string `json:"residstr"`
Suffix string `json:"suffix"`
Preview string `json:"preview"`
Thumbnail string `json:"thumbnail"`
Creator int `json:"creator"`
Duration int `json:"duration"`
IsImg bool `json:"isImg"`
PreviewURL string `json:"previewUrl"`
Filetype string `json:"filetype"`
Filepath string `json:"filepath"`
Sort int `json:"sort"`
Topsort int `json:"topsort"`
ResTypeValue int `json:"resTypeValue"`
Extinfo string `json:"extinfo"`
DisableOpt bool `json:"disableOpt"`
Resid int64 `json:"resid"`
Crc string `json:"crc"`
Puid int `json:"puid"`
Isfile bool `json:"isfile"`
Pantype string `json:"pantype"`
Size int `json:"size"`
Name string `json:"name"`
ObjectID string `json:"objectId"`
Restype string `json:"restype"`
UploadDate int64 `json:"uploadDate"`
ModifyDate int64 `json:"modifyDate"`
UploadDateFormat string `json:"uploadDateFormat"`
Residstr string `json:"residstr"`
Suffix string `json:"suffix"`
Preview string `json:"preview"`
Thumbnail string `json:"thumbnail"`
Creator int `json:"creator"`
Duration int `json:"duration"`
IsImg bool `json:"isImg"`
PreviewURL string `json:"previewUrl"`
Filetype string `json:"filetype"`
Filepath string `json:"filepath"`
Sort int `json:"sort"`
Topsort int `json:"topsort"`
ResTypeValue int `json:"resTypeValue"`
Extinfo string `json:"extinfo"`
} `json:"data"`
}
@ -225,33 +225,33 @@ type UploadDoneParam struct {
Cataid string `json:"cataid"`
Key string `json:"key"`
Param struct {
DisableOpt bool `json:"disableOpt"`
Resid int64 `json:"resid"`
Crc string `json:"crc"`
Puid int `json:"puid"`
Isfile bool `json:"isfile"`
Pantype string `json:"pantype"`
Size int `json:"size"`
Name string `json:"name"`
ObjectID string `json:"objectId"`
Restype string `json:"restype"`
UploadDate time.Time `json:"uploadDate"`
ModifyDate time.Time `json:"modifyDate"`
UploadDateFormat string `json:"uploadDateFormat"`
Residstr string `json:"residstr"`
Suffix string `json:"suffix"`
Preview string `json:"preview"`
Thumbnail string `json:"thumbnail"`
Creator int `json:"creator"`
Duration int `json:"duration"`
IsImg bool `json:"isImg"`
PreviewURL string `json:"previewUrl"`
Filetype string `json:"filetype"`
Filepath string `json:"filepath"`
Sort int `json:"sort"`
Topsort int `json:"topsort"`
ResTypeValue int `json:"resTypeValue"`
Extinfo string `json:"extinfo"`
DisableOpt bool `json:"disableOpt"`
Resid int64 `json:"resid"`
Crc string `json:"crc"`
Puid int `json:"puid"`
Isfile bool `json:"isfile"`
Pantype string `json:"pantype"`
Size int `json:"size"`
Name string `json:"name"`
ObjectID string `json:"objectId"`
Restype string `json:"restype"`
UploadDate int64 `json:"uploadDate"`
ModifyDate int64 `json:"modifyDate"`
UploadDateFormat string `json:"uploadDateFormat"`
Residstr string `json:"residstr"`
Suffix string `json:"suffix"`
Preview string `json:"preview"`
Thumbnail string `json:"thumbnail"`
Creator int `json:"creator"`
Duration int `json:"duration"`
IsImg bool `json:"isImg"`
PreviewURL string `json:"previewUrl"`
Filetype string `json:"filetype"`
Filepath string `json:"filepath"`
Sort int `json:"sort"`
Topsort int `json:"topsort"`
ResTypeValue int `json:"resTypeValue"`
Extinfo string `json:"extinfo"`
} `json:"param"`
}

View File

@ -147,7 +147,7 @@ func (d *HalalCloud) IsLogin() bool {
if err != nil {
return false
}
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
result, err := pbPublicUser.NewPubUserClient(serv.GetGrpcConnection()).Get(ctx, &pbPublicUser.User{
Identity: "",

View File

@ -12,9 +12,9 @@ type Addition struct {
RefreshToken string `json:"refresh_token" required:"true" help:"login type is refresh_token,this is required"`
UploadThread string `json:"upload_thread" default:"3" help:"1 <= thread <= 32"`
AppID string `json:"app_id" required:"true" default:"devDebugger/1.0"`
AppID string `json:"app_id" required:"true" default:"alist/10001"`
AppVersion string `json:"app_version" required:"true" default:"1.0.0"`
AppSecret string `json:"app_secret" required:"true" default:"Nkx3Y2xvZ2luLmNu"`
AppSecret string `json:"app_secret" required:"true" default:"bR4SJwOkvnG5WvVJ"`
}
var config = driver.Config{

View File

@ -29,9 +29,9 @@ import (
)
const (
AppID = "devDebugger/1.0"
AppID = "alist/10001"
AppVersion = "1.0.0"
AppSecret = "Nkx3Y2xvZ2luLmNu"
AppSecret = "bR4SJwOkvnG5WvVJ"
)
const (
@ -62,7 +62,7 @@ func (d *HalalCloud) NewAuthServiceWithOauth(options ...HalalOption) (*AuthServi
}
defer grpcConnection.Close()
userClient := pbPublicUser.NewPubUserClient(grpcConnection)
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
stateString := uuid.New().String()
// queryValues.Add("callback", oauthToken.Callback)
@ -179,16 +179,16 @@ func (s *AuthService) signContext(method string, ctx context.Context) context.Co
bufferedString := bytes.NewBufferString(method)
kvString = append(kvString, "timestamp", currentTimeStamp)
bufferedString.WriteString(currentTimeStamp)
kvString = append(kvString, "appid", AppID)
bufferedString.WriteString(AppID)
kvString = append(kvString, "appversion", AppVersion)
bufferedString.WriteString(AppVersion)
kvString = append(kvString, "appid", s.appID)
bufferedString.WriteString(s.appID)
kvString = append(kvString, "appversion", s.appVersion)
bufferedString.WriteString(s.appVersion)
if s.tr != nil && len(s.tr.AccessToken) > 0 {
authorization := "Bearer " + s.tr.AccessToken
kvString = append(kvString, "authorization", authorization)
bufferedString.WriteString(authorization)
}
bufferedString.WriteString(AppSecret)
bufferedString.WriteString(s.appSecret)
sign := GetMD5Hash(bufferedString.String())
kvString = append(kvString, "sign", sign)
return metadata.AppendToOutgoingContext(ctx, kvString...)

273
drivers/kodbox/driver.go Normal file
View File

@ -0,0 +1,273 @@
package kodbox
import (
"context"
"fmt"
"github.com/alist-org/alist/v3/pkg/utils"
"github.com/go-resty/resty/v2"
"net/http"
"path/filepath"
"strings"
"time"
"github.com/alist-org/alist/v3/internal/driver"
"github.com/alist-org/alist/v3/internal/model"
)
type KodBox struct {
model.Storage
Addition
authorization string
}
func (d *KodBox) Config() driver.Config {
return config
}
func (d *KodBox) GetAddition() driver.Additional {
return &d.Addition
}
func (d *KodBox) Init(ctx context.Context) error {
d.Address = strings.TrimSuffix(d.Address, "/")
d.RootFolderPath = strings.TrimPrefix(utils.FixAndCleanPath(d.RootFolderPath), "/")
return d.getToken()
}
func (d *KodBox) Drop(ctx context.Context) error {
return nil
}
func (d *KodBox) List(ctx context.Context, dir model.Obj, args model.ListArgs) ([]model.Obj, error) {
var (
resp *CommonResp
listPathData *ListPathData
)
_, err := d.request(http.MethodPost, "/?explorer/list/path", func(req *resty.Request) {
req.SetResult(&resp).SetFormData(map[string]string{
"path": dir.GetPath(),
})
}, true)
if err != nil {
return nil, err
}
dataBytes, err := utils.Json.Marshal(resp.Data)
if err != nil {
return nil, err
}
err = utils.Json.Unmarshal(dataBytes, &listPathData)
if err != nil {
return nil, err
}
FolderAndFiles := append(listPathData.FolderList, listPathData.FileList...)
return utils.SliceConvert(FolderAndFiles, func(f FolderOrFile) (model.Obj, error) {
return &model.ObjThumb{
Object: model.Object{
Path: f.Path,
Name: f.Name,
Ctime: time.Unix(f.CreateTime, 0),
Modified: time.Unix(f.ModifyTime, 0),
Size: f.Size,
IsFolder: f.Type == "folder",
},
//Thumbnail: model.Thumbnail{},
}, nil
})
}
func (d *KodBox) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (*model.Link, error) {
path := file.GetPath()
return &model.Link{
URL: fmt.Sprintf("%s/?explorer/index/fileOut&path=%s&download=1&accessToken=%s",
d.Address,
path,
d.authorization)}, nil
}
func (d *KodBox) MakeDir(ctx context.Context, parentDir model.Obj, dirName string) (model.Obj, error) {
var resp *CommonResp
newDirPath := filepath.Join(parentDir.GetPath(), dirName)
_, err := d.request(http.MethodPost, "/?explorer/index/mkdir", func(req *resty.Request) {
req.SetResult(&resp).SetFormData(map[string]string{
"path": newDirPath,
})
})
if err != nil {
return nil, err
}
code := resp.Code.(bool)
if !code {
return nil, fmt.Errorf("%s", resp.Data)
}
return &model.ObjThumb{
Object: model.Object{
Path: resp.Info.(string),
Name: dirName,
IsFolder: true,
Modified: time.Now(),
Ctime: time.Now(),
},
}, nil
}
func (d *KodBox) Move(ctx context.Context, srcObj, dstDir model.Obj) (model.Obj, error) {
var resp *CommonResp
_, err := d.request(http.MethodPost, "/?explorer/index/pathCuteTo", func(req *resty.Request) {
req.SetResult(&resp).SetFormData(map[string]string{
"dataArr": fmt.Sprintf("[{\"path\": \"%s\", \"name\": \"%s\"}]",
srcObj.GetPath(),
srcObj.GetName()),
"path": dstDir.GetPath(),
})
}, true)
if err != nil {
return nil, err
}
code := resp.Code.(bool)
if !code {
return nil, fmt.Errorf("%s", resp.Data)
}
return &model.ObjThumb{
Object: model.Object{
Path: srcObj.GetPath(),
Name: srcObj.GetName(),
IsFolder: srcObj.IsDir(),
Modified: srcObj.ModTime(),
Ctime: srcObj.CreateTime(),
},
}, nil
}
func (d *KodBox) Rename(ctx context.Context, srcObj model.Obj, newName string) (model.Obj, error) {
var resp *CommonResp
_, err := d.request(http.MethodPost, "/?explorer/index/pathRename", func(req *resty.Request) {
req.SetResult(&resp).SetFormData(map[string]string{
"path": srcObj.GetPath(),
"newName": newName,
})
}, true)
if err != nil {
return nil, err
}
code := resp.Code.(bool)
if !code {
return nil, fmt.Errorf("%s", resp.Data)
}
return &model.ObjThumb{
Object: model.Object{
Path: srcObj.GetPath(),
Name: newName,
IsFolder: srcObj.IsDir(),
Modified: time.Now(),
Ctime: srcObj.CreateTime(),
},
}, nil
}
func (d *KodBox) Copy(ctx context.Context, srcObj, dstDir model.Obj) (model.Obj, error) {
var resp *CommonResp
_, err := d.request(http.MethodPost, "/?explorer/index/pathCopyTo", func(req *resty.Request) {
req.SetResult(&resp).SetFormData(map[string]string{
"dataArr": fmt.Sprintf("[{\"path\": \"%s\", \"name\": \"%s\"}]",
srcObj.GetPath(),
srcObj.GetName()),
"path": dstDir.GetPath(),
})
})
if err != nil {
return nil, err
}
code := resp.Code.(bool)
if !code {
return nil, fmt.Errorf("%s", resp.Data)
}
path := resp.Info.([]interface{})[0].(string)
objectName, err := d.getFileOrFolderName(ctx, path)
if err != nil {
return nil, err
}
return &model.ObjThumb{
Object: model.Object{
Path: path,
Name: *objectName,
IsFolder: srcObj.IsDir(),
Modified: time.Now(),
Ctime: time.Now(),
},
}, nil
}
func (d *KodBox) Remove(ctx context.Context, obj model.Obj) error {
var resp *CommonResp
_, err := d.request(http.MethodPost, "/?explorer/index/pathDelete", func(req *resty.Request) {
req.SetResult(&resp).SetFormData(map[string]string{
"dataArr": fmt.Sprintf("[{\"path\": \"%s\", \"name\": \"%s\"}]",
obj.GetPath(),
obj.GetName()),
"shiftDelete": "1",
})
})
if err != nil {
return err
}
code := resp.Code.(bool)
if !code {
return fmt.Errorf("%s", resp.Data)
}
return nil
}
func (d *KodBox) Put(ctx context.Context, dstDir model.Obj, stream model.FileStreamer, up driver.UpdateProgress) (model.Obj, error) {
var resp *CommonResp
_, err := d.request(http.MethodPost, "/?explorer/upload/fileUpload", func(req *resty.Request) {
req.SetFileReader("file", stream.GetName(), stream).
SetResult(&resp).
SetFormData(map[string]string{
"path": dstDir.GetPath(),
})
})
if err != nil {
return nil, err
}
code := resp.Code.(bool)
if !code {
return nil, fmt.Errorf("%s", resp.Data)
}
return &model.ObjThumb{
Object: model.Object{
Path: resp.Info.(string),
Name: stream.GetName(),
Size: stream.GetSize(),
IsFolder: false,
Modified: time.Now(),
Ctime: time.Now(),
},
}, nil
}
func (d *KodBox) getFileOrFolderName(ctx context.Context, path string) (*string, error) {
var resp *CommonResp
_, err := d.request(http.MethodPost, "/?explorer/index/pathInfo", func(req *resty.Request) {
req.SetResult(&resp).SetFormData(map[string]string{
"dataArr": fmt.Sprintf("[{\"path\": \"%s\"}]", path)})
})
if err != nil {
return nil, err
}
code := resp.Code.(bool)
if !code {
return nil, fmt.Errorf("%s", resp.Data)
}
folderOrFileName := resp.Data.(map[string]any)["name"].(string)
return &folderOrFileName, nil
}
var _ driver.Driver = (*KodBox)(nil)

25
drivers/kodbox/meta.go Normal file
View File

@ -0,0 +1,25 @@
package kodbox
import (
"github.com/alist-org/alist/v3/internal/driver"
"github.com/alist-org/alist/v3/internal/op"
)
type Addition struct {
driver.RootPath
Address string `json:"address" required:"true"`
UserName string `json:"username" required:"false"`
Password string `json:"password" required:"false"`
}
var config = driver.Config{
Name: "KodBox",
DefaultRoot: "",
}
func init() {
op.RegisterDriver(func() driver.Driver {
return &KodBox{}
})
}

24
drivers/kodbox/types.go Normal file
View File

@ -0,0 +1,24 @@
package kodbox
type CommonResp struct {
Code any `json:"code"`
TimeUse string `json:"timeUse"`
TimeNow string `json:"timeNow"`
Data any `json:"data"`
Info any `json:"info"`
}
type ListPathData struct {
FolderList []FolderOrFile `json:"folderList"`
FileList []FolderOrFile `json:"fileList"`
}
type FolderOrFile struct {
Name string `json:"name"`
Path string `json:"path"`
Type string `json:"type"`
Ext string `json:"ext,omitempty"` // 文件特有字段
Size int64 `json:"size"`
CreateTime int64 `json:"createTime"`
ModifyTime int64 `json:"modifyTime"`
}

86
drivers/kodbox/util.go Normal file
View File

@ -0,0 +1,86 @@
package kodbox
import (
"fmt"
"github.com/alist-org/alist/v3/drivers/base"
"github.com/alist-org/alist/v3/pkg/utils"
"github.com/go-resty/resty/v2"
"strings"
)
func (d *KodBox) getToken() error {
var authResp CommonResp
res, err := base.RestyClient.R().
SetResult(&authResp).
SetQueryParams(map[string]string{
"name": d.UserName,
"password": d.Password,
}).
Post(d.Address + "/?user/index/loginSubmit")
if err != nil {
return err
}
if res.StatusCode() >= 400 {
return fmt.Errorf("get token failed: %s", res.String())
}
if res.StatusCode() == 200 && authResp.Code.(bool) == false {
return fmt.Errorf("get token failed: %s", res.String())
}
d.authorization = fmt.Sprintf("%s", authResp.Info)
return nil
}
func (d *KodBox) request(method string, pathname string, callback base.ReqCallback, noRedirect ...bool) ([]byte, error) {
full := pathname
if !strings.HasPrefix(pathname, "http") {
full = d.Address + pathname
}
req := base.RestyClient.R()
if len(noRedirect) > 0 && noRedirect[0] {
req = base.NoRedirectClient.R()
}
req.SetFormData(map[string]string{
"accessToken": d.authorization,
})
callback(req)
var (
res *resty.Response
commonResp *CommonResp
err error
skip bool
)
for i := 0; i < 2; i++ {
if skip {
break
}
res, err = req.Execute(method, full)
if err != nil {
return nil, err
}
err := utils.Json.Unmarshal(res.Body(), &commonResp)
if err != nil {
return nil, err
}
switch commonResp.Code.(type) {
case bool:
skip = true
case string:
if commonResp.Code.(string) == "10001" {
err = d.getToken()
if err != nil {
return nil, err
}
req.SetFormData(map[string]string{"accessToken": d.authorization})
}
}
}
if commonResp.Code.(bool) == false {
return nil, fmt.Errorf("request failed: %s", commonResp.Data)
}
return res.Body(), nil
}

View File

@ -30,6 +30,9 @@ func (d *LanZou) GetAddition() driver.Additional {
}
func (d *LanZou) Init(ctx context.Context) (err error) {
if d.UserAgent == "" {
d.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.39 (KHTML, like Gecko) Chrome/89.0.4389.111 Safari/537.39"
}
switch d.Type {
case "account":
_, err := d.Login()

View File

@ -16,7 +16,8 @@ type Addition struct {
driver.RootID
SharePassword string `json:"share_password"`
BaseUrl string `json:"baseUrl" required:"true" default:"https://pc.woozooo.com" help:"basic URL for file operation"`
ShareUrl string `json:"shareUrl" required:"true" default:"https://pan.lanzouo.com" help:"used to get the sharing page"`
ShareUrl string `json:"shareUrl" required:"true" default:"https://pan.lanzoui.com" help:"used to get the sharing page"`
UserAgent string `json:"user_agent" required:"true" default:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.39 (KHTML, like Gecko) Chrome/89.0.4389.111 Safari/537.39"`
RepairFileInfo bool `json:"repair_file_info" help:"To use webdav, you need to enable it"`
}

View File

@ -106,7 +106,8 @@ func (d *LanZou) request(url string, method string, callback base.ReqCallback, u
}
req.SetHeaders(map[string]string{
"Referer": "https://pc.woozooo.com",
"Referer": "https://pc.woozooo.com",
"User-Agent": d.UserAgent,
})
if d.Cookie != "" {

View File

@ -0,0 +1,121 @@
package LenovoNasShare
import (
"context"
"net/http"
"github.com/go-resty/resty/v2"
"github.com/alist-org/alist/v3/internal/driver"
"github.com/alist-org/alist/v3/internal/errs"
"github.com/alist-org/alist/v3/internal/model"
"github.com/alist-org/alist/v3/pkg/utils"
)
type LenovoNasShare struct {
model.Storage
Addition
stoken string
}
func (d *LenovoNasShare) Config() driver.Config {
return config
}
func (d *LenovoNasShare) GetAddition() driver.Additional {
return &d.Addition
}
func (d *LenovoNasShare) Init(ctx context.Context) error {
if d.Host == "" {
d.Host = "https://siot-share.lenovo.com.cn"
}
query := map[string]string{
"code": d.ShareId,
"password": d.SharePwd,
}
resp, err := d.request(d.Host+"/oneproxy/api/share/v1/access", http.MethodGet, func(req *resty.Request) {
req.SetQueryParams(query)
}, nil)
if err != nil {
return err
}
d.stoken = utils.Json.Get(resp, "data", "stoken").ToString()
return nil
}
func (d *LenovoNasShare) Drop(ctx context.Context) error {
return nil
}
func (d *LenovoNasShare) List(ctx context.Context, dir model.Obj, args model.ListArgs) ([]model.Obj, error) {
files := make([]File, 0)
var resp Files
query := map[string]string{
"code": d.ShareId,
"num": "5000",
"stoken": d.stoken,
"path": dir.GetPath(),
}
_, err := d.request(d.Host+"/oneproxy/api/share/v1/files", http.MethodGet, func(req *resty.Request) {
req.SetQueryParams(query)
}, &resp)
if err != nil {
return nil, err
}
files = append(files, resp.Data.List...)
return utils.SliceConvert(files, func(src File) (model.Obj, error) {
return src, nil
})
}
func (d *LenovoNasShare) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (*model.Link, error) {
query := map[string]string{
"code": d.ShareId,
"stoken": d.stoken,
"path": file.GetPath(),
}
resp, err := d.request(d.Host+"/oneproxy/api/share/v1/file/link", http.MethodGet, func(req *resty.Request) {
req.SetQueryParams(query)
}, nil)
if err != nil {
return nil, err
}
downloadUrl := d.Host + "/oneproxy/api/share/v1/file/download?code=" + d.ShareId + "&dtoken=" + utils.Json.Get(resp, "data", "param", "dtoken").ToString()
link := model.Link{
URL: downloadUrl,
Header: http.Header{
"Referer": []string{"https://siot-share.lenovo.com.cn"},
},
}
return &link, nil
}
func (d *LenovoNasShare) MakeDir(ctx context.Context, parentDir model.Obj, dirName string) (model.Obj, error) {
return nil, errs.NotImplement
}
func (d *LenovoNasShare) Move(ctx context.Context, srcObj, dstDir model.Obj) (model.Obj, error) {
return nil, errs.NotImplement
}
func (d *LenovoNasShare) Rename(ctx context.Context, srcObj model.Obj, newName string) (model.Obj, error) {
return nil, errs.NotImplement
}
func (d *LenovoNasShare) Copy(ctx context.Context, srcObj, dstDir model.Obj) (model.Obj, error) {
return nil, errs.NotImplement
}
func (d *LenovoNasShare) Remove(ctx context.Context, obj model.Obj) error {
return errs.NotImplement
}
func (d *LenovoNasShare) Put(ctx context.Context, dstDir model.Obj, stream model.FileStreamer, up driver.UpdateProgress) (model.Obj, error) {
return nil, errs.NotImplement
}
var _ driver.Driver = (*LenovoNasShare)(nil)

View File

@ -0,0 +1,33 @@
package LenovoNasShare
import (
"github.com/alist-org/alist/v3/internal/driver"
"github.com/alist-org/alist/v3/internal/op"
)
type Addition struct {
driver.RootPath
ShareId string `json:"share_id" required:"true" help:"The part after the last / in the shared link"`
SharePwd string `json:"share_pwd" required:"true" help:"The password of the shared link"`
Host string `json:"host" required:"true" default:"https://siot-share.lenovo.com.cn" help:"You can change it to your local area network"`
}
var config = driver.Config{
Name: "LenovoNasShare",
LocalSort: true,
OnlyLocal: false,
OnlyProxy: false,
NoCache: false,
NoUpload: true,
NeedMs: false,
DefaultRoot: "",
CheckStatus: false,
Alert: "",
NoOverwriteUpload: false,
}
func init() {
op.RegisterDriver(func() driver.Driver {
return &LenovoNasShare{}
})
}

View File

@ -0,0 +1,82 @@
package LenovoNasShare
import (
"encoding/json"
"time"
"github.com/alist-org/alist/v3/pkg/utils"
_ "github.com/alist-org/alist/v3/internal/model"
)
func (f *File) UnmarshalJSON(data []byte) error {
type Alias File
aux := &struct {
CreateAt int64 `json:"time"`
UpdateAt int64 `json:"chtime"`
*Alias
}{
Alias: (*Alias)(f),
}
if err := json.Unmarshal(data, aux); err != nil {
return err
}
f.CreateAt = time.Unix(aux.CreateAt, 0)
f.UpdateAt = time.Unix(aux.UpdateAt, 0)
return nil
}
type File struct {
FileName string `json:"name"`
Size int64 `json:"size"`
CreateAt time.Time `json:"time"`
UpdateAt time.Time `json:"chtime"`
Path string `json:"path"`
Type string `json:"type"`
}
func (f File) GetHash() utils.HashInfo {
return utils.HashInfo{}
}
func (f File) GetPath() string {
return f.Path
}
func (f File) GetSize() int64 {
return f.Size
}
func (f File) GetName() string {
return f.FileName
}
func (f File) ModTime() time.Time {
return f.UpdateAt
}
func (f File) CreateTime() time.Time {
return f.CreateAt
}
func (f File) IsDir() bool {
return f.Type == "dir"
}
func (f File) GetID() string {
return f.GetPath()
}
func (f File) Thumb() string {
return ""
}
type Files struct {
Data struct {
List []File `json:"list"`
HasMore bool `json:"has_more"`
} `json:"data"`
}

View File

@ -0,0 +1,36 @@
package LenovoNasShare
import (
"errors"
"github.com/alist-org/alist/v3/drivers/base"
"github.com/alist-org/alist/v3/pkg/utils"
jsoniter "github.com/json-iterator/go"
)
func (d *LenovoNasShare) request(url string, method string, callback base.ReqCallback, resp interface{}) ([]byte, error) {
req := base.RestyClient.R()
req.SetHeaders(map[string]string{
"origin": "https://siot-share.lenovo.com.cn",
"referer": "https://siot-share.lenovo.com.cn/",
"user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) alist-client",
"platform": "web",
"app-version": "3",
})
if callback != nil {
callback(req)
}
if resp != nil {
req.SetResult(resp)
}
res, err := req.Execute(method, url)
if err != nil {
return nil, err
}
body := res.Body()
result := utils.Json.Get(body, "result").ToBool()
if !result {
return nil, errors.New(jsoniter.Get(body, "error", "msg").ToString())
}
return body, nil
}

View File

@ -4,30 +4,27 @@ import (
"context"
"encoding/json"
"fmt"
"github.com/alist-org/alist/v3/internal/op"
"net/http"
"strconv"
"strings"
"github.com/alist-org/alist/v3/drivers/base"
"github.com/alist-org/alist/v3/internal/driver"
"github.com/alist-org/alist/v3/internal/model"
"github.com/alist-org/alist/v3/internal/op"
"github.com/alist-org/alist/v3/pkg/utils"
hash_extend "github.com/alist-org/alist/v3/pkg/utils/hash"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/s3/s3manager"
"github.com/go-resty/resty/v2"
log "github.com/sirupsen/logrus"
"golang.org/x/oauth2"
"net/http"
"strconv"
"strings"
)
type PikPak struct {
model.Storage
Addition
*Common
oauth2Token oauth2.TokenSource
RefreshToken string
AccessToken string
oauth2Token oauth2.TokenSource
}
func (d *PikPak) Config() driver.Config {
@ -39,10 +36,6 @@ func (d *PikPak) GetAddition() driver.Additional {
}
func (d *PikPak) Init(ctx context.Context) (err error) {
if d.ClientID == "" || d.ClientSecret == "" {
d.ClientID = "YNxT9w7GMdWvEOKa"
d.ClientSecret = "dbw2OtmVEeuUvIptb1Coyg"
}
if d.Common == nil {
d.Common = &Common{
@ -50,7 +43,7 @@ func (d *PikPak) Init(ctx context.Context) (err error) {
CaptchaToken: "",
UserID: "",
DeviceID: utils.GetMD5EncodeStr(d.Username + d.Password),
UserAgent: BuildCustomUserAgent(utils.GetMD5EncodeStr(d.Username+d.Password), ClientID, PackageName, SdkVersion, ClientVersion, PackageName, ""),
UserAgent: "",
RefreshCTokenCk: func(token string) {
d.Common.CaptchaToken = token
op.MustSaveDriverStorage(d)
@ -58,6 +51,33 @@ func (d *PikPak) Init(ctx context.Context) (err error) {
}
}
if d.Platform == "android" {
d.ClientID = AndroidClientID
d.ClientSecret = AndroidClientSecret
d.ClientVersion = AndroidClientVersion
d.PackageName = AndroidPackageName
d.Algorithms = AndroidAlgorithms
d.UserAgent = BuildCustomUserAgent(utils.GetMD5EncodeStr(d.Username+d.Password), AndroidClientID, AndroidPackageName, AndroidSdkVersion, AndroidClientVersion, AndroidPackageName, "")
} else if d.Platform == "web" {
d.ClientID = WebClientID
d.ClientSecret = WebClientSecret
d.ClientVersion = WebClientVersion
d.PackageName = WebPackageName
d.Algorithms = WebAlgorithms
d.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36"
}
if d.Addition.CaptchaToken != "" && d.Addition.RefreshToken == "" {
d.SetCaptchaToken(d.Addition.CaptchaToken)
}
if d.Addition.DeviceID != "" {
d.SetDeviceID(d.Addition.DeviceID)
} else {
d.Addition.DeviceID = d.Common.DeviceID
op.MustSaveDriverStorage(d)
}
// 初始化 oauth2Config
oauth2Config := &oauth2.Config{
ClientID: d.ClientID,
ClientSecret: d.ClientSecret,
@ -68,21 +88,53 @@ func (d *PikPak) Init(ctx context.Context) (err error) {
},
}
d.oauth2Token = oauth2.ReuseTokenSource(nil, utils.TokenSource(func() (*oauth2.Token, error) {
return oauth2Config.PasswordCredentialsToken(
context.WithValue(context.Background(), oauth2.HTTPClient, base.HttpClient),
d.Username,
d.Password,
)
}))
// 如果已经有RefreshToken直接获取AccessToken
if d.Addition.RefreshToken != "" {
// 使用 oauth2 刷新令牌
// 初始化 oauth2Token
d.oauth2Token = oauth2.ReuseTokenSource(nil, utils.TokenSource(func() (*oauth2.Token, error) {
return oauth2Config.TokenSource(ctx, &oauth2.Token{
RefreshToken: d.Addition.RefreshToken,
}).Token()
}))
} else {
// 如果没有填写RefreshToken尝试登录 获取 refreshToken
if err := d.login(); err != nil {
return err
}
d.oauth2Token = oauth2.ReuseTokenSource(nil, utils.TokenSource(func() (*oauth2.Token, error) {
return oauth2Config.TokenSource(ctx, &oauth2.Token{
RefreshToken: d.RefreshToken,
}).Token()
}))
}
// 获取用户ID
_ = d.GetUserID()
token, err := d.oauth2Token.Token()
if err != nil {
return err
}
d.RefreshToken = token.RefreshToken
d.AccessToken = token.AccessToken
// 获取CaptchaToken
_ = d.RefreshCaptchaTokenAtLogin(GetAction(http.MethodGet, "https://api-drive.mypikpak.com/drive/v1/files"), d.Common.UserID)
err = d.RefreshCaptchaTokenAtLogin(GetAction(http.MethodGet, "https://api-drive.mypikpak.com/drive/v1/files"), d.Username)
if err != nil {
return err
}
// 获取用户ID
userID := token.Extra("sub").(string)
if userID != "" {
d.Common.SetUserID(userID)
}
// 更新UserAgent
d.Common.UserAgent = BuildCustomUserAgent(d.Common.DeviceID, ClientID, PackageName, SdkVersion, ClientVersion, PackageName, d.Common.UserID)
if d.Platform == "android" {
d.Common.UserAgent = BuildCustomUserAgent(utils.GetMD5EncodeStr(d.Username+d.Password), AndroidClientID, AndroidPackageName, AndroidSdkVersion, AndroidClientVersion, AndroidPackageName, d.Common.UserID)
}
// 保存 有效的 RefreshToken
d.Addition.RefreshToken = d.RefreshToken
op.MustSaveDriverStorage(d)
return nil
}
@ -102,8 +154,18 @@ func (d *PikPak) List(ctx context.Context, dir model.Obj, args model.ListArgs) (
func (d *PikPak) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (*model.Link, error) {
var resp File
_, err := d.requestWithCaptchaToken(fmt.Sprintf("https://api-drive.mypikpak.com/drive/v1/files/%s?_magic=2021&thumbnail_size=SIZE_LARGE", file.GetID()),
http.MethodGet, nil, &resp)
queryParams := map[string]string{
"_magic": "2021",
"usage": "FETCH",
"thumbnail_size": "SIZE_LARGE",
}
if !d.DisableMediaLink {
queryParams["usage"] = "CACHE"
}
_, err := d.request(fmt.Sprintf("https://api-drive.mypikpak.com/drive/v1/files/%s", file.GetID()),
http.MethodGet, func(req *resty.Request) {
req.SetQueryParams(queryParams)
}, &resp)
if err != nil {
return nil, err
}
@ -209,27 +271,17 @@ func (d *PikPak) Put(ctx context.Context, dstDir model.Obj, stream model.FileStr
}
params := resp.Resumable.Params
endpoint := strings.Join(strings.Split(params.Endpoint, ".")[1:], ".")
cfg := &aws.Config{
Credentials: credentials.NewStaticCredentials(params.AccessKeyID, params.AccessKeySecret, params.SecurityToken),
Region: aws.String("pikpak"),
Endpoint: &endpoint,
//endpoint := strings.Join(strings.Split(params.Endpoint, ".")[1:], ".")
// web 端上传 返回的endpoint 为 `mypikpak.com` | android 端上传 返回的endpoint 为 `vip-lixian-07.mypikpak.com`·
if d.Addition.Platform == "android" {
params.Endpoint = "mypikpak.com"
}
ss, err := session.NewSession(cfg)
if err != nil {
return err
if stream.GetSize() <= 10*utils.MB { // 文件大小 小于10MB改用普通模式上传
return d.UploadByOSS(&params, stream, up)
}
uploader := s3manager.NewUploader(ss)
if stream.GetSize() > s3manager.MaxUploadParts*s3manager.DefaultUploadPartSize {
uploader.PartSize = stream.GetSize() / (s3manager.MaxUploadParts - 1)
}
input := &s3manager.UploadInput{
Bucket: &params.Bucket,
Key: &params.Key,
Body: stream,
}
_, err = uploader.UploadWithContext(ctx, input)
return err
// 分片上传
return d.UploadByMultipart(&params, stream.GetSize(), stream, up)
}
// 离线下载文件
@ -320,19 +372,4 @@ func (d *PikPak) DeleteOfflineTasks(ctx context.Context, taskIDs []string, delet
return nil
}
func (d *PikPak) GetUserID() error {
token, err := d.oauth2Token.Token()
if err != nil {
return err
}
userID := token.Extra("sub").(string)
if userID != "" {
d.Common.SetUserID(userID)
}
return nil
}
var _ driver.Driver = (*PikPak)(nil)

View File

@ -9,9 +9,11 @@ type Addition struct {
driver.RootID
Username string `json:"username" required:"true"`
Password string `json:"password" required:"true"`
ClientID string `json:"client_id" required:"true" default:"YNxT9w7GMdWvEOKa"`
ClientSecret string `json:"client_secret" required:"true" default:"dbw2OtmVEeuUvIptb1Coyg"`
DisableMediaLink bool `json:"disable_media_link"`
Platform string `json:"platform" required:"true" type:"select" options:"android,web"`
RefreshToken string `json:"refresh_token" required:"true" default:""`
CaptchaToken string `json:"captcha_token" default:""`
DeviceID string `json:"device_id" required:"false" default:""`
DisableMediaLink bool `json:"disable_media_link" default:"true"`
}
var config = driver.Config{

View File

@ -80,22 +80,24 @@ type UploadTaskData struct {
UploadType string `json:"upload_type"`
//UPLOAD_TYPE_RESUMABLE
Resumable *struct {
Kind string `json:"kind"`
Params struct {
AccessKeyID string `json:"access_key_id"`
AccessKeySecret string `json:"access_key_secret"`
Bucket string `json:"bucket"`
Endpoint string `json:"endpoint"`
Expiration time.Time `json:"expiration"`
Key string `json:"key"`
SecurityToken string `json:"security_token"`
} `json:"params"`
Provider string `json:"provider"`
Kind string `json:"kind"`
Params S3Params `json:"params"`
Provider string `json:"provider"`
} `json:"resumable"`
File File `json:"file"`
}
type S3Params struct {
AccessKeyID string `json:"access_key_id"`
AccessKeySecret string `json:"access_key_secret"`
Bucket string `json:"bucket"`
Endpoint string `json:"endpoint"`
Expiration time.Time `json:"expiration"`
Key string `json:"key"`
SecurityToken string `json:"security_token"`
}
// 添加离线下载响应
type OfflineDownloadResp struct {
File *string `json:"file"`

View File

@ -1,14 +1,24 @@
package pikpak
import (
"bytes"
"crypto/md5"
"crypto/sha1"
"encoding/hex"
"fmt"
"github.com/alist-org/alist/v3/internal/driver"
"github.com/alist-org/alist/v3/internal/model"
"github.com/alist-org/alist/v3/internal/op"
"github.com/alist-org/alist/v3/pkg/utils"
"github.com/aliyun/aliyun-oss-go-sdk/oss"
jsoniter "github.com/json-iterator/go"
"github.com/pkg/errors"
"io"
"net/http"
"path/filepath"
"regexp"
"strings"
"sync"
"time"
"github.com/alist-org/alist/v3/drivers/base"
@ -17,34 +27,141 @@ import (
// do others that not defined in Driver interface
var Algorithms = []string{
"PAe56I7WZ6FCSkFy77A96jHWcQA27ui80Qy4",
"SUbmk67TfdToBAEe2cZyP8vYVeN",
"1y3yFSZVWiGN95fw/2FQlRuH/Oy6WnO",
"8amLtHJpGzHPz4m9hGz7r+i+8dqQiAk",
"tmIEq5yl2g/XWwM3sKZkY4SbL8YUezrvxPksNabUJ",
"4QvudeJwgJuSf/qb9/wjC21L5aib",
"D1RJd+FZ+LBbt+dAmaIyYrT9gxJm0BB",
"1If",
"iGZr/SJPUFRkwvC174eelKy",
var AndroidAlgorithms = []string{
"Gez0T9ijiI9WCeTsKSg3SMlx",
"zQdbalsolyb1R/",
"ftOjr52zt51JD68C3s",
"yeOBMH0JkbQdEFNNwQ0RI9T3wU/v",
"BRJrQZiTQ65WtMvwO",
"je8fqxKPdQVJiy1DM6Bc9Nb1",
"niV",
"9hFCW2R1",
"sHKHpe2i96",
"p7c5E6AcXQ/IJUuAEC9W6",
"",
"aRv9hjc9P+Pbn+u3krN6",
"BzStcgE8qVdqjEH16l4",
"SqgeZvL5j9zoHP95xWHt",
"zVof5yaJkPe3VFpadPof",
}
var WebAlgorithms = []string{
"C9qPpZLN8ucRTaTiUMWYS9cQvWOE",
"+r6CQVxjzJV6LCV",
"F",
"pFJRC",
"9WXYIDGrwTCz2OiVlgZa90qpECPD6olt",
"/750aCr4lm/Sly/c",
"RB+DT/gZCrbV",
"",
"CyLsf7hdkIRxRm215hl",
"7xHvLi2tOYP0Y92b",
"ZGTXXxu8E/MIWaEDB+Sm/",
"1UI3",
"E7fP5Pfijd+7K+t6Tg/NhuLq0eEUVChpJSkrKxpO",
"ihtqpG6FMt65+Xk+tWUH2",
"NhXXU9rg4XXdzo7u5o",
}
const (
ClientID = "YNxT9w7GMdWvEOKa"
ClientSecret = "dbw2OtmVEeuUvIptb1Coyg"
ClientVersion = "1.46.2"
PackageName = "com.pikcloud.pikpak"
SdkVersion = "2.0.4.204000 "
OSSUserAgent = "aliyun-sdk-android/2.9.13(Linux/Android 14/M2004j7ac;UKQ1.231108.001)"
OssSecurityTokenHeaderName = "X-OSS-Security-Token"
ThreadsNum = 10
)
const (
AndroidClientID = "YNxT9w7GMdWvEOKa"
AndroidClientSecret = "dbw2OtmVEeuUvIptb1Coyg"
AndroidClientVersion = "1.47.1"
AndroidPackageName = "com.pikcloud.pikpak"
AndroidSdkVersion = "2.0.4.204000"
WebClientID = "YUMx5nI8ZU8Ap8pm"
WebClientSecret = "dbw2OtmVEeuUvIptb1Coyg"
WebClientVersion = "2.0.0"
WebPackageName = "mypikpak.com"
WebSdkVersion = "8.0.3"
)
func (d *PikPak) login() error {
url := "https://user.mypikpak.com/v1/auth/signin"
// 使用 用户填写的 CaptchaToken —————— (验证后的captcha_token)
if d.GetCaptchaToken() == "" {
if err := d.RefreshCaptchaTokenInLogin(GetAction(http.MethodPost, url), d.Username); err != nil {
return err
}
}
var e ErrResp
res, err := base.RestyClient.SetRetryCount(1).R().SetError(&e).SetBody(base.Json{
"captcha_token": d.GetCaptchaToken(),
"client_id": d.ClientID,
"client_secret": d.ClientSecret,
"username": d.Username,
"password": d.Password,
}).SetQueryParam("client_id", d.ClientID).Post(url)
if err != nil {
return err
}
if e.ErrorCode != 0 {
return &e
}
data := res.Body()
d.RefreshToken = jsoniter.Get(data, "refresh_token").ToString()
d.AccessToken = jsoniter.Get(data, "access_token").ToString()
d.Common.SetUserID(jsoniter.Get(data, "sub").ToString())
return nil
}
//func (d *PikPak) refreshToken() error {
// url := "https://user.mypikpak.com/v1/auth/token"
// var e ErrResp
// res, err := base.RestyClient.SetRetryCount(1).R().SetError(&e).
// SetHeader("user-agent", "").SetBody(base.Json{
// "client_id": ClientID,
// "client_secret": ClientSecret,
// "grant_type": "refresh_token",
// "refresh_token": d.RefreshToken,
// }).SetQueryParam("client_id", ClientID).Post(url)
// if err != nil {
// d.Status = err.Error()
// op.MustSaveDriverStorage(d)
// return err
// }
// if e.ErrorCode != 0 {
// if e.ErrorCode == 4126 {
// // refresh_token invalid, re-login
// return d.login()
// }
// d.Status = e.Error()
// op.MustSaveDriverStorage(d)
// return errors.New(e.Error())
// }
// data := res.Body()
// d.Status = "work"
// d.RefreshToken = jsoniter.Get(data, "refresh_token").ToString()
// d.AccessToken = jsoniter.Get(data, "access_token").ToString()
// d.Common.SetUserID(jsoniter.Get(data, "sub").ToString())
// d.Addition.RefreshToken = d.RefreshToken
// op.MustSaveDriverStorage(d)
// return nil
//}
func (d *PikPak) request(url string, method string, callback base.ReqCallback, resp interface{}) ([]byte, error) {
req := base.RestyClient.R()
token, err := d.oauth2Token.Token()
if err != nil {
return nil, err
req.SetHeaders(map[string]string{
//"Authorization": "Bearer " + d.AccessToken,
"User-Agent": d.GetUserAgent(),
"X-Device-ID": d.GetDeviceID(),
"X-Captcha-Token": d.GetCaptchaToken(),
})
if d.oauth2Token != nil {
// 使用oauth2 获取 access_token
token, err := d.oauth2Token.Token()
if err != nil {
return nil, err
}
req.SetAuthScheme(token.TokenType).SetAuthToken(token.AccessToken)
}
req.SetAuthScheme(token.TokenType).SetAuthToken(token.AccessToken)
if callback != nil {
callback(req)
@ -59,48 +176,35 @@ func (d *PikPak) request(url string, method string, callback base.ReqCallback, r
return nil, err
}
if e.IsError() {
return nil, &e
}
return res.Body(), nil
}
func (d *PikPak) requestWithCaptchaToken(url string, method string, callback base.ReqCallback, resp interface{}) ([]byte, error) {
data, err := d.request(url, method, func(req *resty.Request) {
req.SetHeaders(map[string]string{
"User-Agent": d.GetUserAgent(),
"X-Device-ID": d.GetDeviceID(),
"X-Captcha-Token": d.GetCaptchaToken(),
})
if callback != nil {
callback(req)
}
}, resp)
errResp, ok := err.(*ErrResp)
if !ok {
return nil, err
}
switch errResp.ErrorCode {
switch e.ErrorCode {
case 0:
return data, nil
//case 4122, 4121, 10, 16:
// if d.refreshTokenFunc != nil {
// if err = xc.refreshTokenFunc(); err == nil {
// break
// }
// }
// return nil, err
return res.Body(), nil
case 4122, 4121, 16:
// access_token 过期
//if err1 := d.refreshToken(); err1 != nil {
// return nil, err1
//}
t, err := d.oauth2Token.Token()
if err != nil {
return nil, err
}
d.AccessToken = t.AccessToken
d.RefreshToken = t.RefreshToken
d.Addition.RefreshToken = t.RefreshToken
op.MustSaveDriverStorage(d)
return d.request(url, method, callback, resp)
case 9: // 验证码token过期
if err = d.RefreshCaptchaTokenAtLogin(GetAction(method, url), d.Common.UserID); err != nil {
return nil, err
}
return d.request(url, method, callback, resp)
case 10: // 操作频繁
return nil, errors.New(e.ErrorDescription)
default:
return nil, err
return nil, errors.New(e.Error())
}
return d.requestWithCaptchaToken(url, method, callback, resp)
}
func (d *PikPak) getFiles(id string) ([]File, error) {
@ -141,8 +245,13 @@ type Common struct {
CaptchaToken string
UserID string
// 必要值,签名相关
DeviceID string
UserAgent string
ClientID string
ClientSecret string
ClientVersion string
PackageName string
Algorithms []string
DeviceID string
UserAgent string
// 验证码token刷新成功回调
RefreshCTokenCk func(token string)
}
@ -231,8 +340,8 @@ func (c *Common) GetDeviceID() string {
// RefreshCaptchaTokenAtLogin 刷新验证码token(登录后)
func (d *PikPak) RefreshCaptchaTokenAtLogin(action, userID string) error {
metas := map[string]string{
"client_version": ClientVersion,
"package_name": PackageName,
"client_version": d.ClientVersion,
"package_name": d.PackageName,
"user_id": userID,
}
metas["timestamp"], metas["captcha_sign"] = d.Common.GetCaptchaSign()
@ -255,8 +364,8 @@ func (d *PikPak) RefreshCaptchaTokenInLogin(action, username string) error {
// GetCaptchaSign 获取验证码签名
func (c *Common) GetCaptchaSign() (timestamp, sign string) {
timestamp = fmt.Sprint(time.Now().UnixMilli())
str := fmt.Sprint(ClientID, ClientVersion, PackageName, c.DeviceID, timestamp)
for _, algorithm := range Algorithms {
str := fmt.Sprint(c.ClientID, c.ClientVersion, c.PackageName, c.DeviceID, timestamp)
for _, algorithm := range c.Algorithms {
str = utils.GetMD5EncodeStr(str + algorithm)
}
sign = "1." + str
@ -267,16 +376,16 @@ func (c *Common) GetCaptchaSign() (timestamp, sign string) {
func (d *PikPak) refreshCaptchaToken(action string, metas map[string]string) error {
param := CaptchaTokenRequest{
Action: action,
CaptchaToken: d.Common.CaptchaToken,
ClientID: ClientID,
DeviceID: d.Common.DeviceID,
CaptchaToken: d.GetCaptchaToken(),
ClientID: d.ClientID,
DeviceID: d.GetDeviceID(),
Meta: metas,
RedirectUri: "xlaccsdk01://xbase.cloud/callback?state=harbor",
}
var e ErrResp
var resp CaptchaTokenResponse
_, err := d.request("https://user.mypikpak.com/v1/shield/captcha/init", http.MethodPost, func(req *resty.Request) {
req.SetError(&e).SetBody(param)
req.SetError(&e).SetBody(param).SetQueryParam("client_id", d.ClientID)
}, &resp)
if err != nil {
@ -284,20 +393,250 @@ func (d *PikPak) refreshCaptchaToken(action string, metas map[string]string) err
}
if e.IsError() {
return &e
return errors.New(e.Error())
}
if resp.Url != "" {
return fmt.Errorf(`need verify: <a target="_blank" href="%s">Click Here</a>`, resp.Url)
}
if resp.CaptchaToken == "" {
return fmt.Errorf("empty captchaToken")
}
if d.Common.RefreshCTokenCk != nil {
d.Common.RefreshCTokenCk(resp.CaptchaToken)
}
d.Common.SetCaptchaToken(resp.CaptchaToken)
return nil
}
func (d *PikPak) UploadByOSS(params *S3Params, stream model.FileStreamer, up driver.UpdateProgress) error {
ossClient, err := oss.New(params.Endpoint, params.AccessKeyID, params.AccessKeySecret)
if err != nil {
return err
}
bucket, err := ossClient.Bucket(params.Bucket)
if err != nil {
return err
}
err = bucket.PutObject(params.Key, stream, OssOption(params)...)
if err != nil {
return err
}
return nil
}
func (d *PikPak) UploadByMultipart(params *S3Params, fileSize int64, stream model.FileStreamer, up driver.UpdateProgress) error {
var (
chunks []oss.FileChunk
parts []oss.UploadPart
imur oss.InitiateMultipartUploadResult
ossClient *oss.Client
bucket *oss.Bucket
err error
)
tmpF, err := stream.CacheFullInTempFile()
if err != nil {
return err
}
if ossClient, err = oss.New(params.Endpoint, params.AccessKeyID, params.AccessKeySecret); err != nil {
return err
}
if bucket, err = ossClient.Bucket(params.Bucket); err != nil {
return err
}
ticker := time.NewTicker(time.Hour * 12)
defer ticker.Stop()
// 设置超时
timeout := time.NewTimer(time.Hour * 24)
if chunks, err = SplitFile(fileSize); err != nil {
return err
}
if imur, err = bucket.InitiateMultipartUpload(params.Key,
oss.SetHeader(OssSecurityTokenHeaderName, params.SecurityToken),
oss.UserAgentHeader(OSSUserAgent),
); err != nil {
return err
}
wg := sync.WaitGroup{}
wg.Add(len(chunks))
chunksCh := make(chan oss.FileChunk)
errCh := make(chan error)
UploadedPartsCh := make(chan oss.UploadPart)
quit := make(chan struct{})
// producer
go chunksProducer(chunksCh, chunks)
go func() {
wg.Wait()
quit <- struct{}{}
}()
// consumers
for i := 0; i < ThreadsNum; i++ {
go func(threadId int) {
defer func() {
if r := recover(); r != nil {
errCh <- fmt.Errorf("recovered in %v", r)
}
}()
for chunk := range chunksCh {
var part oss.UploadPart // 出现错误就继续尝试共尝试3次
for retry := 0; retry < 3; retry++ {
select {
case <-ticker.C:
errCh <- errors.Wrap(err, "ossToken 过期")
default:
}
buf := make([]byte, chunk.Size)
if _, err = tmpF.ReadAt(buf, chunk.Offset); err != nil && !errors.Is(err, io.EOF) {
continue
}
b := bytes.NewBuffer(buf)
if part, err = bucket.UploadPart(imur, b, chunk.Size, chunk.Number, OssOption(params)...); err == nil {
break
}
}
if err != nil {
errCh <- errors.Wrap(err, fmt.Sprintf("上传 %s 的第%d个分片时出现错误%v", stream.GetName(), chunk.Number, err))
}
UploadedPartsCh <- part
}
}(i)
}
go func() {
for part := range UploadedPartsCh {
parts = append(parts, part)
wg.Done()
}
}()
LOOP:
for {
select {
case <-ticker.C:
// ossToken 过期
return err
case <-quit:
break LOOP
case <-errCh:
return err
case <-timeout.C:
return fmt.Errorf("time out")
}
}
// EOF错误是xml的Unmarshal导致的响应其实是json格式所以实际上上传是成功的
if _, err = bucket.CompleteMultipartUpload(imur, parts, OssOption(params)...); err != nil && !errors.Is(err, io.EOF) {
// 当文件名含有 &< 这两个字符之一时响应的xml解析会出现错误实际上上传是成功的
if filename := filepath.Base(stream.GetName()); !strings.ContainsAny(filename, "&<") {
return err
}
}
return nil
}
func chunksProducer(ch chan oss.FileChunk, chunks []oss.FileChunk) {
for _, chunk := range chunks {
ch <- chunk
}
}
func SplitFile(fileSize int64) (chunks []oss.FileChunk, err error) {
for i := int64(1); i < 10; i++ {
if fileSize < i*utils.GB { // 文件大小小于iGB时分为i*100片
if chunks, err = SplitFileByPartNum(fileSize, int(i*100)); err != nil {
return
}
break
}
}
if fileSize > 9*utils.GB { // 文件大小大于9GB时分为1000片
if chunks, err = SplitFileByPartNum(fileSize, 1000); err != nil {
return
}
}
// 单个分片大小不能小于1MB
if chunks[0].Size < 1*utils.MB {
if chunks, err = SplitFileByPartSize(fileSize, 1*utils.MB); err != nil {
return
}
}
return
}
// SplitFileByPartNum splits big file into parts by the num of parts.
// Split the file with specified parts count, returns the split result when error is nil.
func SplitFileByPartNum(fileSize int64, chunkNum int) ([]oss.FileChunk, error) {
if chunkNum <= 0 || chunkNum > 10000 {
return nil, errors.New("chunkNum invalid")
}
if int64(chunkNum) > fileSize {
return nil, errors.New("oss: chunkNum invalid")
}
var chunks []oss.FileChunk
chunk := oss.FileChunk{}
chunkN := (int64)(chunkNum)
for i := int64(0); i < chunkN; i++ {
chunk.Number = int(i + 1)
chunk.Offset = i * (fileSize / chunkN)
if i == chunkN-1 {
chunk.Size = fileSize/chunkN + fileSize%chunkN
} else {
chunk.Size = fileSize / chunkN
}
chunks = append(chunks, chunk)
}
return chunks, nil
}
// SplitFileByPartSize splits big file into parts by the size of parts.
// Splits the file by the part size. Returns the FileChunk when error is nil.
func SplitFileByPartSize(fileSize int64, chunkSize int64) ([]oss.FileChunk, error) {
if chunkSize <= 0 {
return nil, errors.New("chunkSize invalid")
}
chunkN := fileSize / chunkSize
if chunkN >= 10000 {
return nil, errors.New("Too many parts, please increase part size")
}
var chunks []oss.FileChunk
chunk := oss.FileChunk{}
for i := int64(0); i < chunkN; i++ {
chunk.Number = int(i + 1)
chunk.Offset = i * chunkSize
chunk.Size = chunkSize
chunks = append(chunks, chunk)
}
if fileSize%chunkSize > 0 {
chunk.Number = len(chunks) + 1
chunk.Offset = int64(len(chunks)) * chunkSize
chunk.Size = fileSize % chunkSize
chunks = append(chunks, chunk)
}
return chunks, nil
}
// OssOption get options
func OssOption(params *S3Params) []oss.Option {
options := []oss.Option{
oss.SetHeader(OssSecurityTokenHeaderName, params.SecurityToken),
oss.UserAgentHeader(OSSUserAgent),
}
return options
}

View File

@ -2,20 +2,20 @@ package pikpak_share
import (
"context"
"github.com/alist-org/alist/v3/internal/op"
"net/http"
"time"
"github.com/alist-org/alist/v3/drivers/base"
"github.com/alist-org/alist/v3/internal/driver"
"github.com/alist-org/alist/v3/internal/model"
"github.com/alist-org/alist/v3/pkg/utils"
"github.com/go-resty/resty/v2"
"golang.org/x/oauth2"
)
type PikPakShare struct {
model.Storage
Addition
oauth2Token oauth2.TokenSource
*Common
PassCodeToken string
}
@ -28,28 +28,45 @@ func (d *PikPakShare) GetAddition() driver.Additional {
}
func (d *PikPakShare) Init(ctx context.Context) error {
if d.ClientID == "" || d.ClientSecret == "" {
d.ClientID = "YNxT9w7GMdWvEOKa"
d.ClientSecret = "dbw2OtmVEeuUvIptb1Coyg"
if d.Common == nil {
d.Common = &Common{
DeviceID: utils.GetMD5EncodeStr(d.Addition.ShareId + d.Addition.SharePwd + time.Now().String()),
UserAgent: "",
RefreshCTokenCk: func(token string) {
d.Common.CaptchaToken = token
op.MustSaveDriverStorage(d)
},
}
}
oauth2Config := &oauth2.Config{
ClientID: d.ClientID,
ClientSecret: d.ClientSecret,
Endpoint: oauth2.Endpoint{
AuthURL: "https://user.mypikpak.com/v1/auth/signin",
TokenURL: "https://user.mypikpak.com/v1/auth/token",
AuthStyle: oauth2.AuthStyleInParams,
},
if d.Addition.DeviceID != "" {
d.SetDeviceID(d.Addition.DeviceID)
} else {
d.Addition.DeviceID = d.Common.DeviceID
op.MustSaveDriverStorage(d)
}
d.oauth2Token = oauth2.ReuseTokenSource(nil, utils.TokenSource(func() (*oauth2.Token, error) {
return oauth2Config.PasswordCredentialsToken(
context.WithValue(context.Background(), oauth2.HTTPClient, base.HttpClient),
d.Username,
d.Password,
)
}))
if d.Platform == "android" {
d.ClientID = AndroidClientID
d.ClientSecret = AndroidClientSecret
d.ClientVersion = AndroidClientVersion
d.PackageName = AndroidPackageName
d.Algorithms = AndroidAlgorithms
d.UserAgent = BuildCustomUserAgent(d.GetDeviceID(), AndroidClientID, AndroidPackageName, AndroidSdkVersion, AndroidClientVersion, AndroidPackageName, "")
} else if d.Platform == "web" {
d.ClientID = WebClientID
d.ClientSecret = WebClientSecret
d.ClientVersion = WebClientVersion
d.PackageName = WebPackageName
d.Algorithms = WebAlgorithms
d.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36"
}
// 获取CaptchaToken
err := d.RefreshCaptchaToken(GetAction(http.MethodGet, "https://api-drive.mypikpak.com/drive/v1/share:batch_file_info"), "")
if err != nil {
return err
}
if d.SharePwd != "" {
return d.getSharePassToken()
@ -87,9 +104,14 @@ func (d *PikPakShare) Link(ctx context.Context, file model.Obj, args model.LinkA
downloadUrl := resp.FileInfo.WebContentLink
if downloadUrl == "" && len(resp.FileInfo.Medias) > 0 {
downloadUrl = resp.FileInfo.Medias[0].Link.Url
}
// 使用转码后的链接
if d.Addition.UseTransCodingAddress && len(resp.FileInfo.Medias) > 1 {
downloadUrl = resp.FileInfo.Medias[1].Link.Url
} else {
downloadUrl = resp.FileInfo.Medias[0].Link.Url
}
}
link := model.Link{
URL: downloadUrl,
}

View File

@ -7,12 +7,11 @@ import (
type Addition struct {
driver.RootID
Username string `json:"username" required:"true"`
Password string `json:"password" required:"true"`
ShareId string `json:"share_id" required:"true"`
SharePwd string `json:"share_pwd"`
ClientID string `json:"client_id" required:"true" default:"YNxT9w7GMdWvEOKa"`
ClientSecret string `json:"client_secret" required:"true" default:"dbw2OtmVEeuUvIptb1Coyg"`
ShareId string `json:"share_id" required:"true"`
SharePwd string `json:"share_pwd"`
Platform string `json:"platform" required:"true" type:"select" options:"android,web"`
DeviceID string `json:"device_id" required:"false" default:""`
UseTransCodingAddress bool `json:"use_transcoding_address" required:"true" default:"false"`
}
var config = driver.Config{

View File

@ -1,20 +1,16 @@
package pikpak_share
import (
"fmt"
"strconv"
"time"
"github.com/alist-org/alist/v3/internal/model"
)
type RespErr struct {
ErrorCode int `json:"error_code"`
Error string `json:"error"`
}
type ShareResp struct {
ShareStatus string `json:"share_status"`
ShareStatusText string `json:"share_status_text"`
ShareStatus string `json:"share_status"`
ShareStatusText string `json:"share_status_text"`
FileInfo File `json:"file_info"`
Files []File `json:"files"`
NextPageToken string `json:"next_page_token"`
@ -78,3 +74,32 @@ type Media struct {
IsVisible bool `json:"is_visible"`
Category string `json:"category"`
}
type CaptchaTokenRequest struct {
Action string `json:"action"`
CaptchaToken string `json:"captcha_token"`
ClientID string `json:"client_id"`
DeviceID string `json:"device_id"`
Meta map[string]string `json:"meta"`
RedirectUri string `json:"redirect_uri"`
}
type CaptchaTokenResponse struct {
CaptchaToken string `json:"captcha_token"`
ExpiresIn int64 `json:"expires_in"`
Url string `json:"url"`
}
type ErrResp struct {
ErrorCode int64 `json:"error_code"`
ErrorMsg string `json:"error"`
ErrorDescription string `json:"error_description"`
}
func (e *ErrResp) IsError() bool {
return e.ErrorCode != 0 || e.ErrorMsg != "" || e.ErrorDescription != ""
}
func (e *ErrResp) Error() string {
return fmt.Sprintf("ErrorCode: %d ,Error: %s ,ErrorDescription: %s ", e.ErrorCode, e.ErrorMsg, e.ErrorDescription)
}

View File

@ -1,21 +1,78 @@
package pikpak_share
import (
"crypto/md5"
"crypto/sha1"
"encoding/hex"
"errors"
"fmt"
"github.com/alist-org/alist/v3/pkg/utils"
"net/http"
"regexp"
"strings"
"time"
"github.com/alist-org/alist/v3/drivers/base"
"github.com/go-resty/resty/v2"
)
var AndroidAlgorithms = []string{
"Gez0T9ijiI9WCeTsKSg3SMlx",
"zQdbalsolyb1R/",
"ftOjr52zt51JD68C3s",
"yeOBMH0JkbQdEFNNwQ0RI9T3wU/v",
"BRJrQZiTQ65WtMvwO",
"je8fqxKPdQVJiy1DM6Bc9Nb1",
"niV",
"9hFCW2R1",
"sHKHpe2i96",
"p7c5E6AcXQ/IJUuAEC9W6",
"",
"aRv9hjc9P+Pbn+u3krN6",
"BzStcgE8qVdqjEH16l4",
"SqgeZvL5j9zoHP95xWHt",
"zVof5yaJkPe3VFpadPof",
}
var WebAlgorithms = []string{
"C9qPpZLN8ucRTaTiUMWYS9cQvWOE",
"+r6CQVxjzJV6LCV",
"F",
"pFJRC",
"9WXYIDGrwTCz2OiVlgZa90qpECPD6olt",
"/750aCr4lm/Sly/c",
"RB+DT/gZCrbV",
"",
"CyLsf7hdkIRxRm215hl",
"7xHvLi2tOYP0Y92b",
"ZGTXXxu8E/MIWaEDB+Sm/",
"1UI3",
"E7fP5Pfijd+7K+t6Tg/NhuLq0eEUVChpJSkrKxpO",
"ihtqpG6FMt65+Xk+tWUH2",
"NhXXU9rg4XXdzo7u5o",
}
const (
AndroidClientID = "YNxT9w7GMdWvEOKa"
AndroidClientSecret = "dbw2OtmVEeuUvIptb1Coyg"
AndroidClientVersion = "1.47.1"
AndroidPackageName = "com.pikcloud.pikpak"
AndroidSdkVersion = "2.0.4.204000"
WebClientID = "YUMx5nI8ZU8Ap8pm"
WebClientSecret = "dbw2OtmVEeuUvIptb1Coyg"
WebClientVersion = "2.0.0"
WebPackageName = "mypikpak.com"
WebSdkVersion = "8.0.3"
)
func (d *PikPakShare) request(url string, method string, callback base.ReqCallback, resp interface{}) ([]byte, error) {
req := base.RestyClient.R()
token, err := d.oauth2Token.Token()
if err != nil {
return nil, err
}
req.SetAuthScheme(token.TokenType).SetAuthToken(token.AccessToken)
req.SetHeaders(map[string]string{
"User-Agent": d.GetUserAgent(),
"X-Client-ID": d.GetClientID(),
"X-Device-ID": d.GetDeviceID(),
"X-Captcha-Token": d.GetCaptchaToken(),
})
if callback != nil {
callback(req)
@ -23,16 +80,25 @@ func (d *PikPakShare) request(url string, method string, callback base.ReqCallba
if resp != nil {
req.SetResult(resp)
}
var e RespErr
var e ErrResp
req.SetError(&e)
res, err := req.Execute(method, url)
if err != nil {
return nil, err
}
if e.ErrorCode != 0 {
return nil, errors.New(e.Error)
switch e.ErrorCode {
case 0:
return res.Body(), nil
case 9: // 验证码token过期
if err = d.RefreshCaptchaToken(GetAction(method, url), ""); err != nil {
return nil, err
}
return d.request(url, method, callback, resp)
case 10: // 操作频繁
return nil, errors.New(e.ErrorDescription)
default:
return nil, errors.New(e.Error())
}
return res.Body(), nil
}
func (d *PikPakShare) getSharePassToken() error {
@ -92,3 +158,161 @@ func (d *PikPakShare) getFiles(id string) ([]File, error) {
}
return res, nil
}
func GetAction(method string, url string) string {
urlpath := regexp.MustCompile(`://[^/]+((/[^/\s?#]+)*)`).FindStringSubmatch(url)[1]
return method + ":" + urlpath
}
type Common struct {
client *resty.Client
CaptchaToken string
// 必要值,签名相关
ClientID string
ClientSecret string
ClientVersion string
PackageName string
Algorithms []string
DeviceID string
UserAgent string
// 验证码token刷新成功回调
RefreshCTokenCk func(token string)
}
func (c *Common) SetUserAgent(userAgent string) {
c.UserAgent = userAgent
}
func (c *Common) SetCaptchaToken(captchaToken string) {
c.CaptchaToken = captchaToken
}
func (c *Common) SetDeviceID(deviceID string) {
c.DeviceID = deviceID
}
func (c *Common) GetCaptchaToken() string {
return c.CaptchaToken
}
func (c *Common) GetClientID() string {
return c.ClientID
}
func (c *Common) GetUserAgent() string {
return c.UserAgent
}
func (c *Common) GetDeviceID() string {
return c.DeviceID
}
func generateDeviceSign(deviceID, packageName string) string {
signatureBase := fmt.Sprintf("%s%s%s%s", deviceID, packageName, "1", "appkey")
sha1Hash := sha1.New()
sha1Hash.Write([]byte(signatureBase))
sha1Result := sha1Hash.Sum(nil)
sha1String := hex.EncodeToString(sha1Result)
md5Hash := md5.New()
md5Hash.Write([]byte(sha1String))
md5Result := md5Hash.Sum(nil)
md5String := hex.EncodeToString(md5Result)
deviceSign := fmt.Sprintf("div101.%s%s", deviceID, md5String)
return deviceSign
}
func BuildCustomUserAgent(deviceID, clientID, appName, sdkVersion, clientVersion, packageName, userID string) string {
deviceSign := generateDeviceSign(deviceID, packageName)
var sb strings.Builder
sb.WriteString(fmt.Sprintf("ANDROID-%s/%s ", appName, clientVersion))
sb.WriteString("protocolVersion/200 ")
sb.WriteString("accesstype/ ")
sb.WriteString(fmt.Sprintf("clientid/%s ", clientID))
sb.WriteString(fmt.Sprintf("clientversion/%s ", clientVersion))
sb.WriteString("action_type/ ")
sb.WriteString("networktype/WIFI ")
sb.WriteString("sessionid/ ")
sb.WriteString(fmt.Sprintf("deviceid/%s ", deviceID))
sb.WriteString("providername/NONE ")
sb.WriteString(fmt.Sprintf("devicesign/%s ", deviceSign))
sb.WriteString("refresh_token/ ")
sb.WriteString(fmt.Sprintf("sdkversion/%s ", sdkVersion))
sb.WriteString(fmt.Sprintf("datetime/%d ", time.Now().UnixMilli()))
sb.WriteString(fmt.Sprintf("usrno/%s ", userID))
sb.WriteString(fmt.Sprintf("appname/android-%s ", appName))
sb.WriteString(fmt.Sprintf("session_origin/ "))
sb.WriteString(fmt.Sprintf("grant_type/ "))
sb.WriteString(fmt.Sprintf("appid/ "))
sb.WriteString(fmt.Sprintf("clientip/ "))
sb.WriteString(fmt.Sprintf("devicename/Xiaomi_M2004j7ac "))
sb.WriteString(fmt.Sprintf("osversion/13 "))
sb.WriteString(fmt.Sprintf("platformversion/10 "))
sb.WriteString(fmt.Sprintf("accessmode/ "))
sb.WriteString(fmt.Sprintf("devicemodel/M2004J7AC "))
return sb.String()
}
// RefreshCaptchaToken 刷新验证码token
func (d *PikPakShare) RefreshCaptchaToken(action, userID string) error {
metas := map[string]string{
"client_version": d.ClientVersion,
"package_name": d.PackageName,
"user_id": userID,
}
metas["timestamp"], metas["captcha_sign"] = d.Common.GetCaptchaSign()
return d.refreshCaptchaToken(action, metas)
}
// GetCaptchaSign 获取验证码签名
func (c *Common) GetCaptchaSign() (timestamp, sign string) {
timestamp = fmt.Sprint(time.Now().UnixMilli())
str := fmt.Sprint(c.ClientID, c.ClientVersion, c.PackageName, c.DeviceID, timestamp)
for _, algorithm := range c.Algorithms {
str = utils.GetMD5EncodeStr(str + algorithm)
}
sign = "1." + str
return
}
// refreshCaptchaToken 刷新CaptchaToken
func (d *PikPakShare) refreshCaptchaToken(action string, metas map[string]string) error {
param := CaptchaTokenRequest{
Action: action,
CaptchaToken: d.GetCaptchaToken(),
ClientID: d.ClientID,
DeviceID: d.GetDeviceID(),
Meta: metas,
}
var e ErrResp
var resp CaptchaTokenResponse
_, err := d.request("https://user.mypikpak.com/v1/shield/captcha/init", http.MethodPost, func(req *resty.Request) {
req.SetError(&e).SetBody(param)
}, &resp)
if err != nil {
return err
}
if e.IsError() {
return errors.New(e.Error())
}
//if resp.Url != "" {
// return fmt.Errorf(`need verify: <a target="_blank" href="%s">Click Here</a>`, resp.Url)
//}
if d.Common.RefreshCTokenCk != nil {
d.Common.RefreshCTokenCk(resp.CaptchaToken)
}
d.Common.SetCaptchaToken(resp.CaptchaToken)
return nil
}

View File

@ -0,0 +1,174 @@
package quark_uc_tv
import (
"context"
"fmt"
"github.com/alist-org/alist/v3/internal/op"
"github.com/alist-org/alist/v3/pkg/utils"
"github.com/go-resty/resty/v2"
"strconv"
"time"
"github.com/alist-org/alist/v3/internal/driver"
"github.com/alist-org/alist/v3/internal/errs"
"github.com/alist-org/alist/v3/internal/model"
)
type QuarkUCTV struct {
*QuarkUCTVCommon
model.Storage
Addition
config driver.Config
conf Conf
}
func (d *QuarkUCTV) Config() driver.Config {
return d.config
}
func (d *QuarkUCTV) GetAddition() driver.Additional {
return &d.Addition
}
func (d *QuarkUCTV) Init(ctx context.Context) error {
if d.Addition.DeviceID == "" {
d.Addition.DeviceID = utils.GetMD5EncodeStr(time.Now().String())
}
op.MustSaveDriverStorage(d)
if d.QuarkUCTVCommon == nil {
d.QuarkUCTVCommon = &QuarkUCTVCommon{
AccessToken: "",
}
}
ctx1, cancelFunc := context.WithTimeout(ctx, 5*time.Second)
defer cancelFunc()
if d.Addition.RefreshToken == "" {
if d.Addition.QueryToken == "" {
qrData, err := d.getLoginCode(ctx1)
if err != nil {
return err
}
// 展示二维码
qrTemplate := `<body>
<img src="data:image/jpeg;base64,%s"/>
</body>`
qrPage := fmt.Sprintf(qrTemplate, qrData)
return fmt.Errorf("need verify: \n%s", qrPage)
} else {
// 通过query token获取code -> refresh token
code, err := d.getCode(ctx1)
if err != nil {
return err
}
// 通过code获取refresh token
err = d.getRefreshTokenByTV(ctx1, code, false)
if err != nil {
return err
}
}
}
// 通过refresh token获取access token
if d.QuarkUCTVCommon.AccessToken == "" {
err := d.getRefreshTokenByTV(ctx1, d.Addition.RefreshToken, true)
if err != nil {
return err
}
}
// 验证 access token 是否有效
_, err := d.isLogin(ctx1)
if err != nil {
return err
}
return nil
}
func (d *QuarkUCTV) Drop(ctx context.Context) error {
return nil
}
func (d *QuarkUCTV) List(ctx context.Context, dir model.Obj, args model.ListArgs) ([]model.Obj, error) {
files := make([]model.Obj, 0)
pageIndex := int64(0)
pageSize := int64(100)
for {
var filesData FilesData
_, err := d.request(ctx, "/file", "GET", func(req *resty.Request) {
req.SetQueryParams(map[string]string{
"method": "list",
"parent_fid": dir.GetID(),
"order_by": "3",
"desc": "1",
"category": "",
"source": "",
"ex_source": "",
"list_all": "0",
"page_size": strconv.FormatInt(pageSize, 10),
"page_index": strconv.FormatInt(pageIndex, 10),
})
}, &filesData)
if err != nil {
return nil, err
}
for i := range filesData.Data.Files {
files = append(files, &filesData.Data.Files[i])
}
if pageIndex*pageSize >= filesData.Data.TotalCount {
break
} else {
pageIndex++
}
}
return files, nil
}
func (d *QuarkUCTV) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (*model.Link, error) {
files := &model.Link{}
var fileLink FileLink
_, err := d.request(ctx, "/file", "GET", func(req *resty.Request) {
req.SetQueryParams(map[string]string{
"method": "download",
"group_by": "source",
"fid": file.GetID(),
"resolution": "low,normal,high,super,2k,4k",
"support": "dolby_vision",
})
}, &fileLink)
if err != nil {
return nil, err
}
files.URL = fileLink.Data.DownloadURL
return files, nil
}
func (d *QuarkUCTV) MakeDir(ctx context.Context, parentDir model.Obj, dirName string) (model.Obj, error) {
return nil, errs.NotImplement
}
func (d *QuarkUCTV) Move(ctx context.Context, srcObj, dstDir model.Obj) (model.Obj, error) {
return nil, errs.NotImplement
}
func (d *QuarkUCTV) Rename(ctx context.Context, srcObj model.Obj, newName string) (model.Obj, error) {
return nil, errs.NotImplement
}
func (d *QuarkUCTV) Copy(ctx context.Context, srcObj, dstDir model.Obj) (model.Obj, error) {
return nil, errs.NotImplement
}
func (d *QuarkUCTV) Remove(ctx context.Context, obj model.Obj) error {
return errs.NotImplement
}
func (d *QuarkUCTV) Put(ctx context.Context, dstDir model.Obj, stream model.FileStreamer, up driver.UpdateProgress) (model.Obj, error) {
return nil, errs.NotImplement
}
type QuarkUCTVCommon struct {
AccessToken string
}
var _ driver.Driver = (*QuarkUCTV)(nil)

View File

@ -0,0 +1,67 @@
package quark_uc_tv
import (
"github.com/alist-org/alist/v3/internal/driver"
"github.com/alist-org/alist/v3/internal/op"
)
type Addition struct {
// Usually one of two
driver.RootID
// define other
RefreshToken string `json:"refresh_token" required:"false" default:""`
// 必要且影响登录,由签名决定
DeviceID string `json:"device_id" required:"false" default:""`
// 登陆所用的数据 无需手动填写
QueryToken string `json:"query_token" required:"false" default:"" help:"don't edit'"`
}
type Conf struct {
api string
clientID string
signKey string
appVer string
channel string
codeApi string
}
func init() {
op.RegisterDriver(func() driver.Driver {
return &QuarkUCTV{
config: driver.Config{
Name: "QuarkTV",
OnlyLocal: false,
DefaultRoot: "0",
NoOverwriteUpload: true,
NoUpload: true,
},
conf: Conf{
api: "https://open-api-drive.quark.cn",
clientID: "d3194e61504e493eb6222857bccfed94",
signKey: "kw2dvtd7p4t3pjl2d9ed9yc8yej8kw2d",
appVer: "1.5.6",
channel: "CP",
codeApi: "http://api.extscreen.com/quarkdrive",
},
}
})
op.RegisterDriver(func() driver.Driver {
return &QuarkUCTV{
config: driver.Config{
Name: "UCTV",
OnlyLocal: false,
DefaultRoot: "0",
NoOverwriteUpload: true,
NoUpload: true,
},
conf: Conf{
api: "https://open-api-drive.uc.cn",
clientID: "5acf882d27b74502b7040b0c65519aa7",
signKey: "l3srvtd7p42l0d0x1u8d7yc8ye9kki4d",
appVer: "1.6.5",
channel: "UCTVOFFICIALWEB",
codeApi: "http://api.extscreen.com/ucdrive",
},
}
})
}

View File

@ -0,0 +1,102 @@
package quark_uc_tv
import (
"github.com/alist-org/alist/v3/internal/model"
"github.com/alist-org/alist/v3/pkg/utils"
"time"
)
type Resp struct {
CommonRsp
Errno int `json:"errno"`
ErrorInfo string `json:"error_info"`
}
type CommonRsp struct {
Status int `json:"status"`
ReqID string `json:"req_id"`
}
type RefreshTokenAuthResp struct {
Code int `json:"code"`
Message string `json:"message"`
Data struct {
Status int `json:"status"`
Errno int `json:"errno"`
ErrorInfo string `json:"error_info"`
ReqID string `json:"req_id"`
AccessToken string `json:"access_token"`
RefreshToken string `json:"refresh_token"`
ExpiresIn int `json:"expires_in"`
Scope string `json:"scope"`
} `json:"data"`
}
type Files struct {
Fid string `json:"fid"`
ParentFid string `json:"parent_fid"`
Category int `json:"category"`
Filename string `json:"filename"`
Size int64 `json:"size"`
FileType string `json:"file_type"`
SubItems int `json:"sub_items,omitempty"`
Isdir int `json:"isdir"`
Duration int `json:"duration"`
CreatedAt int64 `json:"created_at"`
UpdatedAt int64 `json:"updated_at"`
IsBackup int `json:"is_backup"`
ThumbnailURL string `json:"thumbnail_url,omitempty"`
}
func (f *Files) GetSize() int64 {
return f.Size
}
func (f *Files) GetName() string {
return f.Filename
}
func (f *Files) ModTime() time.Time {
//return time.Unix(f.UpdatedAt, 0)
return time.Unix(0, f.UpdatedAt*int64(time.Millisecond))
}
func (f *Files) CreateTime() time.Time {
//return time.Unix(f.CreatedAt, 0)
return time.Unix(0, f.CreatedAt*int64(time.Millisecond))
}
func (f *Files) IsDir() bool {
return f.Isdir == 1
}
func (f *Files) GetHash() utils.HashInfo {
return utils.HashInfo{}
}
func (f *Files) GetID() string {
return f.Fid
}
func (f *Files) GetPath() string {
return ""
}
var _ model.Obj = (*Files)(nil)
type FilesData struct {
CommonRsp
Data struct {
TotalCount int64 `json:"total_count"`
Files []Files `json:"files"`
} `json:"data"`
}
type FileLink struct {
CommonRsp
Data struct {
Fid string `json:"fid"`
FileName string `json:"file_name"`
Size int64 `json:"size"`
DownloadURL string `json:"download_url"`
} `json:"data"`
}

211
drivers/quark_uc_tv/util.go Normal file
View File

@ -0,0 +1,211 @@
package quark_uc_tv
import (
"context"
"crypto/md5"
"crypto/sha256"
"encoding/hex"
"errors"
"github.com/alist-org/alist/v3/drivers/base"
"github.com/alist-org/alist/v3/internal/op"
"github.com/alist-org/alist/v3/pkg/utils"
"github.com/go-resty/resty/v2"
"net/http"
"strconv"
"time"
)
const (
UserAgent = "Mozilla/5.0 (Linux; U; Android 13; zh-cn; M2004J7AC Build/UKQ1.231108.001) AppleWebKit/533.1 (KHTML, like Gecko) Mobile Safari/533.1"
DeviceBrand = "Xiaomi"
Platform = "tv"
DeviceName = "M2004J7AC"
DeviceModel = "M2004J7AC"
BuildDevice = "M2004J7AC"
BuildProduct = "M2004J7AC"
DeviceGpu = "Adreno (TM) 550"
ActivityRect = "{}"
)
func (d *QuarkUCTV) request(ctx context.Context, pathname string, method string, callback base.ReqCallback, resp interface{}) ([]byte, error) {
u := d.conf.api + pathname
tm, token, reqID := d.generateReqSign(method, pathname, d.conf.signKey)
req := base.RestyClient.R()
req.SetContext(ctx)
req.SetHeaders(map[string]string{
"Accept": "application/json, text/plain, */*",
"User-Agent": UserAgent,
"x-pan-tm": tm,
"x-pan-token": token,
"x-pan-client-id": d.conf.clientID,
})
req.SetQueryParams(map[string]string{
"req_id": reqID,
"access_token": d.QuarkUCTVCommon.AccessToken,
"app_ver": d.conf.appVer,
"device_id": d.Addition.DeviceID,
"device_brand": DeviceBrand,
"platform": Platform,
"device_name": DeviceName,
"device_model": DeviceModel,
"build_device": BuildDevice,
"build_product": BuildProduct,
"device_gpu": DeviceGpu,
"activity_rect": ActivityRect,
"channel": d.conf.channel,
})
if callback != nil {
callback(req)
}
if resp != nil {
req.SetResult(resp)
}
var e Resp
req.SetError(&e)
res, err := req.Execute(method, u)
if err != nil {
return nil, err
}
// 判断 是否需要 刷新 access_token
if e.Status == -1 && e.Errno == 10001 {
// token 过期
err = d.getRefreshTokenByTV(ctx, d.Addition.RefreshToken, true)
if err != nil {
return nil, err
}
ctx1, cancelFunc := context.WithTimeout(ctx, 10*time.Second)
defer cancelFunc()
return d.request(ctx1, pathname, method, callback, resp)
}
if e.Status >= 400 || e.Errno != 0 {
return nil, errors.New(e.ErrorInfo)
}
return res.Body(), nil
}
func (d *QuarkUCTV) getLoginCode(ctx context.Context) (string, error) {
// 获取登录二维码
pathname := "/oauth/authorize"
var resp struct {
CommonRsp
QrData string `json:"qr_data"`
QueryToken string `json:"query_token"`
}
_, err := d.request(ctx, pathname, "GET", func(req *resty.Request) {
req.SetQueryParams(map[string]string{
"auth_type": "code",
"client_id": d.conf.clientID,
"scope": "netdisk",
"qrcode": "1",
"qr_width": "460",
"qr_height": "460",
})
}, &resp)
if err != nil {
return "", err
}
// 保存query_token 用于后续登录
if resp.QueryToken != "" {
d.Addition.QueryToken = resp.QueryToken
op.MustSaveDriverStorage(d)
}
return resp.QrData, nil
}
func (d *QuarkUCTV) getCode(ctx context.Context) (string, error) {
// 通过query token获取code
pathname := "/oauth/code"
var resp struct {
CommonRsp
Code string `json:"code"`
}
_, err := d.request(ctx, pathname, "GET", func(req *resty.Request) {
req.SetQueryParams(map[string]string{
"client_id": d.conf.clientID,
"scope": "netdisk",
"query_token": d.Addition.QueryToken,
})
}, &resp)
if err != nil {
return "", err
}
return resp.Code, nil
}
func (d *QuarkUCTV) getRefreshTokenByTV(ctx context.Context, code string, isRefresh bool) error {
pathname := "/token"
_, _, reqID := d.generateReqSign("POST", pathname, d.conf.signKey)
u := d.conf.codeApi + pathname
var resp RefreshTokenAuthResp
body := map[string]string{
"req_id": reqID,
"app_ver": d.conf.appVer,
"device_id": d.Addition.DeviceID,
"device_brand": DeviceBrand,
"platform": Platform,
"device_name": DeviceName,
"device_model": DeviceModel,
"build_device": BuildDevice,
"build_product": BuildProduct,
"device_gpu": DeviceGpu,
"activity_rect": ActivityRect,
"channel": d.conf.channel,
}
if isRefresh {
body["refresh_token"] = code
} else {
body["code"] = code
}
_, err := base.RestyClient.R().
SetHeader("Content-Type", "application/json").
SetBody(body).
SetResult(&resp).
SetContext(ctx).
Post(u)
if err != nil {
return err
}
if resp.Code != 200 {
return errors.New(resp.Message)
}
if resp.Data.RefreshToken != "" {
d.Addition.RefreshToken = resp.Data.RefreshToken
op.MustSaveDriverStorage(d)
d.QuarkUCTVCommon.AccessToken = resp.Data.AccessToken
} else {
return errors.New("refresh token is empty")
}
return nil
}
func (d *QuarkUCTV) isLogin(ctx context.Context) (bool, error) {
_, err := d.request(ctx, "/user", http.MethodGet, func(req *resty.Request) {
req.SetQueryParams(map[string]string{
"method": "user_info",
})
}, nil)
return err == nil, err
}
func (d *QuarkUCTV) generateReqSign(method string, pathname string, key string) (string, string, string) {
//timestamp 13位时间戳
timestamp := strconv.FormatInt(time.Now().UnixNano()/int64(time.Millisecond), 10)
deviceID := d.Addition.DeviceID
if deviceID == "" {
deviceID = utils.GetMD5EncodeStr(timestamp)
d.Addition.DeviceID = deviceID
op.MustSaveDriverStorage(d)
}
// 生成req_id
reqID := md5.Sum([]byte(deviceID + timestamp))
reqIDHex := hex.EncodeToString(reqID[:])
// 生成x_pan_token
tokenData := method + "&" + pathname + "&" + timestamp + "&" + key
xPanToken := sha256.Sum256([]byte(tokenData))
xPanTokenHex := hex.EncodeToString(xPanToken[:])
return timestamp, xPanTokenHex, reqIDHex
}

View File

@ -4,6 +4,7 @@ import (
"bytes"
"context"
"fmt"
"github.com/alist-org/alist/v3/server/common"
"io"
"net/url"
stdpath "path"
@ -95,23 +96,27 @@ func (d *S3) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (*mo
input.ResponseContentDisposition = &disposition
}
req, _ := d.linkClient.GetObjectRequest(input)
var link string
var link model.Link
var err error
if d.CustomHost != "" {
err = req.Build()
link = req.HTTPRequest.URL.String()
link.URL = req.HTTPRequest.URL.String()
if d.RemoveBucket {
link = strings.Replace(link, "/"+d.Bucket, "", 1)
link.URL = strings.Replace(link.URL, "/"+d.Bucket, "", 1)
}
} else {
link, err = req.Presign(time.Hour * time.Duration(d.SignURLExpire))
if common.ShouldProxy(d, filename) {
err = req.Sign()
link.URL = req.HTTPRequest.URL.String()
link.Header = req.HTTPRequest.Header
} else {
link.URL, err = req.Presign(time.Hour * time.Duration(d.SignURLExpire))
}
}
if err != nil {
return nil, err
}
return &model.Link{
URL: link,
}, nil
return &link, nil
}
func (d *S3) MakeDir(ctx context.Context, parentDir model.Obj, dirName string) error {

View File

@ -15,8 +15,8 @@ import (
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/s3/s3manager"
"github.com/go-resty/resty/v2"
"io"
"net/http"
"regexp"
"strings"
)
@ -309,7 +309,7 @@ type XunLeiBrowserCommon struct {
}
func (xc *XunLeiBrowserCommon) List(ctx context.Context, dir model.Obj, args model.ListArgs) ([]model.Obj, error) {
return xc.getFiles(ctx, dir.GetID(), args.ReqPath)
return xc.getFiles(ctx, dir, args.ReqPath)
}
func (xc *XunLeiBrowserCommon) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (*model.Link, error) {
@ -317,17 +317,10 @@ func (xc *XunLeiBrowserCommon) Link(ctx context.Context, file model.Obj, args mo
params := map[string]string{
"_magic": "2021",
"space": "SPACE_BROWSER",
"space": file.(*Files).GetSpace(),
"thumbnail_size": "SIZE_LARGE",
"with": "url",
}
// 对 "迅雷云盘" 内的文件 特殊处理
if file.GetPath() == ThunderDriveFileID {
params = map[string]string{}
} else if file.GetPath() == ThunderBrowserDriveSafeFileID {
// 对 "超级保险箱" 内的文件 特殊处理
params["space"] = "SPACE_BROWSER_SAFE"
}
_, err := xc.Request(FILE_API_URL+"/{fileID}", http.MethodGet, func(r *resty.Request) {
r.SetContext(ctx)
@ -361,22 +354,9 @@ func (xc *XunLeiBrowserCommon) MakeDir(ctx context.Context, parentDir model.Obj,
"kind": FOLDER,
"name": dirName,
"parent_id": parentDir.GetID(),
"space": "SPACE_BROWSER",
}
if parentDir.GetPath() == ThunderDriveFileID {
js = base.Json{
"kind": FOLDER,
"name": dirName,
"parent_id": parentDir.GetID(),
}
} else if parentDir.GetPath() == ThunderBrowserDriveSafeFileID {
js = base.Json{
"kind": FOLDER,
"name": dirName,
"parent_id": parentDir.GetID(),
"space": "SPACE_BROWSER_SAFE",
}
"space": parentDir.(*Files).GetSpace(),
}
_, err := xc.Request(FILE_API_URL, http.MethodPost, func(r *resty.Request) {
r.SetContext(ctx)
r.SetBody(&js)
@ -386,33 +366,14 @@ func (xc *XunLeiBrowserCommon) MakeDir(ctx context.Context, parentDir model.Obj,
func (xc *XunLeiBrowserCommon) Move(ctx context.Context, srcObj, dstDir model.Obj) error {
srcSpace := "SPACE_BROWSER"
dstSpace := "SPACE_BROWSER"
// 对 "超级保险箱" 内的文件 特殊处理
if srcObj.GetPath() == ThunderBrowserDriveSafeFileID {
srcSpace = "SPACE_BROWSER_SAFE"
}
if dstDir.GetPath() == ThunderBrowserDriveSafeFileID {
dstSpace = "SPACE_BROWSER_SAFE"
}
params := map[string]string{
"_from": dstSpace,
"_from": srcObj.(*Files).GetSpace(),
}
js := base.Json{
"to": base.Json{"parent_id": dstDir.GetID(), "space": dstSpace},
"space": srcSpace,
"to": base.Json{"parent_id": dstDir.GetID(), "space": dstDir.(*Files).GetSpace()},
"space": srcObj.(*Files).GetSpace(),
"ids": []string{srcObj.GetID()},
}
// 对 "迅雷云盘" 内的文件 特殊处理
if srcObj.GetPath() == ThunderDriveFileID {
params = map[string]string{}
js = base.Json{
"to": base.Json{"parent_id": dstDir.GetID()},
"ids": []string{srcObj.GetID()},
}
}
_, err := xc.Request(FILE_API_URL+":batchMove", http.MethodPost, func(r *resty.Request) {
r.SetContext(ctx)
@ -425,16 +386,7 @@ func (xc *XunLeiBrowserCommon) Move(ctx context.Context, srcObj, dstDir model.Ob
func (xc *XunLeiBrowserCommon) Rename(ctx context.Context, srcObj model.Obj, newName string) error {
params := map[string]string{
"space": "SPACE_BROWSER",
}
// 对 "迅雷云盘" 内的文件 特殊处理
if srcObj.GetPath() == ThunderDriveFileID {
params = map[string]string{}
} else if srcObj.GetPath() == ThunderBrowserDriveSafeFileID {
// 对 "超级保险箱" 内的文件 特殊处理
params = map[string]string{
"space": "SPACE_BROWSER_SAFE",
}
"space": srcObj.(*Files).GetSpace(),
}
_, err := xc.Request(FILE_API_URL+"/{fileID}", http.MethodPatch, func(r *resty.Request) {
@ -448,33 +400,14 @@ func (xc *XunLeiBrowserCommon) Rename(ctx context.Context, srcObj model.Obj, new
func (xc *XunLeiBrowserCommon) Copy(ctx context.Context, srcObj, dstDir model.Obj) error {
srcSpace := "SPACE_BROWSER"
dstSpace := "SPACE_BROWSER"
// 对 "超级保险箱" 内的文件 特殊处理
if srcObj.GetPath() == ThunderBrowserDriveSafeFileID {
srcSpace = "SPACE_BROWSER_SAFE"
}
if dstDir.GetPath() == ThunderBrowserDriveSafeFileID {
dstSpace = "SPACE_BROWSER_SAFE"
}
params := map[string]string{
"_from": dstSpace,
"_from": srcObj.(*Files).GetSpace(),
}
js := base.Json{
"to": base.Json{"parent_id": dstDir.GetID(), "space": dstSpace},
"space": srcSpace,
"to": base.Json{"parent_id": dstDir.GetID(), "space": dstDir.(*Files).GetSpace()},
"space": srcObj.(*Files).GetSpace(),
"ids": []string{srcObj.GetID()},
}
// 对 "迅雷云盘" 内的文件 特殊处理
if srcObj.GetPath() == ThunderDriveFileID {
params = map[string]string{}
js = base.Json{
"to": base.Json{"parent_id": dstDir.GetID()},
"ids": []string{srcObj.GetID()},
}
}
_, err := xc.Request(FILE_API_URL+":batchCopy", http.MethodPost, func(r *resty.Request) {
r.SetContext(ctx)
@ -488,30 +421,17 @@ func (xc *XunLeiBrowserCommon) Remove(ctx context.Context, obj model.Obj) error
js := base.Json{
"ids": []string{obj.GetID()},
"space": "SPACE_BROWSER",
"space": obj.(*Files).GetSpace(),
}
// 对 "迅雷云盘" 内的文件 特殊处理
if obj.GetPath() == ThunderDriveFileID {
js = base.Json{
"ids": []string{obj.GetID()},
}
} else if obj.GetPath() == ThunderBrowserDriveSafeFileID {
// 对 "超级保险箱" 内的文件 特殊处理
js = base.Json{
"ids": []string{obj.GetID()},
"space": "SPACE_BROWSER_SAFE",
}
}
// 先判断是否是特殊情况
if obj.GetPath() == ThunderDriveFileID {
if obj.(*Files).GetSpace() == ThunderDriveSpace {
_, err := xc.Request(FILE_API_URL+"/{fileID}/trash", http.MethodPatch, func(r *resty.Request) {
r.SetContext(ctx)
r.SetPathParam("fileID", obj.GetID())
r.SetBody("{}")
}, nil)
return err
} else if obj.GetPath() == ThunderBrowserDriveSafeFileID {
} else if obj.(*Files).GetSpace() == ThunderBrowserDriveSafeSpace || obj.(*Files).GetSpace() == ThunderDriveSafeSpace {
_, err := xc.Request(FILE_API_URL+":batchDelete", http.MethodPost, func(r *resty.Request) {
r.SetContext(ctx)
r.SetBody(&js)
@ -557,29 +477,7 @@ func (xc *XunLeiBrowserCommon) Put(ctx context.Context, dstDir model.Obj, stream
"size": stream.GetSize(),
"hash": gcid,
"upload_type": UPLOAD_TYPE_RESUMABLE,
"space": "SPACE_BROWSER",
}
// 对 "迅雷云盘" 内的文件 特殊处理
if dstDir.GetPath() == ThunderDriveFileID {
js = base.Json{
"kind": FILE,
"parent_id": dstDir.GetID(),
"name": stream.GetName(),
"size": stream.GetSize(),
"hash": gcid,
"upload_type": UPLOAD_TYPE_RESUMABLE,
}
} else if dstDir.GetPath() == ThunderBrowserDriveSafeFileID {
// 对 "超级保险箱" 内的文件 特殊处理
js = base.Json{
"kind": FILE,
"parent_id": dstDir.GetID(),
"name": stream.GetName(),
"size": stream.GetSize(),
"hash": gcid,
"upload_type": UPLOAD_TYPE_RESUMABLE,
"space": "SPACE_BROWSER_SAFE",
}
"space": dstDir.(*Files).GetSpace(),
}
var resp UploadTaskResponse
@ -610,58 +508,35 @@ func (xc *XunLeiBrowserCommon) Put(ctx context.Context, dstDir model.Obj, stream
Bucket: aws.String(param.Bucket),
Key: aws.String(param.Key),
Expires: aws.Time(param.Expiration),
Body: stream,
Body: io.TeeReader(stream, driver.NewProgress(stream.GetSize(), up)),
})
return err
}
return nil
}
func (xc *XunLeiBrowserCommon) getFiles(ctx context.Context, folderId string, path string) ([]model.Obj, error) {
func (xc *XunLeiBrowserCommon) getFiles(ctx context.Context, dir model.Obj, path string) ([]model.Obj, error) {
files := make([]model.Obj, 0)
var pageToken string
for {
var fileList FileList
folderSpace := "SPACE_BROWSER"
folderSpace := ""
switch dirF := dir.(type) {
case *Files:
folderSpace = dirF.GetSpace()
default:
// 处理 根目录的情况
folderSpace = ThunderBrowserDriveSpace
}
params := map[string]string{
"parent_id": folderId,
"parent_id": dir.GetID(),
"page_token": pageToken,
"space": folderSpace,
"filters": `{"trashed":{"eq":false}}`,
"with": "url",
"with_audit": "true",
"thumbnail_size": "SIZE_LARGE",
}
var fileType int8
// 处理特殊目录 “迅雷云盘” 设置特殊的 params 以便正常访问
pattern1 := fmt.Sprintf(`^/.*/%s(/.*)?$`, ThunderDriveFolderName)
thunderDriveMatch, _ := regexp.MatchString(pattern1, path)
// 处理特殊目录 “超级保险箱” 设置特殊的 params 以便正常访问
pattern2 := fmt.Sprintf(`^/.*/%s(/.*)?$`, ThunderBrowserDriveSafeFolderName)
thunderBrowserDriveSafeMatch, _ := regexp.MatchString(pattern2, path)
// 如果是 "迅雷云盘" 内的
if folderId == ThunderDriveFileID || thunderDriveMatch {
params = map[string]string{
"space": "",
"__type": "drive",
"refresh": "true",
"__sync": "true",
"parent_id": folderId,
"page_token": pageToken,
"with_audit": "true",
"limit": "100",
"filters": `{"phase":{"eq":"PHASE_TYPE_COMPLETE"},"trashed":{"eq":false}}`,
}
// 如果不是 "迅雷云盘"的"根目录"
if folderId == ThunderDriveFileID {
params["parent_id"] = ""
}
fileType = ThunderDriveType
} else if thunderBrowserDriveSafeMatch {
// 如果是 "超级保险箱" 内的
fileType = ThunderBrowserDriveSafeType
params["space"] = "SPACE_BROWSER_SAFE"
}
_, err := xc.Request(FILE_API_URL, http.MethodGet, func(r *resty.Request) {
r.SetContext(ctx)
@ -670,24 +545,13 @@ func (xc *XunLeiBrowserCommon) getFiles(ctx context.Context, folderId string, pa
if err != nil {
return nil, err
}
// 对文件夹也进行处理
fileList.FolderType = fileType
for i := 0; i < len(fileList.Files); i++ {
file := &fileList.Files[i]
// 标记 文件夹内的文件
file.FileType = fileList.FolderType
for i := range fileList.Files {
// 解决 "迅雷云盘" 重复出现问题————迅雷后端发送错误
if file.Name == ThunderDriveFolderName && file.ID == "" && file.FolderType == ThunderDriveFolderType && folderId != "" {
if fileList.Files[i].FolderType == ThunderDriveFolderType && fileList.Files[i].ID == "" && fileList.Files[i].Space == "" && dir.GetID() != "" {
continue
}
// 处理特殊目录 “迅雷云盘” 设置特殊的文件夹ID
if file.Name == ThunderDriveFolderName && file.ID == "" && file.FolderType == ThunderDriveFolderType {
file.ID = ThunderDriveFileID
} else if file.Name == ThunderBrowserDriveSafeFolderName && file.FolderType == ThunderBrowserDriveSafeFolderType {
file.FileType = ThunderBrowserDriveSafeType
}
files = append(files, file)
files = append(files, &fileList.Files[i])
}
if fileList.NextPageToken == "" {

View File

@ -25,7 +25,7 @@ type ExpertAddition struct {
SafePassword string `json:"safe_password" required:"true" help:"super safe password"` // 超级保险箱密码
// 签名方法1
Algorithms string `json:"algorithms" required:"true" help:"sign type is algorithms,this is required" default:"p+ExqPV,LwdwKlprzv7cQBQmxN5,vc08P1NwUBnbGsl58LzTW,VVNeXaXmZ8HH1SJEnp6YpVFSFU,pNAOJ,CNChvyDehAmUR1TDodfOusBAx,MS98NnX4Np8nxvEh6Ulv+SMMKMzKvD34C7lGWbb,9MpFF21GnVOYku0NM9Y/hzsK471UCUZ2o+,EY1QfeA06fXlw9wZNoZaXEED5zZPvNWI,,sciE,FIPqgQDUUW1e0GkiBFd5w7mCQ,zW,75XFdEO0Gi"`
Algorithms string `json:"algorithms" required:"true" help:"sign type is algorithms,this is required" default:"uWRwO7gPfdPB/0NfPtfQO+71,F93x+qPluYy6jdgNpq+lwdH1ap6WOM+nfz8/V,0HbpxvpXFsBK5CoTKam,dQhzbhzFRcawnsZqRETT9AuPAJ+wTQso82mRv,SAH98AmLZLRa6DB2u68sGhyiDh15guJpXhBzI,unqfo7Z64Rie9RNHMOB,7yxUdFADp3DOBvXdz0DPuKNVT35wqa5z0DEyEvf,RBG,ThTWPG5eC0UBqlbQ+04nZAptqGCdpv9o55A"`
// 签名方法2
CaptchaSign string `json:"captcha_sign" required:"true" help:"sign type is captcha_sign,this is required"`
Timestamp string `json:"timestamp" required:"true" help:"sign type is captcha_sign,this is required"`
@ -37,7 +37,7 @@ type ExpertAddition struct {
DeviceID string `json:"device_id" required:"false" default:""`
ClientID string `json:"client_id" required:"true" default:"ZUBzD9J_XPXfn7f7"`
ClientSecret string `json:"client_secret" required:"true" default:"yESVmHecEe6F0aou69vl-g"`
ClientVersion string `json:"client_version" required:"true" default:"1.0.8.2215"`
ClientVersion string `json:"client_version" required:"true" default:"1.10.0.2633"`
PackageName string `json:"package_name" required:"true" default:"com.xunlei.browser"`
// 不影响登录,影响下载速度

View File

@ -114,8 +114,8 @@ type Files struct {
ModifiedTime CustomTime `json:"modified_time"`
IconLink string `json:"icon_link"`
ThumbnailLink string `json:"thumbnail_link"`
// Md5Checksum string `json:"md5_checksum"`
Hash string `json:"hash"`
Md5Checksum string `json:"md5_checksum"`
Hash string `json:"hash"`
// Links map[string]Link `json:"links"`
// Phase string `json:"phase"`
// Audit struct {
@ -153,12 +153,22 @@ type Files struct {
OriginalURL string `json:"original_url"`
//Params struct{} `json:"params"`
//OriginalFileIndex int `json:"original_file_index"`
//Space string `json:"space"`
Space string `json:"space"`
//Apps []interface{} `json:"apps"`
//Writable bool `json:"writable"`
FolderType string `json:"folder_type"`
//Collection interface{} `json:"collection"`
FileType int8
SortName string `json:"sort_name"`
UserModifiedTime CustomTime `json:"user_modified_time"`
//SpellName []interface{} `json:"spell_name"`
//FileCategory string `json:"file_category"`
//Tags []interface{} `json:"tags"`
//ReferenceEvents []interface{} `json:"reference_events"`
//ReferenceResource interface{} `json:"reference_resource"`
//Params0 struct {
// PlatformIcon string `json:"platform_icon"`
// SmallThumbnail string `json:"small_thumbnail"`
//} `json:"params,omitempty"`
}
func (c *Files) GetHash() utils.HashInfo {
@ -172,16 +182,19 @@ func (c *Files) ModTime() time.Time { return c.ModifiedTime.Time }
func (c *Files) IsDir() bool { return c.Kind == FOLDER }
func (c *Files) GetID() string { return c.ID }
func (c *Files) GetPath() string {
// 对特殊文件进行特殊处理
if c.FileType == ThunderDriveType {
return ThunderDriveFileID
} else if c.FileType == ThunderBrowserDriveSafeType {
return ThunderBrowserDriveSafeFileID
}
return ""
}
func (c *Files) Thumb() string { return c.ThumbnailLink }
func (c *Files) GetSpace() string {
if c.Space != "" {
return c.Space
} else {
// "迅雷云盘" 文件夹内 Space 为空
return ""
}
}
/*
* 上传
**/

View File

@ -23,29 +23,24 @@ const (
)
var Algorithms = []string{
"p+ExqPV",
"LwdwKlprzv7cQBQmxN5",
"vc08P1NwUBnbGsl58LzTW",
"VVNeXaXmZ8HH1SJEnp6YpVFSFU",
"pNAOJ",
"CNChvyDehAmUR1TDodfOusBAx",
"MS98NnX4Np8nxvEh6Ulv+SMMKMzKvD34C7lGWbb",
"9MpFF21GnVOYku0NM9Y/hzsK471UCUZ2o+",
"EY1QfeA06fXlw9wZNoZaXEED5zZPvNWI",
"",
"sciE",
"FIPqgQDUUW1e0GkiBFd5w7mCQ",
"zW",
"75XFdEO0Gi",
"uWRwO7gPfdPB/0NfPtfQO+71",
"F93x+qPluYy6jdgNpq+lwdH1ap6WOM+nfz8/V",
"0HbpxvpXFsBK5CoTKam",
"dQhzbhzFRcawnsZqRETT9AuPAJ+wTQso82mRv",
"SAH98AmLZLRa6DB2u68sGhyiDh15guJpXhBzI",
"unqfo7Z64Rie9RNHMOB",
"7yxUdFADp3DOBvXdz0DPuKNVT35wqa5z0DEyEvf",
"RBG",
"ThTWPG5eC0UBqlbQ+04nZAptqGCdpv9o55A",
}
const (
ClientID = "ZUBzD9J_XPXfn7f7"
ClientSecret = "yESVmHecEe6F0aou69vl-g"
ClientVersion = "1.0.8.2215"
ClientVersion = "1.10.0.2633"
PackageName = "com.xunlei.browser"
DownloadUserAgent = "AndroidDownloadManager/13 (Linux; U; Android 13; M2004J7AC Build/SP1A.210812.016)"
SdkVersion = "2.0.3.262"
SdkVersion = "233100"
)
const (
@ -62,12 +57,10 @@ const (
)
const (
ThunderDriveFileID = "XXXXXXXXXXXXXXXXXXXXXXXXXX"
ThunderBrowserDriveSafeFileID = "YYYYYYYYYYYYYYYYYYYYYYYYYY"
ThunderDriveFolderName = "迅雷云盘"
ThunderBrowserDriveSafeFolderName = "超级保险箱"
ThunderDriveType = 1
ThunderBrowserDriveSafeType = 2
ThunderDriveSpace = ""
ThunderDriveSafeSpace = "SPACE_SAFE"
ThunderBrowserDriveSpace = "SPACE_BROWSER"
ThunderBrowserDriveSafeSpace = "SPACE_BROWSER_SAFE"
ThunderDriveFolderType = "DEFAULT_ROOT"
ThunderBrowserDriveSafeFolderType = "BROWSER_SAFE"
)

70
go.mod
View File

@ -3,33 +3,33 @@ module github.com/alist-org/alist/v3
go 1.22.4
require (
github.com/SheltonZhu/115driver v1.0.25
github.com/Xhofe/go-cache v0.0.0-20220723083548-714439c8af9a
github.com/SheltonZhu/115driver v1.0.27
github.com/Xhofe/go-cache v0.0.0-20240804043513-b1a71927bc21
github.com/Xhofe/rateg v0.0.0-20230728072201-251a4e1adad4
github.com/alist-org/gofakes3 v0.0.6
github.com/alist-org/times v0.0.0-20240721124318-c2e3da27cc69
github.com/alist-org/gofakes3 v0.0.7
github.com/alist-org/times v0.0.0-20240721124654-efa0c7d3ad92
github.com/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible
github.com/avast/retry-go v3.0.0+incompatible
github.com/aws/aws-sdk-go v1.54.19
github.com/blevesearch/bleve/v2 v2.4.1
github.com/aws/aws-sdk-go v1.55.5
github.com/blevesearch/bleve/v2 v2.4.2
github.com/caarlos0/env/v9 v9.0.0
github.com/charmbracelet/bubbles v0.18.0
github.com/charmbracelet/bubbletea v0.26.6
github.com/charmbracelet/lipgloss v0.12.1
github.com/city404/v6-public-rpc-proto/go v0.0.0-20240708163039-9a9b82a0ce4d
github.com/charmbracelet/bubbles v0.19.0
github.com/charmbracelet/bubbletea v0.27.0
github.com/charmbracelet/lipgloss v0.13.0
github.com/city404/v6-public-rpc-proto/go v0.0.0-20240817070657-90f8e24b653e
github.com/coreos/go-oidc v2.2.1+incompatible
github.com/deckarep/golang-set/v2 v2.6.0
github.com/dhowden/tag v0.0.0-20240417053706-3d75831295e8
github.com/disintegration/imaging v1.6.2
github.com/dlclark/regexp2 v1.11.2
github.com/dlclark/regexp2 v1.11.4
github.com/dustinxie/ecc v0.0.0-20210511000915-959544187564
github.com/foxxorcat/mopan-sdk-go v0.1.6
github.com/foxxorcat/weiyun-sdk-go v0.1.3
github.com/gaoyb7/115drive-webdav v0.1.8
github.com/gin-contrib/cors v1.7.2
github.com/gin-gonic/gin v1.10.0
github.com/go-resty/resty/v2 v2.13.1
github.com/go-webauthn/webauthn v0.10.2
github.com/go-resty/resty/v2 v2.14.0
github.com/go-webauthn/webauthn v0.11.1
github.com/golang-jwt/jwt/v4 v4.5.0
github.com/google/uuid v1.6.0
github.com/gorilla/websocket v1.5.3
@ -37,9 +37,9 @@ require (
github.com/ipfs/go-ipfs-api v0.7.0
github.com/jlaffaye/ftp v0.2.0
github.com/json-iterator/go v1.1.12
github.com/larksuite/oapi-sdk-go/v3 v3.2.8
github.com/larksuite/oapi-sdk-go/v3 v3.3.1
github.com/maruel/natural v1.1.1
github.com/meilisearch/meilisearch-go v0.27.0
github.com/meilisearch/meilisearch-go v0.28.0
github.com/minio/sio v0.4.0
github.com/natefinch/lumberjack v2.0.0+incompatible
github.com/ncw/swift/v2 v2.0.2
@ -55,15 +55,15 @@ require (
github.com/u2takey/ffmpeg-go v0.5.0
github.com/upyun/go-sdk/v3 v3.0.4
github.com/winfsp/cgofuse v1.5.1-0.20230130140708-f87f5db493b5
github.com/xhofe/tache v0.1.1
github.com/xhofe/tache v0.1.2
github.com/xhofe/wopan-sdk-go v0.1.3
github.com/zzzhr1990/go-common-entity v0.0.0-20221216044934-fd1c571e3a22
golang.org/x/crypto v0.25.0
golang.org/x/exp v0.0.0-20240707233637-46b078467d37
golang.org/x/image v0.18.0
golang.org/x/net v0.27.0
golang.org/x/oauth2 v0.21.0
golang.org/x/time v0.5.0
golang.org/x/crypto v0.26.0
golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa
golang.org/x/image v0.19.0
golang.org/x/net v0.28.0
golang.org/x/oauth2 v0.22.0
golang.org/x/time v0.6.0
google.golang.org/appengine v1.6.8
gopkg.in/ldap.v3 v3.1.0
gorm.io/driver/mysql v1.5.7
@ -74,8 +74,8 @@ require (
require (
github.com/BurntSushi/toml v0.3.1 // indirect
github.com/blevesearch/go-faiss v1.0.19 // indirect
github.com/blevesearch/zapx/v16 v16.1.4 // indirect
github.com/blevesearch/go-faiss v1.0.20 // indirect
github.com/blevesearch/zapx/v16 v16.1.5 // indirect
github.com/bytedance/sonic/loader v0.1.1 // indirect
github.com/charmbracelet/x/ansi v0.1.4 // indirect
github.com/charmbracelet/x/input v0.1.0 // indirect
@ -102,12 +102,12 @@ require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/bits-and-blooms/bitset v1.12.0 // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/blevesearch/bleve_index_api v1.1.9 // indirect
github.com/blevesearch/bleve_index_api v1.1.10 // indirect
github.com/blevesearch/geo v0.1.20 // indirect
github.com/blevesearch/go-porterstemmer v1.0.3 // indirect
github.com/blevesearch/gtreap v0.1.1 // indirect
github.com/blevesearch/mmap-go v1.0.4 // indirect
github.com/blevesearch/scorch_segment_api/v2 v2.2.14 // indirect
github.com/blevesearch/scorch_segment_api/v2 v2.2.15 // indirect
github.com/blevesearch/segment v0.9.1 // indirect
github.com/blevesearch/snowballstem v0.9.0 // indirect
github.com/blevesearch/upsidedown_store_api v1.0.2 // indirect
@ -125,7 +125,7 @@ require (
github.com/crackcomm/go-gitignore v0.0.0-20170627025303-887ab5e44cc3 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect
github.com/fxamacker/cbor/v2 v2.6.0 // indirect
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/geoffgarside/ber v1.1.0 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
@ -135,13 +135,13 @@ require (
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.20.0 // indirect
github.com/go-sql-driver/mysql v1.7.0 // indirect
github.com/go-webauthn/x v0.1.9 // indirect
github.com/go-webauthn/x v0.1.12 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/golang-jwt/jwt/v5 v5.2.1 // indirect
github.com/golang/geo v0.0.0-20210211234256-740aa86cb551 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/go-tpm v0.9.0 // indirect
github.com/google/go-tpm v0.9.1 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
@ -169,7 +169,7 @@ require (
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-localereader v0.0.1 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/mattn/go-sqlite3 v1.14.22 // indirect
github.com/minio/sha256-simd v1.0.1 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
@ -219,11 +219,11 @@ require (
github.com/yusufpapurcu/wmi v1.2.4 // indirect
go.etcd.io/bbolt v1.3.8 // indirect
golang.org/x/arch v0.8.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/term v0.22.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/tools v0.23.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.24.0 // indirect
golang.org/x/term v0.23.0 // indirect
golang.org/x/text v0.17.0 // indirect
golang.org/x/tools v0.24.0 // indirect
google.golang.org/api v0.169.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 // indirect
google.golang.org/grpc v1.65.0

153
go.sum
View File

@ -7,22 +7,22 @@ github.com/Max-Sum/base32768 v0.0.0-20230304063302-18e6ce5945fd h1:nzE1YQBdx1bq9
github.com/Max-Sum/base32768 v0.0.0-20230304063302-18e6ce5945fd/go.mod h1:C8yoIfvESpM3GD07OCHU7fqI7lhwyZ2Td1rbNbTAhnc=
github.com/RoaringBitmap/roaring v1.9.3 h1:t4EbC5qQwnisr5PrP9nt0IRhRTb9gMUgQF4t4S2OByM=
github.com/RoaringBitmap/roaring v1.9.3/go.mod h1:6AXUsoIEzDTFFQCe1RbGA6uFONMhvejWj5rqITANK90=
github.com/SheltonZhu/115driver v1.0.25 h1:i101yanLKUwV1Pi7x+vgNOwgz7Hp9JbNmo6BCZ9/4wo=
github.com/SheltonZhu/115driver v1.0.25/go.mod h1:e3fPOBANbH/FsTya8FquJwOR3ErhCQgEab3q6CVY2k4=
github.com/SheltonZhu/115driver v1.0.27 h1:Ya1HYHYXFmi7JnqQ/+Vy6xZvq3leto+E+PxTm6UChj8=
github.com/SheltonZhu/115driver v1.0.27/go.mod h1:e3fPOBANbH/FsTya8FquJwOR3ErhCQgEab3q6CVY2k4=
github.com/Unknwon/goconfig v1.0.0 h1:9IAu/BYbSLQi8puFjUQApZTxIHqSwrj5d8vpP8vTq4A=
github.com/Unknwon/goconfig v1.0.0/go.mod h1:wngxua9XCNjvHjDiTiV26DaKDT+0c63QR6H5hjVUUxw=
github.com/Xhofe/go-cache v0.0.0-20220723083548-714439c8af9a h1:RenIAa2q4H8UcS/cqmwdT1WCWIAH5aumP8m8RpbqVsE=
github.com/Xhofe/go-cache v0.0.0-20220723083548-714439c8af9a/go.mod h1:sSBbaOg90XwWKtpT56kVujF0bIeVITnPlssLclogS04=
github.com/Xhofe/go-cache v0.0.0-20240804043513-b1a71927bc21 h1:h6q5E9aMBhhdqouW81LozVPI1I+Pu6IxL2EKpfm5OjY=
github.com/Xhofe/go-cache v0.0.0-20240804043513-b1a71927bc21/go.mod h1:sSBbaOg90XwWKtpT56kVujF0bIeVITnPlssLclogS04=
github.com/Xhofe/rateg v0.0.0-20230728072201-251a4e1adad4 h1:WnvifFgYyogPz2ZFvaVLk4gI/Co0paF92FmxSR6U1zY=
github.com/Xhofe/rateg v0.0.0-20230728072201-251a4e1adad4/go.mod h1:8pWlL2rpusvx7Xa6yYaIWOJ8bR3gPdFBUT7OystyGOY=
github.com/abbot/go-http-auth v0.4.0 h1:QjmvZ5gSC7jm3Zg54DqWE/T5m1t2AfDu6QlXJT0EVT0=
github.com/abbot/go-http-auth v0.4.0/go.mod h1:Cz6ARTIzApMJDzh5bRMSUou6UMSp0IEXg9km/ci7TJM=
github.com/aead/ecdh v0.2.0 h1:pYop54xVaq/CEREFEcukHRZfTdjiWvYIsZDXXrBapQQ=
github.com/aead/ecdh v0.2.0/go.mod h1:a9HHtXuSo8J1Js1MwLQx2mBhkXMT6YwUmVVEY4tTB8U=
github.com/alist-org/gofakes3 v0.0.6 h1:kenkDSqOIJt5ZDJ9KW91YkwplFXpfToPDjP3Bd6GZRg=
github.com/alist-org/gofakes3 v0.0.6/go.mod h1:6IyGtYGIX29fLvtXo+XZhtwX2P33KVYYj8uTgAHSu58=
github.com/alist-org/times v0.0.0-20240721124318-c2e3da27cc69 h1:E9QJ4vVTu1KYRhelnCsQImCsbl7NlkH3Yxs3/L2ldDk=
github.com/alist-org/times v0.0.0-20240721124318-c2e3da27cc69/go.mod h1:oPJwGY3sLmGgcJamGumz//0A35f4BwQRacyqLNcJTOU=
github.com/alist-org/gofakes3 v0.0.7 h1:0cDGI7fLBrqumhCBto9T3ZYCL71AyGZ1l+xxJgjqe8s=
github.com/alist-org/gofakes3 v0.0.7/go.mod h1:6IyGtYGIX29fLvtXo+XZhtwX2P33KVYYj8uTgAHSu58=
github.com/alist-org/times v0.0.0-20240721124654-efa0c7d3ad92 h1:pIEI87zhv8ZzQcu65rTL7kqirrs8dR6HDiXrqWat2Fk=
github.com/alist-org/times v0.0.0-20240721124654-efa0c7d3ad92/go.mod h1:oPJwGY3sLmGgcJamGumz//0A35f4BwQRacyqLNcJTOU=
github.com/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible h1:8psS8a+wKfiLt1iVDX79F7Y6wUM49Lcha2FMXt4UM8g=
github.com/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible/go.mod h1:T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8=
github.com/andreburgaud/crypt2go v1.2.0 h1:oly/ENAodeqTYpUafgd4r3v+VKLQnmOKUyfpj+TxHbE=
@ -32,12 +32,14 @@ github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHG
github.com/avast/retry-go v3.0.0+incompatible h1:4SOWQ7Qs+oroOTQOYnAHqelpCO0biHSxpiH9JdtuBj0=
github.com/avast/retry-go v3.0.0+incompatible/go.mod h1:XtSnn+n/sHqQIpZ10K1qAevBhOOCWBLXXy3hyiqqBrY=
github.com/aws/aws-sdk-go v1.38.20/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro=
github.com/aws/aws-sdk-go v1.54.19 h1:tyWV+07jagrNiCcGRzRhdtVjQs7Vy41NwsuOcl0IbVI=
github.com/aws/aws-sdk-go v1.54.19/go.mod h1:eRwEWoyTWFMVYVQzKMNHWP5/RV4xIUGMQfXQHfHkpNU=
github.com/aws/aws-sdk-go v1.55.5 h1:KKUZBfBoyqy5d3swXyiC7Q76ic40rYcbqH7qjh59kzU=
github.com/aws/aws-sdk-go v1.55.5/go.mod h1:eRwEWoyTWFMVYVQzKMNHWP5/RV4xIUGMQfXQHfHkpNU=
github.com/axgle/mahonia v0.0.0-20180208002826-3358181d7394 h1:OYA+5W64v3OgClL+IrOD63t4i/RW7RqrAVl9LTZ9UqQ=
github.com/axgle/mahonia v0.0.0-20180208002826-3358181d7394/go.mod h1:Q8n74mJTIgjX4RBBcHnJ05h//6/k6foqmgE45jTQtxg=
github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=
github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=
github.com/aymanbagabas/go-udiff v0.2.0 h1:TK0fH4MteXUDspT88n8CKzvK0X9O2xu9yQjWpi6yML8=
github.com/aymanbagabas/go-udiff v0.2.0/go.mod h1:RE4Ex0qsGkTAJoQdQQCA0uG+nAzJO/pI/QwceO5fgrA=
github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A=
github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
@ -46,22 +48,22 @@ github.com/bits-and-blooms/bitset v1.12.0 h1:U/q1fAF7xXRhFCrhROzIfffYnu+dlS38vCZ
github.com/bits-and-blooms/bitset v1.12.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8=
github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM=
github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ=
github.com/blevesearch/bleve/v2 v2.4.1 h1:8QWqsifq693mN3h6cSigKqkKUsUfv5hu0FDgz/4bFuA=
github.com/blevesearch/bleve/v2 v2.4.1/go.mod h1:Ezmvsouspi+uVwnDzjIsCeUIT0WuBKlicP5JZnExWzo=
github.com/blevesearch/bleve_index_api v1.1.9 h1:Cpq0Lp3As0Gfk3+PmcoNDRKeI50C5yuFNpj0YlN/bOE=
github.com/blevesearch/bleve_index_api v1.1.9/go.mod h1:PbcwjIcRmjhGbkS/lJCpfgVSMROV6TRubGGAODaK1W8=
github.com/blevesearch/bleve/v2 v2.4.2 h1:NooYP1mb3c0StkiY9/xviiq2LGSaE8BQBCc/pirMx0U=
github.com/blevesearch/bleve/v2 v2.4.2/go.mod h1:ATNKj7Yl2oJv/lGuF4kx39bST2dveX6w0th2FFYLkc8=
github.com/blevesearch/bleve_index_api v1.1.10 h1:PDLFhVjrjQWr6jCuU7TwlmByQVCSEURADHdCqVS9+g0=
github.com/blevesearch/bleve_index_api v1.1.10/go.mod h1:PbcwjIcRmjhGbkS/lJCpfgVSMROV6TRubGGAODaK1W8=
github.com/blevesearch/geo v0.1.20 h1:paaSpu2Ewh/tn5DKn/FB5SzvH0EWupxHEIwbCk/QPqM=
github.com/blevesearch/geo v0.1.20/go.mod h1:DVG2QjwHNMFmjo+ZgzrIq2sfCh6rIHzy9d9d0B59I6w=
github.com/blevesearch/go-faiss v1.0.19 h1:UKoP8hS7DVsVSRRloNJb4qPfe2UQ99pP4D3oXd23g2A=
github.com/blevesearch/go-faiss v1.0.19/go.mod h1:jrxHrbl42X/RnDPI+wBoZU8joxxuRwedrxqswQ3xfU8=
github.com/blevesearch/go-faiss v1.0.20 h1:AIkdTQFWuZ5LQmKQSebgMR4RynGNw8ZseJXaan5kvtI=
github.com/blevesearch/go-faiss v1.0.20/go.mod h1:jrxHrbl42X/RnDPI+wBoZU8joxxuRwedrxqswQ3xfU8=
github.com/blevesearch/go-porterstemmer v1.0.3 h1:GtmsqID0aZdCSNiY8SkuPJ12pD4jI+DdXTAn4YRcHCo=
github.com/blevesearch/go-porterstemmer v1.0.3/go.mod h1:angGc5Ht+k2xhJdZi511LtmxuEf0OVpvUUNrwmM1P7M=
github.com/blevesearch/gtreap v0.1.1 h1:2JWigFrzDMR+42WGIN/V2p0cUvn4UP3C4Q5nmaZGW8Y=
github.com/blevesearch/gtreap v0.1.1/go.mod h1:QaQyDRAT51sotthUWAH4Sj08awFSSWzgYICSZ3w0tYk=
github.com/blevesearch/mmap-go v1.0.4 h1:OVhDhT5B/M1HNPpYPBKIEJaD0F3Si+CrEKULGCDPWmc=
github.com/blevesearch/mmap-go v1.0.4/go.mod h1:EWmEAOmdAS9z/pi/+Toxu99DnsbhG1TIxUoRmJw/pSs=
github.com/blevesearch/scorch_segment_api/v2 v2.2.14 h1:fgMLMpGWR7u2TdRm7XSZVWhPvMAcdYHh25Lq1fQ6Fjo=
github.com/blevesearch/scorch_segment_api/v2 v2.2.14/go.mod h1:B7+a7vfpY4NsjuTkpv/eY7RZ91Xr90VaJzT2t7upZN8=
github.com/blevesearch/scorch_segment_api/v2 v2.2.15 h1:prV17iU/o+A8FiZi9MXmqbagd8I0bCqM7OKUYPbnb5Y=
github.com/blevesearch/scorch_segment_api/v2 v2.2.15/go.mod h1:db0cmP03bPNadXrCDuVkKLV6ywFSiRgPFT1YVrestBc=
github.com/blevesearch/segment v0.9.1 h1:+dThDy+Lvgj5JMxhmOVlgFfkUtZV2kw49xax4+jTfSU=
github.com/blevesearch/segment v0.9.1/go.mod h1:zN21iLm7+GnBHWTao9I+Au/7MBiL8pPFtJBJTsk6kQw=
github.com/blevesearch/snowballstem v0.9.0 h1:lMQ189YspGP6sXvZQ4WZ+MLawfV8wOmPoD/iWeNXm8s=
@ -80,8 +82,8 @@ github.com/blevesearch/zapx/v14 v14.3.10 h1:SG6xlsL+W6YjhX5N3aEiL/2tcWh3DO75Bnz7
github.com/blevesearch/zapx/v14 v14.3.10/go.mod h1:qqyuR0u230jN1yMmE4FIAuCxmahRQEOehF78m6oTgns=
github.com/blevesearch/zapx/v15 v15.3.13 h1:6EkfaZiPlAxqXz0neniq35my6S48QI94W/wyhnpDHHQ=
github.com/blevesearch/zapx/v15 v15.3.13/go.mod h1:Turk/TNRKj9es7ZpKK95PS7f6D44Y7fAFy8F4LXQtGg=
github.com/blevesearch/zapx/v16 v16.1.4 h1:TBQfG77g2UUXwfjOVcEtB9pXkg6JBmGXkeZKI67+TiA=
github.com/blevesearch/zapx/v16 v16.1.4/go.mod h1:+Q+Z89Iv7ewhdX2jyE6Qs/RUnN4tZuokaQ0xvTaFmx8=
github.com/blevesearch/zapx/v16 v16.1.5 h1:b0sMcarqNFxuXvjoXsF8WtwVahnxyhEvBSRJi/AUHjU=
github.com/blevesearch/zapx/v16 v16.1.5/go.mod h1:J4mSF39w1QELc11EWRSBFkPeZuO7r/NPKkHzDCoiaI8=
github.com/bluele/gcache v0.0.2 h1:WcbfdXICg7G/DGBh1PFfcirkWOQV+v077yF1pSy3DGw=
github.com/bluele/gcache v0.0.2/go.mod h1:m15KV+ECjptwSPxKhOhQoAFQVtUFjTVkc3H8o0t/fp0=
github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc h1:biVzkmvwrH8WK8raXaxBx6fRVTlJILwEwQGL1I/ByEI=
@ -94,14 +96,16 @@ github.com/caarlos0/env/v9 v9.0.0 h1:SI6JNsOA+y5gj9njpgybykATIylrRMklbs5ch6wO6pc
github.com/caarlos0/env/v9 v9.0.0/go.mod h1:ye5mlCVMYh6tZ+vCgrs/B95sj88cg5Tlnc0XIzgZ020=
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/charmbracelet/bubbles v0.18.0 h1:PYv1A036luoBGroX6VWjQIE9Syf2Wby2oOl/39KLfy0=
github.com/charmbracelet/bubbles v0.18.0/go.mod h1:08qhZhtIwzgrtBjAcJnij1t1H0ZRjwHyGsy6AL11PSw=
github.com/charmbracelet/bubbletea v0.26.6 h1:zTCWSuST+3yZYZnVSvbXwKOPRSNZceVeqpzOLN2zq1s=
github.com/charmbracelet/bubbletea v0.26.6/go.mod h1:dz8CWPlfCCGLFbBlTY4N7bjLiyOGDJEnd2Muu7pOWhk=
github.com/charmbracelet/lipgloss v0.12.1 h1:/gmzszl+pedQpjCOH+wFkZr/N90Snz40J/NR7A0zQcs=
github.com/charmbracelet/lipgloss v0.12.1/go.mod h1:V2CiwIuhx9S1S1ZlADfOj9HmxeMAORuz5izHb0zGbB8=
github.com/charmbracelet/bubbles v0.19.0 h1:gKZkKXPP6GlDk6EcfujDK19PCQqRjaJZQ7QRERx1UF0=
github.com/charmbracelet/bubbles v0.19.0/go.mod h1:WILteEqZ+krG5c3ntGEMeG99nCupcuIk7V0/zOP0tOA=
github.com/charmbracelet/bubbletea v0.27.0 h1:Mznj+vvYuYagD9Pn2mY7fuelGvP0HAXtZYGgRBCbHvU=
github.com/charmbracelet/bubbletea v0.27.0/go.mod h1:5MdP9XH6MbQkgGhnlxUqCNmBXf9I74KRQ8HIidRxV1Y=
github.com/charmbracelet/lipgloss v0.13.0 h1:4X3PPeoWEDCMvzDvGmTajSyYPcZM4+y8sCA/SsA3cjw=
github.com/charmbracelet/lipgloss v0.13.0/go.mod h1:nw4zy0SBX/F/eAO1cWdcvy6qnkDUxr8Lw7dvFrAIbbY=
github.com/charmbracelet/x/ansi v0.1.4 h1:IEU3D6+dWwPSgZ6HBH+v6oUuZ/nVawMiWj5831KfiLM=
github.com/charmbracelet/x/ansi v0.1.4/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw=
github.com/charmbracelet/x/exp/golden v0.0.0-20240815200342-61de596daa2b h1:MnAMdlwSltxJyULnrYbkZpp4k58Co7Tah3ciKhSNo0Q=
github.com/charmbracelet/x/exp/golden v0.0.0-20240815200342-61de596daa2b/go.mod h1:wDlXFlCrmJ8J+swcL/MnGUuYnqgQdW9rhSD61oNMb6U=
github.com/charmbracelet/x/input v0.1.0 h1:TEsGSfZYQyOtp+STIjyBq6tpRaorH0qpwZUj8DavAhQ=
github.com/charmbracelet/x/input v0.1.0/go.mod h1:ZZwaBxPF7IG8gWWzPUVqHEtWhc1+HXJPNuerJGRGZ28=
github.com/charmbracelet/x/term v0.1.1 h1:3cosVAiPOig+EV4X9U+3LDgtwwAoEzJjNdwbXDjF6yI=
@ -110,8 +114,8 @@ github.com/charmbracelet/x/windows v0.1.0 h1:gTaxdvzDM5oMa/I2ZNF7wN78X/atWemG9Wp
github.com/charmbracelet/x/windows v0.1.0/go.mod h1:GLEO/l+lizvFDBPLIOk+49gdX49L9YWMB5t+DZd0jkQ=
github.com/cheekybits/is v0.0.0-20150225183255-68e9c0620927 h1:SKI1/fuSdodxmNNyVBR8d7X/HuLnRpvvFO0AgyQk764=
github.com/cheekybits/is v0.0.0-20150225183255-68e9c0620927/go.mod h1:h/aW8ynjgkuj+NQRlZcDbAbM1ORAbXjXX77sX7T289U=
github.com/city404/v6-public-rpc-proto/go v0.0.0-20240708163039-9a9b82a0ce4d h1:p5T6ZPvh7nihJfjI9M/W2cbcX7n766u/OGorLmE4xoQ=
github.com/city404/v6-public-rpc-proto/go v0.0.0-20240708163039-9a9b82a0ce4d/go.mod h1:akxZg8LuwOIeCPRjcDrUS1WWcIwmLNSR2lfe4y85PH4=
github.com/city404/v6-public-rpc-proto/go v0.0.0-20240817070657-90f8e24b653e h1:GLC8iDDcbt1H8+RkNao2nRGjyNTIo81e1rAJT9/uWYA=
github.com/city404/v6-public-rpc-proto/go v0.0.0-20240817070657-90f8e24b653e/go.mod h1:ln9Whp+wVY/FTbn2SK0ag+SKD2fC0yQCF/Lqowc1LmU=
github.com/cloudwego/base64x v0.1.4 h1:jwCgWpFanWmN8xoIUHa2rtzmkd5J2plF/dnLS6Xd/0Y=
github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w=
github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg=
@ -138,8 +142,8 @@ github.com/dhowden/tag v0.0.0-20240417053706-3d75831295e8 h1:OtSeLS5y0Uy01jaKK4m
github.com/dhowden/tag v0.0.0-20240417053706-3d75831295e8/go.mod h1:apkPC/CR3s48O2D7Y++n1XWEpgPNNCjXYga3PPbJe2E=
github.com/disintegration/imaging v1.6.2 h1:w1LecBlG2Lnp8B3jk5zSuNqd7b4DXhcjwek1ei82L+c=
github.com/disintegration/imaging v1.6.2/go.mod h1:44/5580QXChDfwIclfc/PCwrr44amcmDAg8hxG0Ewe4=
github.com/dlclark/regexp2 v1.11.2 h1:/u628IuisSTwri5/UKloiIsH8+qF2Pu7xEQX+yIKg68=
github.com/dlclark/regexp2 v1.11.2/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
github.com/dlclark/regexp2 v1.11.4 h1:rPYF9/LECdNymJufQKmri9gV604RvvABwgOA8un7yAo=
github.com/dlclark/regexp2 v1.11.4/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
github.com/dustinxie/ecc v0.0.0-20210511000915-959544187564 h1:I6KUy4CI6hHjqnyJLNCEi7YHVMkwwtfSr2k9splgdSM=
github.com/dustinxie/ecc v0.0.0-20210511000915-959544187564/go.mod h1:yekO+3ZShy19S+bsmnERmznGy9Rfg6dWWWpiGJjNAz8=
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6baUTXGLOoWe4PQhGxaX0KpnayAqC48p4=
@ -151,8 +155,8 @@ github.com/foxxorcat/mopan-sdk-go v0.1.6/go.mod h1:UaY6D88yBXWGrcu/PcyLWyL4lzrk5
github.com/foxxorcat/weiyun-sdk-go v0.1.3 h1:I5c5nfGErhq9DBumyjCVCggRA74jhgriMqRRFu5jeeY=
github.com/foxxorcat/weiyun-sdk-go v0.1.3/go.mod h1:TPxzN0d2PahweUEHlOBWlwZSA+rELSUlGYMWgXRn9ps=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fxamacker/cbor/v2 v2.6.0 h1:sU6J2usfADwWlYDAFhZBQ6TnLFBHxgesMrQfQgk1tWA=
github.com/fxamacker/cbor/v2 v2.6.0/go.mod h1:pxXPTn3joSm21Gbwsv0w9OSA2y1HFR9qXEeXQVeNoDQ=
github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv5E=
github.com/fxamacker/cbor/v2 v2.7.0/go.mod h1:pxXPTn3joSm21Gbwsv0w9OSA2y1HFR9qXEeXQVeNoDQ=
github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0=
github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk=
github.com/gaoyb7/115drive-webdav v0.1.8 h1:EJt4PSmcbvBY4KUh2zSo5p6fN9LZFNkIzuKejipubVw=
@ -190,14 +194,14 @@ github.com/go-playground/validator/v10 v10.11.0/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4
github.com/go-playground/validator/v10 v10.20.0 h1:K9ISHbSaI0lyB2eWMPJo+kOS/FBExVwjEviJTixqxL8=
github.com/go-playground/validator/v10 v10.20.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
github.com/go-resty/resty/v2 v2.7.0/go.mod h1:9PWDzw47qPphMRFfhsyk0NnSgvluHcljSMVIq3w7q0I=
github.com/go-resty/resty/v2 v2.13.1 h1:x+LHXBI2nMB1vqndymf26quycC4aggYJ7DECYbiz03g=
github.com/go-resty/resty/v2 v2.13.1/go.mod h1:GznXlLxkq6Nh4sU59rPmUw3VtgpO3aS96ORAI6Q7d+0=
github.com/go-resty/resty/v2 v2.14.0 h1:/rhkzsAqGQkozwfKS5aFAbb6TyKd3zyFRWcdRXLPCAU=
github.com/go-resty/resty/v2 v2.14.0/go.mod h1:IW6mekUOsElt9C7oWr0XRt9BNSD6D5rr9mhk6NjmNHg=
github.com/go-sql-driver/mysql v1.7.0 h1:ueSltNNllEqE3qcWBTD0iQd3IpL/6U+mJxLkazJ7YPc=
github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
github.com/go-webauthn/webauthn v0.10.2 h1:OG7B+DyuTytrEPFmTX503K77fqs3HDK/0Iv+z8UYbq4=
github.com/go-webauthn/webauthn v0.10.2/go.mod h1:Gd1IDsGAybuvK1NkwUTLbGmeksxuRJjVN2PE/xsPxHs=
github.com/go-webauthn/x v0.1.9 h1:v1oeLmoaa+gPOaZqUdDentu6Rl7HkSSsmOT6gxEQHhE=
github.com/go-webauthn/x v0.1.9/go.mod h1:pJNMlIMP1SU7cN8HNlKJpLEnFHCygLCvaLZ8a1xeoQA=
github.com/go-webauthn/webauthn v0.11.1 h1:5G/+dg91/VcaJHTtJUfwIlNJkLwbJCcnUc4W8VtkpzA=
github.com/go-webauthn/webauthn v0.11.1/go.mod h1:YXRm1WG0OtUyDFaVAgB5KG7kVqW+6dYCJ7FTQH4SxEE=
github.com/go-webauthn/x v0.1.12 h1:RjQ5cvApzyU/xLCiP+rub0PE4HBZsLggbxGR5ZpUf/A=
github.com/go-webauthn/x v0.1.12/go.mod h1:XlRcGkNH8PT45TfeJYc6gqpOtiOendHhVmnOxh+5yHs=
github.com/goccy/go-json v0.9.7/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
@ -222,8 +226,8 @@ github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-tpm v0.9.0 h1:sQF6YqWMi+SCXpsmS3fd21oPy/vSddwZry4JnmltHVk=
github.com/google/go-tpm v0.9.0/go.mod h1:FkNVkc6C+IsvDI9Jw1OveJmxGZUUaKxtrpOS47QWKfU=
github.com/google/go-tpm v0.9.1 h1:0pGc4X//bAlmZzMKf8iz6IsDo1nYTbYJ6FZN/rg4zdM=
github.com/google/go-tpm v0.9.1/go.mod h1:h9jEsEECg7gtLis0upRBQU+GhYVH6jMjrFxI8u6bVUY=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/s2a-go v0.1.7 h1:60BLSyTrOV4/haCDW4zb1guZItoSq8foHCXrAnjBo/o=
github.com/google/s2a-go v0.1.7/go.mod h1:50CgR4k1jNlWBu4UfS4AcfhVe1r6pdZPygJ3R8F0Qdw=
@ -304,8 +308,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/larksuite/oapi-sdk-go/v3 v3.2.8 h1:elbufnS+gQVOkzX9JLkS/N9u3ay/IAIE17nE4kNoYZ4=
github.com/larksuite/oapi-sdk-go/v3 v3.2.8/go.mod h1:ZEplY+kwuIrj/nqw5uSCINNATcH3KdxSN7y+UxYY5fI=
github.com/larksuite/oapi-sdk-go/v3 v3.3.1 h1:DLQQEgHUAGZB6RVlceB1f6A94O206exxW2RIMH+gMUc=
github.com/larksuite/oapi-sdk-go/v3 v3.3.1/go.mod h1:ZEplY+kwuIrj/nqw5uSCINNATcH3KdxSN7y+UxYY5fI=
github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY=
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
@ -332,12 +336,14 @@ github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWE
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-localereader v0.0.1 h1:ygSAOl7ZXTx4RdPYinUpg6W99U8jWvWi9Ye2JC/oIi4=
github.com/mattn/go-localereader v0.0.1/go.mod h1:8fBrzywKY7BI3czFoHkuzRoWE9C+EiG4R1k4Cjx5p88=
github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U=
github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU=
github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
github.com/meilisearch/meilisearch-go v0.27.0 h1:lDFq8WzbsZCtt3/byr7GFqfOygWF5iy9TtDgzJo0Ds8=
github.com/meilisearch/meilisearch-go v0.27.0/go.mod h1:SxuSqDcPBIykjWz1PX+KzsYzArNLSCadQodWs8extS0=
github.com/meilisearch/meilisearch-go v0.27.2 h1:3G21dJ5i208shnLPDsIEZ0L0Geg/5oeXABFV7nlK94k=
github.com/meilisearch/meilisearch-go v0.27.2/go.mod h1:SxuSqDcPBIykjWz1PX+KzsYzArNLSCadQodWs8extS0=
github.com/meilisearch/meilisearch-go v0.28.0 h1:f3XJ66ZM+R8bANAOLqsjvoq/HhQNpVJPYoNt6QgNzME=
github.com/meilisearch/meilisearch-go v0.28.0/go.mod h1:Szcc9CaDiKIfjdgdt49jlmDKpEzjD+x+b6Y6heMdlQ0=
github.com/minio/sha256-simd v1.0.1 h1:6kaan5IFmwTNynnKKpDHe6FWHohJOHhCPchzK49dzMM=
github.com/minio/sha256-simd v1.0.1/go.mod h1:Pz6AKMiUdngCLpeTL/RJY1M9rUuPMYujV5xJjtbRSN8=
github.com/minio/sio v0.4.0 h1:u4SWVEm5lXSqU42ZWawV0D9I5AZ5YMmo2RXpEQ/kRhc=
@ -504,8 +510,8 @@ github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
github.com/xhofe/gsync v0.0.0-20230917091818-2111ceb38a25 h1:eDfebW/yfq9DtG9RO3KP7BT2dot2CvJGIvrB0NEoDXI=
github.com/xhofe/gsync v0.0.0-20230917091818-2111ceb38a25/go.mod h1:fH4oNm5F9NfI5dLi0oIMtsLNKQOirUDbEMCIBb/7SU0=
github.com/xhofe/tache v0.1.1 h1:O5QY4cVjIGELx3UGh6LbVAc18MWGXgRNQjMt72x6w/8=
github.com/xhofe/tache v0.1.1/go.mod h1:iKumPFvywf30FRpAHHCt64G0JHLMzT0K+wyGedHsmTQ=
github.com/xhofe/tache v0.1.2 h1:pHrXlrWcbTb4G7hVUDW7Rc+YTUnLJvnLBrdktVE1Fqg=
github.com/xhofe/tache v0.1.2/go.mod h1:iKumPFvywf30FRpAHHCt64G0JHLMzT0K+wyGedHsmTQ=
github.com/xhofe/wopan-sdk-go v0.1.3 h1:J58X6v+n25ewBZjb05pKOr7AWGohb+Rdll4CThGh6+A=
github.com/xhofe/wopan-sdk-go v0.1.3/go.mod h1:dcY9yA28fnaoZPnXZiVTFSkcd7GnIPTpTIIlfSI5z5Q=
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=
@ -544,19 +550,24 @@ golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0
golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw=
golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc=
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30=
golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M=
golang.org/x/exp v0.0.0-20240707233637-46b078467d37 h1:uLDX+AfeFCct3a2C7uIWBKMJIR3CJMhcgfrUAqjRK6w=
golang.org/x/exp v0.0.0-20240707233637-46b078467d37/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY=
golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw=
golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54=
golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa h1:ELnwvuAXPNtPk1TJRuGkI9fDTwym6AYBu0qzT8AcHdI=
golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa/go.mod h1:akd2r19cwCdwSwWeIdzYQGa/EZZyqcOdwWiwj5L5eKQ=
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.18.0 h1:jGzIakQa/ZXI1I0Fxvaa9W7yP25TqT6cHIHn+6CqvSQ=
golang.org/x/image v0.18.0/go.mod h1:4yyo5vMFQjVjUcVk4jEQcU9MGy/rulF5WvUILseCM2E=
golang.org/x/image v0.19.0 h1:D9FX4QWkLfkeqaC62SonffIIuYdOk/UE2XKUBgRIBIQ=
golang.org/x/image v0.19.0/go.mod h1:y0zrRqlQRWQ5PXaYCOMLTW2fpsxZ8Qh9I/ohnInJEys=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
@ -570,19 +581,24 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug
golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys=
golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE=
golang.org/x/oauth2 v0.21.0 h1:tsimM75w1tF/uws5rbeHzIWxEqElMehnc+iW793zsZs=
golang.org/x/oauth2 v0.21.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE=
golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg=
golang.org/x/oauth2 v0.22.0 h1:BzDx2FehcG7jJwgWLELCdmLuxk2i+x9UDpSiss2u0ZA=
golang.org/x/oauth2 v0.22.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@ -609,20 +625,25 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg=
golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU=
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY=
golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk=
golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4=
golang.org/x/term v0.23.0 h1:F6D4vR+EHoL9/sWAWgAR1H2DcHr4PareCbAaCo1RpuU=
golang.org/x/term v0.23.0/go.mod h1:DgV24QBUrK6jhZXl+20l6UWznPlwAHm1Q1mGHtydmSk=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
@ -632,14 +653,16 @@ golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc=
golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20220722155302-e5dcc9cfc0b9/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
golang.org/x/time v0.6.0 h1:eTDhh4ZXt5Qf0augr54TN6suAUudPcawVZeIAPU7D4U=
golang.org/x/time v0.6.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190829051458-42f498d34c4d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
@ -648,8 +671,10 @@ golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roY
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/tools v0.23.0 h1:SGsXPZ+2l4JsgaCKkx+FQ9YZ5XEtA1GZYuoDjenLjvg=
golang.org/x/tools v0.23.0/go.mod h1:pnu6ufv6vQkll6szChhK3C3L/ruaIv5eBeztNG8wtsI=
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
golang.org/x/tools v0.24.0 h1:J1shsA93PJUEVaUSaay7UXAyE8aimq3GW0pjlolpa24=
golang.org/x/tools v0.24.0/go.mod h1:YhNqVBIfWHdzvTLs0d8LCuMhkKUgSUKldakyV7W/WDQ=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

View File

@ -68,11 +68,7 @@ func InitConfig() {
}
conf.Conf.TempDir = absPath
}
err := os.RemoveAll(filepath.Join(conf.Conf.TempDir))
if err != nil {
log.Errorln("failed delete temp file:", err)
}
err = os.MkdirAll(conf.Conf.TempDir, 0o777)
err := os.MkdirAll(conf.Conf.TempDir, 0o777)
if err != nil {
log.Fatalf("create temp dir error: %+v", err)
}
@ -104,3 +100,9 @@ func initURL() {
}
conf.URL = u
}
func CleanTempDir() {
if err := os.RemoveAll(conf.Conf.TempDir); err != nil {
log.Errorln("failed delete temp file: ", err)
}
}

View File

@ -5,6 +5,7 @@ import "github.com/alist-org/alist/v3/cmd/flags"
func InitData() {
initUser()
initSettings()
initTasks()
if flags.Dev {
initDevData()
initDevDo()

View File

@ -34,6 +34,7 @@ func initSettings() {
// create or save setting
for i := range initialSettingItems {
item := &initialSettingItems[i]
item.Index = uint(i)
if item.PreDefault == "" {
item.PreDefault = item.Value
}

View File

@ -0,0 +1,29 @@
package data
import (
"github.com/alist-org/alist/v3/internal/db"
"github.com/alist-org/alist/v3/internal/model"
)
var initialTaskItems []model.TaskItem
func initTasks() {
InitialTasks()
for i := range initialTaskItems {
item := &initialTaskItems[i]
taskitem, _ := db.GetTaskDataByType(item.Key)
if taskitem == nil {
db.CreateTaskData(item)
}
}
}
func InitialTasks() []model.TaskItem {
initialTaskItems = []model.TaskItem{
{Key: "copy", PersistData: "[]"},
{Key: "download", PersistData: "[]"},
{Key: "transfer", PersistData: "[]"},
}
return initialTaskItems
}

View File

@ -2,14 +2,18 @@ package bootstrap
import (
"github.com/alist-org/alist/v3/internal/conf"
"github.com/alist-org/alist/v3/internal/db"
"github.com/alist-org/alist/v3/internal/fs"
"github.com/alist-org/alist/v3/internal/offline_download/tool"
"github.com/xhofe/tache"
)
func InitTaskManager() {
fs.UploadTaskManager = tache.NewManager[*fs.UploadTask](tache.WithWorks(conf.Conf.Tasks.Upload.Workers), tache.WithMaxRetry(conf.Conf.Tasks.Upload.MaxRetry))
fs.CopyTaskManager = tache.NewManager[*fs.CopyTask](tache.WithWorks(conf.Conf.Tasks.Copy.Workers), tache.WithMaxRetry(conf.Conf.Tasks.Copy.MaxRetry))
tool.DownloadTaskManager = tache.NewManager[*tool.DownloadTask](tache.WithWorks(conf.Conf.Tasks.Download.Workers), tache.WithMaxRetry(conf.Conf.Tasks.Download.MaxRetry))
tool.TransferTaskManager = tache.NewManager[*tool.TransferTask](tache.WithWorks(conf.Conf.Tasks.Transfer.Workers), tache.WithMaxRetry(conf.Conf.Tasks.Transfer.MaxRetry))
fs.UploadTaskManager = tache.NewManager[*fs.UploadTask](tache.WithWorks(conf.Conf.Tasks.Upload.Workers), tache.WithMaxRetry(conf.Conf.Tasks.Upload.MaxRetry)) //upload will not support persist
fs.CopyTaskManager = tache.NewManager[*fs.CopyTask](tache.WithWorks(conf.Conf.Tasks.Copy.Workers), tache.WithPersistFunction(db.GetTaskDataFunc("copy", conf.Conf.Tasks.Copy.TaskPersistant), db.UpdateTaskDataFunc("copy", conf.Conf.Tasks.Copy.TaskPersistant)), tache.WithMaxRetry(conf.Conf.Tasks.Copy.MaxRetry))
tool.DownloadTaskManager = tache.NewManager[*tool.DownloadTask](tache.WithWorks(conf.Conf.Tasks.Download.Workers), tache.WithPersistFunction(db.GetTaskDataFunc("download", conf.Conf.Tasks.Download.TaskPersistant), db.UpdateTaskDataFunc("download", conf.Conf.Tasks.Download.TaskPersistant)), tache.WithMaxRetry(conf.Conf.Tasks.Download.MaxRetry))
tool.TransferTaskManager = tache.NewManager[*tool.TransferTask](tache.WithWorks(conf.Conf.Tasks.Transfer.Workers), tache.WithPersistFunction(db.GetTaskDataFunc("transfer", conf.Conf.Tasks.Transfer.TaskPersistant), db.UpdateTaskDataFunc("transfer", conf.Conf.Tasks.Transfer.TaskPersistant)), tache.WithMaxRetry(conf.Conf.Tasks.Transfer.MaxRetry))
if len(tool.TransferTaskManager.GetAll()) == 0 { //prevent offline downloaded files from being deleted
CleanTempDir()
}
}

View File

@ -47,8 +47,9 @@ type LogConfig struct {
}
type TaskConfig struct {
Workers int `json:"workers" env:"WORKERS"`
MaxRetry int `json:"max_retry" env:"MAX_RETRY"`
Workers int `json:"workers" env:"WORKERS"`
MaxRetry int `json:"max_retry" env:"MAX_RETRY"`
TaskPersistant bool `json:"task_persistant" env:"TASK_PERSISTANT"`
}
type TasksConfig struct {
@ -130,19 +131,22 @@ func DefaultConfig() *Config {
TlsInsecureSkipVerify: true,
Tasks: TasksConfig{
Download: TaskConfig{
Workers: 5,
MaxRetry: 1,
Workers: 5,
MaxRetry: 1,
TaskPersistant: true,
},
Transfer: TaskConfig{
Workers: 5,
MaxRetry: 2,
Workers: 5,
MaxRetry: 2,
TaskPersistant: true,
},
Upload: TaskConfig{
Workers: 5,
},
Copy: TaskConfig{
Workers: 5,
MaxRetry: 2,
Workers: 5,
MaxRetry: 2,
TaskPersistant: true,
},
},
Cors: Cors{

View File

@ -12,7 +12,7 @@ var db *gorm.DB
func Init(d *gorm.DB) {
db = d
err := AutoMigrate(new(model.Storage), new(model.User), new(model.Meta), new(model.SettingItem), new(model.SearchNode))
err := AutoMigrate(new(model.Storage), new(model.User), new(model.Meta), new(model.SettingItem), new(model.SearchNode), new(model.TaskItem))
if err != nil {
log.Fatalf("failed migrate database: %s", err.Error())
}

View File

@ -34,7 +34,7 @@ func GetMetas(pageIndex, pageSize int) (metas []model.Meta, count int64, err err
if err = metaDB.Count(&count).Error; err != nil {
return nil, 0, errors.Wrapf(err, "failed get metas count")
}
if err = metaDB.Offset((pageIndex - 1) * pageSize).Limit(pageSize).Find(&metas).Error; err != nil {
if err = metaDB.Order(columnName("id")).Offset((pageIndex - 1) * pageSize).Limit(pageSize).Find(&metas).Error; err != nil {
return nil, 0, errors.Wrapf(err, "failed get find metas")
}
return metas, count, nil

View File

@ -49,7 +49,8 @@ func GetSettingItemsByGroup(group int) ([]model.SettingItem, error) {
func GetSettingItemsInGroups(groups []int) ([]model.SettingItem, error) {
var settingItems []model.SettingItem
if err := db.Where(fmt.Sprintf("%s in ?", columnName("group")), groups).Find(&settingItems).Error; err != nil {
err := db.Order(columnName("index")).Where(fmt.Sprintf("%s in ?", columnName("group")), groups).Find(&settingItems).Error
if err != nil {
return nil, errors.WithStack(err)
}
return settingItems, nil

View File

@ -2,7 +2,6 @@ package db
import (
"fmt"
"sort"
"github.com/alist-org/alist/v3/internal/model"
"github.com/pkg/errors"
@ -36,7 +35,7 @@ func GetStorages(pageIndex, pageSize int) ([]model.Storage, int64, error) {
return nil, 0, errors.Wrapf(err, "failed get storages count")
}
var storages []model.Storage
if err := storageDB.Order(columnName("order")).Offset((pageIndex - 1) * pageSize).Limit(pageSize).Find(&storages).Error; err != nil {
if err := addStorageOrder(storageDB).Order(columnName("order")).Offset((pageIndex - 1) * pageSize).Limit(pageSize).Find(&storages).Error; err != nil {
return nil, 0, errors.WithStack(err)
}
return storages, count, nil
@ -63,11 +62,9 @@ func GetStorageByMountPath(mountPath string) (*model.Storage, error) {
func GetEnabledStorages() ([]model.Storage, error) {
var storages []model.Storage
if err := db.Where(fmt.Sprintf("%s = ?", columnName("disabled")), false).Find(&storages).Error; err != nil {
err := addStorageOrder(db).Where(fmt.Sprintf("%s = ?", columnName("disabled")), false).Find(&storages).Error
if err != nil {
return nil, errors.WithStack(err)
}
sort.Slice(storages, func(i, j int) bool {
return storages[i].Order < storages[j].Order
})
return storages, nil
}

48
internal/db/tasks.go Normal file
View File

@ -0,0 +1,48 @@
package db
import (
"github.com/alist-org/alist/v3/internal/model"
"github.com/pkg/errors"
)
func GetTaskDataByType(type_s string) (*model.TaskItem, error) {
task := model.TaskItem{Key: type_s}
if err := db.Where(task).First(&task).Error; err != nil {
return nil, errors.Wrapf(err, "failed find task")
}
return &task, nil
}
func UpdateTaskData(t *model.TaskItem) error {
return errors.WithStack(db.Model(&model.TaskItem{}).Where("key = ?", t.Key).Update("persist_data", t.PersistData).Error)
}
func CreateTaskData(t *model.TaskItem) error {
return errors.WithStack(db.Create(t).Error)
}
func GetTaskDataFunc(type_s string, enabled bool) func() ([]byte, error) {
if !enabled {
return nil
}
task, err := GetTaskDataByType(type_s)
if err != nil {
return nil
}
return func() ([]byte, error) {
return []byte(task.PersistData), nil
}
}
func UpdateTaskDataFunc(type_s string, enabled bool) func([]byte) error {
if !enabled {
return nil
}
return func(data []byte) error {
s := string(data)
if s == "null" || s == "" {
s = "[]"
}
return UpdateTaskData(&model.TaskItem{Key: type_s, PersistData: s})
}
}

View File

@ -54,7 +54,7 @@ func GetUsers(pageIndex, pageSize int) (users []model.User, count int64, err err
if err := userDB.Count(&count).Error; err != nil {
return nil, 0, errors.Wrapf(err, "failed get users count")
}
if err := userDB.Offset((pageIndex - 1) * pageSize).Limit(pageSize).Find(&users).Error; err != nil {
if err := userDB.Order(columnName("id")).Offset((pageIndex - 1) * pageSize).Limit(pageSize).Find(&users).Error; err != nil {
return nil, 0, errors.Wrapf(err, "failed get find users")
}
return users, count, nil

View File

@ -4,6 +4,7 @@ import (
"fmt"
"github.com/alist-org/alist/v3/internal/conf"
"gorm.io/gorm"
)
func columnName(name string) string {
@ -12,3 +13,7 @@ func columnName(name string) string {
}
return fmt.Sprintf("`%s`", name)
}
func addStorageOrder(db *gorm.DB) *gorm.DB {
return db.Order(fmt.Sprintf("%s, %s", columnName("order"), columnName("id")))
}

View File

@ -3,5 +3,6 @@ package errs
import "fmt"
var (
SearchNotAvailable = fmt.Errorf("search not available")
SearchNotAvailable = fmt.Errorf("search not available")
BuildIndexIsRunning = fmt.Errorf("build index is running, please try later")
)

View File

@ -3,6 +3,9 @@ package fs
import (
"context"
"fmt"
"net/http"
stdpath "path"
"github.com/alist-org/alist/v3/internal/conf"
"github.com/alist-org/alist/v3/internal/driver"
"github.com/alist-org/alist/v3/internal/model"
@ -11,20 +14,21 @@ import (
"github.com/alist-org/alist/v3/pkg/utils"
"github.com/pkg/errors"
"github.com/xhofe/tache"
"net/http"
stdpath "path"
)
type CopyTask struct {
tache.Base
Status string `json:"status"`
srcStorage, dstStorage driver.Driver
srcObjPath, dstDirPath string
Status string `json:"-"` //don't save status to save space
SrcObjPath string `json:"src_path"`
DstDirPath string `json:"dst_path"`
srcStorage driver.Driver `json:"-"`
dstStorage driver.Driver `json:"-"`
SrcStorageMp string `json:"src_storage_mp"`
DstStorageMp string `json:"dst_storage_mp"`
}
func (t *CopyTask) GetName() string {
return fmt.Sprintf("copy [%s](%s) to [%s](%s)",
t.srcStorage.GetStorage().MountPath, t.srcObjPath, t.dstStorage.GetStorage().MountPath, t.dstDirPath)
return fmt.Sprintf("copy [%s](%s) to [%s](%s)", t.SrcStorageMp, t.SrcObjPath, t.DstStorageMp, t.DstDirPath)
}
func (t *CopyTask) GetStatus() string {
@ -32,7 +36,17 @@ func (t *CopyTask) GetStatus() string {
}
func (t *CopyTask) Run() error {
return copyBetween2Storages(t, t.srcStorage, t.dstStorage, t.srcObjPath, t.dstDirPath)
var err error
if t.srcStorage == nil {
t.srcStorage, err = op.GetStorageByMountPath(t.SrcStorageMp)
}
if t.dstStorage == nil {
t.dstStorage, err = op.GetStorageByMountPath(t.DstStorageMp)
}
if err != nil {
return errors.WithMessage(err, "failed get storage")
}
return copyBetween2Storages(t, t.srcStorage, t.dstStorage, t.SrcObjPath, t.DstDirPath)
}
var CopyTaskManager *tache.Manager[*CopyTask]
@ -79,10 +93,12 @@ func _copy(ctx context.Context, srcObjPath, dstDirPath string, lazyCache ...bool
}
// not in the same storage
t := &CopyTask{
srcStorage: srcStorage,
dstStorage: dstStorage,
srcObjPath: srcObjActualPath,
dstDirPath: dstDirActualPath,
srcStorage: srcStorage,
dstStorage: dstStorage,
SrcObjPath: srcObjActualPath,
DstDirPath: dstDirActualPath,
SrcStorageMp: srcStorage.GetStorage().MountPath,
DstStorageMp: dstStorage.GetStorage().MountPath,
}
CopyTaskManager.Add(t)
return t, nil
@ -107,10 +123,12 @@ func copyBetween2Storages(t *CopyTask, srcStorage, dstStorage driver.Driver, src
srcObjPath := stdpath.Join(srcObjPath, obj.GetName())
dstObjPath := stdpath.Join(dstDirPath, srcObj.GetName())
CopyTaskManager.Add(&CopyTask{
srcStorage: srcStorage,
dstStorage: dstStorage,
srcObjPath: srcObjPath,
dstDirPath: dstObjPath,
srcStorage: srcStorage,
dstStorage: dstStorage,
SrcObjPath: srcObjPath,
DstDirPath: dstObjPath,
SrcStorageMp: srcStorage.GetStorage().MountPath,
DstStorageMp: dstStorage.GetStorage().MountPath,
})
}
t.Status = "src object is dir, added all copy tasks of objs"

View File

@ -29,6 +29,7 @@ type SettingItem struct {
Options string `json:"options"` // values for select
Group int `json:"group"` // use to group setting in frontend
Flag int `json:"flag"` // 0 = public, 1 = private, 2 = readonly, 3 = deprecated, etc.
Index uint `json:"index"`
}
func (s SettingItem) IsDeprecated() bool {

6
internal/model/task.go Normal file
View File

@ -0,0 +1,6 @@
package model
type TaskItem struct {
Key string `json:"key"`
PersistData string `gorm:"type:text" json:"persist_data"`
}

View File

@ -1,6 +1,7 @@
package net
import (
"compress/gzip"
"context"
"fmt"
"io"
@ -222,8 +223,19 @@ func RequestHttp(ctx context.Context, httpMethod string, headerOverride http.Hea
}
// TODO clean header with blocklist or passlist
res.Header.Del("set-cookie")
var reader io.Reader
if res.StatusCode >= 400 {
all, _ := io.ReadAll(res.Body)
// 根据 Content-Encoding 判断 Body 是否压缩
switch res.Header.Get("Content-Encoding") {
case "gzip":
// 使用gzip.NewReader解压缩
reader, _ = gzip.NewReader(res.Body)
defer reader.(*gzip.Reader).Close()
default:
// 没有Content-Encoding直接读取
reader = res.Body
}
all, _ := io.ReadAll(reader)
_ = res.Body.Close()
msg := string(all)
log.Debugln(msg)

View File

@ -0,0 +1,124 @@
package _115
import (
"context"
"fmt"
"github.com/alist-org/alist/v3/drivers/115"
"github.com/alist-org/alist/v3/internal/errs"
"github.com/alist-org/alist/v3/internal/model"
"github.com/alist-org/alist/v3/internal/offline_download/tool"
"github.com/alist-org/alist/v3/internal/op"
)
type Cloud115 struct {
refreshTaskCache bool
}
func (p *Cloud115) Name() string {
return "115 Cloud"
}
func (p *Cloud115) Items() []model.SettingItem {
return nil
}
func (p *Cloud115) Run(task *tool.DownloadTask) error {
return errs.NotSupport
}
func (p *Cloud115) Init() (string, error) {
p.refreshTaskCache = false
return "ok", nil
}
func (p *Cloud115) IsReady() bool {
return true
}
func (p *Cloud115) AddURL(args *tool.AddUrlArgs) (string, error) {
// 添加新任务刷新缓存
p.refreshTaskCache = true
// args.TempDir 已经被修改为了 DstDirPath
storage, actualPath, err := op.GetStorageAndActualPath(args.TempDir)
if err != nil {
return "", err
}
driver115, ok := storage.(*_115.Pan115)
if !ok {
return "", fmt.Errorf("unsupported storage driver for offline download, only 115 Cloud is supported")
}
ctx := context.Background()
parentDir, err := op.GetUnwrap(ctx, storage, actualPath)
if err != nil {
return "", err
}
hashs, err := driver115.OfflineDownload(ctx, []string{args.Url}, parentDir)
if err != nil || len(hashs) < 1 {
return "", fmt.Errorf("failed to add offline download task: %w", err)
}
return hashs[0], nil
}
func (p *Cloud115) Remove(task *tool.DownloadTask) error {
storage, _, err := op.GetStorageAndActualPath(task.DstDirPath)
if err != nil {
return err
}
driver115, ok := storage.(*_115.Pan115)
if !ok {
return fmt.Errorf("unsupported storage driver for offline download, only 115 Cloud is supported")
}
ctx := context.Background()
if err := driver115.DeleteOfflineTasks(ctx, []string{task.GID}, false); err != nil {
return err
}
return nil
}
func (p *Cloud115) Status(task *tool.DownloadTask) (*tool.Status, error) {
storage, _, err := op.GetStorageAndActualPath(task.DstDirPath)
if err != nil {
return nil, err
}
driver115, ok := storage.(*_115.Pan115)
if !ok {
return nil, fmt.Errorf("unsupported storage driver for offline download, only 115 Cloud is supported")
}
tasks, err := driver115.OfflineList(context.Background())
if err != nil {
return nil, err
}
s := &tool.Status{
Progress: 0,
NewGID: "",
Completed: false,
Status: "the task has been deleted",
Err: nil,
}
for _, t := range tasks {
if t.InfoHash == task.GID {
s.Progress = t.Percent
s.Status = t.GetStatus()
s.Completed = t.IsDone()
if t.IsFailed() {
s.Err = fmt.Errorf(t.GetStatus())
}
return s, nil
}
}
s.Err = fmt.Errorf("the task has been deleted")
return nil, nil
}
var _ tool.Tool = (*Cloud115)(nil)
func init() {
tool.Tools.Add(&Cloud115{})
}

View File

@ -1,6 +1,7 @@
package offline_download
import (
_ "github.com/alist-org/alist/v3/internal/offline_download/115"
_ "github.com/alist-org/alist/v3/internal/offline_download/aria2"
_ "github.com/alist-org/alist/v3/internal/offline_download/http"
_ "github.com/alist-org/alist/v3/internal/offline_download/pikpak"

View File

@ -2,14 +2,16 @@ package http
import (
"fmt"
"github.com/alist-org/alist/v3/internal/model"
"github.com/alist-org/alist/v3/internal/offline_download/tool"
"github.com/alist-org/alist/v3/pkg/utils"
"net/http"
"net/url"
"os"
"path"
"path/filepath"
"strings"
"github.com/alist-org/alist/v3/internal/model"
"github.com/alist-org/alist/v3/internal/offline_download/tool"
"github.com/alist-org/alist/v3/pkg/utils"
)
type SimpleHttp struct {
@ -63,7 +65,12 @@ func (s SimpleHttp) Run(task *tool.DownloadTask) error {
if resp.StatusCode >= 400 {
return fmt.Errorf("http status code %d", resp.StatusCode)
}
filename := path.Base(_u.Path)
// If Path is empty, use Hostname; otherwise, filePath euqals TempDir which causes os.Create to fail
urlPath := _u.Path
if urlPath == "" {
urlPath = strings.ReplaceAll(_u.Host, ".", "_")
}
filename := path.Base(urlPath)
if n, err := parseFilenameFromContentDisposition(resp.Header.Get("Content-Disposition")); err == nil {
filename = n
}

View File

@ -66,16 +66,24 @@ func AddURL(ctx context.Context, args *AddURLArgs) (tache.TaskWithInfo, error) {
uid := uuid.NewString()
tempDir := filepath.Join(conf.Conf.TempDir, args.Tool, uid)
deletePolicy := args.DeletePolicy
if args.Tool == "pikpak" {
switch args.Tool {
case "115 Cloud":
tempDir = args.DstDirPath
// 防止将下载好的文件删除
deletePolicy = DeleteNever
case "pikpak":
tempDir = args.DstDirPath
// 防止将下载好的文件删除
deletePolicy = DeleteNever
}
t := &DownloadTask{
Url: args.URL,
DstDirPath: args.DstDirPath,
TempDir: tempDir,
DeletePolicy: deletePolicy,
Toolname: args.Tool,
tool: tool,
}
DownloadTaskManager.Add(t)

View File

@ -14,19 +14,26 @@ import (
type DownloadTask struct {
tache.Base
Url string `json:"url"`
DstDirPath string `json:"dst_dir_path"`
TempDir string `json:"temp_dir"`
DeletePolicy DeletePolicy `json:"delete_policy"`
Status string `json:"status"`
Signal chan int `json:"-"`
GID string `json:"-"`
Url string `json:"url"`
DstDirPath string `json:"dst_dir_path"`
TempDir string `json:"temp_dir"`
DeletePolicy DeletePolicy `json:"delete_policy"`
Toolname string `json:"toolname"`
Status string `json:"-"`
Signal chan int `json:"-"`
GID string `json:"-"`
tool Tool
callStatusRetried int
}
func (t *DownloadTask) Run() error {
if t.tool == nil {
tool, err := Tools.Get(t.Toolname)
if err != nil {
return errors.WithMessage(err, "failed get tool")
}
t.tool = tool
}
if err := t.tool.Run(t); !errs.IsNotSupportError(err) {
if err == nil {
return t.Complete()
@ -47,9 +54,7 @@ func (t *DownloadTask) Run() error {
return err
}
t.GID = gid
var (
ok bool
)
var ok bool
outer:
for {
select {
@ -74,6 +79,15 @@ outer:
if t.tool.Name() == "pikpak" {
return nil
}
if t.tool.Name() == "115 Cloud" {
// hack for 115
<-time.After(time.Second * 1)
err := t.tool.Remove(t)
if err != nil {
log.Errorln(err.Error())
}
return nil
}
t.Status = "offline download completed, maybe transferring"
// hack for qBittorrent
if t.tool.Name() == "qBittorrent" {
@ -129,6 +143,9 @@ func (t *DownloadTask) Complete() error {
if t.tool.Name() == "pikpak" {
return nil
}
if t.tool.Name() == "115 Cloud" {
return nil
}
if getFileser, ok := t.tool.(GetFileser); ok {
files = getFileser.GetFiles(t)
} else {
@ -142,9 +159,10 @@ func (t *DownloadTask) Complete() error {
file := files[i]
TransferTaskManager.Add(&TransferTask{
file: file,
dstDirPath: t.DstDirPath,
tempDir: t.TempDir,
deletePolicy: t.DeletePolicy,
DstDirPath: t.DstDirPath,
TempDir: t.TempDir,
DeletePolicy: t.DeletePolicy,
FileDir: file.Path,
})
}
return nil
@ -158,6 +176,4 @@ func (t *DownloadTask) GetStatus() string {
return t.Status
}
var (
DownloadTaskManager *tache.Manager[*DownloadTask]
)
var DownloadTaskManager *tache.Manager[*DownloadTask]

View File

@ -2,6 +2,9 @@ package tool
import (
"fmt"
"os"
"path/filepath"
"github.com/alist-org/alist/v3/internal/model"
"github.com/alist-org/alist/v3/internal/op"
"github.com/alist-org/alist/v3/internal/stream"
@ -9,21 +12,27 @@ import (
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
"github.com/xhofe/tache"
"os"
"path/filepath"
)
type TransferTask struct {
tache.Base
FileDir string `json:"file_dir"`
DstDirPath string `json:"dst_dir_path"`
TempDir string `json:"temp_dir"`
DeletePolicy DeletePolicy `json:"delete_policy"`
file File
dstDirPath string
tempDir string
deletePolicy DeletePolicy
}
func (t *TransferTask) Run() error {
// check dstDir again
storage, dstDirActualPath, err := op.GetStorageAndActualPath(t.dstDirPath)
var err error
if (t.file == File{}) {
t.file, err = GetFile(t.FileDir)
if err != nil {
return errors.Wrapf(err, "failed to get file %s", t.FileDir)
}
}
storage, dstDirActualPath, err := op.GetStorageAndActualPath(t.DstDirPath)
if err != nil {
return errors.WithMessage(err, "failed get storage")
}
@ -44,7 +53,7 @@ func (t *TransferTask) Run() error {
Mimetype: mimetype,
Closers: utils.NewClosers(rc),
}
relDir, err := filepath.Rel(t.tempDir, filepath.Dir(t.file.Path))
relDir, err := filepath.Rel(t.TempDir, filepath.Dir(t.file.Path))
if err != nil {
log.Errorf("find relation directory error: %v", err)
}
@ -53,7 +62,7 @@ func (t *TransferTask) Run() error {
}
func (t *TransferTask) GetName() string {
return fmt.Sprintf("transfer %s to [%s]", t.file.Path, t.dstDirPath)
return fmt.Sprintf("transfer %s to [%s]", t.file.Path, t.DstDirPath)
}
func (t *TransferTask) GetStatus() string {
@ -61,7 +70,7 @@ func (t *TransferTask) GetStatus() string {
}
func (t *TransferTask) OnSucceeded() {
if t.deletePolicy == DeleteOnUploadSucceed || t.deletePolicy == DeleteAlways {
if t.DeletePolicy == DeleteOnUploadSucceed || t.DeletePolicy == DeleteAlways {
err := os.Remove(t.file.Path)
if err != nil {
log.Errorf("failed to delete file %s, error: %s", t.file.Path, err.Error())
@ -70,7 +79,7 @@ func (t *TransferTask) OnSucceeded() {
}
func (t *TransferTask) OnFailed() {
if t.deletePolicy == DeleteOnUploadFailed || t.deletePolicy == DeleteAlways {
if t.DeletePolicy == DeleteOnUploadFailed || t.DeletePolicy == DeleteAlways {
err := os.Remove(t.file.Path)
if err != nil {
log.Errorf("failed to delete file %s, error: %s", t.file.Path, err.Error())

View File

@ -26,3 +26,16 @@ func GetFiles(dir string) ([]File, error) {
}
return files, nil
}
func GetFile(path string) (File, error) {
info, err := os.Stat(path)
if err != nil {
return File{}, err
}
return File{
Name: info.Name(),
Size: info.Size(),
Path: path,
Modified: info.ModTime(),
}, nil
}

View File

@ -136,9 +136,7 @@ func List(ctx context.Context, storage driver.Driver, path string, args model.Li
model.WrapObjsName(files)
// call hooks
go func(reqPath string, files []model.Obj) {
for _, hook := range objsUpdateHooks {
hook(reqPath, files)
}
HandleObjsUpdateHook(reqPath, files)
}(utils.GetFullPath(storage.GetStorage().MountPath, path), files)
// sort objs
@ -466,6 +464,9 @@ func Remove(ctx context.Context, storage driver.Driver, path string) error {
if storage.Config().CheckStatus && storage.GetStorage().Status != WORK {
return errors.Errorf("storage not init: %s", storage.GetStorage().Status)
}
if utils.PathEqual(path, "/") {
return errors.New("delete root folder is not allowed, please goto the manage page to delete the storage instead")
}
path = utils.FixAndCleanPath(path)
rawObj, err := Get(ctx, storage, path)
if err != nil {

View File

@ -5,10 +5,12 @@ import (
"path"
"path/filepath"
"strings"
"sync"
"sync/atomic"
"time"
"github.com/alist-org/alist/v3/internal/conf"
"github.com/alist-org/alist/v3/internal/errs"
"github.com/alist-org/alist/v3/internal/fs"
"github.com/alist-org/alist/v3/internal/model"
"github.com/alist-org/alist/v3/internal/op"
@ -21,10 +23,13 @@ import (
)
var (
Running = atomic.Bool{}
Quit chan struct{}
Quit = atomic.Pointer[chan struct{}]{}
)
func Running() bool {
return Quit.Load() != nil
}
func BuildIndex(ctx context.Context, indexPaths, ignorePaths []string, maxDepth int, count bool) error {
var (
err error
@ -33,11 +38,27 @@ func BuildIndex(ctx context.Context, indexPaths, ignorePaths []string, maxDepth
)
log.Infof("build index for: %+v", indexPaths)
log.Infof("ignore paths: %+v", ignorePaths)
Running.Store(true)
Quit = make(chan struct{}, 1)
indexMQ := mq.NewInMemoryMQ[ObjWithParent]()
quit := make(chan struct{}, 1)
if !Quit.CompareAndSwap(nil, &quit) {
// other goroutine is running
return errs.BuildIndexIsRunning
}
var (
indexMQ = mq.NewInMemoryMQ[ObjWithParent]()
running = atomic.Bool{} // current goroutine running
wg = &sync.WaitGroup{}
)
running.Store(true)
wg.Add(1)
go func() {
ticker := time.NewTicker(time.Second)
defer func() {
Quit.Store(nil)
wg.Done()
// notify walk to exit when StopIndex api called
running.Store(false)
ticker.Stop()
}()
tickCount := 0
for {
select {
@ -70,9 +91,8 @@ func BuildIndex(ctx context.Context, indexPaths, ignorePaths []string, maxDepth
}
})
case <-Quit:
Running.Store(false)
ticker.Stop()
case <-quit:
log.Debugf("build index for %+v received quit", indexPaths)
eMsg := ""
now := time.Now()
originErr := err
@ -100,14 +120,22 @@ func BuildIndex(ctx context.Context, indexPaths, ignorePaths []string, maxDepth
})
}
})
log.Debugf("build index for %+v quit success", indexPaths)
return
}
}
}()
defer func() {
if Running.Load() {
Quit <- struct{}{}
if !running.Load() || Quit.Load() != &quit {
log.Debugf("build index for %+v stopped by StopIndex", indexPaths)
return
}
select {
// avoid goroutine leak
case quit <- struct{}{}:
default:
}
wg.Wait()
}()
admin, err := op.GetAdmin()
if err != nil {
@ -121,7 +149,7 @@ func BuildIndex(ctx context.Context, indexPaths, ignorePaths []string, maxDepth
}
for _, indexPath := range indexPaths {
walkFn := func(indexPath string, info model.Obj) error {
if !Running.Load() {
if !running.Load() {
return filepath.SkipDir
}
for _, avoidPath := range ignorePaths {
@ -167,7 +195,7 @@ func Config(ctx context.Context) searcher.Config {
}
func Update(parent string, objs []model.Obj) {
if instance == nil || !instance.Config().AutoUpdate || !setting.GetBool(conf.AutoUpdateIndex) || Running.Load() {
if instance == nil || !instance.Config().AutoUpdate || !setting.GetBool(conf.AutoUpdateIndex) || Running() {
return
}
if isIgnorePath(parent) {

View File

@ -27,7 +27,7 @@ func Init(mode string) error {
}
instance = nil
}
if Running.Load() {
if Running() {
return fmt.Errorf("index is running")
}
if mode == "none" {

View File

@ -57,5 +57,7 @@ func (mq *inMemoryMQ[T]) Clear() {
}
func (mq *inMemoryMQ[T]) Len() int {
mq.Lock()
defer mq.Unlock()
return mq.queue.Len()
}

View File

@ -3,6 +3,7 @@ package common
import (
"time"
"github.com/Xhofe/go-cache"
"github.com/alist-org/alist/v3/internal/conf"
"github.com/alist-org/alist/v3/internal/model"
"github.com/golang-jwt/jwt/v4"
@ -17,6 +18,8 @@ type UserClaims struct {
jwt.RegisteredClaims
}
var validTokenCache = cache.NewMemCache[bool]()
func GenerateToken(user *model.User) (tokenString string, err error) {
claim := UserClaims{
Username: user.Username,
@ -28,6 +31,10 @@ func GenerateToken(user *model.User) (tokenString string, err error) {
}}
token := jwt.NewWithClaims(jwt.SigningMethodHS256, claim)
tokenString, err = token.SignedString(SecretKey)
if err != nil {
return "", err
}
validTokenCache.Set(tokenString, true)
return tokenString, err
}
@ -35,6 +42,9 @@ func ParseToken(tokenString string) (*UserClaims, error) {
token, err := jwt.ParseWithClaims(tokenString, &UserClaims{}, func(token *jwt.Token) (interface{}, error) {
return SecretKey, nil
})
if IsTokenInvalidated(tokenString) {
return nil, errors.New("token is invalidated")
}
if err != nil {
if ve, ok := err.(*jwt.ValidationError); ok {
if ve.Errors&jwt.ValidationErrorMalformed != 0 {
@ -53,3 +63,16 @@ func ParseToken(tokenString string) (*UserClaims, error) {
}
return nil, errors.New("couldn't handle this token")
}
func InvalidateToken(tokenString string) error {
if tokenString == "" {
return nil // don't invalidate empty guest token
}
validTokenCache.Del(tokenString)
return nil
}
func IsTokenInvalidated(tokenString string) bool {
_, ok := validTokenCache.Get(tokenString)
return !ok
}

View File

@ -181,3 +181,12 @@ func Verify2FA(c *gin.Context) {
common.SuccessResp(c)
}
}
func LogOut(c *gin.Context) {
err := common.InvalidateToken(c.GetHeader("Authorization"))
if err != nil {
common.ErrorResp(c, err, 500)
} else {
common.SuccessResp(c)
}
}

View File

@ -19,7 +19,7 @@ type UpdateIndexReq struct {
}
func BuildIndex(c *gin.Context) {
if search.Running.Load() {
if search.Running() {
common.ErrorStrResp(c, "index is running", 400)
return
}
@ -45,7 +45,7 @@ func UpdateIndex(c *gin.Context) {
common.ErrorResp(c, err, 400)
return
}
if search.Running.Load() {
if search.Running() {
common.ErrorStrResp(c, "index is running", 400)
return
}
@ -72,16 +72,20 @@ func UpdateIndex(c *gin.Context) {
}
func StopIndex(c *gin.Context) {
if !search.Running.Load() {
quit := search.Quit.Load()
if quit == nil {
common.ErrorStrResp(c, "index is not running", 400)
return
}
search.Quit <- struct{}{}
select {
case *quit <- struct{}{}:
default:
}
common.SuccessResp(c)
}
func ClearIndex(c *gin.Context) {
if search.Running.Load() {
if search.Running() {
common.ErrorStrResp(c, "index is running", 400)
return
}

View File

@ -54,6 +54,7 @@ func Init(e *gin.Engine) {
auth.POST("/me/update", handles.UpdateCurrent)
auth.POST("/auth/2fa/generate", handles.Generate2FA)
auth.POST("/auth/2fa/verify", handles.Verify2FA)
auth.GET("/auth/logout", handles.LogOut)
// auth
api.GET("/auth/sso", handles.SSOLoginRedirect)

View File

@ -267,8 +267,19 @@ func (b *s3Backend) PutObject(
}
bucketPath := bucket.Path
isDir := strings.HasSuffix(objectName, "/")
log.Debugf("isDir: %v", isDir)
fp := path.Join(bucketPath, objectName)
reqPath := path.Dir(fp)
log.Debugf("fp: %s, bucketPath: %s, objectName: %s", fp, bucketPath, objectName)
var reqPath string
if isDir {
reqPath = fp + "/"
} else {
reqPath = path.Dir(fp)
}
log.Debugf("reqPath: %s", reqPath)
fmeta, _ := op.GetNearestMeta(fp)
ctx = context.WithValue(ctx, "meta", fmeta)
@ -285,6 +296,10 @@ func (b *s3Backend) PutObject(
}
}
if isDir {
return result, nil
}
var ti time.Time
if val, ok := meta["X-Amz-Meta-Mtime"]; ok {