Compare commits
43 Commits
Author | SHA1 | Date | |
---|---|---|---|
bd2418c438 | |||
8421c72c5c | |||
a80e21997c | |||
4369cbbac3 | |||
89f76d7899 | |||
ef68f84787 | |||
2c1f70fbe9 | |||
b2f5757f8d | |||
6b97b4eb20 | |||
645c10c11f | |||
571bcf07b0 | |||
63de65be45 | |||
a3446720a2 | |||
3c4c2ad4e0 | |||
077a525961 | |||
5be79eb26e | |||
ddc19ab699 | |||
ddfca5a29b | |||
c19166be1c | |||
daad61443c | |||
4b0c01158d | |||
f97f1d532e | |||
e15755fef0 | |||
ea88998325 | |||
74d971aa8a | |||
d41d868a8d | |||
555cc26cbf | |||
ab4215080b | |||
9502f5acd7 | |||
b03879403f | |||
ee4ac81677 | |||
b69fc8c306 | |||
ee6c31332d | |||
9fa16bd5fc | |||
c77ed5fcb0 | |||
822be17fb9 | |||
7e3b13ea2d | |||
f8fb48fb32 | |||
4bf46268da | |||
b7ea73b3c2 | |||
9fbc54314d | |||
cf8ab29a17 | |||
51cadd2d49 |
4
.github/stale.yml
vendored
4
.github/stale.yml
vendored
@ -1,7 +1,7 @@
|
|||||||
# Number of days of inactivity before an issue becomes stale
|
# Number of days of inactivity before an issue becomes stale
|
||||||
daysUntilStale: 44
|
daysUntilStale: 44
|
||||||
# Number of days of inactivity before a stale issue is closed
|
# Number of days of inactivity before a stale issue is closed
|
||||||
daysUntilClose: 8
|
daysUntilClose: 10
|
||||||
# Issues with these labels will never be considered stale
|
# Issues with these labels will never be considered stale
|
||||||
exemptLabels:
|
exemptLabels:
|
||||||
- accepted
|
- accepted
|
||||||
@ -16,4 +16,4 @@ markComment: >
|
|||||||
# Comment to post when closing a stale issue. Set to `false` to disable
|
# Comment to post when closing a stale issue. Set to `false` to disable
|
||||||
closeComment: >
|
closeComment: >
|
||||||
This issue was closed due to inactive more than 52 days. You can reopen or
|
This issue was closed due to inactive more than 52 days. You can reopen or
|
||||||
recreate it if you think it should continue. Thank you for your contributions again.
|
recreate it if you think it should continue. Thank you for your contributions again.
|
||||||
|
8
.github/workflows/issue_close_question.yml
vendored
8
.github/workflows/issue_close_question.yml
vendored
@ -2,7 +2,7 @@ name: Close need info
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
schedule:
|
schedule:
|
||||||
- cron: "0 0 */7 * *"
|
- cron: "0 0 */1 * *"
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
@ -15,8 +15,8 @@ jobs:
|
|||||||
actions: 'close-issues'
|
actions: 'close-issues'
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
labels: 'question'
|
labels: 'question'
|
||||||
inactive-day: 7
|
inactive-day: 3
|
||||||
close-reason: 'not_planned'
|
close-reason: 'not_planned'
|
||||||
body: |
|
body: |
|
||||||
Hello @${{ github.event.issue.user.login }}, this issue was closed due to no activities in 7 days.
|
Hello @${{ github.event.issue.user.login }}, this issue was closed due to no activities in 3 days.
|
||||||
你好 @${{ github.event.issue.user.login }},此issue因超过7天未回复被关闭。
|
你好 @${{ github.event.issue.user.login }},此issue因超过3天未回复被关闭。
|
21
.github/workflows/issue_close_stale.yml
vendored
Normal file
21
.github/workflows/issue_close_stale.yml
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
name: Close inactive
|
||||||
|
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
- cron: "0 0 */7 * *"
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
close-inactive:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: close-issues
|
||||||
|
uses: actions-cool/issues-helper@v3
|
||||||
|
with:
|
||||||
|
actions: 'close-issues'
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
labels: 'stale'
|
||||||
|
inactive-day: 8
|
||||||
|
close-reason: 'not_planned'
|
||||||
|
body: |
|
||||||
|
Hello @${{ github.event.issue.user.login }}, this issue was closed due to inactive more than 52 days. You can reopen or recreate it if you think it should continue.
|
4
.github/workflows/issue_question.yml
vendored
4
.github/workflows/issue_question.yml
vendored
@ -16,5 +16,5 @@ jobs:
|
|||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
issue-number: ${{ github.event.issue.number }}
|
issue-number: ${{ github.event.issue.number }}
|
||||||
body: |
|
body: |
|
||||||
Hello @${{ github.event.issue.user.login }}, please input issue by template and add detail. Issues labeled by `question` will be closed if no activities in 7 days.
|
Hello @${{ github.event.issue.user.login }}, please input issue by template and add detail. Issues labeled by `question` will be closed if no activities in 3 days.
|
||||||
你好 @${{ github.event.issue.user.login }},请按照issue模板填写, 并详细说明问题/日志记录/复现步骤/复现链接/实现思路或提供更多信息等, 7天内未回复issue自动关闭。
|
你好 @${{ github.event.issue.user.login }},请按照issue模板填写, 并详细说明问题/日志记录/复现步骤/复现链接/实现思路或提供更多信息等, 3天内未回复issue自动关闭。
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
Prerequisites:
|
Prerequisites:
|
||||||
|
|
||||||
- [git](https://nodejs.org/zh-cn/)
|
- [git](https://git-scm.com)
|
||||||
- [Go 1.19+](https://golang.org/doc/install)
|
- [Go 1.19+](https://golang.org/doc/install)
|
||||||
- [gcc](https://gcc.gnu.org/)
|
- [gcc](https://gcc.gnu.org/)
|
||||||
- [nodejs](https://nodejs.org/)
|
- [nodejs](https://nodejs.org/)
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
FROM alpine:3.17 as builder
|
FROM alpine:3.18 as builder
|
||||||
LABEL stage=go-builder
|
LABEL stage=go-builder
|
||||||
WORKDIR /app/
|
WORKDIR /app/
|
||||||
COPY ./ ./
|
COPY ./ ./
|
||||||
RUN apk add --no-cache bash curl gcc git go musl-dev; \
|
RUN apk add --no-cache bash curl gcc git go musl-dev; \
|
||||||
bash build.sh release docker
|
bash build.sh release docker
|
||||||
|
|
||||||
FROM alpine:3.17
|
FROM alpine:3.18
|
||||||
LABEL MAINTAINER="i@nn.ci"
|
LABEL MAINTAINER="i@nn.ci"
|
||||||
VOLUME /opt/alist/data/
|
VOLUME /opt/alist/data/
|
||||||
WORKDIR /opt/alist/
|
WORKDIR /opt/alist/
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<div align="center">
|
<div align="center">
|
||||||
<a href="https://alist.nn.ci"><img height="100px" alt="logo" src="https://cdn.jsdelivr.net/gh/alist-org/logo@main/logo.svg"/></a>
|
<a href="https://alist.nn.ci"><img height="100px" alt="logo" src="https://cdn.jsdelivr.net/gh/alist-org/logo@main/logo.svg"/></a>
|
||||||
<p><em>🗂️A file list program that supports multiple storage, powered by Gin and Solidjs.</em></p>
|
<p><em>🗂️A file list program that supports multiple storages, powered by Gin and Solidjs.</em></p>
|
||||||
<div>
|
<div>
|
||||||
<a href="https://goreportcard.com/report/github.com/alist-org/alist/v3">
|
<a href="https://goreportcard.com/report/github.com/alist-org/alist/v3">
|
||||||
<img src="https://goreportcard.com/badge/github.com/alist-org/alist/v3" alt="latest version" />
|
<img src="https://goreportcard.com/badge/github.com/alist-org/alist/v3" alt="latest version" />
|
||||||
@ -62,6 +62,7 @@ English | [中文](./README_cn.md) | [Contributing](./CONTRIBUTING.md) | [CODE_O
|
|||||||
- [x] [YandexDisk](https://disk.yandex.com/)
|
- [x] [YandexDisk](https://disk.yandex.com/)
|
||||||
- [x] [BaiduNetdisk](http://pan.baidu.com/)
|
- [x] [BaiduNetdisk](http://pan.baidu.com/)
|
||||||
- [x] [Terabox](https://www.terabox.com/main)
|
- [x] [Terabox](https://www.terabox.com/main)
|
||||||
|
- [x] [UC](https://drive.uc.cn)
|
||||||
- [x] [Quark](https://pan.quark.cn)
|
- [x] [Quark](https://pan.quark.cn)
|
||||||
- [x] [Thunder](https://pan.xunlei.com)
|
- [x] [Thunder](https://pan.xunlei.com)
|
||||||
- [x] [Lanzou](https://www.lanzou.com/)
|
- [x] [Lanzou](https://www.lanzou.com/)
|
||||||
|
@ -61,6 +61,7 @@
|
|||||||
- [x] [和彩云](https://yun.139.com/) (个人云, 家庭云)
|
- [x] [和彩云](https://yun.139.com/) (个人云, 家庭云)
|
||||||
- [x] [Yandex.Disk](https://disk.yandex.com/)
|
- [x] [Yandex.Disk](https://disk.yandex.com/)
|
||||||
- [x] [百度网盘](http://pan.baidu.com/)
|
- [x] [百度网盘](http://pan.baidu.com/)
|
||||||
|
- [x] [UC网盘](https://drive.uc.cn)
|
||||||
- [x] [夸克网盘](https://pan.quark.cn)
|
- [x] [夸克网盘](https://pan.quark.cn)
|
||||||
- [x] [迅雷网盘](https://pan.xunlei.com)
|
- [x] [迅雷网盘](https://pan.xunlei.com)
|
||||||
- [x] [蓝奏云](https://www.lanzou.com/)
|
- [x] [蓝奏云](https://www.lanzou.com/)
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/SheltonZhu/115driver/pkg/driver"
|
"github.com/SheltonZhu/115driver/pkg/driver"
|
||||||
|
"github.com/alist-org/alist/v3/drivers/base"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -15,6 +16,7 @@ func (d *Pan115) login() error {
|
|||||||
driver.UA(UserAgent),
|
driver.UA(UserAgent),
|
||||||
}
|
}
|
||||||
d.client = driver.New(opts...)
|
d.client = driver.New(opts...)
|
||||||
|
d.client.SetHttpClient(base.HttpClient)
|
||||||
cr := &driver.Credential{}
|
cr := &driver.Credential{}
|
||||||
if d.Addition.QRCodeToken != "" {
|
if d.Addition.QRCodeToken != "" {
|
||||||
s := &driver.QRCodeSession{
|
s := &driver.QRCodeSession{
|
||||||
|
@ -30,12 +30,9 @@ func (d *Cloud189) GetAddition() driver.Additional {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *Cloud189) Init(ctx context.Context) error {
|
func (d *Cloud189) Init(ctx context.Context) error {
|
||||||
d.client = resty.New().
|
d.client = base.NewRestyClient().
|
||||||
SetTimeout(base.DefaultTimeout).
|
SetHeader("Referer", "https://cloud.189.cn/")
|
||||||
SetRetryCount(3).
|
return d.newLogin()
|
||||||
SetHeader("Referer", "https://cloud.189.cn/").
|
|
||||||
SetHeader("User-Agent", base.UserAgent)
|
|
||||||
return d.login()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Cloud189) Drop(ctx context.Context) error {
|
func (d *Cloud189) Drop(ctx context.Context) error {
|
||||||
|
126
drivers/189/login.go
Normal file
126
drivers/189/login.go
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
package _189
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/alist-org/alist/v3/pkg/utils"
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
)
|
||||||
|
|
||||||
|
type AppConf struct {
|
||||||
|
Data struct {
|
||||||
|
AccountType string `json:"accountType"`
|
||||||
|
AgreementCheck string `json:"agreementCheck"`
|
||||||
|
AppKey string `json:"appKey"`
|
||||||
|
ClientType int `json:"clientType"`
|
||||||
|
IsOauth2 bool `json:"isOauth2"`
|
||||||
|
LoginSort string `json:"loginSort"`
|
||||||
|
MailSuffix string `json:"mailSuffix"`
|
||||||
|
PageKey string `json:"pageKey"`
|
||||||
|
ParamId string `json:"paramId"`
|
||||||
|
RegReturnUrl string `json:"regReturnUrl"`
|
||||||
|
ReqId string `json:"reqId"`
|
||||||
|
ReturnUrl string `json:"returnUrl"`
|
||||||
|
ShowFeedback string `json:"showFeedback"`
|
||||||
|
ShowPwSaveName string `json:"showPwSaveName"`
|
||||||
|
ShowQrSaveName string `json:"showQrSaveName"`
|
||||||
|
ShowSmsSaveName string `json:"showSmsSaveName"`
|
||||||
|
Sso string `json:"sso"`
|
||||||
|
} `json:"data"`
|
||||||
|
Msg string `json:"msg"`
|
||||||
|
Result string `json:"result"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type EncryptConf struct {
|
||||||
|
Result int `json:"result"`
|
||||||
|
Data struct {
|
||||||
|
UpSmsOn string `json:"upSmsOn"`
|
||||||
|
Pre string `json:"pre"`
|
||||||
|
PreDomain string `json:"preDomain"`
|
||||||
|
PubKey string `json:"pubKey"`
|
||||||
|
} `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *Cloud189) newLogin() error {
|
||||||
|
url := "https://cloud.189.cn/api/portal/loginUrl.action?redirectURL=https%3A%2F%2Fcloud.189.cn%2Fmain.action"
|
||||||
|
res, err := d.client.R().Get(url)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// Is logged in
|
||||||
|
redirectURL := res.RawResponse.Request.URL
|
||||||
|
if redirectURL.String() == "https://cloud.189.cn/web/main" {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
lt := redirectURL.Query().Get("lt")
|
||||||
|
reqId := redirectURL.Query().Get("reqId")
|
||||||
|
appId := redirectURL.Query().Get("appId")
|
||||||
|
headers := map[string]string{
|
||||||
|
"lt": lt,
|
||||||
|
"reqid": reqId,
|
||||||
|
"referer": redirectURL.String(),
|
||||||
|
"origin": "https://open.e.189.cn",
|
||||||
|
}
|
||||||
|
// get app Conf
|
||||||
|
var appConf AppConf
|
||||||
|
res, err = d.client.R().SetHeaders(headers).SetFormData(map[string]string{
|
||||||
|
"version": "2.0",
|
||||||
|
"appKey": appId,
|
||||||
|
}).SetResult(&appConf).Post("https://open.e.189.cn/api/logbox/oauth2/appConf.do")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
log.Debugf("189 AppConf resp body: %s", res.String())
|
||||||
|
if appConf.Result != "0" {
|
||||||
|
return errors.New(appConf.Msg)
|
||||||
|
}
|
||||||
|
// get encrypt conf
|
||||||
|
var encryptConf EncryptConf
|
||||||
|
res, err = d.client.R().SetHeaders(headers).SetFormData(map[string]string{
|
||||||
|
"appId": appId,
|
||||||
|
}).Post("https://open.e.189.cn/api/logbox/config/encryptConf.do")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = utils.Json.Unmarshal(res.Body(), &encryptConf)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
log.Debugf("189 EncryptConf resp body: %s\n%+v", res.String(), encryptConf)
|
||||||
|
if encryptConf.Result != 0 {
|
||||||
|
return errors.New("get EncryptConf error:" + res.String())
|
||||||
|
}
|
||||||
|
// TODO: getUUID? needcaptcha
|
||||||
|
// login
|
||||||
|
loginData := map[string]string{
|
||||||
|
"version": "v2.0",
|
||||||
|
"apToken": "",
|
||||||
|
"appKey": appId,
|
||||||
|
"accountType": appConf.Data.AccountType,
|
||||||
|
"userName": encryptConf.Data.Pre + RsaEncode([]byte(d.Username), encryptConf.Data.PubKey, true),
|
||||||
|
"epd": encryptConf.Data.Pre + RsaEncode([]byte(d.Password), encryptConf.Data.PubKey, true),
|
||||||
|
"captchaType": "",
|
||||||
|
"validateCode": "",
|
||||||
|
"smsValidateCode": "",
|
||||||
|
"captchaToken": "",
|
||||||
|
"returnUrl": appConf.Data.ReturnUrl,
|
||||||
|
"mailSuffix": appConf.Data.MailSuffix,
|
||||||
|
"dynamicCheck": "FALSE",
|
||||||
|
"clientType": strconv.Itoa(appConf.Data.ClientType),
|
||||||
|
"cb_SaveName": "3",
|
||||||
|
"isOauth2": strconv.FormatBool(appConf.Data.IsOauth2),
|
||||||
|
"state": "",
|
||||||
|
"paramId": appConf.Data.ParamId,
|
||||||
|
}
|
||||||
|
res, err = d.client.R().SetHeaders(headers).SetFormData(loginData).Post("https://open.e.189.cn/api/logbox/oauth2/loginSubmit.do")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
log.Debugf("189 login resp body: %s", res.String())
|
||||||
|
loginResult := utils.Json.Get(res.Body(), "result").ToInt()
|
||||||
|
if loginResult != 0 {
|
||||||
|
return errors.New(utils.Json.Get(res.Body(), "msg").ToString())
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
@ -8,6 +8,7 @@ import (
|
|||||||
type Addition struct {
|
type Addition struct {
|
||||||
Username string `json:"username" required:"true"`
|
Username string `json:"username" required:"true"`
|
||||||
Password string `json:"password" required:"true"`
|
Password string `json:"password" required:"true"`
|
||||||
|
Cookie string `json:"cookie" help:"Fill in the cookie if need captcha"`
|
||||||
driver.RootID
|
driver.RootID
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -15,6 +16,7 @@ var config = driver.Config{
|
|||||||
Name: "189Cloud",
|
Name: "189Cloud",
|
||||||
LocalSort: true,
|
LocalSort: true,
|
||||||
DefaultRoot: "-11",
|
DefaultRoot: "-11",
|
||||||
|
Alert: `info|You can try to use 189PC driver if this driver does not work.`,
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -11,16 +11,13 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"math"
|
"math"
|
||||||
"net/http"
|
"net/http"
|
||||||
"regexp"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/alist-org/alist/v3/drivers/base"
|
"github.com/alist-org/alist/v3/drivers/base"
|
||||||
"github.com/alist-org/alist/v3/internal/conf"
|
|
||||||
"github.com/alist-org/alist/v3/internal/driver"
|
"github.com/alist-org/alist/v3/internal/driver"
|
||||||
"github.com/alist-org/alist/v3/internal/model"
|
"github.com/alist-org/alist/v3/internal/model"
|
||||||
"github.com/alist-org/alist/v3/internal/setting"
|
|
||||||
"github.com/alist-org/alist/v3/pkg/utils"
|
"github.com/alist-org/alist/v3/pkg/utils"
|
||||||
myrand "github.com/alist-org/alist/v3/pkg/utils/random"
|
myrand "github.com/alist-org/alist/v3/pkg/utils/random"
|
||||||
"github.com/go-resty/resty/v2"
|
"github.com/go-resty/resty/v2"
|
||||||
@ -30,118 +27,118 @@ import (
|
|||||||
|
|
||||||
// do others that not defined in Driver interface
|
// do others that not defined in Driver interface
|
||||||
|
|
||||||
func (d *Cloud189) login() error {
|
//func (d *Cloud189) login() error {
|
||||||
url := "https://cloud.189.cn/api/portal/loginUrl.action?redirectURL=https%3A%2F%2Fcloud.189.cn%2Fmain.action"
|
// url := "https://cloud.189.cn/api/portal/loginUrl.action?redirectURL=https%3A%2F%2Fcloud.189.cn%2Fmain.action"
|
||||||
b := ""
|
// b := ""
|
||||||
lt := ""
|
// lt := ""
|
||||||
ltText := regexp.MustCompile(`lt = "(.+?)"`)
|
// ltText := regexp.MustCompile(`lt = "(.+?)"`)
|
||||||
var res *resty.Response
|
// var res *resty.Response
|
||||||
var err error
|
// var err error
|
||||||
for i := 0; i < 3; i++ {
|
// for i := 0; i < 3; i++ {
|
||||||
res, err = d.client.R().Get(url)
|
// res, err = d.client.R().Get(url)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return err
|
// return err
|
||||||
}
|
// }
|
||||||
// 已经登陆
|
// // 已经登陆
|
||||||
if res.RawResponse.Request.URL.String() == "https://cloud.189.cn/web/main" {
|
// if res.RawResponse.Request.URL.String() == "https://cloud.189.cn/web/main" {
|
||||||
return nil
|
// return nil
|
||||||
}
|
// }
|
||||||
b = res.String()
|
// b = res.String()
|
||||||
ltTextArr := ltText.FindStringSubmatch(b)
|
// ltTextArr := ltText.FindStringSubmatch(b)
|
||||||
if len(ltTextArr) > 0 {
|
// if len(ltTextArr) > 0 {
|
||||||
lt = ltTextArr[1]
|
// lt = ltTextArr[1]
|
||||||
break
|
// break
|
||||||
} else {
|
// } else {
|
||||||
<-time.After(time.Second)
|
// <-time.After(time.Second)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
if lt == "" {
|
// if lt == "" {
|
||||||
return fmt.Errorf("get page: %s \nstatus: %d \nrequest url: %s\nredirect url: %s",
|
// return fmt.Errorf("get page: %s \nstatus: %d \nrequest url: %s\nredirect url: %s",
|
||||||
b, res.StatusCode(), res.RawResponse.Request.URL.String(), res.Header().Get("location"))
|
// b, res.StatusCode(), res.RawResponse.Request.URL.String(), res.Header().Get("location"))
|
||||||
}
|
// }
|
||||||
captchaToken := regexp.MustCompile(`captchaToken' value='(.+?)'`).FindStringSubmatch(b)[1]
|
// captchaToken := regexp.MustCompile(`captchaToken' value='(.+?)'`).FindStringSubmatch(b)[1]
|
||||||
returnUrl := regexp.MustCompile(`returnUrl = '(.+?)'`).FindStringSubmatch(b)[1]
|
// returnUrl := regexp.MustCompile(`returnUrl = '(.+?)'`).FindStringSubmatch(b)[1]
|
||||||
paramId := regexp.MustCompile(`paramId = "(.+?)"`).FindStringSubmatch(b)[1]
|
// paramId := regexp.MustCompile(`paramId = "(.+?)"`).FindStringSubmatch(b)[1]
|
||||||
//reqId := regexp.MustCompile(`reqId = "(.+?)"`).FindStringSubmatch(b)[1]
|
// //reqId := regexp.MustCompile(`reqId = "(.+?)"`).FindStringSubmatch(b)[1]
|
||||||
jRsakey := regexp.MustCompile(`j_rsaKey" value="(\S+)"`).FindStringSubmatch(b)[1]
|
// jRsakey := regexp.MustCompile(`j_rsaKey" value="(\S+)"`).FindStringSubmatch(b)[1]
|
||||||
vCodeID := regexp.MustCompile(`picCaptcha\.do\?token\=([A-Za-z0-9\&\=]+)`).FindStringSubmatch(b)[1]
|
// vCodeID := regexp.MustCompile(`picCaptcha\.do\?token\=([A-Za-z0-9\&\=]+)`).FindStringSubmatch(b)[1]
|
||||||
vCodeRS := ""
|
// vCodeRS := ""
|
||||||
if vCodeID != "" {
|
// if vCodeID != "" {
|
||||||
// need ValidateCode
|
// // need ValidateCode
|
||||||
log.Debugf("try to identify verification codes")
|
// log.Debugf("try to identify verification codes")
|
||||||
timeStamp := strconv.FormatInt(time.Now().UnixNano()/1e6, 10)
|
// timeStamp := strconv.FormatInt(time.Now().UnixNano()/1e6, 10)
|
||||||
u := "https://open.e.189.cn/api/logbox/oauth2/picCaptcha.do?token=" + vCodeID + timeStamp
|
// u := "https://open.e.189.cn/api/logbox/oauth2/picCaptcha.do?token=" + vCodeID + timeStamp
|
||||||
imgRes, err := d.client.R().SetHeaders(map[string]string{
|
// imgRes, err := d.client.R().SetHeaders(map[string]string{
|
||||||
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:74.0) Gecko/20100101 Firefox/76.0",
|
// "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:74.0) Gecko/20100101 Firefox/76.0",
|
||||||
"Referer": "https://open.e.189.cn/api/logbox/oauth2/unifyAccountLogin.do",
|
// "Referer": "https://open.e.189.cn/api/logbox/oauth2/unifyAccountLogin.do",
|
||||||
"Sec-Fetch-Dest": "image",
|
// "Sec-Fetch-Dest": "image",
|
||||||
"Sec-Fetch-Mode": "no-cors",
|
// "Sec-Fetch-Mode": "no-cors",
|
||||||
"Sec-Fetch-Site": "same-origin",
|
// "Sec-Fetch-Site": "same-origin",
|
||||||
}).Get(u)
|
// }).Get(u)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return err
|
// return err
|
||||||
}
|
// }
|
||||||
// Enter the verification code manually
|
// // Enter the verification code manually
|
||||||
//err = message.GetMessenger().WaitSend(message.Message{
|
// //err = message.GetMessenger().WaitSend(message.Message{
|
||||||
// Type: "image",
|
// // Type: "image",
|
||||||
// Content: "data:image/png;base64," + base64.StdEncoding.EncodeToString(imgRes.Body()),
|
// // Content: "data:image/png;base64," + base64.StdEncoding.EncodeToString(imgRes.Body()),
|
||||||
//}, 10)
|
// //}, 10)
|
||||||
//if err != nil {
|
// //if err != nil {
|
||||||
// return err
|
// // return err
|
||||||
//}
|
// //}
|
||||||
//vCodeRS, err = message.GetMessenger().WaitReceive(30)
|
// //vCodeRS, err = message.GetMessenger().WaitReceive(30)
|
||||||
// use ocr api
|
// // use ocr api
|
||||||
vRes, err := base.RestyClient.R().SetMultipartField(
|
// vRes, err := base.RestyClient.R().SetMultipartField(
|
||||||
"image", "validateCode.png", "image/png", bytes.NewReader(imgRes.Body())).
|
// "image", "validateCode.png", "image/png", bytes.NewReader(imgRes.Body())).
|
||||||
Post(setting.GetStr(conf.OcrApi))
|
// Post(setting.GetStr(conf.OcrApi))
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return err
|
// return err
|
||||||
}
|
// }
|
||||||
if jsoniter.Get(vRes.Body(), "status").ToInt() != 200 {
|
// if jsoniter.Get(vRes.Body(), "status").ToInt() != 200 {
|
||||||
return errors.New("ocr error:" + jsoniter.Get(vRes.Body(), "msg").ToString())
|
// return errors.New("ocr error:" + jsoniter.Get(vRes.Body(), "msg").ToString())
|
||||||
}
|
// }
|
||||||
vCodeRS = jsoniter.Get(vRes.Body(), "result").ToString()
|
// vCodeRS = jsoniter.Get(vRes.Body(), "result").ToString()
|
||||||
log.Debugln("code: ", vCodeRS)
|
// log.Debugln("code: ", vCodeRS)
|
||||||
}
|
// }
|
||||||
userRsa := RsaEncode([]byte(d.Username), jRsakey, true)
|
// userRsa := RsaEncode([]byte(d.Username), jRsakey, true)
|
||||||
passwordRsa := RsaEncode([]byte(d.Password), jRsakey, true)
|
// passwordRsa := RsaEncode([]byte(d.Password), jRsakey, true)
|
||||||
url = "https://open.e.189.cn/api/logbox/oauth2/loginSubmit.do"
|
// url = "https://open.e.189.cn/api/logbox/oauth2/loginSubmit.do"
|
||||||
var loginResp LoginResp
|
// var loginResp LoginResp
|
||||||
res, err = d.client.R().
|
// res, err = d.client.R().
|
||||||
SetHeaders(map[string]string{
|
// SetHeaders(map[string]string{
|
||||||
"lt": lt,
|
// "lt": lt,
|
||||||
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36",
|
// "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36",
|
||||||
"Referer": "https://open.e.189.cn/",
|
// "Referer": "https://open.e.189.cn/",
|
||||||
"accept": "application/json;charset=UTF-8",
|
// "accept": "application/json;charset=UTF-8",
|
||||||
}).SetFormData(map[string]string{
|
// }).SetFormData(map[string]string{
|
||||||
"appKey": "cloud",
|
// "appKey": "cloud",
|
||||||
"accountType": "01",
|
// "accountType": "01",
|
||||||
"userName": "{RSA}" + userRsa,
|
// "userName": "{RSA}" + userRsa,
|
||||||
"password": "{RSA}" + passwordRsa,
|
// "password": "{RSA}" + passwordRsa,
|
||||||
"validateCode": vCodeRS,
|
// "validateCode": vCodeRS,
|
||||||
"captchaToken": captchaToken,
|
// "captchaToken": captchaToken,
|
||||||
"returnUrl": returnUrl,
|
// "returnUrl": returnUrl,
|
||||||
"mailSuffix": "@pan.cn",
|
// "mailSuffix": "@pan.cn",
|
||||||
"paramId": paramId,
|
// "paramId": paramId,
|
||||||
"clientType": "10010",
|
// "clientType": "10010",
|
||||||
"dynamicCheck": "FALSE",
|
// "dynamicCheck": "FALSE",
|
||||||
"cb_SaveName": "1",
|
// "cb_SaveName": "1",
|
||||||
"isOauth2": "false",
|
// "isOauth2": "false",
|
||||||
}).Post(url)
|
// }).Post(url)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return err
|
// return err
|
||||||
}
|
// }
|
||||||
err = utils.Json.Unmarshal(res.Body(), &loginResp)
|
// err = utils.Json.Unmarshal(res.Body(), &loginResp)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
log.Error(err.Error())
|
// log.Error(err.Error())
|
||||||
return err
|
// return err
|
||||||
}
|
// }
|
||||||
if loginResp.Result != 0 {
|
// if loginResp.Result != 0 {
|
||||||
return fmt.Errorf(loginResp.Msg)
|
// return fmt.Errorf(loginResp.Msg)
|
||||||
}
|
// }
|
||||||
_, err = d.client.R().Get(loginResp.ToUrl)
|
// _, err = d.client.R().Get(loginResp.ToUrl)
|
||||||
return err
|
// return err
|
||||||
}
|
//}
|
||||||
|
|
||||||
func (d *Cloud189) request(url string, method string, callback base.ReqCallback, resp interface{}) ([]byte, error) {
|
func (d *Cloud189) request(url string, method string, callback base.ReqCallback, resp interface{}) ([]byte, error) {
|
||||||
var e Error
|
var e Error
|
||||||
@ -163,7 +160,7 @@ func (d *Cloud189) request(url string, method string, callback base.ReqCallback,
|
|||||||
//log.Debug(res.String())
|
//log.Debug(res.String())
|
||||||
if e.ErrorCode != "" {
|
if e.ErrorCode != "" {
|
||||||
if e.ErrorCode == "InvalidSessionKey" {
|
if e.ErrorCode == "InvalidSessionKey" {
|
||||||
err = d.login()
|
err = d.newLogin()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/alist-org/alist/v3/drivers/base"
|
"github.com/alist-org/alist/v3/drivers/base"
|
||||||
"github.com/alist-org/alist/v3/internal/driver"
|
"github.com/alist-org/alist/v3/internal/driver"
|
||||||
@ -19,8 +18,7 @@ type Cloud189PC struct {
|
|||||||
|
|
||||||
identity string
|
identity string
|
||||||
|
|
||||||
client *resty.Client
|
client *resty.Client
|
||||||
putClient *resty.Client
|
|
||||||
|
|
||||||
loginParam *LoginParam
|
loginParam *LoginParam
|
||||||
tokenInfo *AppSessionResp
|
tokenInfo *AppSessionResp
|
||||||
@ -51,9 +49,6 @@ func (y *Cloud189PC) Init(ctx context.Context) (err error) {
|
|||||||
"Referer": WEB_URL,
|
"Referer": WEB_URL,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if y.putClient == nil {
|
|
||||||
y.putClient = base.NewRestyClient().SetTimeout(120 * time.Second)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 避免重复登陆
|
// 避免重复登陆
|
||||||
identity := utils.GetMD5Encode(y.Username + y.Password)
|
identity := utils.GetMD5Encode(y.Username + y.Password)
|
||||||
@ -266,8 +261,14 @@ func (y *Cloud189PC) Remove(ctx context.Context, obj model.Obj) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (y *Cloud189PC) Put(ctx context.Context, dstDir model.Obj, stream model.FileStreamer, up driver.UpdateProgress) error {
|
func (y *Cloud189PC) Put(ctx context.Context, dstDir model.Obj, stream model.FileStreamer, up driver.UpdateProgress) error {
|
||||||
if y.RapidUpload {
|
switch y.UploadMethod {
|
||||||
|
case "stream":
|
||||||
|
return y.CommonUpload(ctx, dstDir, stream, up)
|
||||||
|
case "old":
|
||||||
|
return y.OldUpload(ctx, dstDir, stream, up)
|
||||||
|
case "rapid":
|
||||||
return y.FastUpload(ctx, dstDir, stream, up)
|
return y.FastUpload(ctx, dstDir, stream, up)
|
||||||
|
default:
|
||||||
|
return y.CommonUpload(ctx, dstDir, stream, up)
|
||||||
}
|
}
|
||||||
return y.CommonUpload(ctx, dstDir, stream, up)
|
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import (
|
|||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/pem"
|
"encoding/pem"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"math"
|
||||||
"net/http"
|
"net/http"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
@ -131,3 +132,18 @@ func BoolToNumber(b bool) int {
|
|||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 计算分片大小
|
||||||
|
// 对分片数量有限制
|
||||||
|
// 10MIB 20 MIB 999片
|
||||||
|
// 50MIB 60MIB 70MIB 80MIB ∞MIB 1999片
|
||||||
|
func partSize(size int64) int64 {
|
||||||
|
const DEFAULT = 1024 * 1024 * 10 // 10MIB
|
||||||
|
if size > DEFAULT*2*999 {
|
||||||
|
return int64(math.Max(math.Ceil((float64(size)/1999) /*=单个切片大小*/ /float64(DEFAULT)) /*=倍率*/, 5) * DEFAULT)
|
||||||
|
}
|
||||||
|
if size > DEFAULT*999 {
|
||||||
|
return DEFAULT * 2 // 20MIB
|
||||||
|
}
|
||||||
|
return DEFAULT
|
||||||
|
}
|
||||||
|
@ -14,13 +14,14 @@ type Addition struct {
|
|||||||
OrderDirection string `json:"order_direction" type:"select" options:"asc,desc" default:"asc"`
|
OrderDirection string `json:"order_direction" type:"select" options:"asc,desc" default:"asc"`
|
||||||
Type string `json:"type" type:"select" options:"personal,family" default:"personal"`
|
Type string `json:"type" type:"select" options:"personal,family" default:"personal"`
|
||||||
FamilyID string `json:"family_id"`
|
FamilyID string `json:"family_id"`
|
||||||
RapidUpload bool `json:"rapid_upload"`
|
UploadMethod string `json:"upload_method" type:"select" options:"stream,rapid,old" default:"stream"`
|
||||||
NoUseOcr bool `json:"no_use_ocr"`
|
NoUseOcr bool `json:"no_use_ocr"`
|
||||||
}
|
}
|
||||||
|
|
||||||
var config = driver.Config{
|
var config = driver.Config{
|
||||||
Name: "189CloudPC",
|
Name: "189CloudPC",
|
||||||
DefaultRoot: "-11",
|
DefaultRoot: "-11",
|
||||||
|
CheckStatus: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -10,20 +10,62 @@ import (
|
|||||||
|
|
||||||
// 居然有四种返回方式
|
// 居然有四种返回方式
|
||||||
type RespErr struct {
|
type RespErr struct {
|
||||||
ResCode string `json:"res_code"`
|
ResCode any `json:"res_code"` // int or string
|
||||||
ResMessage string `json:"res_message"`
|
ResMessage string `json:"res_message"`
|
||||||
|
|
||||||
|
Error_ string `json:"error"`
|
||||||
|
|
||||||
XMLName xml.Name `xml:"error"`
|
XMLName xml.Name `xml:"error"`
|
||||||
Code string `json:"code" xml:"code"`
|
Code string `json:"code" xml:"code"`
|
||||||
Message string `json:"message" xml:"message"`
|
Message string `json:"message" xml:"message"`
|
||||||
|
Msg string `json:"msg"`
|
||||||
// Code string `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
|
|
||||||
ErrorCode string `json:"errorCode"`
|
ErrorCode string `json:"errorCode"`
|
||||||
ErrorMsg string `json:"errorMsg"`
|
ErrorMsg string `json:"errorMsg"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (e *RespErr) HasError() bool {
|
||||||
|
switch v := e.ResCode.(type) {
|
||||||
|
case int, int64, int32:
|
||||||
|
return v != 0
|
||||||
|
case string:
|
||||||
|
return e.ResCode != ""
|
||||||
|
}
|
||||||
|
return (e.Code != "" && e.Code != "SUCCESS") || e.ErrorCode != "" || e.Error_ != ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *RespErr) Error() string {
|
||||||
|
switch v := e.ResCode.(type) {
|
||||||
|
case int, int64, int32:
|
||||||
|
if v != 0 {
|
||||||
|
return fmt.Sprintf("res_code: %d ,res_msg: %s", v, e.ResMessage)
|
||||||
|
}
|
||||||
|
case string:
|
||||||
|
if e.ResCode != "" {
|
||||||
|
return fmt.Sprintf("res_code: %s ,res_msg: %s", e.ResCode, e.ResMessage)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if e.Code != "" && e.Code != "SUCCESS" {
|
||||||
|
if e.Msg != "" {
|
||||||
|
return fmt.Sprintf("code: %s ,msg: %s", e.Code, e.Msg)
|
||||||
|
}
|
||||||
|
if e.Message != "" {
|
||||||
|
return fmt.Sprintf("code: %s ,msg: %s", e.Code, e.Message)
|
||||||
|
}
|
||||||
|
return "code: " + e.Code
|
||||||
|
}
|
||||||
|
|
||||||
|
if e.ErrorCode != "" {
|
||||||
|
return fmt.Sprintf("err_code: %s ,err_msg: %s", e.ErrorCode, e.ErrorMsg)
|
||||||
|
}
|
||||||
|
|
||||||
|
if e.Error_ != "" {
|
||||||
|
return fmt.Sprintf("error: %s ,message: %s", e.ErrorCode, e.Message)
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
// 登陆需要的参数
|
// 登陆需要的参数
|
||||||
type LoginParam struct {
|
type LoginParam struct {
|
||||||
// 加密后的用户名和密码
|
// 加密后的用户名和密码
|
||||||
@ -218,6 +260,42 @@ type Part struct {
|
|||||||
RequestHeader string `json:"requestHeader"`
|
RequestHeader string `json:"requestHeader"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 第二种上传方式 */
|
||||||
|
type CreateUploadFileResp struct {
|
||||||
|
// 上传文件请求ID
|
||||||
|
UploadFileId int64 `json:"uploadFileId"`
|
||||||
|
// 上传文件数据的URL路径
|
||||||
|
FileUploadUrl string `json:"fileUploadUrl"`
|
||||||
|
// 上传文件完成后确认路径
|
||||||
|
FileCommitUrl string `json:"fileCommitUrl"`
|
||||||
|
// 文件是否已存在云盘中,0-未存在,1-已存在
|
||||||
|
FileDataExists int `json:"fileDataExists"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetUploadFileStatusResp struct {
|
||||||
|
CreateUploadFileResp
|
||||||
|
|
||||||
|
// 已上传的大小
|
||||||
|
DataSize int64 `json:"dataSize"`
|
||||||
|
Size int64 `json:"size"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *GetUploadFileStatusResp) GetSize() int64 {
|
||||||
|
return r.DataSize + r.Size
|
||||||
|
}
|
||||||
|
|
||||||
|
type CommitUploadFileResp struct {
|
||||||
|
XMLName xml.Name `xml:"file"`
|
||||||
|
Id string `xml:"id"`
|
||||||
|
Name string `xml:"name"`
|
||||||
|
Size string `xml:"size"`
|
||||||
|
Md5 string `xml:"md5"`
|
||||||
|
CreateDate string `xml:"createDate"`
|
||||||
|
Rev string `xml:"rev"`
|
||||||
|
UserId string `xml:"userId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
/* query 加密参数*/
|
||||||
type Params map[string]string
|
type Params map[string]string
|
||||||
|
|
||||||
func (p Params) Set(k, v string) {
|
func (p Params) Set(k, v string) {
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
|
"encoding/xml"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"math"
|
"math"
|
||||||
@ -15,6 +16,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/alist-org/alist/v3/drivers/base"
|
"github.com/alist-org/alist/v3/drivers/base"
|
||||||
"github.com/alist-org/alist/v3/internal/conf"
|
"github.com/alist-org/alist/v3/internal/conf"
|
||||||
@ -23,9 +25,12 @@ import (
|
|||||||
"github.com/alist-org/alist/v3/internal/op"
|
"github.com/alist-org/alist/v3/internal/op"
|
||||||
"github.com/alist-org/alist/v3/internal/setting"
|
"github.com/alist-org/alist/v3/internal/setting"
|
||||||
"github.com/alist-org/alist/v3/pkg/utils"
|
"github.com/alist-org/alist/v3/pkg/utils"
|
||||||
|
|
||||||
|
"github.com/avast/retry-go"
|
||||||
"github.com/go-resty/resty/v2"
|
"github.com/go-resty/resty/v2"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -47,7 +52,7 @@ const (
|
|||||||
CHANNEL_ID = "web_cloud.189.cn"
|
CHANNEL_ID = "web_cloud.189.cn"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (y *Cloud189PC) request(url, method string, callback base.ReqCallback, params Params, resp interface{}) ([]byte, error) {
|
func (y *Cloud189PC) SignatureHeader(url, method, params string) map[string]string {
|
||||||
dateOfGmt := getHttpDateStr()
|
dateOfGmt := getHttpDateStr()
|
||||||
sessionKey := y.tokenInfo.SessionKey
|
sessionKey := y.tokenInfo.SessionKey
|
||||||
sessionSecret := y.tokenInfo.SessionSecret
|
sessionSecret := y.tokenInfo.SessionSecret
|
||||||
@ -56,19 +61,40 @@ func (y *Cloud189PC) request(url, method string, callback base.ReqCallback, para
|
|||||||
sessionSecret = y.tokenInfo.FamilySessionSecret
|
sessionSecret = y.tokenInfo.FamilySessionSecret
|
||||||
}
|
}
|
||||||
|
|
||||||
req := y.client.R().SetQueryParams(clientSuffix()).SetHeaders(map[string]string{
|
header := map[string]string{
|
||||||
"Date": dateOfGmt,
|
"Date": dateOfGmt,
|
||||||
"SessionKey": sessionKey,
|
"SessionKey": sessionKey,
|
||||||
"X-Request-ID": uuid.NewString(),
|
"X-Request-ID": uuid.NewString(),
|
||||||
})
|
"Signature": signatureOfHmac(sessionSecret, sessionKey, method, url, dateOfGmt, params),
|
||||||
|
}
|
||||||
|
return header
|
||||||
|
}
|
||||||
|
|
||||||
|
func (y *Cloud189PC) EncryptParams(params Params) string {
|
||||||
|
sessionSecret := y.tokenInfo.SessionSecret
|
||||||
|
if y.isFamily() {
|
||||||
|
sessionSecret = y.tokenInfo.FamilySessionSecret
|
||||||
|
}
|
||||||
|
if params != nil {
|
||||||
|
return AesECBEncrypt(params.Encode(), sessionSecret[:16])
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (y *Cloud189PC) request(url, method string, callback base.ReqCallback, params Params, resp interface{}) ([]byte, error) {
|
||||||
|
req := y.client.R().SetQueryParams(clientSuffix())
|
||||||
|
|
||||||
// 设置params
|
// 设置params
|
||||||
var paramsData string
|
paramsData := y.EncryptParams(params)
|
||||||
if params != nil {
|
if paramsData != "" {
|
||||||
paramsData = AesECBEncrypt(params.Encode(), sessionSecret[:16])
|
|
||||||
req.SetQueryParam("params", paramsData)
|
req.SetQueryParam("params", paramsData)
|
||||||
}
|
}
|
||||||
req.SetHeader("Signature", signatureOfHmac(sessionSecret, sessionKey, method, url, dateOfGmt, paramsData))
|
|
||||||
|
// Signature
|
||||||
|
req.SetHeaders(y.SignatureHeader(url, method, paramsData))
|
||||||
|
|
||||||
|
var erron RespErr
|
||||||
|
req.SetError(&erron)
|
||||||
|
|
||||||
if callback != nil {
|
if callback != nil {
|
||||||
callback(req)
|
callback(req)
|
||||||
@ -80,32 +106,6 @@ func (y *Cloud189PC) request(url, method string, callback base.ReqCallback, para
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
var erron RespErr
|
|
||||||
utils.Json.Unmarshal(res.Body(), &erron)
|
|
||||||
|
|
||||||
if erron.ResCode != "" {
|
|
||||||
return nil, fmt.Errorf("res_code: %s ,res_msg: %s", erron.ResCode, erron.ResMessage)
|
|
||||||
}
|
|
||||||
if erron.Code != "" && erron.Code != "SUCCESS" {
|
|
||||||
if erron.Msg != "" {
|
|
||||||
return nil, fmt.Errorf("code: %s ,msg: %s", erron.Code, erron.Msg)
|
|
||||||
}
|
|
||||||
if erron.Message != "" {
|
|
||||||
return nil, fmt.Errorf("code: %s ,msg: %s", erron.Code, erron.Message)
|
|
||||||
}
|
|
||||||
return nil, fmt.Errorf(res.String())
|
|
||||||
}
|
|
||||||
switch erron.ErrorCode {
|
|
||||||
case "":
|
|
||||||
break
|
|
||||||
case "InvalidSessionKey":
|
|
||||||
if err = y.refreshSession(); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return y.request(url, method, callback, params, resp)
|
|
||||||
default:
|
|
||||||
return nil, fmt.Errorf("err_code: %s ,err_msg: %s", erron.ErrorCode, erron.ErrorMsg)
|
|
||||||
}
|
|
||||||
|
|
||||||
if strings.Contains(res.String(), "userSessionBO is null") {
|
if strings.Contains(res.String(), "userSessionBO is null") {
|
||||||
if err = y.refreshSession(); err != nil {
|
if err = y.refreshSession(); err != nil {
|
||||||
@ -114,14 +114,17 @@ func (y *Cloud189PC) request(url, method string, callback base.ReqCallback, para
|
|||||||
return y.request(url, method, callback, params, resp)
|
return y.request(url, method, callback, params, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
resCode := utils.Json.Get(res.Body(), "res_code").ToInt64()
|
// 处理错误
|
||||||
message := utils.Json.Get(res.Body(), "res_message").ToString()
|
if erron.HasError() {
|
||||||
switch resCode {
|
if erron.ErrorCode == "InvalidSessionKey" {
|
||||||
case 0:
|
if err = y.refreshSession(); err != nil {
|
||||||
return res.Body(), nil
|
return nil, err
|
||||||
default:
|
}
|
||||||
return nil, fmt.Errorf("res_code: %d ,res_msg: %s", resCode, message)
|
return y.request(url, method, callback, params, resp)
|
||||||
|
}
|
||||||
|
return nil, &erron
|
||||||
}
|
}
|
||||||
|
return res.Body(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (y *Cloud189PC) get(url string, callback base.ReqCallback, resp interface{}) ([]byte, error) {
|
func (y *Cloud189PC) get(url string, callback base.ReqCallback, resp interface{}) ([]byte, error) {
|
||||||
@ -132,6 +135,50 @@ func (y *Cloud189PC) post(url string, callback base.ReqCallback, resp interface{
|
|||||||
return y.request(url, http.MethodPost, callback, nil, resp)
|
return y.request(url, http.MethodPost, callback, nil, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (y *Cloud189PC) put(ctx context.Context, url string, headers map[string]string, sign bool, file io.Reader) ([]byte, error) {
|
||||||
|
req, err := http.NewRequestWithContext(ctx, http.MethodPut, url, file)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
query := req.URL.Query()
|
||||||
|
for key, value := range clientSuffix() {
|
||||||
|
query.Add(key, value)
|
||||||
|
}
|
||||||
|
req.URL.RawQuery = query.Encode()
|
||||||
|
|
||||||
|
for key, value := range headers {
|
||||||
|
req.Header.Add(key, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
if sign {
|
||||||
|
for key, value := range y.SignatureHeader(url, http.MethodPut, "") {
|
||||||
|
req.Header.Add(key, value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := base.HttpClient.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
body, err := io.ReadAll(resp.Body)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var erron RespErr
|
||||||
|
jsoniter.Unmarshal(body, &erron)
|
||||||
|
xml.Unmarshal(body, &erron)
|
||||||
|
if erron.HasError() {
|
||||||
|
return nil, &erron
|
||||||
|
}
|
||||||
|
if resp.StatusCode != http.StatusOK {
|
||||||
|
return nil, errors.Errorf("put fail,err:%s", string(body))
|
||||||
|
}
|
||||||
|
return body, nil
|
||||||
|
}
|
||||||
func (y *Cloud189PC) getFiles(ctx context.Context, fileId string) ([]model.Obj, error) {
|
func (y *Cloud189PC) getFiles(ctx context.Context, fileId string) ([]model.Obj, error) {
|
||||||
fullUrl := API_URL
|
fullUrl := API_URL
|
||||||
if y.isFamily() {
|
if y.isFamily() {
|
||||||
@ -186,7 +233,7 @@ func (y *Cloud189PC) getFiles(ctx context.Context, fileId string) ([]model.Obj,
|
|||||||
|
|
||||||
func (y *Cloud189PC) login() (err error) {
|
func (y *Cloud189PC) login() (err error) {
|
||||||
// 初始化登陆所需参数
|
// 初始化登陆所需参数
|
||||||
if y.loginParam == nil || !y.NoUseOcr {
|
if y.loginParam == nil {
|
||||||
if err = y.initLoginParam(); err != nil {
|
if err = y.initLoginParam(); err != nil {
|
||||||
// 验证码也通过错误返回
|
// 验证码也通过错误返回
|
||||||
return err
|
return err
|
||||||
@ -197,7 +244,7 @@ func (y *Cloud189PC) login() (err error) {
|
|||||||
y.VCode = ""
|
y.VCode = ""
|
||||||
// 销毁登陆参数
|
// 销毁登陆参数
|
||||||
y.loginParam = nil
|
y.loginParam = nil
|
||||||
// 遇到错误,重新加载登陆参数
|
// 遇到错误,重新加载登陆参数(刷新验证码)
|
||||||
if err != nil && y.NoUseOcr {
|
if err != nil && y.NoUseOcr {
|
||||||
if err1 := y.initLoginParam(); err1 != nil {
|
if err1 := y.initLoginParam(); err1 != nil {
|
||||||
err = fmt.Errorf("err1: %s \nerr2: %s", err, err1)
|
err = fmt.Errorf("err1: %s \nerr2: %s", err, err1)
|
||||||
@ -249,9 +296,8 @@ func (y *Cloud189PC) login() (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if erron.ResCode != "" {
|
if erron.HasError() {
|
||||||
err = fmt.Errorf(erron.ResMessage)
|
return &erron
|
||||||
return
|
|
||||||
}
|
}
|
||||||
if tokenInfo.ResCode != 0 {
|
if tokenInfo.ResCode != 0 {
|
||||||
err = fmt.Errorf(tokenInfo.ResMessage)
|
err = fmt.Errorf(tokenInfo.ResMessage)
|
||||||
@ -304,6 +350,21 @@ func (y *Cloud189PC) initLoginParam() error {
|
|||||||
param.RsaPassword = encryptConf.Data.Pre + RsaEncrypt(param.jRsaKey, y.Password)
|
param.RsaPassword = encryptConf.Data.Pre + RsaEncrypt(param.jRsaKey, y.Password)
|
||||||
y.loginParam = ¶m
|
y.loginParam = ¶m
|
||||||
|
|
||||||
|
// 判断是否需要验证码
|
||||||
|
resp, err := y.client.R().
|
||||||
|
SetFormData(map[string]string{
|
||||||
|
"appKey": APP_ID,
|
||||||
|
"accountType": ACCOUNT_TYPE,
|
||||||
|
"userName": param.RsaUsername,
|
||||||
|
}).Post(AUTH_URL + "/api/logbox/oauth2/needcaptcha.do")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if resp.String() == "0" {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// 拉取验证码
|
||||||
imgRes, err := y.client.R().
|
imgRes, err := y.client.R().
|
||||||
SetQueryParams(map[string]string{
|
SetQueryParams(map[string]string{
|
||||||
"token": param.CaptchaToken,
|
"token": param.CaptchaToken,
|
||||||
@ -359,33 +420,23 @@ func (y *Cloud189PC) refreshSession() (err error) {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
switch erron.ResCode {
|
if erron.HasError() {
|
||||||
case "":
|
if erron.ResCode == "UserInvalidOpenToken" {
|
||||||
break
|
if err = y.login(); err != nil {
|
||||||
case "UserInvalidOpenToken":
|
return err
|
||||||
if err = y.login(); err != nil {
|
}
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
default:
|
return &erron
|
||||||
err = fmt.Errorf("res_code: %s ,res_msg: %s", erron.ResCode, erron.ResMessage)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
switch userSessionResp.ResCode {
|
|
||||||
case 0:
|
|
||||||
y.tokenInfo.UserSessionResp = userSessionResp
|
|
||||||
default:
|
|
||||||
err = fmt.Errorf("code: %d , msg: %s", userSessionResp.ResCode, userSessionResp.ResMessage)
|
|
||||||
}
|
}
|
||||||
|
y.tokenInfo.UserSessionResp = userSessionResp
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 普通上传
|
// 普通上传
|
||||||
func (y *Cloud189PC) CommonUpload(ctx context.Context, dstDir model.Obj, file model.FileStreamer, up driver.UpdateProgress) (err error) {
|
func (y *Cloud189PC) CommonUpload(ctx context.Context, dstDir model.Obj, file model.FileStreamer, up driver.UpdateProgress) (err error) {
|
||||||
const DEFAULT int64 = 10485760
|
var DEFAULT = partSize(file.GetSize())
|
||||||
var count = int64(math.Ceil(float64(file.GetSize()) / float64(DEFAULT)))
|
var count = int(math.Ceil(float64(file.GetSize()) / float64(DEFAULT)))
|
||||||
|
|
||||||
requestID := uuid.NewString()
|
|
||||||
params := Params{
|
params := Params{
|
||||||
"parentFolderId": dstDir.GetID(),
|
"parentFolderId": dstDir.GetID(),
|
||||||
"fileName": url.QueryEscape(file.GetName()),
|
"fileName": url.QueryEscape(file.GetName()),
|
||||||
@ -407,7 +458,6 @@ func (y *Cloud189PC) CommonUpload(ctx context.Context, dstDir model.Obj, file mo
|
|||||||
var initMultiUpload InitMultiUploadResp
|
var initMultiUpload InitMultiUploadResp
|
||||||
_, err = y.request(fullUrl+"/initMultiUpload", http.MethodGet, func(req *resty.Request) {
|
_, err = y.request(fullUrl+"/initMultiUpload", http.MethodGet, func(req *resty.Request) {
|
||||||
req.SetContext(ctx)
|
req.SetContext(ctx)
|
||||||
req.SetHeader("X-Request-ID", requestID)
|
|
||||||
}, params, &initMultiUpload)
|
}, params, &initMultiUpload)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -417,7 +467,7 @@ func (y *Cloud189PC) CommonUpload(ctx context.Context, dstDir model.Obj, file mo
|
|||||||
silceMd5 := md5.New()
|
silceMd5 := md5.New()
|
||||||
silceMd5Hexs := make([]string, 0, count)
|
silceMd5Hexs := make([]string, 0, count)
|
||||||
byteData := bytes.NewBuffer(make([]byte, DEFAULT))
|
byteData := bytes.NewBuffer(make([]byte, DEFAULT))
|
||||||
for i := int64(1); i <= count; i++ {
|
for i := 1; i <= count; i++ {
|
||||||
if utils.IsCanceled(ctx) {
|
if utils.IsCanceled(ctx) {
|
||||||
return ctx.Err()
|
return ctx.Err()
|
||||||
}
|
}
|
||||||
@ -440,7 +490,6 @@ func (y *Cloud189PC) CommonUpload(ctx context.Context, dstDir model.Obj, file mo
|
|||||||
_, err = y.request(fullUrl+"/getMultiUploadUrls", http.MethodGet,
|
_, err = y.request(fullUrl+"/getMultiUploadUrls", http.MethodGet,
|
||||||
func(req *resty.Request) {
|
func(req *resty.Request) {
|
||||||
req.SetContext(ctx)
|
req.SetContext(ctx)
|
||||||
req.SetHeader("X-Request-ID", requestID)
|
|
||||||
}, Params{
|
}, Params{
|
||||||
"partInfo": fmt.Sprintf("%d-%s", i, silceMd5Base64),
|
"partInfo": fmt.Sprintf("%d-%s", i, silceMd5Base64),
|
||||||
"uploadFileId": initMultiUpload.Data.UploadFileID,
|
"uploadFileId": initMultiUpload.Data.UploadFileID,
|
||||||
@ -451,18 +500,18 @@ func (y *Cloud189PC) CommonUpload(ctx context.Context, dstDir model.Obj, file mo
|
|||||||
|
|
||||||
// 开始上传
|
// 开始上传
|
||||||
uploadData := uploadUrl.UploadUrls[fmt.Sprint("partNumber_", i)]
|
uploadData := uploadUrl.UploadUrls[fmt.Sprint("partNumber_", i)]
|
||||||
res, err := y.putClient.R().
|
|
||||||
SetContext(ctx).
|
err = retry.Do(func() error {
|
||||||
SetQueryParams(clientSuffix()).
|
_, err := y.put(ctx, uploadData.RequestURL, ParseHttpHeader(uploadData.RequestHeader), false, bytes.NewReader(byteData.Bytes()))
|
||||||
SetHeaders(ParseHttpHeader(uploadData.RequestHeader)).
|
return err
|
||||||
SetBody(byteData).
|
},
|
||||||
Put(uploadData.RequestURL)
|
retry.Context(ctx),
|
||||||
|
retry.Attempts(3),
|
||||||
|
retry.Delay(time.Second),
|
||||||
|
retry.MaxDelay(5*time.Second))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if res.StatusCode() != http.StatusOK {
|
|
||||||
return fmt.Errorf("updload fail,msg: %s", res.String())
|
|
||||||
}
|
|
||||||
up(int(i * 100 / count))
|
up(int(i * 100 / count))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -476,7 +525,6 @@ func (y *Cloud189PC) CommonUpload(ctx context.Context, dstDir model.Obj, file mo
|
|||||||
_, err = y.request(fullUrl+"/commitMultiUploadFile", http.MethodGet,
|
_, err = y.request(fullUrl+"/commitMultiUploadFile", http.MethodGet,
|
||||||
func(req *resty.Request) {
|
func(req *resty.Request) {
|
||||||
req.SetContext(ctx)
|
req.SetContext(ctx)
|
||||||
req.SetHeader("X-Request-ID", requestID)
|
|
||||||
}, Params{
|
}, Params{
|
||||||
"uploadFileId": initMultiUpload.Data.UploadFileID,
|
"uploadFileId": initMultiUpload.Data.UploadFileID,
|
||||||
"fileMd5": fileMd5Hex,
|
"fileMd5": fileMd5Hex,
|
||||||
@ -500,7 +548,7 @@ func (y *Cloud189PC) FastUpload(ctx context.Context, dstDir model.Obj, file mode
|
|||||||
_ = os.Remove(tempFile.Name())
|
_ = os.Remove(tempFile.Name())
|
||||||
}()
|
}()
|
||||||
|
|
||||||
const DEFAULT int64 = 10485760
|
var DEFAULT = partSize(file.GetSize())
|
||||||
count := int(math.Ceil(float64(file.GetSize()) / float64(DEFAULT)))
|
count := int(math.Ceil(float64(file.GetSize()) / float64(DEFAULT)))
|
||||||
|
|
||||||
// 优先计算所需信息
|
// 优先计算所需信息
|
||||||
@ -531,7 +579,6 @@ func (y *Cloud189PC) FastUpload(ctx context.Context, dstDir model.Obj, file mode
|
|||||||
sliceMd5Hex = strings.ToUpper(utils.GetMD5Encode(strings.Join(silceMd5Hexs, "\n")))
|
sliceMd5Hex = strings.ToUpper(utils.GetMD5Encode(strings.Join(silceMd5Hexs, "\n")))
|
||||||
}
|
}
|
||||||
|
|
||||||
requestID := uuid.NewString()
|
|
||||||
// 检测是否支持快传
|
// 检测是否支持快传
|
||||||
params := Params{
|
params := Params{
|
||||||
"parentFolderId": dstDir.GetID(),
|
"parentFolderId": dstDir.GetID(),
|
||||||
@ -554,7 +601,6 @@ func (y *Cloud189PC) FastUpload(ctx context.Context, dstDir model.Obj, file mode
|
|||||||
var uploadInfo InitMultiUploadResp
|
var uploadInfo InitMultiUploadResp
|
||||||
_, err = y.request(fullUrl+"/initMultiUpload", http.MethodGet, func(req *resty.Request) {
|
_, err = y.request(fullUrl+"/initMultiUpload", http.MethodGet, func(req *resty.Request) {
|
||||||
req.SetContext(ctx)
|
req.SetContext(ctx)
|
||||||
req.SetHeader("X-Request-ID", requestID)
|
|
||||||
}, params, &uploadInfo)
|
}, params, &uploadInfo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -566,7 +612,6 @@ func (y *Cloud189PC) FastUpload(ctx context.Context, dstDir model.Obj, file mode
|
|||||||
_, err = y.request(fullUrl+"/getMultiUploadUrls", http.MethodGet,
|
_, err = y.request(fullUrl+"/getMultiUploadUrls", http.MethodGet,
|
||||||
func(req *resty.Request) {
|
func(req *resty.Request) {
|
||||||
req.SetContext(ctx)
|
req.SetContext(ctx)
|
||||||
req.SetHeader("X-Request-ID", requestID)
|
|
||||||
}, Params{
|
}, Params{
|
||||||
"uploadFileId": uploadInfo.Data.UploadFileID,
|
"uploadFileId": uploadInfo.Data.UploadFileID,
|
||||||
"partInfo": strings.Join(silceMd5Base64s, ","),
|
"partInfo": strings.Join(silceMd5Base64s, ","),
|
||||||
@ -575,26 +620,29 @@ func (y *Cloud189PC) FastUpload(ctx context.Context, dstDir model.Obj, file mode
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buf := make([]byte, DEFAULT)
|
||||||
for i := 1; i <= count; i++ {
|
for i := 1; i <= count; i++ {
|
||||||
select {
|
if utils.IsCanceled(ctx) {
|
||||||
case <-ctx.Done():
|
|
||||||
return ctx.Err()
|
return ctx.Err()
|
||||||
default:
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
n, err := io.ReadFull(tempFile, buf)
|
||||||
|
if err != nil && err != io.EOF && err != io.ErrUnexpectedEOF {
|
||||||
|
return err
|
||||||
|
}
|
||||||
uploadData := uploadUrls.UploadUrls[fmt.Sprint("partNumber_", i)]
|
uploadData := uploadUrls.UploadUrls[fmt.Sprint("partNumber_", i)]
|
||||||
res, err := y.putClient.R().
|
err = retry.Do(func() error {
|
||||||
SetContext(ctx).
|
_, err := y.put(ctx, uploadData.RequestURL, ParseHttpHeader(uploadData.RequestHeader), false, bytes.NewReader(buf[:n]))
|
||||||
SetQueryParams(clientSuffix()).
|
return err
|
||||||
SetHeaders(ParseHttpHeader(uploadData.RequestHeader)).
|
},
|
||||||
SetBody(io.LimitReader(tempFile, DEFAULT)).
|
retry.Context(ctx),
|
||||||
Put(uploadData.RequestURL)
|
retry.Attempts(3),
|
||||||
|
retry.Delay(time.Second),
|
||||||
|
retry.MaxDelay(5*time.Second))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if res.StatusCode() != http.StatusOK {
|
|
||||||
return fmt.Errorf("updload fail,msg: %s", res.String())
|
|
||||||
}
|
|
||||||
up(int(i * 100 / count))
|
up(int(i * 100 / count))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -603,7 +651,6 @@ func (y *Cloud189PC) FastUpload(ctx context.Context, dstDir model.Obj, file mode
|
|||||||
_, err = y.request(fullUrl+"/commitMultiUploadFile", http.MethodGet,
|
_, err = y.request(fullUrl+"/commitMultiUploadFile", http.MethodGet,
|
||||||
func(req *resty.Request) {
|
func(req *resty.Request) {
|
||||||
req.SetContext(ctx)
|
req.SetContext(ctx)
|
||||||
req.SetHeader("X-Request-ID", requestID)
|
|
||||||
}, Params{
|
}, Params{
|
||||||
"uploadFileId": uploadInfo.Data.UploadFileID,
|
"uploadFileId": uploadInfo.Data.UploadFileID,
|
||||||
"isLog": "0",
|
"isLog": "0",
|
||||||
@ -612,6 +659,137 @@ func (y *Cloud189PC) FastUpload(ctx context.Context, dstDir model.Obj, file mode
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (y *Cloud189PC) OldUpload(ctx context.Context, dstDir model.Obj, file model.FileStreamer, up driver.UpdateProgress) (err error) {
|
||||||
|
// 需要获取完整文件md5,必须支持 io.Seek
|
||||||
|
tempFile, err := utils.CreateTempFile(file.GetReadCloser())
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer func() {
|
||||||
|
_ = tempFile.Close()
|
||||||
|
_ = os.Remove(tempFile.Name())
|
||||||
|
}()
|
||||||
|
|
||||||
|
// 计算md5
|
||||||
|
fileMd5 := md5.New()
|
||||||
|
if _, err := io.Copy(fileMd5, tempFile); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if _, err = tempFile.Seek(0, io.SeekStart); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
fileMd5Hex := strings.ToUpper(hex.EncodeToString(fileMd5.Sum(nil)))
|
||||||
|
|
||||||
|
// 创建上传会话
|
||||||
|
var uploadInfo CreateUploadFileResp
|
||||||
|
|
||||||
|
fullUrl := API_URL + "/createUploadFile.action"
|
||||||
|
if y.isFamily() {
|
||||||
|
fullUrl = API_URL + "/family/file/createFamilyFile.action"
|
||||||
|
}
|
||||||
|
_, err = y.post(fullUrl, func(req *resty.Request) {
|
||||||
|
req.SetContext(ctx)
|
||||||
|
if y.isFamily() {
|
||||||
|
req.SetQueryParams(map[string]string{
|
||||||
|
"familyId": y.FamilyID,
|
||||||
|
"fileMd5": fileMd5Hex,
|
||||||
|
"fileName": file.GetName(),
|
||||||
|
"fileSize": fmt.Sprint(file.GetSize()),
|
||||||
|
"parentId": dstDir.GetID(),
|
||||||
|
"resumePolicy": "1",
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
req.SetFormData(map[string]string{
|
||||||
|
"parentFolderId": dstDir.GetID(),
|
||||||
|
"fileName": file.GetName(),
|
||||||
|
"size": fmt.Sprint(file.GetSize()),
|
||||||
|
"md5": fileMd5Hex,
|
||||||
|
"opertype": "3",
|
||||||
|
"flag": "1",
|
||||||
|
"resumePolicy": "1",
|
||||||
|
"isLog": "0",
|
||||||
|
// "baseFileId": "",
|
||||||
|
// "lastWrite":"",
|
||||||
|
// "localPath": strings.ReplaceAll(param.LocalPath, "\\", "/"),
|
||||||
|
// "fileExt": "",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}, &uploadInfo)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// 网盘中不存在该文件,开始上传
|
||||||
|
status := GetUploadFileStatusResp{CreateUploadFileResp: uploadInfo}
|
||||||
|
for status.Size < file.GetSize() && status.FileDataExists != 1 {
|
||||||
|
if utils.IsCanceled(ctx) {
|
||||||
|
return ctx.Err()
|
||||||
|
}
|
||||||
|
|
||||||
|
header := map[string]string{
|
||||||
|
"ResumePolicy": "1",
|
||||||
|
"Expect": "100-continue",
|
||||||
|
}
|
||||||
|
|
||||||
|
if y.isFamily() {
|
||||||
|
header["FamilyId"] = fmt.Sprint(y.FamilyID)
|
||||||
|
header["UploadFileId"] = fmt.Sprint(status.UploadFileId)
|
||||||
|
} else {
|
||||||
|
header["Edrive-UploadFileId"] = fmt.Sprint(status.UploadFileId)
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err := y.put(ctx, status.FileUploadUrl, header, true, io.NopCloser(tempFile))
|
||||||
|
if err, ok := err.(*RespErr); ok && err.Code != "InputStreamReadError" {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取断点状态
|
||||||
|
fullUrl := API_URL + "/getUploadFileStatus.action"
|
||||||
|
if y.isFamily() {
|
||||||
|
fullUrl = API_URL + "/family/file/getFamilyFileStatus.action"
|
||||||
|
}
|
||||||
|
_, err = y.get(fullUrl, func(req *resty.Request) {
|
||||||
|
req.SetContext(ctx).SetQueryParams(map[string]string{
|
||||||
|
"uploadFileId": fmt.Sprint(status.UploadFileId),
|
||||||
|
"resumePolicy": "1",
|
||||||
|
})
|
||||||
|
if y.isFamily() {
|
||||||
|
req.SetQueryParam("familyId", fmt.Sprint(y.FamilyID))
|
||||||
|
}
|
||||||
|
}, &status)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err := tempFile.Seek(status.GetSize(), io.SeekStart); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
up(int(status.Size / file.GetSize()))
|
||||||
|
}
|
||||||
|
|
||||||
|
// 提交
|
||||||
|
var resp CommitUploadFileResp
|
||||||
|
_, err = y.post(status.FileCommitUrl, func(req *resty.Request) {
|
||||||
|
req.SetContext(ctx)
|
||||||
|
if y.isFamily() {
|
||||||
|
req.SetHeaders(map[string]string{
|
||||||
|
"ResumePolicy": "1",
|
||||||
|
"UploadFileId": fmt.Sprint(status.UploadFileId),
|
||||||
|
"FamilyId": fmt.Sprint(y.FamilyID),
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
req.SetFormData(map[string]string{
|
||||||
|
"opertype": "3",
|
||||||
|
"resumePolicy": "1",
|
||||||
|
"uploadFileId": fmt.Sprint(status.UploadFileId),
|
||||||
|
"isLog": "0",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}, &resp)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
func (y *Cloud189PC) isFamily() bool {
|
func (y *Cloud189PC) isFamily() bool {
|
||||||
return y.Type == "family"
|
return y.Type == "family"
|
||||||
}
|
}
|
||||||
|
@ -72,11 +72,21 @@ func (d *Alias) list(ctx context.Context, dst, sub string) ([]model.Obj, error)
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return utils.SliceConvert(objs, func(obj model.Obj) (model.Obj, error) {
|
return utils.SliceConvert(objs, func(obj model.Obj) (model.Obj, error) {
|
||||||
return &model.Object{
|
thumb, ok := model.GetThumb(obj)
|
||||||
|
objRes := model.Object{
|
||||||
Name: obj.GetName(),
|
Name: obj.GetName(),
|
||||||
Size: obj.GetSize(),
|
Size: obj.GetSize(),
|
||||||
Modified: obj.ModTime(),
|
Modified: obj.ModTime(),
|
||||||
IsFolder: obj.IsDir(),
|
IsFolder: obj.IsDir(),
|
||||||
|
}
|
||||||
|
if !ok {
|
||||||
|
return &objRes, nil
|
||||||
|
}
|
||||||
|
return &model.ObjThumb{
|
||||||
|
Object: objRes,
|
||||||
|
Thumbnail: model.Thumbnail{
|
||||||
|
Thumbnail: thumb,
|
||||||
|
},
|
||||||
}, nil
|
}, nil
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -93,7 +103,8 @@ func (d *Alias) link(ctx context.Context, dst, sub string, args model.LinkArgs)
|
|||||||
}
|
}
|
||||||
if common.ShouldProxy(storage, stdpath.Base(sub)) {
|
if common.ShouldProxy(storage, stdpath.Base(sub)) {
|
||||||
return &model.Link{
|
return &model.Link{
|
||||||
URL: fmt.Sprintf("/p%s?sign=%s",
|
URL: fmt.Sprintf("%s/p%s?sign=%s",
|
||||||
|
common.GetApiUrl(args.HttpReq),
|
||||||
utils.EncodePath(reqPath, true),
|
utils.EncodePath(reqPath, true),
|
||||||
sign.Sign(reqPath)),
|
sign.Sign(reqPath)),
|
||||||
}, nil
|
}, nil
|
||||||
|
@ -2,13 +2,17 @@ package alist_v3
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"path"
|
"path"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/alist-org/alist/v3/drivers/base"
|
||||||
|
"github.com/alist-org/alist/v3/internal/conf"
|
||||||
"github.com/alist-org/alist/v3/internal/driver"
|
"github.com/alist-org/alist/v3/internal/driver"
|
||||||
"github.com/alist-org/alist/v3/internal/model"
|
"github.com/alist-org/alist/v3/internal/model"
|
||||||
|
"github.com/alist-org/alist/v3/pkg/utils"
|
||||||
"github.com/alist-org/alist/v3/server/common"
|
"github.com/alist-org/alist/v3/server/common"
|
||||||
"github.com/go-resty/resty/v2"
|
"github.com/go-resty/resty/v2"
|
||||||
)
|
)
|
||||||
@ -32,8 +36,33 @@ func (d *AListV3) Init(ctx context.Context) error {
|
|||||||
_, err := d.request("/me", http.MethodGet, func(req *resty.Request) {
|
_, err := d.request("/me", http.MethodGet, func(req *resty.Request) {
|
||||||
req.SetResult(&resp)
|
req.SetResult(&resp)
|
||||||
})
|
})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// if the username is not empty and the username is not the same as the current username, then login again
|
||||||
if d.Username != "" && d.Username != resp.Data.Username {
|
if d.Username != "" && d.Username != resp.Data.Username {
|
||||||
return d.login()
|
err = d.login()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// re-get the user info
|
||||||
|
_, err = d.request("/me", http.MethodGet, func(req *resty.Request) {
|
||||||
|
req.SetResult(&resp)
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if resp.Data.Role == model.GUEST {
|
||||||
|
url := d.Address + "/api/public/settings"
|
||||||
|
res, err := base.RestyClient.R().Get(url)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
allowMounted := utils.Json.Get(res.Body(), "data", conf.AllowMounted).ToString() == "true"
|
||||||
|
if !allowMounted {
|
||||||
|
return fmt.Errorf("the site does not allow mounted")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -146,6 +175,7 @@ func (d *AListV3) Put(ctx context.Context, dstDir model.Obj, stream model.FileSt
|
|||||||
req.SetHeader("File-Path", path.Join(dstDir.GetPath(), stream.GetName())).
|
req.SetHeader("File-Path", path.Join(dstDir.GetPath(), stream.GetName())).
|
||||||
SetHeader("Password", d.MetaPassword).
|
SetHeader("Password", d.MetaPassword).
|
||||||
SetHeader("Content-Length", strconv.FormatInt(stream.GetSize(), 10)).
|
SetHeader("Content-Length", strconv.FormatInt(stream.GetSize(), 10)).
|
||||||
|
SetContentLength(true).
|
||||||
SetBody(stream.GetReadCloser())
|
SetBody(stream.GetReadCloser())
|
||||||
})
|
})
|
||||||
return err
|
return err
|
||||||
|
@ -18,6 +18,7 @@ var config = driver.Config{
|
|||||||
Name: "AList V3",
|
Name: "AList V3",
|
||||||
LocalSort: true,
|
LocalSort: true,
|
||||||
DefaultRoot: "/",
|
DefaultRoot: "/",
|
||||||
|
CheckStatus: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -9,6 +9,7 @@ import (
|
|||||||
"github.com/alist-org/alist/v3/pkg/utils"
|
"github.com/alist-org/alist/v3/pkg/utils"
|
||||||
"github.com/alist-org/alist/v3/server/common"
|
"github.com/alist-org/alist/v3/server/common"
|
||||||
"github.com/go-resty/resty/v2"
|
"github.com/go-resty/resty/v2"
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (d *AListV3) login() error {
|
func (d *AListV3) login() error {
|
||||||
@ -38,6 +39,7 @@ func (d *AListV3) request(api, method string, callback base.ReqCallback, retry .
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
log.Debugf("[alist_v3] response body: %s", res.String())
|
||||||
if res.StatusCode() >= 400 {
|
if res.StatusCode() >= 400 {
|
||||||
return nil, fmt.Errorf("request failed, status: %s", res.Status())
|
return nil, fmt.Errorf("request failed, status: %s", res.Status())
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,9 @@ type AliyundriveOpen struct {
|
|||||||
base string
|
base string
|
||||||
|
|
||||||
DriveId string
|
DriveId string
|
||||||
|
|
||||||
|
limitList func(ctx context.Context, dir model.Obj) ([]model.Obj, error)
|
||||||
|
limitLink func(ctx context.Context, file model.Obj) (*model.Link, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *AliyundriveOpen) Config() driver.Config {
|
func (d *AliyundriveOpen) Config() driver.Config {
|
||||||
@ -37,6 +40,8 @@ func (d *AliyundriveOpen) Init(ctx context.Context) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
d.DriveId = utils.Json.Get(res, "default_drive_id").ToString()
|
d.DriveId = utils.Json.Get(res, "default_drive_id").ToString()
|
||||||
|
d.limitList = utils.LimitRateCtx(d.list, time.Second/4)
|
||||||
|
d.limitLink = utils.LimitRateCtx(d.link, time.Second)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,7 +49,7 @@ func (d *AliyundriveOpen) Drop(ctx context.Context) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *AliyundriveOpen) List(ctx context.Context, dir model.Obj, args model.ListArgs) ([]model.Obj, error) {
|
func (d *AliyundriveOpen) list(ctx context.Context, dir model.Obj) ([]model.Obj, error) {
|
||||||
files, err := d.getFiles(dir.GetID())
|
files, err := d.getFiles(dir.GetID())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -54,7 +59,11 @@ func (d *AliyundriveOpen) List(ctx context.Context, dir model.Obj, args model.Li
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *AliyundriveOpen) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (*model.Link, error) {
|
func (d *AliyundriveOpen) List(ctx context.Context, dir model.Obj, args model.ListArgs) ([]model.Obj, error) {
|
||||||
|
return d.limitList(ctx, dir)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *AliyundriveOpen) link(ctx context.Context, file model.Obj) (*model.Link, error) {
|
||||||
res, err := d.request("/adrive/v1.0/openFile/getDownloadUrl", http.MethodPost, func(req *resty.Request) {
|
res, err := d.request("/adrive/v1.0/openFile/getDownloadUrl", http.MethodPost, func(req *resty.Request) {
|
||||||
req.SetBody(base.Json{
|
req.SetBody(base.Json{
|
||||||
"drive_id": d.DriveId,
|
"drive_id": d.DriveId,
|
||||||
@ -66,11 +75,17 @@ func (d *AliyundriveOpen) Link(ctx context.Context, file model.Obj, args model.L
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
url := utils.Json.Get(res, "url").ToString()
|
url := utils.Json.Get(res, "url").ToString()
|
||||||
|
exp := time.Hour
|
||||||
return &model.Link{
|
return &model.Link{
|
||||||
URL: url,
|
URL: url,
|
||||||
|
Expiration: &exp,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *AliyundriveOpen) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (*model.Link, error) {
|
||||||
|
return d.limitLink(ctx, file)
|
||||||
|
}
|
||||||
|
|
||||||
func (d *AliyundriveOpen) MakeDir(ctx context.Context, parentDir model.Obj, dirName string) error {
|
func (d *AliyundriveOpen) MakeDir(ctx context.Context, parentDir model.Obj, dirName string) error {
|
||||||
_, err := d.request("/adrive/v1.0/openFile/create", http.MethodPost, func(req *resty.Request) {
|
_, err := d.request("/adrive/v1.0/openFile/create", http.MethodPost, func(req *resty.Request) {
|
||||||
req.SetBody(base.Json{
|
req.SetBody(base.Json{
|
||||||
|
@ -33,7 +33,7 @@ var config = driver.Config{
|
|||||||
func init() {
|
func init() {
|
||||||
op.RegisterDriver(func() driver.Driver {
|
op.RegisterDriver(func() driver.Driver {
|
||||||
return &AliyundriveOpen{
|
return &AliyundriveOpen{
|
||||||
base: "https://open.aliyundrive.com",
|
base: "https://openapi.aliyundrive.com",
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ func (d *AliyundriveOpen) request(uri, method string, callback base.ReqCallback,
|
|||||||
}
|
}
|
||||||
isRetry := len(retry) > 0 && retry[0]
|
isRetry := len(retry) > 0 && retry[0]
|
||||||
if e.Code != "" {
|
if e.Code != "" {
|
||||||
if !isRetry && e.Code == "AccessTokenInvalid" {
|
if !isRetry && (utils.SliceContains([]string{"AccessTokenInvalid", "AccessTokenExpired", "I400JD"}, e.Code) || d.AccessToken == "") {
|
||||||
err = d.refreshToken()
|
err = d.refreshToken()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -19,6 +19,7 @@ import (
|
|||||||
_ "github.com/alist-org/alist/v3/drivers/ftp"
|
_ "github.com/alist-org/alist/v3/drivers/ftp"
|
||||||
_ "github.com/alist-org/alist/v3/drivers/google_drive"
|
_ "github.com/alist-org/alist/v3/drivers/google_drive"
|
||||||
_ "github.com/alist-org/alist/v3/drivers/google_photo"
|
_ "github.com/alist-org/alist/v3/drivers/google_photo"
|
||||||
|
_ "github.com/alist-org/alist/v3/drivers/ipfs_api"
|
||||||
_ "github.com/alist-org/alist/v3/drivers/lanzou"
|
_ "github.com/alist-org/alist/v3/drivers/lanzou"
|
||||||
_ "github.com/alist-org/alist/v3/drivers/local"
|
_ "github.com/alist-org/alist/v3/drivers/local"
|
||||||
_ "github.com/alist-org/alist/v3/drivers/mediatrack"
|
_ "github.com/alist-org/alist/v3/drivers/mediatrack"
|
||||||
@ -27,7 +28,7 @@ import (
|
|||||||
_ "github.com/alist-org/alist/v3/drivers/onedrive_app"
|
_ "github.com/alist-org/alist/v3/drivers/onedrive_app"
|
||||||
_ "github.com/alist-org/alist/v3/drivers/pikpak"
|
_ "github.com/alist-org/alist/v3/drivers/pikpak"
|
||||||
_ "github.com/alist-org/alist/v3/drivers/pikpak_share"
|
_ "github.com/alist-org/alist/v3/drivers/pikpak_share"
|
||||||
_ "github.com/alist-org/alist/v3/drivers/quark"
|
_ "github.com/alist-org/alist/v3/drivers/quark_uc"
|
||||||
_ "github.com/alist-org/alist/v3/drivers/s3"
|
_ "github.com/alist-org/alist/v3/drivers/s3"
|
||||||
_ "github.com/alist-org/alist/v3/drivers/seafile"
|
_ "github.com/alist-org/alist/v3/drivers/seafile"
|
||||||
_ "github.com/alist-org/alist/v3/drivers/sftp"
|
_ "github.com/alist-org/alist/v3/drivers/sftp"
|
||||||
|
@ -4,7 +4,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"regexp"
|
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -16,11 +15,6 @@ func getTid() string {
|
|||||||
return fmt.Sprintf("3%d%.0f", time.Now().Unix(), math.Floor(9000000*rand.Float64()+1000000))
|
return fmt.Sprintf("3%d%.0f", time.Now().Unix(), math.Floor(9000000*rand.Float64()+1000000))
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查名称
|
|
||||||
func checkName(name string) bool {
|
|
||||||
return len(name) <= 20 && regexp.MustCompile("[\u4e00-\u9fa5A-Za-z0-9_-]").MatchString(name)
|
|
||||||
}
|
|
||||||
|
|
||||||
func toTime(t int64) *time.Time {
|
func toTime(t int64) *time.Time {
|
||||||
tm := time.Unix(t, 0)
|
tm := time.Unix(t, 0)
|
||||||
return &tm
|
return &tm
|
||||||
|
@ -2,7 +2,6 @@ package baiduphoto
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
@ -22,10 +21,6 @@ const (
|
|||||||
FILE_API_URL_V2 = API_URL + "/file/v2"
|
FILE_API_URL_V2 = API_URL + "/file/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
ErrNotSupportName = errors.New("only chinese and english, numbers and underscores are supported, and the length is no more than 20")
|
|
||||||
)
|
|
||||||
|
|
||||||
func (d *BaiduPhoto) Request(furl string, method string, callback base.ReqCallback, resp interface{}) ([]byte, error) {
|
func (d *BaiduPhoto) Request(furl string, method string, callback base.ReqCallback, resp interface{}) ([]byte, error) {
|
||||||
req := base.RestyClient.R().
|
req := base.RestyClient.R().
|
||||||
SetQueryParam("access_token", d.AccessToken)
|
SetQueryParam("access_token", d.AccessToken)
|
||||||
@ -48,6 +43,8 @@ func (d *BaiduPhoto) Request(furl string, method string, callback base.ReqCallba
|
|||||||
return nil, fmt.Errorf("you have joined album")
|
return nil, fmt.Errorf("you have joined album")
|
||||||
case 50820:
|
case 50820:
|
||||||
return nil, fmt.Errorf("no shared albums found")
|
return nil, fmt.Errorf("no shared albums found")
|
||||||
|
case 50100:
|
||||||
|
return nil, fmt.Errorf("illegal title, only supports 50 characters")
|
||||||
case -6:
|
case -6:
|
||||||
if err = d.refreshToken(); err != nil {
|
if err = d.refreshToken(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -188,9 +185,6 @@ func (d *BaiduPhoto) GetAllAlbumFile(ctx context.Context, album *Album, passwd s
|
|||||||
|
|
||||||
// 创建相册
|
// 创建相册
|
||||||
func (d *BaiduPhoto) CreateAlbum(ctx context.Context, name string) (*Album, error) {
|
func (d *BaiduPhoto) CreateAlbum(ctx context.Context, name string) (*Album, error) {
|
||||||
if !checkName(name) {
|
|
||||||
return nil, ErrNotSupportName
|
|
||||||
}
|
|
||||||
var resp JoinOrCreateAlbumResp
|
var resp JoinOrCreateAlbumResp
|
||||||
_, err := d.Post(ALBUM_API_URL+"/create", func(r *resty.Request) {
|
_, err := d.Post(ALBUM_API_URL+"/create", func(r *resty.Request) {
|
||||||
r.SetContext(ctx).SetResult(&resp)
|
r.SetContext(ctx).SetResult(&resp)
|
||||||
@ -208,10 +202,6 @@ func (d *BaiduPhoto) CreateAlbum(ctx context.Context, name string) (*Album, erro
|
|||||||
|
|
||||||
// 相册改名
|
// 相册改名
|
||||||
func (d *BaiduPhoto) SetAlbumName(ctx context.Context, album *Album, name string) (*Album, error) {
|
func (d *BaiduPhoto) SetAlbumName(ctx context.Context, album *Album, name string) (*Album, error) {
|
||||||
if !checkName(name) {
|
|
||||||
return nil, ErrNotSupportName
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err := d.Post(ALBUM_API_URL+"/settitle", func(r *resty.Request) {
|
_, err := d.Post(ALBUM_API_URL+"/settitle", func(r *resty.Request) {
|
||||||
r.SetContext(ctx)
|
r.SetContext(ctx)
|
||||||
r.SetFormData(map[string]string{
|
r.SetFormData(map[string]string{
|
||||||
|
@ -1,31 +1,48 @@
|
|||||||
package base
|
package base
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/tls"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/alist-org/alist/v3/internal/conf"
|
||||||
"github.com/go-resty/resty/v2"
|
"github.com/go-resty/resty/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
var NoRedirectClient *resty.Client
|
var (
|
||||||
var RestyClient = NewRestyClient()
|
NoRedirectClient *resty.Client
|
||||||
var HttpClient = &http.Client{}
|
RestyClient *resty.Client
|
||||||
|
HttpClient *http.Client
|
||||||
|
)
|
||||||
var UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36"
|
var UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36"
|
||||||
var DefaultTimeout = time.Second * 30
|
var DefaultTimeout = time.Second * 30
|
||||||
|
|
||||||
func init() {
|
func InitClient() {
|
||||||
NoRedirectClient = resty.New().SetRedirectPolicy(
|
NoRedirectClient = resty.New().SetRedirectPolicy(
|
||||||
resty.RedirectPolicyFunc(func(req *http.Request, via []*http.Request) error {
|
resty.RedirectPolicyFunc(func(req *http.Request, via []*http.Request) error {
|
||||||
return http.ErrUseLastResponse
|
return http.ErrUseLastResponse
|
||||||
}),
|
}),
|
||||||
)
|
).SetTLSClientConfig(&tls.Config{InsecureSkipVerify: conf.Conf.TlsInsecureSkipVerify})
|
||||||
NoRedirectClient.SetHeader("user-agent", UserAgent)
|
NoRedirectClient.SetHeader("user-agent", UserAgent)
|
||||||
|
|
||||||
|
RestyClient = NewRestyClient()
|
||||||
|
HttpClient = NewHttpClient()
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewRestyClient() *resty.Client {
|
func NewRestyClient() *resty.Client {
|
||||||
client := resty.New().
|
client := resty.New().
|
||||||
SetHeader("user-agent", UserAgent).
|
SetHeader("user-agent", UserAgent).
|
||||||
SetRetryCount(3).
|
SetRetryCount(3).
|
||||||
SetTimeout(DefaultTimeout)
|
SetTimeout(DefaultTimeout).
|
||||||
|
SetTLSClientConfig(&tls.Config{InsecureSkipVerify: conf.Conf.TlsInsecureSkipVerify})
|
||||||
return client
|
return client
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewHttpClient() *http.Client {
|
||||||
|
return &http.Client{
|
||||||
|
Timeout: time.Hour * 48,
|
||||||
|
Transport: &http.Transport{
|
||||||
|
TLSClientConfig: &tls.Config{InsecureSkipVerify: conf.Conf.TlsInsecureSkipVerify},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/alist-org/alist/v3/drivers/base"
|
"github.com/alist-org/alist/v3/drivers/base"
|
||||||
"github.com/alist-org/alist/v3/internal/driver"
|
"github.com/alist-org/alist/v3/internal/driver"
|
||||||
@ -16,7 +17,6 @@ import (
|
|||||||
type Cloudreve struct {
|
type Cloudreve struct {
|
||||||
model.Storage
|
model.Storage
|
||||||
Addition
|
Addition
|
||||||
Cookie string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Cloudreve) Config() driver.Config {
|
func (d *Cloudreve) Config() driver.Config {
|
||||||
@ -28,6 +28,11 @@ func (d *Cloudreve) GetAddition() driver.Additional {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *Cloudreve) Init(ctx context.Context) error {
|
func (d *Cloudreve) Init(ctx context.Context) error {
|
||||||
|
if d.Cookie != "" {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
// removing trailing slash
|
||||||
|
d.Address = strings.TrimSuffix(d.Address, "/")
|
||||||
return d.login()
|
return d.login()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,8 +10,9 @@ type Addition struct {
|
|||||||
driver.RootPath
|
driver.RootPath
|
||||||
// define other
|
// define other
|
||||||
Address string `json:"address" required:"true"`
|
Address string `json:"address" required:"true"`
|
||||||
Username string `json:"username" required:"true"`
|
Username string `json:"username"`
|
||||||
Password string `json:"password" required:"true"`
|
Password string `json:"password"`
|
||||||
|
Cookie string `json:"cookie"`
|
||||||
}
|
}
|
||||||
|
|
||||||
var config = driver.Config{
|
var config = driver.Config{
|
||||||
|
@ -49,11 +49,13 @@ func (d *Cloudreve) request(method string, path string, callback base.ReqCallbac
|
|||||||
|
|
||||||
// 刷新 cookie
|
// 刷新 cookie
|
||||||
if r.Code == http.StatusUnauthorized && path != loginPath {
|
if r.Code == http.StatusUnauthorized && path != loginPath {
|
||||||
err = d.login()
|
if d.Username != "" && d.Password != "" {
|
||||||
if err != nil {
|
err = d.login()
|
||||||
return err
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return d.request(method, path, callback, out)
|
||||||
}
|
}
|
||||||
return d.request(method, path, callback, out)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return errors.New(r.Msg)
|
return errors.New(r.Msg)
|
||||||
|
@ -17,7 +17,9 @@ import (
|
|||||||
type GoogleDrive struct {
|
type GoogleDrive struct {
|
||||||
model.Storage
|
model.Storage
|
||||||
Addition
|
Addition
|
||||||
AccessToken string
|
AccessToken string
|
||||||
|
ServiceAccountFile int
|
||||||
|
ServiceAccountFileList []string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *GoogleDrive) Config() driver.Config {
|
func (d *GoogleDrive) Config() driver.Config {
|
||||||
|
@ -2,21 +2,134 @@ package google_drive
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"crypto/x509"
|
||||||
|
"encoding/pem"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/alist-org/alist/v3/drivers/base"
|
"github.com/alist-org/alist/v3/drivers/base"
|
||||||
"github.com/alist-org/alist/v3/internal/model"
|
"github.com/alist-org/alist/v3/internal/model"
|
||||||
"github.com/alist-org/alist/v3/pkg/utils"
|
"github.com/alist-org/alist/v3/pkg/utils"
|
||||||
"github.com/go-resty/resty/v2"
|
"github.com/go-resty/resty/v2"
|
||||||
|
"github.com/golang-jwt/jwt/v4"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
// do others that not defined in Driver interface
|
// do others that not defined in Driver interface
|
||||||
|
|
||||||
|
type googleDriveServiceAccount struct {
|
||||||
|
//Type string `json:"type"`
|
||||||
|
//ProjectID string `json:"project_id"`
|
||||||
|
//PrivateKeyID string `json:"private_key_id"`
|
||||||
|
PrivateKey string `json:"private_key"`
|
||||||
|
ClientEMail string `json:"client_email"`
|
||||||
|
//ClientID string `json:"client_id"`
|
||||||
|
//AuthURI string `json:"auth_uri"`
|
||||||
|
TokenURI string `json:"token_uri"`
|
||||||
|
//AuthProviderX509CertURL string `json:"auth_provider_x509_cert_url"`
|
||||||
|
//ClientX509CertURL string `json:"client_x509_cert_url"`
|
||||||
|
}
|
||||||
|
|
||||||
func (d *GoogleDrive) refreshToken() error {
|
func (d *GoogleDrive) refreshToken() error {
|
||||||
|
// googleDriveServiceAccountFile gdsaFile
|
||||||
|
gdsaFile, gdsaFileErr := os.Stat(d.RefreshToken)
|
||||||
|
if gdsaFileErr == nil {
|
||||||
|
gdsaFileThis := d.RefreshToken
|
||||||
|
if gdsaFile.IsDir() {
|
||||||
|
if len(d.ServiceAccountFileList) <= 0 {
|
||||||
|
gdsaReadDir, gdsaDirErr := ioutil.ReadDir(d.RefreshToken)
|
||||||
|
if gdsaDirErr != nil {
|
||||||
|
log.Error("read dir fail")
|
||||||
|
return gdsaDirErr
|
||||||
|
}
|
||||||
|
var gdsaFileList []string
|
||||||
|
for _, fi := range gdsaReadDir {
|
||||||
|
if !fi.IsDir() {
|
||||||
|
match, _ := regexp.MatchString("^.*\\.json$", fi.Name())
|
||||||
|
if !match {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
gdsaDirText := d.RefreshToken
|
||||||
|
if d.RefreshToken[len(d.RefreshToken)-1:] != "/" {
|
||||||
|
gdsaDirText = d.RefreshToken + "/"
|
||||||
|
}
|
||||||
|
gdsaFileList = append(gdsaFileList, gdsaDirText+fi.Name())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
d.ServiceAccountFileList = gdsaFileList
|
||||||
|
gdsaFileThis = d.ServiceAccountFileList[d.ServiceAccountFile]
|
||||||
|
d.ServiceAccountFile++
|
||||||
|
} else {
|
||||||
|
if d.ServiceAccountFile < len(d.ServiceAccountFileList) {
|
||||||
|
d.ServiceAccountFile++
|
||||||
|
} else {
|
||||||
|
d.ServiceAccountFile = 0
|
||||||
|
}
|
||||||
|
gdsaFileThis = d.ServiceAccountFileList[d.ServiceAccountFile]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gdsaFileThisContent, err := ioutil.ReadFile(gdsaFileThis)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now let's unmarshal the data into `payload`
|
||||||
|
var jsonData googleDriveServiceAccount
|
||||||
|
err = utils.Json.Unmarshal(gdsaFileThisContent, &jsonData)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
gdsaScope := "https://www.googleapis.com/auth/drive https://www.googleapis.com/auth/drive.appdata https://www.googleapis.com/auth/drive.file https://www.googleapis.com/auth/drive.metadata https://www.googleapis.com/auth/drive.metadata.readonly https://www.googleapis.com/auth/drive.readonly https://www.googleapis.com/auth/drive.scripts"
|
||||||
|
|
||||||
|
timeNow := time.Now()
|
||||||
|
var timeStart int64 = timeNow.Unix()
|
||||||
|
var timeEnd int64 = timeNow.Add(time.Minute * 60).Unix()
|
||||||
|
|
||||||
|
// load private key from string
|
||||||
|
privateKeyPem, _ := pem.Decode([]byte(jsonData.PrivateKey))
|
||||||
|
privateKey, _ := x509.ParsePKCS8PrivateKey(privateKeyPem.Bytes)
|
||||||
|
|
||||||
|
jwtToken := jwt.NewWithClaims(jwt.SigningMethodRS256,
|
||||||
|
jwt.MapClaims{
|
||||||
|
"iss": jsonData.ClientEMail,
|
||||||
|
"scope": gdsaScope,
|
||||||
|
"aud": jsonData.TokenURI,
|
||||||
|
"exp": timeEnd,
|
||||||
|
"iat": timeStart,
|
||||||
|
})
|
||||||
|
assertion, err := jwtToken.SignedString(privateKey)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
var resp base.TokenResp
|
||||||
|
var e TokenError
|
||||||
|
res, err := base.RestyClient.R().SetResult(&resp).SetError(&e).
|
||||||
|
SetFormData(map[string]string{
|
||||||
|
"assertion": assertion,
|
||||||
|
"grant_type": "urn:ietf:params:oauth:grant-type:jwt-bearer",
|
||||||
|
}).Post(jsonData.TokenURI)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
log.Debug(res.String())
|
||||||
|
if e.Error != "" {
|
||||||
|
return fmt.Errorf(e.Error)
|
||||||
|
}
|
||||||
|
d.AccessToken = resp.AccessToken
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if gdsaFileErr != nil && os.IsExist(gdsaFileErr) {
|
||||||
|
return gdsaFileErr
|
||||||
|
}
|
||||||
url := "https://www.googleapis.com/oauth2/v4/token"
|
url := "https://www.googleapis.com/oauth2/v4/token"
|
||||||
var resp base.TokenResp
|
var resp base.TokenResp
|
||||||
var e TokenError
|
var e TokenError
|
||||||
|
128
drivers/ipfs_api/driver.go
Normal file
128
drivers/ipfs_api/driver.go
Normal file
@ -0,0 +1,128 @@
|
|||||||
|
package ipfs
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"net/url"
|
||||||
|
stdpath "path"
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/alist-org/alist/v3/internal/driver"
|
||||||
|
"github.com/alist-org/alist/v3/internal/model"
|
||||||
|
shell "github.com/ipfs/go-ipfs-api"
|
||||||
|
)
|
||||||
|
|
||||||
|
type IPFS struct {
|
||||||
|
model.Storage
|
||||||
|
Addition
|
||||||
|
sh *shell.Shell
|
||||||
|
gateURL *url.URL
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *IPFS) Config() driver.Config {
|
||||||
|
return config
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *IPFS) GetAddition() driver.Additional {
|
||||||
|
return &d.Addition
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *IPFS) Init(ctx context.Context) error {
|
||||||
|
d.sh = shell.NewShell(d.Endpoint)
|
||||||
|
gateURL, err := url.Parse(d.Gateway)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
d.gateURL = gateURL
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *IPFS) Drop(ctx context.Context) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *IPFS) List(ctx context.Context, dir model.Obj, args model.ListArgs) ([]model.Obj, error) {
|
||||||
|
path := dir.GetPath()
|
||||||
|
if path[len(path):] != "/" {
|
||||||
|
path += "/"
|
||||||
|
}
|
||||||
|
|
||||||
|
path_cid, err := d.sh.FilesStat(ctx, path)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
dirs, err := d.sh.List(path_cid.Hash)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
objlist := []model.Obj{}
|
||||||
|
for _, file := range dirs {
|
||||||
|
gateurl := *d.gateURL
|
||||||
|
gateurl.Path = "ipfs/" + file.Hash
|
||||||
|
gateurl.RawQuery = "filename=" + file.Name
|
||||||
|
objlist = append(objlist, &model.ObjectURL{
|
||||||
|
Object: model.Object{ID: file.Hash, Name: file.Name, Size: int64(file.Size), IsFolder: file.Type == 1},
|
||||||
|
Url: model.Url{Url: gateurl.String()},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return objlist, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *IPFS) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (*model.Link, error) {
|
||||||
|
link := d.Gateway + "/ipfs/" + file.GetID() + "/?filename=" + file.GetName()
|
||||||
|
return &model.Link{URL: link}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *IPFS) MakeDir(ctx context.Context, parentDir model.Obj, dirName string) error {
|
||||||
|
path := parentDir.GetPath()
|
||||||
|
if path[len(path):] != "/" {
|
||||||
|
path += "/"
|
||||||
|
}
|
||||||
|
return d.sh.FilesMkdir(ctx, path+dirName)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *IPFS) Move(ctx context.Context, srcObj, dstDir model.Obj) error {
|
||||||
|
return d.sh.FilesMv(ctx, srcObj.GetPath(), dstDir.GetPath())
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *IPFS) Rename(ctx context.Context, srcObj model.Obj, newName string) error {
|
||||||
|
newFileName := filepath.Dir(srcObj.GetPath()) + "/" + newName
|
||||||
|
return d.sh.FilesMv(ctx, srcObj.GetPath(), strings.ReplaceAll(newFileName, "\\", "/"))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *IPFS) Copy(ctx context.Context, srcObj, dstDir model.Obj) error {
|
||||||
|
// TODO copy obj, optional
|
||||||
|
fmt.Println(srcObj.GetPath())
|
||||||
|
fmt.Println(dstDir.GetPath())
|
||||||
|
newFileName := dstDir.GetPath() + "/" + filepath.Base(srcObj.GetPath())
|
||||||
|
fmt.Println(newFileName)
|
||||||
|
return d.sh.FilesCp(ctx, srcObj.GetPath(), strings.ReplaceAll(newFileName, "\\", "/"))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *IPFS) Remove(ctx context.Context, obj model.Obj) error {
|
||||||
|
// TODO remove obj, optional
|
||||||
|
return d.sh.FilesRm(ctx, obj.GetPath(), true)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *IPFS) Put(ctx context.Context, dstDir model.Obj, stream model.FileStreamer, up driver.UpdateProgress) error {
|
||||||
|
// TODO upload file, optional
|
||||||
|
_, err := d.sh.Add(stream, ToFiles(stdpath.Join(dstDir.GetPath(), stream.GetName())))
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func ToFiles(dstDir string) shell.AddOpts {
|
||||||
|
return func(rb *shell.RequestBuilder) error {
|
||||||
|
rb.Option("to-files", dstDir)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//func (d *Template) Other(ctx context.Context, args model.OtherArgs) (interface{}, error) {
|
||||||
|
// return nil, errs.NotSupport
|
||||||
|
//}
|
||||||
|
|
||||||
|
var _ driver.Driver = (*IPFS)(nil)
|
25
drivers/ipfs_api/meta.go
Normal file
25
drivers/ipfs_api/meta.go
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
package ipfs
|
||||||
|
|
||||||
|
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.RootPath
|
||||||
|
Endpoint string `json:"endpoint" default:"http://127.0.0.1:5001"`
|
||||||
|
Gateway string `json:"gateway" default:"https://ipfs.io"`
|
||||||
|
}
|
||||||
|
|
||||||
|
var config = driver.Config{
|
||||||
|
Name: "IPFS API",
|
||||||
|
DefaultRoot: "/",
|
||||||
|
LocalSort: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
op.RegisterDriver(func() driver.Driver {
|
||||||
|
return &IPFS{}
|
||||||
|
})
|
||||||
|
}
|
@ -5,7 +5,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"regexp"
|
"regexp"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/alist-org/alist/v3/drivers/base"
|
"github.com/alist-org/alist/v3/drivers/base"
|
||||||
"github.com/alist-org/alist/v3/internal/driver"
|
"github.com/alist-org/alist/v3/internal/driver"
|
||||||
@ -15,12 +14,11 @@ import (
|
|||||||
"github.com/go-resty/resty/v2"
|
"github.com/go-resty/resty/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
var upClient = base.NewRestyClient().SetTimeout(120 * time.Second)
|
|
||||||
|
|
||||||
type LanZou struct {
|
type LanZou struct {
|
||||||
Addition
|
Addition
|
||||||
model.Storage
|
model.Storage
|
||||||
uid string
|
uid string
|
||||||
|
vei string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *LanZou) Config() driver.Config {
|
func (d *LanZou) Config() driver.Config {
|
||||||
@ -31,7 +29,7 @@ func (d *LanZou) GetAddition() driver.Additional {
|
|||||||
return &d.Addition
|
return &d.Addition
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *LanZou) Init(ctx context.Context) error {
|
func (d *LanZou) Init(ctx context.Context) (err error) {
|
||||||
if d.IsCookie() {
|
if d.IsCookie() {
|
||||||
if d.RootFolderID == "" {
|
if d.RootFolderID == "" {
|
||||||
d.RootFolderID = "-1"
|
d.RootFolderID = "-1"
|
||||||
@ -41,8 +39,9 @@ func (d *LanZou) Init(ctx context.Context) error {
|
|||||||
return fmt.Errorf("cookie does not contain ylogin")
|
return fmt.Errorf("cookie does not contain ylogin")
|
||||||
}
|
}
|
||||||
d.uid = ylogin[1]
|
d.uid = ylogin[1]
|
||||||
|
d.vei, err = d.getVei()
|
||||||
}
|
}
|
||||||
return nil
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *LanZou) Drop(ctx context.Context) error {
|
func (d *LanZou) Drop(ctx context.Context) error {
|
||||||
@ -209,11 +208,11 @@ func (d *LanZou) Put(ctx context.Context, dstDir model.Obj, stream model.FileStr
|
|||||||
var resp RespText[[]FileOrFolder]
|
var resp RespText[[]FileOrFolder]
|
||||||
_, err := d._post(d.BaseUrl+"/fileup.php", func(req *resty.Request) {
|
_, err := d._post(d.BaseUrl+"/fileup.php", func(req *resty.Request) {
|
||||||
req.SetFormData(map[string]string{
|
req.SetFormData(map[string]string{
|
||||||
"task": "1",
|
"task": "1",
|
||||||
"vie": "2",
|
"vie": "2",
|
||||||
"ve": "2",
|
"ve": "2",
|
||||||
"id": "WU_FILE_0",
|
"id": "WU_FILE_0",
|
||||||
"name": stream.GetName(),
|
"name": stream.GetName(),
|
||||||
"folder_id_bb_n": dstDir.GetID(),
|
"folder_id_bb_n": dstDir.GetID(),
|
||||||
}).SetFileReader("upload_file", stream.GetName(), stream).SetContext(ctx)
|
}).SetFileReader("upload_file", stream.GetName(), stream).SetContext(ctx)
|
||||||
}, &resp, true)
|
}, &resp, true)
|
||||||
|
@ -7,6 +7,7 @@ import (
|
|||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/alist-org/alist/v3/drivers/base"
|
"github.com/alist-org/alist/v3/drivers/base"
|
||||||
@ -16,14 +17,22 @@ import (
|
|||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var upClient *resty.Client
|
||||||
|
var once sync.Once
|
||||||
|
|
||||||
func (d *LanZou) doupload(callback base.ReqCallback, resp interface{}) ([]byte, error) {
|
func (d *LanZou) doupload(callback base.ReqCallback, resp interface{}) ([]byte, error) {
|
||||||
return d.post(d.BaseUrl+"/doupload.php", func(req *resty.Request) {
|
return d.post(d.BaseUrl+"/doupload.php", func(req *resty.Request) {
|
||||||
req.SetQueryParam("uid", d.uid)
|
req.SetQueryParams(map[string]string{
|
||||||
callback(req)
|
"uid": d.uid,
|
||||||
|
"vei": d.vei,
|
||||||
|
})
|
||||||
|
if callback != nil {
|
||||||
|
callback(req)
|
||||||
|
}
|
||||||
}, resp)
|
}, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *LanZou) get(url string, callback base.ReqCallback, resp interface{}) ([]byte, error) {
|
func (d *LanZou) get(url string, callback base.ReqCallback) ([]byte, error) {
|
||||||
return d.request(url, http.MethodGet, callback, false)
|
return d.request(url, http.MethodGet, callback, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,6 +73,9 @@ func (d *LanZou) _post(url string, callback base.ReqCallback, resp interface{},
|
|||||||
func (d *LanZou) request(url string, method string, callback base.ReqCallback, up bool) ([]byte, error) {
|
func (d *LanZou) request(url string, method string, callback base.ReqCallback, up bool) ([]byte, error) {
|
||||||
var req *resty.Request
|
var req *resty.Request
|
||||||
if up {
|
if up {
|
||||||
|
once.Do(func() {
|
||||||
|
upClient = base.NewRestyClient().SetTimeout(120 * time.Second)
|
||||||
|
})
|
||||||
req = upClient.R()
|
req = upClient.R()
|
||||||
} else {
|
} else {
|
||||||
req = base.RestyClient.R()
|
req = base.RestyClient.R()
|
||||||
@ -217,7 +229,7 @@ func (d *LanZou) getShareUrlHtml(shareID string) (string, error) {
|
|||||||
Value: vs,
|
Value: vs,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}, nil)
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
@ -308,7 +320,7 @@ func (d *LanZou) getFilesByShareUrl(shareID, pwd string, sharePageData string) (
|
|||||||
log.Errorf("lanzou: err => not find file page param ,data => %s\n", sharePageData)
|
log.Errorf("lanzou: err => not find file page param ,data => %s\n", sharePageData)
|
||||||
return nil, fmt.Errorf("not find file page param")
|
return nil, fmt.Errorf("not find file page param")
|
||||||
}
|
}
|
||||||
data, err := d.get(fmt.Sprint(d.ShareUrl, urlpaths[1]), nil, nil)
|
data, err := d.get(fmt.Sprint(d.ShareUrl, urlpaths[1]), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -438,3 +450,22 @@ func (d *LanZou) getFileRealInfo(downURL string) (*int64, *time.Time) {
|
|||||||
size, _ := strconv.ParseInt(res.Header().Get("Content-Length"), 10, 64)
|
size, _ := strconv.ParseInt(res.Header().Get("Content-Length"), 10, 64)
|
||||||
return &size, &time
|
return &size, &time
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *LanZou) getVei() (string, error) {
|
||||||
|
resp, err := d.get("https://pc.woozooo.com/mydisk.php", func(req *resty.Request) {
|
||||||
|
req.SetQueryParams(map[string]string{
|
||||||
|
"item": "files",
|
||||||
|
"action": "index",
|
||||||
|
"u": d.uid,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
html := RemoveNotes(string(resp))
|
||||||
|
data, err := htmlJsonToMap(html)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return data["vei"], nil
|
||||||
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package local
|
package local
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
@ -20,7 +19,6 @@ import (
|
|||||||
"github.com/alist-org/alist/v3/internal/sign"
|
"github.com/alist-org/alist/v3/internal/sign"
|
||||||
"github.com/alist-org/alist/v3/pkg/utils"
|
"github.com/alist-org/alist/v3/pkg/utils"
|
||||||
"github.com/alist-org/alist/v3/server/common"
|
"github.com/alist-org/alist/v3/server/common"
|
||||||
"github.com/disintegration/imaging"
|
|
||||||
_ "golang.org/x/image/webp"
|
_ "golang.org/x/image/webp"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -54,6 +52,12 @@ func (d *Local) Init(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
d.Addition.RootFolderPath = abs
|
d.Addition.RootFolderPath = abs
|
||||||
}
|
}
|
||||||
|
if d.ThumbCacheFolder != "" && !utils.Exists(d.ThumbCacheFolder) {
|
||||||
|
err := os.MkdirAll(d.ThumbCacheFolder, os.FileMode(d.mkdirPerm))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,36 +139,18 @@ func (d *Local) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (
|
|||||||
fullPath := file.GetPath()
|
fullPath := file.GetPath()
|
||||||
var link model.Link
|
var link model.Link
|
||||||
if args.Type == "thumb" && utils.Ext(file.GetName()) != "svg" {
|
if args.Type == "thumb" && utils.Ext(file.GetName()) != "svg" {
|
||||||
var srcBuf *bytes.Buffer
|
buf, thumbPath, err := d.getThumb(file)
|
||||||
if utils.GetFileType(file.GetName()) == conf.VIDEO {
|
|
||||||
videoBuf, err := GetSnapshot(fullPath, 10)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
srcBuf = videoBuf
|
|
||||||
} else {
|
|
||||||
imgData, err := os.ReadFile(fullPath)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
imgBuf := bytes.NewBuffer(imgData)
|
|
||||||
srcBuf = imgBuf
|
|
||||||
}
|
|
||||||
|
|
||||||
image, err := imaging.Decode(srcBuf)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
thumbImg := imaging.Resize(image, 144, 0, imaging.Lanczos)
|
|
||||||
var buf bytes.Buffer
|
|
||||||
err = imaging.Encode(&buf, thumbImg, imaging.PNG)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
size := buf.Len()
|
|
||||||
link.Data = io.NopCloser(&buf)
|
|
||||||
link.Header = http.Header{
|
link.Header = http.Header{
|
||||||
"Content-Length": []string{strconv.Itoa(size)},
|
"Content-Type": []string{"image/png"},
|
||||||
|
}
|
||||||
|
if thumbPath != nil {
|
||||||
|
link.FilePath = thumbPath
|
||||||
|
} else {
|
||||||
|
link.Data = io.NopCloser(buf)
|
||||||
|
link.Header.Set("Content-Length", strconv.Itoa(buf.Len()))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
link.FilePath = &fullPath
|
link.FilePath = &fullPath
|
||||||
|
@ -7,9 +7,10 @@ import (
|
|||||||
|
|
||||||
type Addition struct {
|
type Addition struct {
|
||||||
driver.RootPath
|
driver.RootPath
|
||||||
Thumbnail bool `json:"thumbnail" required:"true" help:"enable thumbnail"`
|
Thumbnail bool `json:"thumbnail" required:"true" help:"enable thumbnail"`
|
||||||
ShowHidden bool `json:"show_hidden" default:"true" required:"false" help:"show hidden directories and files"`
|
ThumbCacheFolder string `json:"thumb_cache_folder"`
|
||||||
MkdirPerm string `json:"mkdir_perm" default:"777"`
|
ShowHidden bool `json:"show_hidden" default:"true" required:"false" help:"show hidden directories and files"`
|
||||||
|
MkdirPerm string `json:"mkdir_perm" default:"777"`
|
||||||
}
|
}
|
||||||
|
|
||||||
var config = driver.Config{
|
var config = driver.Config{
|
||||||
|
@ -7,7 +7,12 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sort"
|
"sort"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/alist-org/alist/v3/internal/conf"
|
||||||
|
"github.com/alist-org/alist/v3/internal/model"
|
||||||
|
"github.com/alist-org/alist/v3/pkg/utils"
|
||||||
|
"github.com/disintegration/imaging"
|
||||||
ffmpeg "github.com/u2takey/ffmpeg-go"
|
ffmpeg "github.com/u2takey/ffmpeg-go"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -55,3 +60,52 @@ func readDir(dirname string) ([]fs.FileInfo, error) {
|
|||||||
sort.Slice(list, func(i, j int) bool { return list[i].Name() < list[j].Name() })
|
sort.Slice(list, func(i, j int) bool { return list[i].Name() < list[j].Name() })
|
||||||
return list, nil
|
return list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *Local) getThumb(file model.Obj) (*bytes.Buffer, *string, error) {
|
||||||
|
fullPath := file.GetPath()
|
||||||
|
thumbPrefix := "alist_thumb_"
|
||||||
|
thumbName := thumbPrefix + utils.GetMD5Encode(fullPath) + ".png"
|
||||||
|
if d.ThumbCacheFolder != "" {
|
||||||
|
// skip if the file is a thumbnail
|
||||||
|
if strings.HasPrefix(file.GetName(), thumbPrefix) {
|
||||||
|
return nil, &fullPath, nil
|
||||||
|
}
|
||||||
|
thumbPath := filepath.Join(d.ThumbCacheFolder, thumbName)
|
||||||
|
if utils.Exists(thumbPath) {
|
||||||
|
return nil, &thumbPath, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var srcBuf *bytes.Buffer
|
||||||
|
if utils.GetFileType(file.GetName()) == conf.VIDEO {
|
||||||
|
videoBuf, err := GetSnapshot(fullPath, 10)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
srcBuf = videoBuf
|
||||||
|
} else {
|
||||||
|
imgData, err := os.ReadFile(fullPath)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
imgBuf := bytes.NewBuffer(imgData)
|
||||||
|
srcBuf = imgBuf
|
||||||
|
}
|
||||||
|
|
||||||
|
image, err := imaging.Decode(srcBuf)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
thumbImg := imaging.Resize(image, 144, 0, imaging.Lanczos)
|
||||||
|
var buf bytes.Buffer
|
||||||
|
err = imaging.Encode(&buf, thumbImg, imaging.PNG)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
if d.ThumbCacheFolder != "" {
|
||||||
|
err = os.WriteFile(filepath.Join(d.ThumbCacheFolder, thumbName), buf.Bytes(), 0666)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return &buf, nil, nil
|
||||||
|
}
|
||||||
|
@ -1,26 +0,0 @@
|
|||||||
package quark
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/alist-org/alist/v3/internal/driver"
|
|
||||||
"github.com/alist-org/alist/v3/internal/op"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Addition struct {
|
|
||||||
Cookie string `json:"cookie" required:"true"`
|
|
||||||
driver.RootID
|
|
||||||
OrderBy string `json:"order_by" type:"select" options:"none,file_type,file_name,updated_at" default:"none"`
|
|
||||||
OrderDirection string `json:"order_direction" type:"select" options:"asc,desc" default:"asc"`
|
|
||||||
}
|
|
||||||
|
|
||||||
var config = driver.Config{
|
|
||||||
Name: "Quark",
|
|
||||||
OnlyLocal: true,
|
|
||||||
DefaultRoot: "0",
|
|
||||||
NoOverwriteUpload: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
op.RegisterDriver(func() driver.Driver {
|
|
||||||
return &Quark{}
|
|
||||||
})
|
|
||||||
}
|
|
@ -22,29 +22,31 @@ import (
|
|||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Quark struct {
|
type QuarkOrUC struct {
|
||||||
model.Storage
|
model.Storage
|
||||||
Addition
|
Addition
|
||||||
|
config driver.Config
|
||||||
|
conf Conf
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Quark) Config() driver.Config {
|
func (d *QuarkOrUC) Config() driver.Config {
|
||||||
return config
|
return d.config
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Quark) GetAddition() driver.Additional {
|
func (d *QuarkOrUC) GetAddition() driver.Additional {
|
||||||
return &d.Addition
|
return &d.Addition
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Quark) Init(ctx context.Context) error {
|
func (d *QuarkOrUC) Init(ctx context.Context) error {
|
||||||
_, err := d.request("/config", http.MethodGet, nil, nil)
|
_, err := d.request("/config", http.MethodGet, nil, nil)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Quark) Drop(ctx context.Context) error {
|
func (d *QuarkOrUC) Drop(ctx context.Context) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Quark) List(ctx context.Context, dir model.Obj, args model.ListArgs) ([]model.Obj, error) {
|
func (d *QuarkOrUC) List(ctx context.Context, dir model.Obj, args model.ListArgs) ([]model.Obj, error) {
|
||||||
files, err := d.GetFiles(dir.GetID())
|
files, err := d.GetFiles(dir.GetID())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -54,12 +56,12 @@ func (d *Quark) List(ctx context.Context, dir model.Obj, args model.ListArgs) ([
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Quark) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (*model.Link, error) {
|
func (d *QuarkOrUC) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (*model.Link, error) {
|
||||||
data := base.Json{
|
data := base.Json{
|
||||||
"fids": []string{file.GetID()},
|
"fids": []string{file.GetID()},
|
||||||
}
|
}
|
||||||
var resp DownResp
|
var resp DownResp
|
||||||
ua := "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) quark-cloud-drive/2.5.20 Chrome/100.0.4896.160 Electron/18.3.5.4-b478491100 Safari/537.36 Channel/pckk_other_ch"
|
ua := d.conf.ua
|
||||||
_, err := d.request("/file/download", http.MethodPost, func(req *resty.Request) {
|
_, err := d.request("/file/download", http.MethodPost, func(req *resty.Request) {
|
||||||
req.SetHeader("User-Agent", ua).
|
req.SetHeader("User-Agent", ua).
|
||||||
SetBody(data)
|
SetBody(data)
|
||||||
@ -69,61 +71,63 @@ func (d *Quark) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (
|
|||||||
}
|
}
|
||||||
u := resp.Data[0].DownloadUrl
|
u := resp.Data[0].DownloadUrl
|
||||||
start, end := int64(0), file.GetSize()
|
start, end := int64(0), file.GetSize()
|
||||||
return &model.Link{
|
link := model.Link{
|
||||||
Handle: func(w http.ResponseWriter, r *http.Request) error {
|
Header: http.Header{},
|
||||||
if rg := r.Header.Get("Range"); rg != "" {
|
}
|
||||||
parseRange, err := http_range.ParseRange(rg, file.GetSize())
|
if rg := args.Header.Get("Range"); rg != "" {
|
||||||
if err != nil {
|
parseRange, err := http_range.ParseRange(rg, file.GetSize())
|
||||||
return err
|
if err != nil {
|
||||||
}
|
return nil, err
|
||||||
start, end = parseRange[0].Start, parseRange[0].Start+parseRange[0].Length
|
}
|
||||||
w.Header().Set("Content-Range", parseRange[0].ContentRange(file.GetSize()))
|
start, end = parseRange[0].Start, parseRange[0].Start+parseRange[0].Length
|
||||||
w.Header().Set("Content-Length", strconv.FormatInt(parseRange[0].Length, 10))
|
link.Header.Set("Content-Range", parseRange[0].ContentRange(file.GetSize()))
|
||||||
w.WriteHeader(http.StatusPartialContent)
|
link.Header.Set("Content-Length", strconv.FormatInt(parseRange[0].Length, 10))
|
||||||
} else {
|
link.Status = http.StatusPartialContent
|
||||||
w.Header().Set("Content-Length", strconv.FormatInt(file.GetSize(), 10))
|
} else {
|
||||||
w.WriteHeader(http.StatusOK)
|
link.Header.Set("Content-Length", strconv.FormatInt(file.GetSize(), 10))
|
||||||
|
link.Status = http.StatusOK
|
||||||
|
}
|
||||||
|
link.Writer = func(w io.Writer) error {
|
||||||
|
// request 10 MB at a time
|
||||||
|
chunkSize := int64(10 * 1024 * 1024)
|
||||||
|
for start < end {
|
||||||
|
_end := start + chunkSize
|
||||||
|
if _end > end {
|
||||||
|
_end = end
|
||||||
}
|
}
|
||||||
// request 10 MB at a time
|
_range := "bytes=" + strconv.FormatInt(start, 10) + "-" + strconv.FormatInt(_end-1, 10)
|
||||||
chunkSize := int64(10 * 1024 * 1024)
|
start = _end
|
||||||
for start < end {
|
err = func() error {
|
||||||
_end := start + chunkSize
|
req, err := http.NewRequest(http.MethodGet, u, nil)
|
||||||
if _end > end {
|
|
||||||
_end = end
|
|
||||||
}
|
|
||||||
_range := "bytes=" + strconv.FormatInt(start, 10) + "-" + strconv.FormatInt(_end-1, 10)
|
|
||||||
start = _end
|
|
||||||
err = func() error {
|
|
||||||
req, err := http.NewRequest(r.Method, u, nil)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
req.Header.Set("Range", _range)
|
|
||||||
req.Header.Set("User-Agent", ua)
|
|
||||||
req.Header.Set("Cookie", d.Cookie)
|
|
||||||
req.Header.Set("Referer", "https://pan.quark.cn")
|
|
||||||
resp, err := http.DefaultClient.Do(req)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
defer resp.Body.Close()
|
|
||||||
if resp.StatusCode != http.StatusPartialContent {
|
|
||||||
return fmt.Errorf("unexpected status code: %d", resp.StatusCode)
|
|
||||||
}
|
|
||||||
_, err = io.Copy(w, resp.Body)
|
|
||||||
return err
|
|
||||||
}()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
req.Header.Set("Range", _range)
|
||||||
|
req.Header.Set("User-Agent", ua)
|
||||||
|
req.Header.Set("Cookie", d.Cookie)
|
||||||
|
req.Header.Set("Referer", d.conf.referer)
|
||||||
|
resp, err := base.HttpClient.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
if resp.StatusCode != http.StatusPartialContent {
|
||||||
|
return fmt.Errorf("unexpected status code: %d", resp.StatusCode)
|
||||||
|
}
|
||||||
|
_, err = io.Copy(w, resp.Body)
|
||||||
|
return err
|
||||||
|
}()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
},
|
}
|
||||||
}, nil
|
return &link, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Quark) MakeDir(ctx context.Context, parentDir model.Obj, dirName string) error {
|
func (d *QuarkOrUC) MakeDir(ctx context.Context, parentDir model.Obj, dirName string) error {
|
||||||
data := base.Json{
|
data := base.Json{
|
||||||
"dir_init_lock": false,
|
"dir_init_lock": false,
|
||||||
"dir_path": "",
|
"dir_path": "",
|
||||||
@ -139,7 +143,7 @@ func (d *Quark) MakeDir(ctx context.Context, parentDir model.Obj, dirName string
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Quark) Move(ctx context.Context, srcObj, dstDir model.Obj) error {
|
func (d *QuarkOrUC) Move(ctx context.Context, srcObj, dstDir model.Obj) error {
|
||||||
data := base.Json{
|
data := base.Json{
|
||||||
"action_type": 1,
|
"action_type": 1,
|
||||||
"exclude_fids": []string{},
|
"exclude_fids": []string{},
|
||||||
@ -152,7 +156,7 @@ func (d *Quark) Move(ctx context.Context, srcObj, dstDir model.Obj) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Quark) Rename(ctx context.Context, srcObj model.Obj, newName string) error {
|
func (d *QuarkOrUC) Rename(ctx context.Context, srcObj model.Obj, newName string) error {
|
||||||
data := base.Json{
|
data := base.Json{
|
||||||
"fid": srcObj.GetID(),
|
"fid": srcObj.GetID(),
|
||||||
"file_name": newName,
|
"file_name": newName,
|
||||||
@ -163,11 +167,11 @@ func (d *Quark) Rename(ctx context.Context, srcObj model.Obj, newName string) er
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Quark) Copy(ctx context.Context, srcObj, dstDir model.Obj) error {
|
func (d *QuarkOrUC) Copy(ctx context.Context, srcObj, dstDir model.Obj) error {
|
||||||
return errs.NotSupport
|
return errs.NotSupport
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Quark) Remove(ctx context.Context, obj model.Obj) error {
|
func (d *QuarkOrUC) Remove(ctx context.Context, obj model.Obj) error {
|
||||||
data := base.Json{
|
data := base.Json{
|
||||||
"action_type": 1,
|
"action_type": 1,
|
||||||
"exclude_fids": []string{},
|
"exclude_fids": []string{},
|
||||||
@ -179,7 +183,7 @@ func (d *Quark) Remove(ctx context.Context, obj model.Obj) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Quark) Put(ctx context.Context, dstDir model.Obj, stream model.FileStreamer, up driver.UpdateProgress) error {
|
func (d *QuarkOrUC) Put(ctx context.Context, dstDir model.Obj, stream model.FileStreamer, up driver.UpdateProgress) error {
|
||||||
tempFile, err := utils.CreateTempFile(stream.GetReadCloser())
|
tempFile, err := utils.CreateTempFile(stream.GetReadCloser())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -264,4 +268,4 @@ func (d *Quark) Put(ctx context.Context, dstDir model.Obj, stream model.FileStre
|
|||||||
return d.upFinish(pre)
|
return d.upFinish(pre)
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ driver.Driver = (*Quark)(nil)
|
var _ driver.Driver = (*QuarkOrUC)(nil)
|
55
drivers/quark_uc/meta.go
Normal file
55
drivers/quark_uc/meta.go
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
package quark
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/alist-org/alist/v3/internal/driver"
|
||||||
|
"github.com/alist-org/alist/v3/internal/op"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Addition struct {
|
||||||
|
Cookie string `json:"cookie" required:"true"`
|
||||||
|
driver.RootID
|
||||||
|
OrderBy string `json:"order_by" type:"select" options:"none,file_type,file_name,updated_at" default:"none"`
|
||||||
|
OrderDirection string `json:"order_direction" type:"select" options:"asc,desc" default:"asc"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Conf struct {
|
||||||
|
ua string
|
||||||
|
referer string
|
||||||
|
api string
|
||||||
|
pr string
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
op.RegisterDriver(func() driver.Driver {
|
||||||
|
return &QuarkOrUC{
|
||||||
|
config: driver.Config{
|
||||||
|
Name: "Quark",
|
||||||
|
OnlyLocal: true,
|
||||||
|
DefaultRoot: "0",
|
||||||
|
NoOverwriteUpload: true,
|
||||||
|
},
|
||||||
|
conf: Conf{
|
||||||
|
ua: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) quark-cloud-drive/2.5.20 Chrome/100.0.4896.160 Electron/18.3.5.4-b478491100 Safari/537.36 Channel/pckk_other_ch",
|
||||||
|
referer: "https://pan.quark.cn",
|
||||||
|
api: "https://drive.quark.cn/1/clouddrive",
|
||||||
|
pr: "ucpro",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
})
|
||||||
|
op.RegisterDriver(func() driver.Driver {
|
||||||
|
return &QuarkOrUC{
|
||||||
|
config: driver.Config{
|
||||||
|
Name: "UC",
|
||||||
|
OnlyLocal: true,
|
||||||
|
DefaultRoot: "0",
|
||||||
|
NoOverwriteUpload: true,
|
||||||
|
},
|
||||||
|
conf: Conf{
|
||||||
|
ua: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) uc-cloud-drive/2.5.20 Chrome/100.0.4896.160 Electron/18.3.5.4-b478491100 Safari/537.36 Channel/pckk_other_ch",
|
||||||
|
referer: "https://drive.uc.cn",
|
||||||
|
api: "https://pc-api.uc.cn/1/clouddrive",
|
||||||
|
pr: "UCBrowser",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
@ -22,15 +22,15 @@ import (
|
|||||||
|
|
||||||
// do others that not defined in Driver interface
|
// do others that not defined in Driver interface
|
||||||
|
|
||||||
func (d *Quark) request(pathname string, method string, callback base.ReqCallback, resp interface{}) ([]byte, error) {
|
func (d *QuarkOrUC) request(pathname string, method string, callback base.ReqCallback, resp interface{}) ([]byte, error) {
|
||||||
u := "https://drive.quark.cn/1/clouddrive" + pathname
|
u := d.conf.api + pathname
|
||||||
req := base.RestyClient.R()
|
req := base.RestyClient.R()
|
||||||
req.SetHeaders(map[string]string{
|
req.SetHeaders(map[string]string{
|
||||||
"Cookie": d.Cookie,
|
"Cookie": d.Cookie,
|
||||||
"Accept": "application/json, text/plain, */*",
|
"Accept": "application/json, text/plain, */*",
|
||||||
"Referer": "https://pan.quark.cn/",
|
"Referer": d.conf.referer,
|
||||||
})
|
})
|
||||||
req.SetQueryParam("pr", "ucpro")
|
req.SetQueryParam("pr", d.conf.pr)
|
||||||
req.SetQueryParam("fr", "pc")
|
req.SetQueryParam("fr", "pc")
|
||||||
if callback != nil {
|
if callback != nil {
|
||||||
callback(req)
|
callback(req)
|
||||||
@ -55,7 +55,7 @@ func (d *Quark) request(pathname string, method string, callback base.ReqCallbac
|
|||||||
return res.Body(), nil
|
return res.Body(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Quark) GetFiles(parent string) ([]File, error) {
|
func (d *QuarkOrUC) GetFiles(parent string) ([]File, error) {
|
||||||
files := make([]File, 0)
|
files := make([]File, 0)
|
||||||
page := 1
|
page := 1
|
||||||
size := 100
|
size := 100
|
||||||
@ -85,7 +85,7 @@ func (d *Quark) GetFiles(parent string) ([]File, error) {
|
|||||||
return files, nil
|
return files, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Quark) upPre(file model.FileStreamer, parentId string) (UpPreResp, error) {
|
func (d *QuarkOrUC) upPre(file model.FileStreamer, parentId string) (UpPreResp, error) {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
data := base.Json{
|
data := base.Json{
|
||||||
"ccp_hash_update": true,
|
"ccp_hash_update": true,
|
||||||
@ -105,7 +105,7 @@ func (d *Quark) upPre(file model.FileStreamer, parentId string) (UpPreResp, erro
|
|||||||
return resp, err
|
return resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Quark) upHash(md5, sha1, taskId string) (bool, error) {
|
func (d *QuarkOrUC) upHash(md5, sha1, taskId string) (bool, error) {
|
||||||
data := base.Json{
|
data := base.Json{
|
||||||
"md5": md5,
|
"md5": md5,
|
||||||
"sha1": sha1,
|
"sha1": sha1,
|
||||||
@ -119,8 +119,8 @@ func (d *Quark) upHash(md5, sha1, taskId string) (bool, error) {
|
|||||||
return resp.Data.Finish, err
|
return resp.Data.Finish, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Quark) upPart(ctx context.Context, pre UpPreResp, mineType string, partNumber int, bytes []byte) (string, error) {
|
func (d *QuarkOrUC) upPart(ctx context.Context, pre UpPreResp, mineType string, partNumber int, bytes []byte) (string, error) {
|
||||||
//func (driver Quark) UpPart(pre UpPreResp, mineType string, partNumber int, bytes []byte, account *model.Account, md5Str, sha1Str string) (string, error) {
|
//func (driver QuarkOrUC) UpPart(pre UpPreResp, mineType string, partNumber int, bytes []byte, account *model.Account, md5Str, sha1Str string) (string, error) {
|
||||||
timeStr := time.Now().UTC().Format(http.TimeFormat)
|
timeStr := time.Now().UTC().Format(http.TimeFormat)
|
||||||
data := base.Json{
|
data := base.Json{
|
||||||
"auth_info": pre.Data.AuthInfo,
|
"auth_info": pre.Data.AuthInfo,
|
||||||
@ -169,7 +169,7 @@ x-oss-user-agent:aliyun-sdk-js/6.6.1 Chrome 98.0.4758.80 on Windows 10 64-bit
|
|||||||
return res.Header().Get("ETag"), nil
|
return res.Header().Get("ETag"), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Quark) upCommit(pre UpPreResp, md5s []string) error {
|
func (d *QuarkOrUC) upCommit(pre UpPreResp, md5s []string) error {
|
||||||
timeStr := time.Now().UTC().Format(http.TimeFormat)
|
timeStr := time.Now().UTC().Format(http.TimeFormat)
|
||||||
log.Debugf("md5s: %+v", md5s)
|
log.Debugf("md5s: %+v", md5s)
|
||||||
bodyBuilder := strings.Builder{}
|
bodyBuilder := strings.Builder{}
|
||||||
@ -236,7 +236,7 @@ x-oss-user-agent:aliyun-sdk-js/6.6.1 Chrome 98.0.4758.80 on Windows 10 64-bit
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Quark) upFinish(pre UpPreResp) error {
|
func (d *QuarkOrUC) upFinish(pre UpPreResp) error {
|
||||||
data := base.Json{
|
data := base.Json{
|
||||||
"obj_key": pre.Data.ObjKey,
|
"obj_key": pre.Data.ObjKey,
|
||||||
"task_id": pre.Data.TaskId,
|
"task_id": pre.Data.TaskId,
|
@ -136,11 +136,13 @@ func (d *S3) Put(ctx context.Context, dstDir model.Obj, stream model.FileStreame
|
|||||||
uploader.PartSize = stream.GetSize() / (s3manager.MaxUploadParts - 1)
|
uploader.PartSize = stream.GetSize() / (s3manager.MaxUploadParts - 1)
|
||||||
}
|
}
|
||||||
key := getKey(stdpath.Join(dstDir.GetPath(), stream.GetName()), false)
|
key := getKey(stdpath.Join(dstDir.GetPath(), stream.GetName()), false)
|
||||||
|
contentType := stream.GetMimetype()
|
||||||
log.Debugln("key:", key)
|
log.Debugln("key:", key)
|
||||||
input := &s3manager.UploadInput{
|
input := &s3manager.UploadInput{
|
||||||
Bucket: &d.Bucket,
|
Bucket: &d.Bucket,
|
||||||
Key: &key,
|
Key: &key,
|
||||||
Body: stream,
|
Body: stream,
|
||||||
|
ContentType: &contentType,
|
||||||
}
|
}
|
||||||
_, err := uploader.UploadWithContext(ctx, input)
|
_, err := uploader.UploadWithContext(ctx, input)
|
||||||
return err
|
return err
|
||||||
|
@ -36,11 +36,14 @@ func (d *Seafile) request(method string, pathname string, callback base.ReqCallb
|
|||||||
if len(noRedirect) > 0 && noRedirect[0] {
|
if len(noRedirect) > 0 && noRedirect[0] {
|
||||||
req = base.NoRedirectClient.R()
|
req = base.NoRedirectClient.R()
|
||||||
}
|
}
|
||||||
var res resty.Response
|
req.SetHeader("Authorization", d.authorization)
|
||||||
|
callback(req)
|
||||||
|
var (
|
||||||
|
res *resty.Response
|
||||||
|
err error
|
||||||
|
)
|
||||||
for i := 0; i < 2; i++ {
|
for i := 0; i < 2; i++ {
|
||||||
req.SetHeader("Authorization", d.authorization)
|
res, err = req.Execute(method, full)
|
||||||
callback(req)
|
|
||||||
res, err := req.Execute(method, full)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -125,6 +125,9 @@ func (d *Teambition) Remove(ctx context.Context, obj model.Obj) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *Teambition) Put(ctx context.Context, dstDir model.Obj, stream model.FileStreamer, up driver.UpdateProgress) error {
|
func (d *Teambition) Put(ctx context.Context, dstDir model.Obj, stream model.FileStreamer, up driver.UpdateProgress) error {
|
||||||
|
if d.UseS3UploadMethod {
|
||||||
|
return d.newUpload(ctx, dstDir, stream, up)
|
||||||
|
}
|
||||||
res, err := d.request("/api/v2/users/me", http.MethodGet, nil, nil)
|
res, err := d.request("/api/v2/users/me", http.MethodGet, nil, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -10,8 +10,9 @@ type Addition struct {
|
|||||||
Cookie string `json:"cookie" required:"true"`
|
Cookie string `json:"cookie" required:"true"`
|
||||||
ProjectID string `json:"project_id" required:"true"`
|
ProjectID string `json:"project_id" required:"true"`
|
||||||
driver.RootID
|
driver.RootID
|
||||||
OrderBy string `json:"order_by" type:"select" options:"fileName,fileSize,updated,created" default:"fileName"`
|
OrderBy string `json:"order_by" type:"select" options:"fileName,fileSize,updated,created" default:"fileName"`
|
||||||
OrderDirection string `json:"order_direction" type:"select" options:"Asc,Desc" default:"Asc"`
|
OrderDirection string `json:"order_direction" type:"select" options:"Asc,Desc" default:"Asc"`
|
||||||
|
UseS3UploadMethod bool `json:"use_s3_upload_method" default:"true"`
|
||||||
}
|
}
|
||||||
|
|
||||||
var config = driver.Config{
|
var config = driver.Config{
|
||||||
|
@ -66,3 +66,24 @@ type ChunkUpload struct {
|
|||||||
PreviewExt string `json:"previewExt"`
|
PreviewExt string `json:"previewExt"`
|
||||||
LastUploadTime interface{} `json:"lastUploadTime"`
|
LastUploadTime interface{} `json:"lastUploadTime"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type UploadToken struct {
|
||||||
|
Sdk struct {
|
||||||
|
Endpoint string `json:"endpoint"`
|
||||||
|
Region string `json:"region"`
|
||||||
|
S3ForcePathStyle bool `json:"s3ForcePathStyle"`
|
||||||
|
Credentials struct {
|
||||||
|
AccessKeyId string `json:"accessKeyId"`
|
||||||
|
SecretAccessKey string `json:"secretAccessKey"`
|
||||||
|
SessionToken string `json:"sessionToken"`
|
||||||
|
} `json:"credentials"`
|
||||||
|
} `json:"sdk"`
|
||||||
|
Upload struct {
|
||||||
|
Bucket string `json:"Bucket"`
|
||||||
|
Key string `json:"Key"`
|
||||||
|
ContentDisposition string `json:"ContentDisposition"`
|
||||||
|
ContentType string `json:"ContentType"`
|
||||||
|
} `json:"upload"`
|
||||||
|
Token string `json:"token"`
|
||||||
|
DownloadUrl string `json:"downloadUrl"`
|
||||||
|
}
|
||||||
|
@ -7,13 +7,16 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/alist-org/alist/v3/drivers/base"
|
"github.com/alist-org/alist/v3/drivers/base"
|
||||||
"github.com/alist-org/alist/v3/internal/driver"
|
"github.com/alist-org/alist/v3/internal/driver"
|
||||||
"github.com/alist-org/alist/v3/internal/model"
|
"github.com/alist-org/alist/v3/internal/model"
|
||||||
"github.com/alist-org/alist/v3/pkg/utils"
|
"github.com/alist-org/alist/v3/pkg/utils"
|
||||||
|
"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"
|
"github.com/go-resty/resty/v2"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
@ -210,17 +213,56 @@ func (d *Teambition) finishUpload(file *FileUpload, parentId string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func getBetweenStr(str, start, end string) string {
|
func (d *Teambition) newUpload(ctx context.Context, dstDir model.Obj, stream model.FileStreamer, up driver.UpdateProgress) error {
|
||||||
n := strings.Index(str, start)
|
var uploadToken UploadToken
|
||||||
if n == -1 {
|
_, err := d.request("/api/awos/upload-token", http.MethodPost, func(req *resty.Request) {
|
||||||
return ""
|
req.SetBody(base.Json{
|
||||||
|
"category": "work",
|
||||||
|
"fileName": stream.GetName(),
|
||||||
|
"fileSize": stream.GetSize(),
|
||||||
|
"fileType": stream.GetMimetype(),
|
||||||
|
"payload": base.Json{
|
||||||
|
"involveMembers": []struct{}{},
|
||||||
|
"visible": "members",
|
||||||
|
},
|
||||||
|
"scope": "project:" + d.ProjectID,
|
||||||
|
})
|
||||||
|
}, &uploadToken)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
n = n + len(start)
|
cfg := &aws.Config{
|
||||||
str = string([]byte(str)[n:])
|
Credentials: credentials.NewStaticCredentials(
|
||||||
m := strings.Index(str, end)
|
uploadToken.Sdk.Credentials.AccessKeyId, uploadToken.Sdk.Credentials.SecretAccessKey, uploadToken.Sdk.Credentials.SessionToken),
|
||||||
if m == -1 {
|
Region: &uploadToken.Sdk.Region,
|
||||||
return ""
|
Endpoint: &uploadToken.Sdk.Endpoint,
|
||||||
|
S3ForcePathStyle: &uploadToken.Sdk.S3ForcePathStyle,
|
||||||
}
|
}
|
||||||
str = string([]byte(str)[:m])
|
ss, err := session.NewSession(cfg)
|
||||||
return str
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
uploader := s3manager.NewUploader(ss)
|
||||||
|
input := &s3manager.UploadInput{
|
||||||
|
Bucket: &uploadToken.Upload.Bucket,
|
||||||
|
Key: &uploadToken.Upload.Key,
|
||||||
|
ContentDisposition: &uploadToken.Upload.ContentDisposition,
|
||||||
|
ContentType: &uploadToken.Upload.ContentType,
|
||||||
|
Body: stream,
|
||||||
|
}
|
||||||
|
_, err = uploader.UploadWithContext(ctx, input)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// finish upload
|
||||||
|
_, err = d.request("/api/works", http.MethodPost, func(req *resty.Request) {
|
||||||
|
req.SetBody(base.Json{
|
||||||
|
"fileTokens": []string{uploadToken.Token},
|
||||||
|
"involveMembers": []struct{}{},
|
||||||
|
"visible": "members",
|
||||||
|
"works": []struct{}{},
|
||||||
|
"_parentId": dstDir.GetID(),
|
||||||
|
})
|
||||||
|
}, nil)
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ import (
|
|||||||
"net/url"
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/alist-org/alist/v3/drivers/base"
|
||||||
"github.com/alist-org/alist/v3/internal/driver"
|
"github.com/alist-org/alist/v3/internal/driver"
|
||||||
"github.com/alist-org/alist/v3/internal/errs"
|
"github.com/alist-org/alist/v3/internal/errs"
|
||||||
"github.com/alist-org/alist/v3/internal/model"
|
"github.com/alist-org/alist/v3/internal/model"
|
||||||
@ -31,7 +32,7 @@ func (d *Trainbit) GetAddition() driver.Additional {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *Trainbit) Init(ctx context.Context) error {
|
func (d *Trainbit) Init(ctx context.Context) error {
|
||||||
http.DefaultClient.CheckRedirect = func(req *http.Request, via []*http.Request) error {
|
base.HttpClient.CheckRedirect = func(req *http.Request, via []*http.Request) error {
|
||||||
return http.ErrUseLastResponse
|
return http.ErrUseLastResponse
|
||||||
}
|
}
|
||||||
var err error
|
var err error
|
||||||
@ -119,7 +120,7 @@ func (d *Trainbit) Put(ctx context.Context, dstDir model.Obj, stream model.FileS
|
|||||||
query := &url.Values{}
|
query := &url.Values{}
|
||||||
query.Add("q", strings.Split(dstDir.GetID(), "_")[1])
|
query.Add("q", strings.Split(dstDir.GetID(), "_")[1])
|
||||||
query.Add("guid", guid)
|
query.Add("guid", guid)
|
||||||
query.Add("name", url.QueryEscape(local2provider(stream.GetName(), false) + "."))
|
query.Add("name", url.QueryEscape(local2provider(stream.GetName(), false)+"."))
|
||||||
endpoint.RawQuery = query.Encode()
|
endpoint.RawQuery = query.Encode()
|
||||||
var total int64
|
var total int64
|
||||||
total = 0
|
total = 0
|
||||||
@ -135,7 +136,7 @@ func (d *Trainbit) Put(ctx context.Context, dstDir model.Obj, stream model.FileS
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
req.Header.Set("Content-Type", "text/json; charset=UTF-8")
|
req.Header.Set("Content-Type", "text/json; charset=UTF-8")
|
||||||
_, err = http.DefaultClient.Do(req)
|
_, err = base.HttpClient.Do(req)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/alist-org/alist/v3/drivers/base"
|
||||||
"github.com/alist-org/alist/v3/internal/model"
|
"github.com/alist-org/alist/v3/internal/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -38,7 +39,7 @@ func get(url string, apiKey string, AUSHELLPORTAL string) (*http.Response, error
|
|||||||
Value: apiKey,
|
Value: apiKey,
|
||||||
MaxAge: 2 * 60,
|
MaxAge: 2 * 60,
|
||||||
})
|
})
|
||||||
res, err := http.DefaultClient.Do(req)
|
res, err := base.HttpClient.Do(req)
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,7 +66,7 @@ func postForm(endpoint string, data url.Values, apiExpiredate string, apiKey str
|
|||||||
Value: apiKey,
|
Value: apiKey,
|
||||||
MaxAge: 2 * 60,
|
MaxAge: 2 * 60,
|
||||||
})
|
})
|
||||||
res, err := http.DefaultClient.Do(req)
|
res, err := base.HttpClient.Do(req)
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,19 +78,19 @@ func (d *WebDav) MakeDir(ctx context.Context, parentDir model.Obj, dirName strin
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *WebDav) Move(ctx context.Context, srcObj, dstDir model.Obj) error {
|
func (d *WebDav) Move(ctx context.Context, srcObj, dstDir model.Obj) error {
|
||||||
return d.client.Rename(srcObj.GetPath(), path.Join(dstDir.GetPath(), srcObj.GetName()), true)
|
return d.client.Rename(getPath(srcObj), path.Join(dstDir.GetPath(), srcObj.GetName()), true)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *WebDav) Rename(ctx context.Context, srcObj model.Obj, newName string) error {
|
func (d *WebDav) Rename(ctx context.Context, srcObj model.Obj, newName string) error {
|
||||||
return d.client.Rename(srcObj.GetPath(), path.Join(path.Dir(srcObj.GetPath()), newName), true)
|
return d.client.Rename(getPath(srcObj), path.Join(path.Dir(srcObj.GetPath()), newName), true)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *WebDav) Copy(ctx context.Context, srcObj, dstDir model.Obj) error {
|
func (d *WebDav) Copy(ctx context.Context, srcObj, dstDir model.Obj) error {
|
||||||
return d.client.Copy(srcObj.GetPath(), path.Join(dstDir.GetPath(), srcObj.GetName()), true)
|
return d.client.Copy(getPath(srcObj), path.Join(dstDir.GetPath(), srcObj.GetName()), true)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *WebDav) Remove(ctx context.Context, obj model.Obj) error {
|
func (d *WebDav) Remove(ctx context.Context, obj model.Obj) error {
|
||||||
return d.client.RemoveAll(obj.GetPath())
|
return d.client.RemoveAll(getPath(obj))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *WebDav) Put(ctx context.Context, dstDir model.Obj, stream model.FileStreamer, up driver.UpdateProgress) error {
|
func (d *WebDav) Put(ctx context.Context, dstDir model.Obj, stream model.FileStreamer, up driver.UpdateProgress) error {
|
||||||
|
@ -12,6 +12,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/alist-org/alist/v3/drivers/base"
|
||||||
"golang.org/x/net/publicsuffix"
|
"golang.org/x/net/publicsuffix"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -185,7 +186,7 @@ func (ca *CookieAuth) getSPToken() (*SuccessResponse, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
client := &http.Client{}
|
client := base.HttpClient
|
||||||
resp, err := client.Do(req)
|
resp, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/alist-org/alist/v3/drivers/webdav/odrvcookie"
|
"github.com/alist-org/alist/v3/drivers/webdav/odrvcookie"
|
||||||
|
"github.com/alist-org/alist/v3/internal/model"
|
||||||
"github.com/alist-org/alist/v3/pkg/gowebdav"
|
"github.com/alist-org/alist/v3/pkg/gowebdav"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -29,3 +30,10 @@ func (d *WebDav) setClient() error {
|
|||||||
d.client = c
|
d.client = c
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getPath(obj model.Obj) string {
|
||||||
|
if obj.IsDir() {
|
||||||
|
return obj.GetPath() + "/"
|
||||||
|
}
|
||||||
|
return obj.GetPath()
|
||||||
|
}
|
||||||
|
45
go.mod
45
go.mod
@ -5,8 +5,9 @@ go 1.20
|
|||||||
require (
|
require (
|
||||||
github.com/SheltonZhu/115driver v1.0.14
|
github.com/SheltonZhu/115driver v1.0.14
|
||||||
github.com/Xhofe/go-cache v0.0.0-20220723083548-714439c8af9a
|
github.com/Xhofe/go-cache v0.0.0-20220723083548-714439c8af9a
|
||||||
github.com/aws/aws-sdk-go v1.44.194
|
github.com/avast/retry-go v3.0.0+incompatible
|
||||||
github.com/blevesearch/bleve/v2 v2.3.7
|
github.com/aws/aws-sdk-go v1.44.262
|
||||||
|
github.com/blevesearch/bleve/v2 v2.3.8
|
||||||
github.com/caarlos0/env/v7 v7.1.0
|
github.com/caarlos0/env/v7 v7.1.0
|
||||||
github.com/deckarep/golang-set/v2 v2.3.0
|
github.com/deckarep/golang-set/v2 v2.3.0
|
||||||
github.com/disintegration/imaging v1.6.2
|
github.com/disintegration/imaging v1.6.2
|
||||||
@ -18,6 +19,7 @@ require (
|
|||||||
github.com/google/uuid v1.3.0
|
github.com/google/uuid v1.3.0
|
||||||
github.com/gorilla/websocket v1.5.0
|
github.com/gorilla/websocket v1.5.0
|
||||||
github.com/hirochachacha/go-smb2 v1.1.0
|
github.com/hirochachacha/go-smb2 v1.1.0
|
||||||
|
github.com/ipfs/go-ipfs-api v0.6.0
|
||||||
github.com/jlaffaye/ftp v0.1.0
|
github.com/jlaffaye/ftp v0.1.0
|
||||||
github.com/json-iterator/go v1.1.12
|
github.com/json-iterator/go v1.1.12
|
||||||
github.com/maruel/natural v1.1.0
|
github.com/maruel/natural v1.1.0
|
||||||
@ -25,15 +27,15 @@ require (
|
|||||||
github.com/pkg/errors v0.9.1
|
github.com/pkg/errors v0.9.1
|
||||||
github.com/pkg/sftp v1.13.5
|
github.com/pkg/sftp v1.13.5
|
||||||
github.com/pquerna/otp v1.4.0
|
github.com/pquerna/otp v1.4.0
|
||||||
github.com/sirupsen/logrus v1.9.0
|
github.com/sirupsen/logrus v1.9.2
|
||||||
github.com/spf13/cobra v1.7.0
|
github.com/spf13/cobra v1.7.0
|
||||||
github.com/t3rm1n4l/go-mega v0.0.0-20230228171823-a01a2cda13ca
|
github.com/t3rm1n4l/go-mega v0.0.0-20230228171823-a01a2cda13ca
|
||||||
github.com/u2takey/ffmpeg-go v0.4.1
|
github.com/u2takey/ffmpeg-go v0.4.1
|
||||||
github.com/upyun/go-sdk/v3 v3.0.4
|
github.com/upyun/go-sdk/v3 v3.0.4
|
||||||
github.com/winfsp/cgofuse v1.5.0
|
github.com/winfsp/cgofuse v1.5.0
|
||||||
golang.org/x/crypto v0.8.0
|
golang.org/x/crypto v0.9.0
|
||||||
golang.org/x/image v0.7.0
|
golang.org/x/image v0.7.0
|
||||||
golang.org/x/net v0.9.0
|
golang.org/x/net v0.10.0
|
||||||
gorm.io/driver/mysql v1.4.7
|
gorm.io/driver/mysql v1.4.7
|
||||||
gorm.io/driver/postgres v1.4.8
|
gorm.io/driver/postgres v1.4.8
|
||||||
gorm.io/driver/sqlite v1.4.4
|
gorm.io/driver/sqlite v1.4.4
|
||||||
@ -46,6 +48,7 @@ require (
|
|||||||
github.com/aead/ecdh v0.2.0 // indirect
|
github.com/aead/ecdh v0.2.0 // indirect
|
||||||
github.com/aliyun/aliyun-oss-go-sdk v2.2.5+incompatible // indirect
|
github.com/aliyun/aliyun-oss-go-sdk v2.2.5+incompatible // indirect
|
||||||
github.com/andreburgaud/crypt2go v1.1.0 // indirect
|
github.com/andreburgaud/crypt2go v1.1.0 // indirect
|
||||||
|
github.com/benbjohnson/clock v1.3.0 // indirect
|
||||||
github.com/bits-and-blooms/bitset v1.2.0 // indirect
|
github.com/bits-and-blooms/bitset v1.2.0 // indirect
|
||||||
github.com/blevesearch/bleve_index_api v1.0.5 // indirect
|
github.com/blevesearch/bleve_index_api v1.0.5 // indirect
|
||||||
github.com/blevesearch/geo v0.1.17 // indirect
|
github.com/blevesearch/geo v0.1.17 // indirect
|
||||||
@ -61,11 +64,13 @@ require (
|
|||||||
github.com/blevesearch/zapx/v12 v12.3.7 // indirect
|
github.com/blevesearch/zapx/v12 v12.3.7 // indirect
|
||||||
github.com/blevesearch/zapx/v13 v13.3.7 // indirect
|
github.com/blevesearch/zapx/v13 v13.3.7 // indirect
|
||||||
github.com/blevesearch/zapx/v14 v14.3.7 // indirect
|
github.com/blevesearch/zapx/v14 v14.3.7 // indirect
|
||||||
github.com/blevesearch/zapx/v15 v15.3.9 // indirect
|
github.com/blevesearch/zapx/v15 v15.3.10 // indirect
|
||||||
github.com/bluele/gcache v0.0.2 // indirect
|
github.com/bluele/gcache v0.0.2 // indirect
|
||||||
github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc // indirect
|
github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc // indirect
|
||||||
github.com/bytedance/sonic v1.8.0 // indirect
|
github.com/bytedance/sonic v1.8.0 // indirect
|
||||||
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
|
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
|
||||||
|
github.com/crackcomm/go-gitignore v0.0.0-20170627025303-887ab5e44cc3 // indirect
|
||||||
|
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect
|
||||||
github.com/gaoyb7/115drive-webdav v0.1.8 // indirect
|
github.com/gaoyb7/115drive-webdav v0.1.8 // indirect
|
||||||
github.com/geoffgarside/ber v1.1.0 // indirect
|
github.com/geoffgarside/ber v1.1.0 // indirect
|
||||||
github.com/gin-contrib/sse v0.1.0 // indirect
|
github.com/gin-contrib/sse v0.1.0 // indirect
|
||||||
@ -75,40 +80,58 @@ require (
|
|||||||
github.com/go-sql-driver/mysql v1.7.0 // indirect
|
github.com/go-sql-driver/mysql v1.7.0 // indirect
|
||||||
github.com/goccy/go-json v0.10.0 // indirect
|
github.com/goccy/go-json v0.10.0 // indirect
|
||||||
github.com/golang/geo v0.0.0-20210211234256-740aa86cb551 // indirect
|
github.com/golang/geo v0.0.0-20210211234256-740aa86cb551 // indirect
|
||||||
github.com/golang/protobuf v1.5.0 // indirect
|
github.com/golang/protobuf v1.5.2 // indirect
|
||||||
github.com/golang/snappy v0.0.3 // indirect
|
github.com/golang/snappy v0.0.4 // indirect
|
||||||
github.com/hashicorp/errwrap v1.1.0 // indirect
|
github.com/hashicorp/errwrap v1.1.0 // indirect
|
||||||
github.com/hashicorp/go-multierror v1.1.1 // indirect
|
github.com/hashicorp/go-multierror v1.1.1 // indirect
|
||||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||||
|
github.com/ipfs/boxo v0.8.0 // indirect
|
||||||
|
github.com/ipfs/go-cid v0.4.0 // indirect
|
||||||
github.com/jackc/pgpassfile v1.0.0 // indirect
|
github.com/jackc/pgpassfile v1.0.0 // indirect
|
||||||
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
|
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
|
||||||
github.com/jackc/pgx/v5 v5.3.0 // indirect
|
github.com/jackc/pgx/v5 v5.3.0 // indirect
|
||||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||||
github.com/jinzhu/now v1.1.5 // indirect
|
github.com/jinzhu/now v1.1.5 // indirect
|
||||||
github.com/jmespath/go-jmespath v0.4.0 // indirect
|
github.com/jmespath/go-jmespath v0.4.0 // indirect
|
||||||
github.com/klauspost/cpuid/v2 v2.0.9 // indirect
|
github.com/klauspost/cpuid/v2 v2.2.3 // indirect
|
||||||
github.com/kr/fs v0.1.0 // indirect
|
github.com/kr/fs v0.1.0 // indirect
|
||||||
github.com/leodido/go-urn v1.2.1 // indirect
|
github.com/leodido/go-urn v1.2.1 // indirect
|
||||||
|
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
|
||||||
|
github.com/libp2p/go-flow-metrics v0.1.0 // indirect
|
||||||
|
github.com/libp2p/go-libp2p v0.26.3 // indirect
|
||||||
github.com/mattn/go-isatty v0.0.17 // indirect
|
github.com/mattn/go-isatty v0.0.17 // indirect
|
||||||
github.com/mattn/go-sqlite3 v1.14.15 // indirect
|
github.com/mattn/go-sqlite3 v1.14.15 // indirect
|
||||||
|
github.com/minio/sha256-simd v1.0.0 // indirect
|
||||||
|
github.com/mitchellh/go-homedir v1.1.0 // indirect
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||||
|
github.com/mr-tron/base58 v1.2.0 // indirect
|
||||||
github.com/mschoch/smat v0.2.0 // indirect
|
github.com/mschoch/smat v0.2.0 // indirect
|
||||||
|
github.com/multiformats/go-base32 v0.1.0 // indirect
|
||||||
|
github.com/multiformats/go-base36 v0.2.0 // indirect
|
||||||
|
github.com/multiformats/go-multiaddr v0.8.0 // indirect
|
||||||
|
github.com/multiformats/go-multibase v0.1.1 // indirect
|
||||||
|
github.com/multiformats/go-multicodec v0.8.1 // indirect
|
||||||
|
github.com/multiformats/go-multihash v0.2.1 // indirect
|
||||||
|
github.com/multiformats/go-multistream v0.4.1 // indirect
|
||||||
|
github.com/multiformats/go-varint v0.0.7 // indirect
|
||||||
github.com/orzogc/fake115uploader v0.3.3-0.20221009101310-08b764073b77 // indirect
|
github.com/orzogc/fake115uploader v0.3.3-0.20221009101310-08b764073b77 // indirect
|
||||||
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
|
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
|
||||||
github.com/pierrec/lz4/v4 v4.1.17 // indirect
|
github.com/pierrec/lz4/v4 v4.1.17 // indirect
|
||||||
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e // indirect
|
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e // indirect
|
||||||
|
github.com/spaolacci/murmur3 v1.1.0 // indirect
|
||||||
github.com/spf13/pflag v1.0.5 // indirect
|
github.com/spf13/pflag v1.0.5 // indirect
|
||||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||||
github.com/u2takey/go-utils v0.3.1 // indirect
|
github.com/u2takey/go-utils v0.3.1 // indirect
|
||||||
github.com/ugorji/go/codec v1.2.9 // indirect
|
github.com/ugorji/go/codec v1.2.9 // indirect
|
||||||
|
github.com/whyrusleeping/tar-utils v0.0.0-20180509141711-8c6c8ba81d5c // indirect
|
||||||
go.etcd.io/bbolt v1.3.5 // indirect
|
go.etcd.io/bbolt v1.3.5 // indirect
|
||||||
golang.org/x/arch v0.0.0-20210923205945-b76863e36670 // indirect
|
golang.org/x/arch v0.0.0-20210923205945-b76863e36670 // indirect
|
||||||
golang.org/x/sys v0.7.0 // indirect
|
golang.org/x/sys v0.8.0 // indirect
|
||||||
golang.org/x/text v0.9.0 // indirect
|
golang.org/x/text v0.9.0 // indirect
|
||||||
golang.org/x/time v0.0.0-20220922220347-f3bd1da661af // indirect
|
golang.org/x/time v0.0.0-20220922220347-f3bd1da661af // indirect
|
||||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
|
|
||||||
google.golang.org/protobuf v1.28.1 // indirect
|
google.golang.org/protobuf v1.28.1 // indirect
|
||||||
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
|
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
|
lukechampine.com/blake3 v1.1.7 // indirect
|
||||||
)
|
)
|
||||||
|
98
go.sum
98
go.sum
@ -12,13 +12,17 @@ github.com/aliyun/aliyun-oss-go-sdk v2.2.5+incompatible h1:QoRMR0TCctLDqBCMyOu1e
|
|||||||
github.com/aliyun/aliyun-oss-go-sdk v2.2.5+incompatible/go.mod h1:T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8=
|
github.com/aliyun/aliyun-oss-go-sdk v2.2.5+incompatible/go.mod h1:T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8=
|
||||||
github.com/andreburgaud/crypt2go v1.1.0 h1:eitZxTPY1krUsxinsng3Qvt/Ud7q/aQmmYRh8p4hyPw=
|
github.com/andreburgaud/crypt2go v1.1.0 h1:eitZxTPY1krUsxinsng3Qvt/Ud7q/aQmmYRh8p4hyPw=
|
||||||
github.com/andreburgaud/crypt2go v1.1.0/go.mod h1:4qhZPzarj1dCIRmCkpdgCklwp+hBq9yEt0zPe9Ayuhc=
|
github.com/andreburgaud/crypt2go v1.1.0/go.mod h1:4qhZPzarj1dCIRmCkpdgCklwp+hBq9yEt0zPe9Ayuhc=
|
||||||
|
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.38.20/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro=
|
||||||
github.com/aws/aws-sdk-go v1.44.194 h1:1ZDK+QDcc5oRbZGgRZSz561eR8XVizXCeGpoZKo33NU=
|
github.com/aws/aws-sdk-go v1.44.262 h1:gyXpcJptWoNkK+DiAiaBltlreoWKQXjAIh6FRh60F+I=
|
||||||
github.com/aws/aws-sdk-go v1.44.194/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI=
|
github.com/aws/aws-sdk-go v1.44.262/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI=
|
||||||
|
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/bits-and-blooms/bitset v1.2.0 h1:Kn4yilvwNtMACtf1eYDlG8H77R07mZSPbMjLyS07ChA=
|
github.com/bits-and-blooms/bitset v1.2.0 h1:Kn4yilvwNtMACtf1eYDlG8H77R07mZSPbMjLyS07ChA=
|
||||||
github.com/bits-and-blooms/bitset v1.2.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA=
|
github.com/bits-and-blooms/bitset v1.2.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA=
|
||||||
github.com/blevesearch/bleve/v2 v2.3.7 h1:nIfIrhv28tvgBpbVF8Dq7/U1zW/YiwSqg/PBgE3x8bo=
|
github.com/blevesearch/bleve/v2 v2.3.8 h1:IqFyMJ73n4gY8AmVqM8Sa6EtAZ5beE8yramVqCvs2kQ=
|
||||||
github.com/blevesearch/bleve/v2 v2.3.7/go.mod h1:2tToYD6mDeseIA13jcZiEEqYrVLg6xdk0v6+F7dWquU=
|
github.com/blevesearch/bleve/v2 v2.3.8/go.mod h1:Lh9aZEHrLKxwPnW4z4lsBEGnflZQ1V/aWP/t+htsiDw=
|
||||||
github.com/blevesearch/bleve_index_api v1.0.5 h1:Lc986kpC4Z0/n1g3gg8ul7H+lxgOQPcXb9SxvQGu+tw=
|
github.com/blevesearch/bleve_index_api v1.0.5 h1:Lc986kpC4Z0/n1g3gg8ul7H+lxgOQPcXb9SxvQGu+tw=
|
||||||
github.com/blevesearch/bleve_index_api v1.0.5/go.mod h1:YXMDwaXFFXwncRS8UobWs7nvo0DmusriM1nztTlj1ms=
|
github.com/blevesearch/bleve_index_api v1.0.5/go.mod h1:YXMDwaXFFXwncRS8UobWs7nvo0DmusriM1nztTlj1ms=
|
||||||
github.com/blevesearch/geo v0.1.17 h1:AguzI6/5mHXapzB0gE9IKWo+wWPHZmXZoscHcjFgAFA=
|
github.com/blevesearch/geo v0.1.17 h1:AguzI6/5mHXapzB0gE9IKWo+wWPHZmXZoscHcjFgAFA=
|
||||||
@ -47,8 +51,8 @@ github.com/blevesearch/zapx/v13 v13.3.7 h1:igIQg5eKmjw168I7av0Vtwedf7kHnQro/M+ub
|
|||||||
github.com/blevesearch/zapx/v13 v13.3.7/go.mod h1:yyrB4kJ0OT75UPZwT/zS+Ru0/jYKorCOOSY5dBzAy+s=
|
github.com/blevesearch/zapx/v13 v13.3.7/go.mod h1:yyrB4kJ0OT75UPZwT/zS+Ru0/jYKorCOOSY5dBzAy+s=
|
||||||
github.com/blevesearch/zapx/v14 v14.3.7 h1:gfe+fbWslDWP/evHLtp/GOvmNM3sw1BbqD7LhycBX20=
|
github.com/blevesearch/zapx/v14 v14.3.7 h1:gfe+fbWslDWP/evHLtp/GOvmNM3sw1BbqD7LhycBX20=
|
||||||
github.com/blevesearch/zapx/v14 v14.3.7/go.mod h1:9J/RbOkqZ1KSjmkOes03AkETX7hrXT0sFMpWH4ewC4w=
|
github.com/blevesearch/zapx/v14 v14.3.7/go.mod h1:9J/RbOkqZ1KSjmkOes03AkETX7hrXT0sFMpWH4ewC4w=
|
||||||
github.com/blevesearch/zapx/v15 v15.3.9 h1:/s9zqKxFaZKQTTcMO2b/Tup0ch5MSztlvw+frVDfIBk=
|
github.com/blevesearch/zapx/v15 v15.3.10 h1:bQ9ZxJCj6rKp873EuVJu2JPxQ+EWQZI1cjJGeroovaQ=
|
||||||
github.com/blevesearch/zapx/v15 v15.3.9/go.mod h1:m7Y6m8soYUvS7MjN9eKlz1xrLCcmqfFadmu7GhWIrLY=
|
github.com/blevesearch/zapx/v15 v15.3.10/go.mod h1:m7Y6m8soYUvS7MjN9eKlz1xrLCcmqfFadmu7GhWIrLY=
|
||||||
github.com/bluele/gcache v0.0.2 h1:WcbfdXICg7G/DGBh1PFfcirkWOQV+v077yF1pSy3DGw=
|
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/bluele/gcache v0.0.2/go.mod h1:m15KV+ECjptwSPxKhOhQoAFQVtUFjTVkc3H8o0t/fp0=
|
||||||
github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc h1:biVzkmvwrH8WK8raXaxBx6fRVTlJILwEwQGL1I/ByEI=
|
github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc h1:biVzkmvwrH8WK8raXaxBx6fRVTlJILwEwQGL1I/ByEI=
|
||||||
@ -58,16 +62,22 @@ github.com/bytedance/sonic v1.8.0 h1:ea0Xadu+sHlu7x5O3gKhRpQ1IKiMrSiHttPF0ybECuA
|
|||||||
github.com/bytedance/sonic v1.8.0/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U=
|
github.com/bytedance/sonic v1.8.0/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U=
|
||||||
github.com/caarlos0/env/v7 v7.1.0 h1:9lzTF5amyQeWHZzuZeKlCb5FWSUxpG1js43mhbY8ozg=
|
github.com/caarlos0/env/v7 v7.1.0 h1:9lzTF5amyQeWHZzuZeKlCb5FWSUxpG1js43mhbY8ozg=
|
||||||
github.com/caarlos0/env/v7 v7.1.0/go.mod h1:LPPWniDUq4JaO6Q41vtlyikhMknqymCLBw0eX4dcH1E=
|
github.com/caarlos0/env/v7 v7.1.0/go.mod h1:LPPWniDUq4JaO6Q41vtlyikhMknqymCLBw0eX4dcH1E=
|
||||||
|
github.com/cheekybits/is v0.0.0-20150225183255-68e9c0620927 h1:SKI1/fuSdodxmNNyVBR8d7X/HuLnRpvvFO0AgyQk764=
|
||||||
github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY=
|
github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY=
|
||||||
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 h1:qSGYFH7+jGhDF8vLC+iwCD4WpbV1EBDSzWkJODFLams=
|
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 h1:qSGYFH7+jGhDF8vLC+iwCD4WpbV1EBDSzWkJODFLams=
|
||||||
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk=
|
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk=
|
||||||
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||||
|
github.com/crackcomm/go-gitignore v0.0.0-20170627025303-887ab5e44cc3 h1:HVTnpeuvF6Owjd5mniCL8DEXo7uYXdQEmOP4FJbV5tg=
|
||||||
|
github.com/crackcomm/go-gitignore v0.0.0-20170627025303-887ab5e44cc3/go.mod h1:p1d6YEZWvFzEh4KLyvBcVSnrfNDDvK2zfK/4x2v/4pE=
|
||||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/deckarep/golang-set/v2 v2.3.0 h1:qs18EKUfHm2X9fA50Mr/M5hccg2tNnVqsiBImnyDs0g=
|
github.com/deckarep/golang-set/v2 v2.3.0 h1:qs18EKUfHm2X9fA50Mr/M5hccg2tNnVqsiBImnyDs0g=
|
||||||
github.com/deckarep/golang-set/v2 v2.3.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4=
|
github.com/deckarep/golang-set/v2 v2.3.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4=
|
||||||
|
github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0=
|
||||||
|
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 h1:HbphB4TFFXpv7MNrT52FGrrgVXF1owhMVTHFZIlnvd4=
|
||||||
|
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0/go.mod h1:DZGJHZMqrU4JJqFAWUS2UO1+lbSKsdiOoYi9Zzey7Fc=
|
||||||
github.com/disintegration/imaging v1.6.2 h1:w1LecBlG2Lnp8B3jk5zSuNqd7b4DXhcjwek1ei82L+c=
|
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/disintegration/imaging v1.6.2/go.mod h1:44/5580QXChDfwIclfc/PCwrr44amcmDAg8hxG0Ewe4=
|
||||||
github.com/dustinxie/ecc v0.0.0-20210511000915-959544187564 h1:I6KUy4CI6hHjqnyJLNCEi7YHVMkwwtfSr2k9splgdSM=
|
github.com/dustinxie/ecc v0.0.0-20210511000915-959544187564 h1:I6KUy4CI6hHjqnyJLNCEi7YHVMkwwtfSr2k9splgdSM=
|
||||||
@ -109,10 +119,11 @@ github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOW
|
|||||||
github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
|
github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
|
||||||
github.com/golang/geo v0.0.0-20210211234256-740aa86cb551 h1:gtexQ/VGyN+VVFRXSFiguSNcXmS6rkKT+X7FdIrTtfo=
|
github.com/golang/geo v0.0.0-20210211234256-740aa86cb551 h1:gtexQ/VGyN+VVFRXSFiguSNcXmS6rkKT+X7FdIrTtfo=
|
||||||
github.com/golang/geo v0.0.0-20210211234256-740aa86cb551/go.mod h1:QZ0nwyI2jOfgRAoBvP+ab5aRr7c9x7lhGEJrKvBwjWI=
|
github.com/golang/geo v0.0.0-20210211234256-740aa86cb551/go.mod h1:QZ0nwyI2jOfgRAoBvP+ab5aRr7c9x7lhGEJrKvBwjWI=
|
||||||
github.com/golang/protobuf v1.5.0 h1:LUVKkCeviFUMKqHa4tXIIij/lbhnMbP7Fn5wKdKkRh4=
|
|
||||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||||
github.com/golang/snappy v0.0.3 h1:fHPg5GQYlCeLIPB9BZqMVR5nR9A+IM5zcgeTdjMYmLA=
|
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
|
||||||
github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||||
|
github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
|
||||||
|
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||||
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
|
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
|
||||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||||
@ -131,6 +142,12 @@ github.com/hirochachacha/go-smb2 v1.1.0 h1:b6hs9qKIql9eVXAiN0M2wSFY5xnhbHAQoCwRK
|
|||||||
github.com/hirochachacha/go-smb2 v1.1.0/go.mod h1:8F1A4d5EZzrGu5R7PU163UcMRDJQl4FtcxjBfsY8TZE=
|
github.com/hirochachacha/go-smb2 v1.1.0/go.mod h1:8F1A4d5EZzrGu5R7PU163UcMRDJQl4FtcxjBfsY8TZE=
|
||||||
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
|
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
|
||||||
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
||||||
|
github.com/ipfs/boxo v0.8.0 h1:UdjAJmHzQHo/j3g3b1bAcAXCj/GM6iTwvSlBDvPBNBs=
|
||||||
|
github.com/ipfs/boxo v0.8.0/go.mod h1:RIsi4CnTyQ7AUsNn5gXljJYZlQrHBMnJp94p73liFiA=
|
||||||
|
github.com/ipfs/go-cid v0.4.0 h1:a4pdZq0sx6ZSxbCizebnKiMCx/xI/aBBFlB73IgH4rA=
|
||||||
|
github.com/ipfs/go-cid v0.4.0/go.mod h1:uQHwDeX4c6CtyrFwdqyhpNcxVewur1M7l7fNU7LKwZk=
|
||||||
|
github.com/ipfs/go-ipfs-api v0.6.0 h1:JARgG0VTbjyVhO5ZfesnbXv9wTcMvoKRBLF1SzJqzmg=
|
||||||
|
github.com/ipfs/go-ipfs-api v0.6.0/go.mod h1:iDC2VMwN9LUpQV/GzEeZ2zNqd8NUdRmWcFM+K/6odf0=
|
||||||
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
|
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
|
||||||
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
|
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
|
||||||
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk=
|
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk=
|
||||||
@ -154,8 +171,10 @@ github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnr
|
|||||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||||
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
|
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
|
||||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||||
github.com/klauspost/cpuid/v2 v2.0.9 h1:lgaqFMSdTdQYdZ04uHyN2d/eKdOMyi2YLSvlQIBFYa4=
|
github.com/klauspost/cpuid/v2 v2.0.4/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
||||||
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
||||||
|
github.com/klauspost/cpuid/v2 v2.2.3 h1:sxCkb+qR91z4vsqw4vGGZlDgPz3G7gjaLyK3V8y70BU=
|
||||||
|
github.com/klauspost/cpuid/v2 v2.2.3/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY=
|
||||||
github.com/kr/fs v0.1.0 h1:Jskdu9ieNAYnjxsi0LbQp1ulIKZV1LAFgK1tWhpZgl8=
|
github.com/kr/fs v0.1.0 h1:Jskdu9ieNAYnjxsi0LbQp1ulIKZV1LAFgK1tWhpZgl8=
|
||||||
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
|
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
|
||||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||||
@ -168,6 +187,12 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
|||||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||||
github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w=
|
github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w=
|
||||||
github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY=
|
github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY=
|
||||||
|
github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6cdF0Y8=
|
||||||
|
github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg=
|
||||||
|
github.com/libp2p/go-flow-metrics v0.1.0 h1:0iPhMI8PskQwzh57jB9WxIuIOQ0r+15PChFGkx3Q3WM=
|
||||||
|
github.com/libp2p/go-flow-metrics v0.1.0/go.mod h1:4Xi8MX8wj5aWNDAZttg6UPmc0ZrnFNsMtpsYUClFtro=
|
||||||
|
github.com/libp2p/go-libp2p v0.26.3 h1:6g/psubqwdaBqNNoidbRKSTBEYgaOuKBhHl8Q5tO+PM=
|
||||||
|
github.com/libp2p/go-libp2p v0.26.3/go.mod h1:x75BN32YbwuY0Awm2Uix4d4KOz+/4piInkp4Wr3yOo8=
|
||||||
github.com/maruel/natural v1.1.0 h1:2z1NgP/Vae+gYrtC0VuvrTJ6U35OuyUqDdfluLqMWuQ=
|
github.com/maruel/natural v1.1.0 h1:2z1NgP/Vae+gYrtC0VuvrTJ6U35OuyUqDdfluLqMWuQ=
|
||||||
github.com/maruel/natural v1.1.0/go.mod h1:eFVhYCcUOfZFxXoDZam8Ktya72wa79fNC3lc/leA0DQ=
|
github.com/maruel/natural v1.1.0/go.mod h1:eFVhYCcUOfZFxXoDZam8Ktya72wa79fNC3lc/leA0DQ=
|
||||||
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
||||||
@ -175,6 +200,10 @@ github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPn
|
|||||||
github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||||
github.com/mattn/go-sqlite3 v1.14.15 h1:vfoHhTN1af61xCRSWzFIWzx2YskyMTwHLrExkBOjvxI=
|
github.com/mattn/go-sqlite3 v1.14.15 h1:vfoHhTN1af61xCRSWzFIWzx2YskyMTwHLrExkBOjvxI=
|
||||||
github.com/mattn/go-sqlite3 v1.14.15/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
|
github.com/mattn/go-sqlite3 v1.14.15/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
|
||||||
|
github.com/minio/sha256-simd v1.0.0 h1:v1ta+49hkWZyvaKwrQB8elexRqm6Y0aMLjCNsrYxo6g=
|
||||||
|
github.com/minio/sha256-simd v1.0.0/go.mod h1:OuYzVNI5vcoYIAmbIvHPl3N3jUzVedXbKy5RFepssQM=
|
||||||
|
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
|
||||||
|
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
@ -182,8 +211,26 @@ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lN
|
|||||||
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||||
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||||
|
github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o=
|
||||||
|
github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc=
|
||||||
github.com/mschoch/smat v0.2.0 h1:8imxQsjDm8yFEAVBe7azKmKSgzSkZXDuKkSq9374khM=
|
github.com/mschoch/smat v0.2.0 h1:8imxQsjDm8yFEAVBe7azKmKSgzSkZXDuKkSq9374khM=
|
||||||
github.com/mschoch/smat v0.2.0/go.mod h1:kc9mz7DoBKqDyiRL7VZN8KvXQMWeTaVnttLRXOlotKw=
|
github.com/mschoch/smat v0.2.0/go.mod h1:kc9mz7DoBKqDyiRL7VZN8KvXQMWeTaVnttLRXOlotKw=
|
||||||
|
github.com/multiformats/go-base32 v0.1.0 h1:pVx9xoSPqEIQG8o+UbAe7DNi51oej1NtK+aGkbLYxPE=
|
||||||
|
github.com/multiformats/go-base32 v0.1.0/go.mod h1:Kj3tFY6zNr+ABYMqeUNeGvkIC/UYgtWibDcT0rExnbI=
|
||||||
|
github.com/multiformats/go-base36 v0.2.0 h1:lFsAbNOGeKtuKozrtBsAkSVhv1p9D0/qedU9rQyccr0=
|
||||||
|
github.com/multiformats/go-base36 v0.2.0/go.mod h1:qvnKE++v+2MWCfePClUEjE78Z7P2a1UV0xHgWc0hkp4=
|
||||||
|
github.com/multiformats/go-multiaddr v0.8.0 h1:aqjksEcqK+iD/Foe1RRFsGZh8+XFiGo7FgUCZlpv3LU=
|
||||||
|
github.com/multiformats/go-multiaddr v0.8.0/go.mod h1:Fs50eBDWvZu+l3/9S6xAE7ZYj6yhxlvaVZjakWN7xRs=
|
||||||
|
github.com/multiformats/go-multibase v0.1.1 h1:3ASCDsuLX8+j4kx58qnJ4YFq/JWTJpCyDW27ztsVTOI=
|
||||||
|
github.com/multiformats/go-multibase v0.1.1/go.mod h1:ZEjHE+IsUrgp5mhlEAYjMtZwK1k4haNkcaPg9aoe1a8=
|
||||||
|
github.com/multiformats/go-multicodec v0.8.1 h1:ycepHwavHafh3grIbR1jIXnKCsFm0fqsfEOsJ8NtKE8=
|
||||||
|
github.com/multiformats/go-multicodec v0.8.1/go.mod h1:L3QTQvMIaVBkXOXXtVmYE+LI16i14xuaojr/H7Ai54k=
|
||||||
|
github.com/multiformats/go-multihash v0.2.1 h1:aem8ZT0VA2nCHHk7bPJ1BjUbHNciqZC/d16Vve9l108=
|
||||||
|
github.com/multiformats/go-multihash v0.2.1/go.mod h1:WxoMcYG85AZVQUyRyo9s4wULvW5qrI9vb2Lt6evduFc=
|
||||||
|
github.com/multiformats/go-multistream v0.4.1 h1:rFy0Iiyn3YT0asivDUIR05leAdwZq3de4741sbiSdfo=
|
||||||
|
github.com/multiformats/go-multistream v0.4.1/go.mod h1:Mz5eykRVAjJWckE2U78c6xqdtyNUEhKSM0Lwar2p77Q=
|
||||||
|
github.com/multiformats/go-varint v0.0.7 h1:sWSGR+f/eu5ABZA2ZpYKBILXTTs9JWpdEM/nEGOHFS8=
|
||||||
|
github.com/multiformats/go-varint v0.0.7/go.mod h1:r8PUYw/fD/SjBCiKOoDlGF6QawOELpZAu9eioSos/OU=
|
||||||
github.com/natefinch/lumberjack v2.0.0+incompatible h1:4QJd3OLAMgj7ph+yZTuX13Ld4UpgHp07nNdFX7mqFfM=
|
github.com/natefinch/lumberjack v2.0.0+incompatible h1:4QJd3OLAMgj7ph+yZTuX13Ld4UpgHp07nNdFX7mqFfM=
|
||||||
github.com/natefinch/lumberjack v2.0.0+incompatible/go.mod h1:Wi9p2TTF5DG5oU+6YfsmYQpsTIOm0B1VNzQg9Mw6nPk=
|
github.com/natefinch/lumberjack v2.0.0+incompatible/go.mod h1:Wi9p2TTF5DG5oU+6YfsmYQpsTIOm0B1VNzQg9Mw6nPk=
|
||||||
github.com/orzogc/fake115uploader v0.3.3-0.20221009101310-08b764073b77 h1:dg/EaaJLPIg4xn2kaZil7Ax3wfoxcFXaBwyOTlcz5AI=
|
github.com/orzogc/fake115uploader v0.3.3-0.20221009101310-08b764073b77 h1:dg/EaaJLPIg4xn2kaZil7Ax3wfoxcFXaBwyOTlcz5AI=
|
||||||
@ -209,10 +256,12 @@ github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUA
|
|||||||
github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
|
github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
|
||||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||||
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
|
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
|
||||||
github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
|
github.com/sirupsen/logrus v1.9.2 h1:oxx1eChJGI6Uks2ZC4W1zpLlVgqB8ner4EuQwV4Ik1Y=
|
||||||
github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
github.com/sirupsen/logrus v1.9.2/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
||||||
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e h1:MRM5ITcdelLK2j1vwZ3Je0FKVCfqOLp5zO6trqMLYs0=
|
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e h1:MRM5ITcdelLK2j1vwZ3Je0FKVCfqOLp5zO6trqMLYs0=
|
||||||
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e/go.mod h1:XV66xRDqSt+GTGFMVlhk3ULuV0y9ZmzeVGR4mloJI3M=
|
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e/go.mod h1:XV66xRDqSt+GTGFMVlhk3ULuV0y9ZmzeVGR4mloJI3M=
|
||||||
|
github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI=
|
||||||
|
github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
|
||||||
github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk=
|
github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk=
|
||||||
github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I=
|
github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I=
|
||||||
github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0=
|
github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0=
|
||||||
@ -230,8 +279,8 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
|
|||||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
|
github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
|
||||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||||
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
|
|
||||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||||
|
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
|
||||||
github.com/t3rm1n4l/go-mega v0.0.0-20230228171823-a01a2cda13ca h1:I9rVnNXdIkij4UvMT7OmKhH9sOIvS8iXkxfPdnn9wQA=
|
github.com/t3rm1n4l/go-mega v0.0.0-20230228171823-a01a2cda13ca h1:I9rVnNXdIkij4UvMT7OmKhH9sOIvS8iXkxfPdnn9wQA=
|
||||||
github.com/t3rm1n4l/go-mega v0.0.0-20230228171823-a01a2cda13ca/go.mod h1:suDIky6yrK07NnaBadCB4sS0CqFOvUK91lH7CR+JlDA=
|
github.com/t3rm1n4l/go-mega v0.0.0-20230228171823-a01a2cda13ca/go.mod h1:suDIky6yrK07NnaBadCB4sS0CqFOvUK91lH7CR+JlDA=
|
||||||
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
||||||
@ -247,6 +296,8 @@ github.com/ugorji/go/codec v1.2.9/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZg
|
|||||||
github.com/upyun/go-sdk/v3 v3.0.4 h1:2DCJa/Yi7/3ZybT9UCPATSzvU3wpPPxhXinNlb1Hi8Q=
|
github.com/upyun/go-sdk/v3 v3.0.4 h1:2DCJa/Yi7/3ZybT9UCPATSzvU3wpPPxhXinNlb1Hi8Q=
|
||||||
github.com/upyun/go-sdk/v3 v3.0.4/go.mod h1:P/SnuuwhrIgAVRd/ZpzDWqCsBAf/oHg7UggbAxyZa0E=
|
github.com/upyun/go-sdk/v3 v3.0.4/go.mod h1:P/SnuuwhrIgAVRd/ZpzDWqCsBAf/oHg7UggbAxyZa0E=
|
||||||
github.com/valyala/fastjson v1.6.3 h1:tAKFnnwmeMGPbwJ7IwxcTPCNr3uIzoIj3/Fh90ra4xc=
|
github.com/valyala/fastjson v1.6.3 h1:tAKFnnwmeMGPbwJ7IwxcTPCNr3uIzoIj3/Fh90ra4xc=
|
||||||
|
github.com/whyrusleeping/tar-utils v0.0.0-20180509141711-8c6c8ba81d5c h1:GGsyl0dZ2jJgVT+VvWBf/cNijrHRhkrTjkmp5wg7li0=
|
||||||
|
github.com/whyrusleeping/tar-utils v0.0.0-20180509141711-8c6c8ba81d5c/go.mod h1:xxcJeBb7SIUl/Wzkz1eVKJE/CB34YNrqX2TQI6jY9zs=
|
||||||
github.com/winfsp/cgofuse v1.5.0 h1:MsBP7Mi/LiJf/7/F3O/7HjjR009ds6KCdqXzKpZSWxI=
|
github.com/winfsp/cgofuse v1.5.0 h1:MsBP7Mi/LiJf/7/F3O/7HjjR009ds6KCdqXzKpZSWxI=
|
||||||
github.com/winfsp/cgofuse v1.5.0/go.mod h1:h3awhoUOcn2VYVKCwDaYxSLlZwnyK+A8KaDoLUp2lbU=
|
github.com/winfsp/cgofuse v1.5.0/go.mod h1:h3awhoUOcn2VYVKCwDaYxSLlZwnyK+A8KaDoLUp2lbU=
|
||||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||||
@ -265,8 +316,8 @@ golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0
|
|||||||
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/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.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw=
|
||||||
golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58=
|
golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58=
|
||||||
golang.org/x/crypto v0.8.0 h1:pd9TJtTueMTVQXzk8E2XESSMQDj/U7OUu0PqJqPXQjQ=
|
golang.org/x/crypto v0.9.0 h1:LF6fAI+IutBocDJ2OT0Q1g8plpYljMZ4+lty+dsqw3g=
|
||||||
golang.org/x/crypto v0.8.0/go.mod h1:mRqEX+O9/h5TFCrQhkgjo2yKi0yYA+9ecGkdQoHrywE=
|
golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0=
|
||||||
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||||
golang.org/x/image v0.7.0 h1:gzS29xtG1J5ybQlv0PuyfE3nmc6R4qB73m6LUUmvFuw=
|
golang.org/x/image v0.7.0 h1:gzS29xtG1J5ybQlv0PuyfE3nmc6R4qB73m6LUUmvFuw=
|
||||||
golang.org/x/image v0.7.0/go.mod h1:nd/q4ef1AKKYl/4kft7g+6UyGbdiqWqTP1ZAbRoV7Rg=
|
golang.org/x/image v0.7.0/go.mod h1:nd/q4ef1AKKYl/4kft7g+6UyGbdiqWqTP1ZAbRoV7Rg=
|
||||||
@ -281,8 +332,8 @@ golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qx
|
|||||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||||
golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco=
|
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.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||||
golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM=
|
golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M=
|
||||||
golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
|
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
|
||||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58/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.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.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
@ -300,18 +351,19 @@ golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBc
|
|||||||
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220702020025-31831981b65f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220702020025-31831981b65f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU=
|
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
|
||||||
golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
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.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.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.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||||
golang.org/x/term v0.7.0 h1:BEvjmm5fURWqcfbSKTdpkDXYBrUS1c0m8agp14W48vQ=
|
golang.org/x/term v0.8.0 h1:n5xxQn2i3PC0yLAbjTpNT85q/Kgzcr2gIoX9OrJUols=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
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.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
@ -332,9 +384,9 @@ 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.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
||||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
|
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 h1:H2TDz8ibqkAF6YGhCdN3jS9O0/s90v0rJh3X/OLHEUk=
|
||||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
|
||||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||||
|
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||||
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||||
google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w=
|
google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w=
|
||||||
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||||
@ -365,5 +417,7 @@ gorm.io/gorm v1.24.0/go.mod h1:DVrVomtaYTbqs7gB/x2uVvqnXzv0nqjB396B8cG4dBA=
|
|||||||
gorm.io/gorm v1.24.2/go.mod h1:DVrVomtaYTbqs7gB/x2uVvqnXzv0nqjB396B8cG4dBA=
|
gorm.io/gorm v1.24.2/go.mod h1:DVrVomtaYTbqs7gB/x2uVvqnXzv0nqjB396B8cG4dBA=
|
||||||
gorm.io/gorm v1.24.5 h1:g6OPREKqqlWq4kh/3MCQbZKImeB9e6Xgc4zD+JgNZGE=
|
gorm.io/gorm v1.24.5 h1:g6OPREKqqlWq4kh/3MCQbZKImeB9e6Xgc4zD+JgNZGE=
|
||||||
gorm.io/gorm v1.24.5/go.mod h1:DVrVomtaYTbqs7gB/x2uVvqnXzv0nqjB396B8cG4dBA=
|
gorm.io/gorm v1.24.5/go.mod h1:DVrVomtaYTbqs7gB/x2uVvqnXzv0nqjB396B8cG4dBA=
|
||||||
|
lukechampine.com/blake3 v1.1.7 h1:GgRMhmdsuK8+ii6UZFDL8Nb+VyMwadAgcJyfYHxG6n0=
|
||||||
|
lukechampine.com/blake3 v1.1.7/go.mod h1:tkKEOtDkNtklkXtLNEOGNq5tcV90tJiA1vAA12R78LA=
|
||||||
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
|
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
|
||||||
sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
|
sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package bootstrap
|
package bootstrap
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/tls"
|
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@ -78,9 +77,7 @@ func InitConfig() {
|
|||||||
log.Fatalf("create temp dir error: %+v", err)
|
log.Fatalf("create temp dir error: %+v", err)
|
||||||
}
|
}
|
||||||
log.Debugf("config: %+v", conf.Conf)
|
log.Debugf("config: %+v", conf.Conf)
|
||||||
if conf.Conf.TlsInsecureSkipVerify {
|
base.InitClient()
|
||||||
base.RestyClient = base.RestyClient.SetTLSClientConfig(&tls.Config{InsecureSkipVerify: true})
|
|
||||||
}
|
|
||||||
initURL()
|
initURL()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,6 +85,8 @@ func InitialSettings() []model.SettingItem {
|
|||||||
{Key: "pagination_type", Value: "all", Type: conf.TypeSelect, Options: "all,pagination,load_more,auto_load_more", Group: model.SITE},
|
{Key: "pagination_type", Value: "all", Type: conf.TypeSelect, Options: "all,pagination,load_more,auto_load_more", Group: model.SITE},
|
||||||
{Key: "default_page_size", Value: "30", Type: conf.TypeNumber, Group: model.SITE},
|
{Key: "default_page_size", Value: "30", Type: conf.TypeNumber, Group: model.SITE},
|
||||||
{Key: conf.AllowIndexed, Value: "false", Type: conf.TypeBool, Group: model.SITE},
|
{Key: conf.AllowIndexed, Value: "false", Type: conf.TypeBool, Group: model.SITE},
|
||||||
|
{Key: conf.AllowMounted, Value: "true", Type: conf.TypeBool, Group: model.SITE},
|
||||||
|
{Key: conf.RobotsTxt, Value: "User-agent: *\nAllow: /", Type: conf.TypeText, Group: model.SITE},
|
||||||
// style settings
|
// style settings
|
||||||
{Key: conf.Logo, Value: "https://cdn.jsdelivr.net/gh/alist-org/logo@main/logo.svg", Type: conf.TypeText, Group: model.STYLE},
|
{Key: conf.Logo, Value: "https://cdn.jsdelivr.net/gh/alist-org/logo@main/logo.svg", Type: conf.TypeText, Group: model.STYLE},
|
||||||
{Key: conf.Favicon, Value: "https://cdn.jsdelivr.net/gh/alist-org/logo@main/logo.svg", Type: conf.TypeString, Group: model.STYLE},
|
{Key: conf.Favicon, Value: "https://cdn.jsdelivr.net/gh/alist-org/logo@main/logo.svg", Type: conf.TypeString, Group: model.STYLE},
|
||||||
|
@ -14,6 +14,8 @@ const (
|
|||||||
SiteTitle = "site_title"
|
SiteTitle = "site_title"
|
||||||
Announcement = "announcement"
|
Announcement = "announcement"
|
||||||
AllowIndexed = "allow_indexed"
|
AllowIndexed = "allow_indexed"
|
||||||
|
AllowMounted = "allow_mounted"
|
||||||
|
RobotsTxt = "robots_txt"
|
||||||
|
|
||||||
Logo = "logo"
|
Logo = "logo"
|
||||||
Favicon = "favicon"
|
Favicon = "favicon"
|
||||||
|
@ -3,6 +3,7 @@ package fs
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/http"
|
||||||
stdpath "path"
|
stdpath "path"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
|
||||||
@ -87,7 +88,9 @@ func copyFileBetween2Storages(tsk *task.Task[uint64], srcStorage, dstStorage dri
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithMessagef(err, "failed get src [%s] file", srcFilePath)
|
return errors.WithMessagef(err, "failed get src [%s] file", srcFilePath)
|
||||||
}
|
}
|
||||||
link, _, err := op.Link(tsk.Ctx, srcStorage, srcFilePath, model.LinkArgs{})
|
link, _, err := op.Link(tsk.Ctx, srcStorage, srcFilePath, model.LinkArgs{
|
||||||
|
Header: http.Header{},
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithMessagef(err, "failed get [%s] link", srcFilePath)
|
return errors.WithMessagef(err, "failed get [%s] link", srcFilePath)
|
||||||
}
|
}
|
||||||
|
@ -12,8 +12,8 @@ import (
|
|||||||
|
|
||||||
// List files
|
// List files
|
||||||
func list(ctx context.Context, path string, args *ListArgs) ([]model.Obj, error) {
|
func list(ctx context.Context, path string, args *ListArgs) ([]model.Obj, error) {
|
||||||
meta := ctx.Value("meta").(*model.Meta)
|
meta, _ := ctx.Value("meta").(*model.Meta)
|
||||||
user := ctx.Value("user").(*model.User)
|
user, _ := ctx.Value("user").(*model.User)
|
||||||
virtualFiles := op.GetStorageVirtualFilesByPath(path)
|
virtualFiles := op.GetStorageVirtualFilesByPath(path)
|
||||||
storage, actualPath, err := op.GetStorageAndActualPath(path)
|
storage, actualPath, err := op.GetStorageAndActualPath(path)
|
||||||
if err != nil && len(virtualFiles) == 0 {
|
if err != nil && len(virtualFiles) == 0 {
|
||||||
@ -45,7 +45,7 @@ func list(ctx context.Context, path string, args *ListArgs) ([]model.Obj, error)
|
|||||||
|
|
||||||
func whetherHide(user *model.User, meta *model.Meta, path string) bool {
|
func whetherHide(user *model.User, meta *model.Meta, path string) bool {
|
||||||
// if is admin, don't hide
|
// if is admin, don't hide
|
||||||
if user.CanSeeHides() {
|
if user == nil || user.CanSeeHides() {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
// if meta is nil, don't hide
|
// if meta is nil, don't hide
|
||||||
|
@ -10,31 +10,13 @@ import (
|
|||||||
|
|
||||||
"github.com/alist-org/alist/v3/internal/conf"
|
"github.com/alist-org/alist/v3/internal/conf"
|
||||||
"github.com/alist-org/alist/v3/internal/model"
|
"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/alist-org/alist/v3/pkg/utils"
|
||||||
|
"github.com/alist-org/alist/v3/server/common"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
func ClearCache(path string) {
|
|
||||||
storage, actualPath, err := op.GetStorageAndActualPath(path)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
op.ClearCache(storage, actualPath)
|
|
||||||
}
|
|
||||||
|
|
||||||
func containsByName(files []model.Obj, file model.Obj) bool {
|
|
||||||
for _, f := range files {
|
|
||||||
if f.GetName() == file.GetName() {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
var httpClient = &http.Client{}
|
|
||||||
|
|
||||||
func getFileStreamFromLink(file model.Obj, link *model.Link) (*model.FileStream, error) {
|
func getFileStreamFromLink(file model.Obj, link *model.Link) (*model.FileStream, error) {
|
||||||
var rc io.ReadCloser
|
var rc io.ReadCloser
|
||||||
mimetype := utils.GetMimeType(file.GetName())
|
mimetype := utils.GetMimeType(file.GetName())
|
||||||
@ -52,6 +34,16 @@ func getFileStreamFromLink(file model.Obj, link *model.Link) (*model.FileStream,
|
|||||||
return nil, errors.Wrapf(err, "failed to open file %s", *link.FilePath)
|
return nil, errors.Wrapf(err, "failed to open file %s", *link.FilePath)
|
||||||
}
|
}
|
||||||
rc = f
|
rc = f
|
||||||
|
} else if link.Writer != nil {
|
||||||
|
r, w := io.Pipe()
|
||||||
|
go func() {
|
||||||
|
err := link.Writer(w)
|
||||||
|
err = w.CloseWithError(err)
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("[getFileStreamFromLink] failed to write: %v", err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
rc = r
|
||||||
} else {
|
} else {
|
||||||
req, err := http.NewRequest(http.MethodGet, link.URL, nil)
|
req, err := http.NewRequest(http.MethodGet, link.URL, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -60,7 +52,7 @@ func getFileStreamFromLink(file model.Obj, link *model.Link) (*model.FileStream,
|
|||||||
for h, val := range link.Header {
|
for h, val := range link.Header {
|
||||||
req.Header[h] = val
|
req.Header[h] = val
|
||||||
}
|
}
|
||||||
res, err := httpClient.Do(req)
|
res, err := common.HttpClient().Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrapf(err, "failed to get response for %s", link.URL)
|
return nil, errors.Wrapf(err, "failed to get response for %s", link.URL)
|
||||||
}
|
}
|
||||||
|
@ -11,19 +11,21 @@ type ListArgs struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type LinkArgs struct {
|
type LinkArgs struct {
|
||||||
IP string
|
IP string
|
||||||
Header http.Header
|
Header http.Header
|
||||||
Type string
|
Type string
|
||||||
|
HttpReq *http.Request
|
||||||
}
|
}
|
||||||
|
|
||||||
type Link struct {
|
type Link struct {
|
||||||
URL string `json:"url"`
|
URL string `json:"url"`
|
||||||
Header http.Header `json:"header"` // needed header
|
Header http.Header `json:"header"` // needed header (for url) or response header(for data or writer)
|
||||||
Data io.ReadCloser // return file reader directly
|
Data io.ReadCloser // return file reader directly
|
||||||
Status int // status maybe 200 or 206, etc
|
Status int // status maybe 200 or 206, etc
|
||||||
FilePath *string // local file, return the filepath
|
FilePath *string // local file, return the filepath
|
||||||
Expiration *time.Duration // url expiration time
|
Expiration *time.Duration // url expiration time
|
||||||
Handle func(w http.ResponseWriter, r *http.Request) error // custom handler
|
//Handle func(w http.ResponseWriter, r *http.Request) error `json:"-"` // custom handler
|
||||||
|
Writer WriterFunc `json:"-"` // custom writer
|
||||||
}
|
}
|
||||||
|
|
||||||
type OtherArgs struct {
|
type OtherArgs struct {
|
||||||
@ -37,3 +39,5 @@ type FsOtherArgs struct {
|
|||||||
Method string `json:"method" form:"method"`
|
Method string `json:"method" form:"method"`
|
||||||
Data interface{} `json:"data" form:"data"`
|
Data interface{} `json:"data" form:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type WriterFunc func(w io.Writer) error
|
||||||
|
@ -63,7 +63,7 @@ func getMainItems(config driver.Config) []driver.Item {
|
|||||||
Name: "mount_path",
|
Name: "mount_path",
|
||||||
Type: conf.TypeString,
|
Type: conf.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
Help: "",
|
Help: "The path you want to mount to, it is unique and cannot be repeated",
|
||||||
}, {
|
}, {
|
||||||
Name: "order",
|
Name: "order",
|
||||||
Type: conf.TypeNumber,
|
Type: conf.TypeNumber,
|
||||||
|
@ -12,7 +12,7 @@ import (
|
|||||||
func (c *Client) req(method, path string, body io.Reader, intercept func(*http.Request)) (req *http.Response, err error) {
|
func (c *Client) req(method, path string, body io.Reader, intercept func(*http.Request)) (req *http.Response, err error) {
|
||||||
var r *http.Request
|
var r *http.Request
|
||||||
var retryBuf io.Reader
|
var retryBuf io.Reader
|
||||||
|
canRetry := true
|
||||||
if body != nil {
|
if body != nil {
|
||||||
// If the authorization fails, we will need to restart reading
|
// If the authorization fails, we will need to restart reading
|
||||||
// from the passed body stream.
|
// from the passed body stream.
|
||||||
@ -25,6 +25,8 @@ func (c *Client) req(method, path string, body io.Reader, intercept func(*http.R
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
retryBuf = body
|
retryBuf = body
|
||||||
|
} else if method == http.MethodPut {
|
||||||
|
canRetry = false
|
||||||
} else {
|
} else {
|
||||||
buff := &bytes.Buffer{}
|
buff := &bytes.Buffer{}
|
||||||
retryBuf = buff
|
retryBuf = buff
|
||||||
@ -83,7 +85,9 @@ func (c *Client) req(method, path string, body io.Reader, intercept func(*http.R
|
|||||||
|
|
||||||
// retryBuf will be nil if body was nil initially so no check
|
// retryBuf will be nil if body was nil initially so no check
|
||||||
// for body == nil is required here.
|
// for body == nil is required here.
|
||||||
return c.req(method, path, retryBuf, intercept)
|
if canRetry {
|
||||||
|
return c.req(method, path, retryBuf, intercept)
|
||||||
|
}
|
||||||
} else if rs.StatusCode == 401 {
|
} else if rs.StatusCode == 401 {
|
||||||
return rs, newPathError("Authorize", c.root, rs.StatusCode)
|
return rs, newPathError("Authorize", c.root, rs.StatusCode)
|
||||||
}
|
}
|
||||||
@ -193,7 +197,7 @@ func (c *Client) copymove(method string, oldpath string, newpath string, overwri
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) put(path string, stream io.Reader, callback func(r *http.Request)) (status int, err error) {
|
func (c *Client) put(path string, stream io.Reader, callback func(r *http.Request)) (status int, err error) {
|
||||||
rs, err := c.req("PUT", path, stream, callback)
|
rs, err := c.req(http.MethodPut, path, stream, callback)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
114
pkg/utils/fn_limiter.go
Normal file
114
pkg/utils/fn_limiter.go
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
package utils
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"reflect"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
func LimitRateReflect(f interface{}, interval time.Duration) func(...interface{}) []interface{} {
|
||||||
|
// Use closures to save the time of the last function call
|
||||||
|
var lastCall time.Time
|
||||||
|
|
||||||
|
fValue := reflect.ValueOf(f)
|
||||||
|
fType := fValue.Type()
|
||||||
|
|
||||||
|
if fType.Kind() != reflect.Func {
|
||||||
|
panic("f must be a function")
|
||||||
|
}
|
||||||
|
|
||||||
|
//if fType.NumOut() == 0 {
|
||||||
|
// panic("f must have at least one output parameter")
|
||||||
|
//}
|
||||||
|
|
||||||
|
outCount := fType.NumOut()
|
||||||
|
outTypes := make([]reflect.Type, outCount)
|
||||||
|
|
||||||
|
for i := 0; i < outCount; i++ {
|
||||||
|
outTypes[i] = fType.Out(i)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns a new function, which is used to limit the function to be called only once at a specified time interval
|
||||||
|
return func(args ...interface{}) []interface{} {
|
||||||
|
// Calculate the time interval since the last function call
|
||||||
|
elapsed := time.Since(lastCall)
|
||||||
|
// If the interval is less than the specified time, wait for the remaining time
|
||||||
|
if elapsed < interval {
|
||||||
|
time.Sleep(interval - elapsed)
|
||||||
|
}
|
||||||
|
// Update the time of the last function call
|
||||||
|
lastCall = time.Now()
|
||||||
|
|
||||||
|
inCount := fType.NumIn()
|
||||||
|
in := make([]reflect.Value, inCount)
|
||||||
|
|
||||||
|
if len(args) != inCount {
|
||||||
|
panic("wrong number of arguments")
|
||||||
|
}
|
||||||
|
|
||||||
|
for i := 0; i < inCount; i++ {
|
||||||
|
in[i] = reflect.ValueOf(args[i])
|
||||||
|
}
|
||||||
|
|
||||||
|
out := fValue.Call(in)
|
||||||
|
|
||||||
|
if len(out) != outCount {
|
||||||
|
panic("function returned wrong number of values")
|
||||||
|
}
|
||||||
|
|
||||||
|
result := make([]interface{}, outCount)
|
||||||
|
|
||||||
|
for i := 0; i < outCount; i++ {
|
||||||
|
result[i] = out[i].Interface()
|
||||||
|
}
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type Fn[T any, R any] func(T) (R, error)
|
||||||
|
type FnCtx[T any, R any] func(context.Context, T) (R, error)
|
||||||
|
|
||||||
|
func LimitRate[T any, R any](f Fn[T, R], interval time.Duration) Fn[T, R] {
|
||||||
|
// Use closures to save the time of the last function call
|
||||||
|
var lastCall time.Time
|
||||||
|
// Returns a new function, which is used to limit the function to be called only once at a specified time interval
|
||||||
|
return func(t T) (R, error) {
|
||||||
|
// Calculate the time interval since the last function call
|
||||||
|
elapsed := time.Since(lastCall)
|
||||||
|
// If the interval is less than the specified time, wait for the remaining time
|
||||||
|
if elapsed < interval {
|
||||||
|
time.Sleep(interval - elapsed)
|
||||||
|
}
|
||||||
|
// Update the time of the last function call
|
||||||
|
lastCall = time.Now()
|
||||||
|
// Execute the function that needs to be limited
|
||||||
|
return f(t)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func LimitRateCtx[T any, R any](f FnCtx[T, R], interval time.Duration) FnCtx[T, R] {
|
||||||
|
// Use closures to save the time of the last function call
|
||||||
|
var lastCall time.Time
|
||||||
|
// Returns a new function, which is used to limit the function to be called only once at a specified time interval
|
||||||
|
return func(ctx context.Context, t T) (R, error) {
|
||||||
|
// Calculate the time interval since the last function call
|
||||||
|
elapsed := time.Since(lastCall)
|
||||||
|
// If the interval is less than the specified time, wait for the remaining time
|
||||||
|
if elapsed < interval {
|
||||||
|
t := time.NewTimer(interval - elapsed)
|
||||||
|
select {
|
||||||
|
case <-ctx.Done():
|
||||||
|
t.Stop()
|
||||||
|
var zero R
|
||||||
|
return zero, ctx.Err()
|
||||||
|
case <-t.C:
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Update the time of the last function call
|
||||||
|
lastCall = time.Now()
|
||||||
|
// Execute the function that needs to be limited
|
||||||
|
return f(ctx, t)
|
||||||
|
}
|
||||||
|
}
|
59
pkg/utils/fn_limiter_test.go
Normal file
59
pkg/utils/fn_limiter_test.go
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
package utils_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/alist-org/alist/v3/pkg/utils"
|
||||||
|
)
|
||||||
|
|
||||||
|
func myFunction(a int) (int, error) {
|
||||||
|
// do something
|
||||||
|
return a + 1, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestLimitRate(t *testing.T) {
|
||||||
|
myLimitedFunction := utils.LimitRate(myFunction, time.Second)
|
||||||
|
result, _ := myLimitedFunction(1)
|
||||||
|
t.Log(result) // Output: 2
|
||||||
|
result, _ = myLimitedFunction(2)
|
||||||
|
t.Log(result) // Output: 3
|
||||||
|
}
|
||||||
|
|
||||||
|
type Test struct {
|
||||||
|
limitFn func(string) (string, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *Test) myFunction(a string) (string, error) {
|
||||||
|
// do something
|
||||||
|
return a + " world", nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestLimitRateStruct(t *testing.T) {
|
||||||
|
test := &Test{}
|
||||||
|
test.limitFn = utils.LimitRate(test.myFunction, time.Second)
|
||||||
|
result, _ := test.limitFn("hello")
|
||||||
|
t.Log(result) // Output: hello world
|
||||||
|
result, _ = test.limitFn("hi")
|
||||||
|
t.Log(result) // Output: hi world
|
||||||
|
}
|
||||||
|
|
||||||
|
func myFunctionCtx(ctx context.Context, a int) (int, error) {
|
||||||
|
// do something
|
||||||
|
return a + 1, nil
|
||||||
|
}
|
||||||
|
func TestLimitRateCtx(t *testing.T) {
|
||||||
|
myLimitedFunction := utils.LimitRateCtx(myFunctionCtx, time.Second)
|
||||||
|
result, _ := myLimitedFunction(context.Background(), 1)
|
||||||
|
t.Log(result) // Output: 2
|
||||||
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
go func() {
|
||||||
|
time.Sleep(500 * time.Millisecond)
|
||||||
|
cancel()
|
||||||
|
}()
|
||||||
|
result, err := myLimitedFunction(ctx, 2)
|
||||||
|
t.Log(result, err) // Output: 0 context canceled
|
||||||
|
result, _ = myLimitedFunction(context.Background(), 3)
|
||||||
|
t.Log(result) // Output: 4
|
||||||
|
}
|
@ -8,7 +8,9 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
|
|
||||||
|
"github.com/alist-org/alist/v3/drivers/base"
|
||||||
"github.com/alist-org/alist/v3/internal/conf"
|
"github.com/alist-org/alist/v3/internal/conf"
|
||||||
"github.com/alist-org/alist/v3/internal/model"
|
"github.com/alist-org/alist/v3/internal/model"
|
||||||
"github.com/alist-org/alist/v3/pkg/utils"
|
"github.com/alist-org/alist/v3/pkg/utils"
|
||||||
@ -16,16 +18,23 @@ import (
|
|||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
var HttpClient = &http.Client{
|
func HttpClient() *http.Client {
|
||||||
CheckRedirect: func(req *http.Request, via []*http.Request) error {
|
once.Do(func() {
|
||||||
if len(via) >= 10 {
|
httpClient = base.NewHttpClient()
|
||||||
return errors.New("stopped after 10 redirects")
|
httpClient.CheckRedirect = func(req *http.Request, via []*http.Request) error {
|
||||||
|
if len(via) >= 10 {
|
||||||
|
return errors.New("stopped after 10 redirects")
|
||||||
|
}
|
||||||
|
req.Header.Del("Referer")
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
req.Header.Del("Referer")
|
})
|
||||||
return nil
|
return httpClient
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var once sync.Once
|
||||||
|
var httpClient *http.Client
|
||||||
|
|
||||||
func Proxy(w http.ResponseWriter, r *http.Request, link *model.Link, file model.Obj) error {
|
func Proxy(w http.ResponseWriter, r *http.Request, link *model.Link, file model.Obj) error {
|
||||||
// read data with native
|
// read data with native
|
||||||
var err error
|
var err error
|
||||||
@ -72,8 +81,21 @@ func Proxy(w http.ResponseWriter, r *http.Request, link *model.Link, file model.
|
|||||||
w.Header().Set("Content-Disposition", fmt.Sprintf(`attachment; filename="%s"; filename*=UTF-8''%s`, filename, url.PathEscape(filename)))
|
w.Header().Set("Content-Disposition", fmt.Sprintf(`attachment; filename="%s"; filename*=UTF-8''%s`, filename, url.PathEscape(filename)))
|
||||||
http.ServeContent(w, r, file.GetName(), fileStat.ModTime(), f)
|
http.ServeContent(w, r, file.GetName(), fileStat.ModTime(), f)
|
||||||
return nil
|
return nil
|
||||||
} else if link.Handle != nil {
|
} else if link.Writer != nil {
|
||||||
return link.Handle(w, r)
|
if link.Header != nil {
|
||||||
|
for h, v := range link.Header {
|
||||||
|
w.Header()[h] = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if cd := w.Header().Get("Content-Disposition"); cd == "" {
|
||||||
|
w.Header().Set("Content-Disposition", fmt.Sprintf(`attachment; filename="%s"; filename*=UTF-8''%s`, file.GetName(), url.PathEscape(file.GetName())))
|
||||||
|
}
|
||||||
|
if link.Status == 0 {
|
||||||
|
w.WriteHeader(http.StatusOK)
|
||||||
|
} else {
|
||||||
|
w.WriteHeader(link.Status)
|
||||||
|
}
|
||||||
|
return link.Writer(w)
|
||||||
} else {
|
} else {
|
||||||
req, err := http.NewRequest(r.Method, link.URL, nil)
|
req, err := http.NewRequest(r.Method, link.URL, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -90,7 +112,7 @@ func Proxy(w http.ResponseWriter, r *http.Request, link *model.Link, file model.
|
|||||||
for h, val := range link.Header {
|
for h, val := range link.Header {
|
||||||
req.Header[h] = val
|
req.Header[h] = val
|
||||||
}
|
}
|
||||||
res, err := HttpClient.Do(req)
|
res, err := HttpClient().Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -31,9 +31,10 @@ func Down(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
link, _, err := fs.Link(c, rawPath, model.LinkArgs{
|
link, _, err := fs.Link(c, rawPath, model.LinkArgs{
|
||||||
IP: c.ClientIP(),
|
IP: c.ClientIP(),
|
||||||
Header: c.Request.Header,
|
Header: c.Request.Header,
|
||||||
Type: c.Query("type"),
|
Type: c.Query("type"),
|
||||||
|
HttpReq: c.Request,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
common.ErrorResp(c, err, 500)
|
common.ErrorResp(c, err, 500)
|
||||||
@ -84,8 +85,9 @@ func Proxy(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
link, file, err := fs.Link(c, rawPath, model.LinkArgs{
|
link, file, err := fs.Link(c, rawPath, model.LinkArgs{
|
||||||
Header: c.Request.Header,
|
Header: c.Request.Header,
|
||||||
Type: c.Query("type"),
|
Type: c.Query("type"),
|
||||||
|
HttpReq: c.Request,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
common.ErrorResp(c, err, 500)
|
common.ErrorResp(c, err, 500)
|
||||||
|
@ -476,7 +476,7 @@ func Link(c *gin.Context) {
|
|||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
link, _, err := fs.Link(c, rawPath, model.LinkArgs{IP: c.ClientIP()})
|
link, _, err := fs.Link(c, rawPath, model.LinkArgs{IP: c.ClientIP(), Header: c.Request.Header, HttpReq: c.Request})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
common.ErrorResp(c, err, 500)
|
common.ErrorResp(c, err, 500)
|
||||||
return
|
return
|
||||||
|
@ -286,7 +286,11 @@ func FsGet(c *gin.Context) {
|
|||||||
rawURL = url
|
rawURL = url
|
||||||
} else {
|
} else {
|
||||||
// if storage is not proxy, use raw url by fs.Link
|
// if storage is not proxy, use raw url by fs.Link
|
||||||
link, _, err := fs.Link(c, reqPath, model.LinkArgs{IP: c.ClientIP(), Header: c.Request.Header})
|
link, _, err := fs.Link(c, reqPath, model.LinkArgs{
|
||||||
|
IP: c.ClientIP(),
|
||||||
|
Header: c.Request.Header,
|
||||||
|
HttpReq: c.Request,
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
common.ErrorResp(c, err, 500)
|
common.ErrorResp(c, err, 500)
|
||||||
return
|
return
|
||||||
|
@ -16,6 +16,10 @@ func Favicon(c *gin.Context) {
|
|||||||
c.Redirect(302, setting.GetStr(conf.Favicon))
|
c.Redirect(302, setting.GetStr(conf.Favicon))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Robots(c *gin.Context) {
|
||||||
|
c.String(200, setting.GetStr(conf.RobotsTxt))
|
||||||
|
}
|
||||||
|
|
||||||
func Plist(c *gin.Context) {
|
func Plist(c *gin.Context) {
|
||||||
linkNameB64 := strings.TrimSuffix(c.Param("link_name"), ".plist")
|
linkNameB64 := strings.TrimSuffix(c.Param("link_name"), ".plist")
|
||||||
linkName, err := utils.SafeAtob(linkNameB64)
|
linkName, err := utils.SafeAtob(linkNameB64)
|
||||||
|
@ -51,7 +51,7 @@ func SSOLoginRedirect(c *gin.Context) {
|
|||||||
case "Casdoor":
|
case "Casdoor":
|
||||||
endpoint := strings.TrimSuffix(setting.GetStr(conf.SSOEndpointName), "/")
|
endpoint := strings.TrimSuffix(setting.GetStr(conf.SSOEndpointName), "/")
|
||||||
r_url = endpoint + "/login/oauth/authorize?"
|
r_url = endpoint + "/login/oauth/authorize?"
|
||||||
urlValues.Add("scope", "read")
|
urlValues.Add("scope", "profile")
|
||||||
urlValues.Add("state", endpoint)
|
urlValues.Add("state", endpoint)
|
||||||
default:
|
default:
|
||||||
common.ErrorStrResp(c, "invalid platform", 400)
|
common.ErrorStrResp(c, "invalid platform", 400)
|
||||||
@ -103,8 +103,11 @@ func SSOLoginCallback(c *gin.Context) {
|
|||||||
case "Casdoor":
|
case "Casdoor":
|
||||||
endpoint := strings.TrimSuffix(setting.GetStr(conf.SSOEndpointName), "/")
|
endpoint := strings.TrimSuffix(setting.GetStr(conf.SSOEndpointName), "/")
|
||||||
url1 = endpoint + "/api/login/oauth/access_token"
|
url1 = endpoint + "/api/login/oauth/access_token"
|
||||||
url2 = endpoint + "/account"
|
url2 = endpoint + "/api/userinfo"
|
||||||
|
additionalbody = "&grant_type=authorization_code"
|
||||||
|
scope = "profile"
|
||||||
authstring = "code"
|
authstring = "code"
|
||||||
|
idstring = "preferred_username"
|
||||||
default:
|
default:
|
||||||
common.ErrorStrResp(c, "invalid platform", 400)
|
common.ErrorStrResp(c, "invalid platform", 400)
|
||||||
return
|
return
|
||||||
|
@ -24,6 +24,9 @@ func Init(e *gin.Engine) {
|
|||||||
g.Any("/ping", func(c *gin.Context) {
|
g.Any("/ping", func(c *gin.Context) {
|
||||||
c.String(200, "pong")
|
c.String(200, "pong")
|
||||||
})
|
})
|
||||||
|
g.GET("/favicon.ico", handles.Favicon)
|
||||||
|
g.GET("/robots.txt", handles.Robots)
|
||||||
|
g.GET("/i/:link_name", handles.Plist)
|
||||||
common.SecretKey = []byte(conf.Conf.JwtSecret)
|
common.SecretKey = []byte(conf.Conf.JwtSecret)
|
||||||
g.Use(middlewares.StoragesLoaded)
|
g.Use(middlewares.StoragesLoaded)
|
||||||
if conf.Conf.MaxConnections > 0 {
|
if conf.Conf.MaxConnections > 0 {
|
||||||
@ -31,8 +34,6 @@ func Init(e *gin.Engine) {
|
|||||||
}
|
}
|
||||||
WebDav(g.Group("/dav"))
|
WebDav(g.Group("/dav"))
|
||||||
|
|
||||||
g.GET("/favicon.ico", handles.Favicon)
|
|
||||||
g.GET("/i/:link_name", handles.Plist)
|
|
||||||
g.GET("/d/*path", middlewares.Down, handles.Down)
|
g.GET("/d/*path", middlewares.Down, handles.Down)
|
||||||
g.GET("/p/*path", middlewares.Down, handles.Proxy)
|
g.GET("/p/*path", middlewares.Down, handles.Proxy)
|
||||||
|
|
||||||
|
@ -232,7 +232,7 @@ func (h *Handler) handleGetHeadPost(w http.ResponseWriter, r *http.Request) (sta
|
|||||||
storage, _ := fs.GetStorage(reqPath, &fs.GetStoragesArgs{})
|
storage, _ := fs.GetStorage(reqPath, &fs.GetStoragesArgs{})
|
||||||
downProxyUrl := storage.GetStorage().DownProxyUrl
|
downProxyUrl := storage.GetStorage().DownProxyUrl
|
||||||
if storage.GetStorage().WebdavNative() || (storage.GetStorage().WebdavProxy() && downProxyUrl == "") {
|
if storage.GetStorage().WebdavNative() || (storage.GetStorage().WebdavProxy() && downProxyUrl == "") {
|
||||||
link, _, err := fs.Link(ctx, reqPath, model.LinkArgs{Header: r.Header})
|
link, _, err := fs.Link(ctx, reqPath, model.LinkArgs{Header: r.Header, HttpReq: r})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return http.StatusInternalServerError, err
|
return http.StatusInternalServerError, err
|
||||||
}
|
}
|
||||||
@ -249,7 +249,7 @@ func (h *Handler) handleGetHeadPost(w http.ResponseWriter, r *http.Request) (sta
|
|||||||
w.Header().Set("Cache-Control", "max-age=0, no-cache, no-store, must-revalidate")
|
w.Header().Set("Cache-Control", "max-age=0, no-cache, no-store, must-revalidate")
|
||||||
http.Redirect(w, r, u, http.StatusFound)
|
http.Redirect(w, r, u, http.StatusFound)
|
||||||
} else {
|
} else {
|
||||||
link, _, err := fs.Link(ctx, reqPath, model.LinkArgs{IP: utils.ClientIP(r)})
|
link, _, err := fs.Link(ctx, reqPath, model.LinkArgs{IP: utils.ClientIP(r), Header: r.Header, HttpReq: r})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return http.StatusInternalServerError, err
|
return http.StatusInternalServerError, err
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user