Compare commits
102 Commits
Author | SHA1 | Date | |
---|---|---|---|
bd52df1926 | |||
ba9d568539 | |||
a66b2d92b7 | |||
0b3c5f3e2b | |||
cc74effd30 | |||
51b8b4380d | |||
5e59b0a697 | |||
1d3b86985f | |||
c711ba53a3 | |||
532a326ad6 | |||
917ad07ab7 | |||
50fd7de045 | |||
f6527f1c4c | |||
a3ef3d1416 | |||
89b05021f8 | |||
7e40acad3f | |||
eb15bce24b | |||
52814266b8 | |||
f845ec05e0 | |||
29fb02c886 | |||
072e854a71 | |||
cae0a5f603 | |||
7c6d8ca222 | |||
f6be50f15a | |||
c35d54d092 | |||
323dad2a1c | |||
62aefc4f68 | |||
6a7eb8b3eb | |||
eb549f2631 | |||
9207eb69ee | |||
866df0540b | |||
04e04a1aa6 | |||
6a66e39d5b | |||
f2b2728be7 | |||
39b8f28fc4 | |||
e1ccc0b215 | |||
87e339850d | |||
79c9b6ac77 | |||
aeb2297f1f | |||
3b59bb5c09 | |||
bc4bac921f | |||
f917882a84 | |||
6a67d1cf69 | |||
041b3587bf | |||
0eef7a129c | |||
4b635f06e3 | |||
279111a8e2 | |||
67674835da | |||
732e9eb1c3 | |||
b6af9aa587 | |||
a9027c0f06 | |||
d780fa18a5 | |||
d5626d6e2f | |||
52dcbfe1a4 | |||
bf0ee3d315 | |||
0237e78c1e | |||
44b8c6abf7 | |||
33e1acd344 | |||
c54cb61f14 | |||
734b204709 | |||
b7d9c5e4ff | |||
e698b457b9 | |||
5258c21656 | |||
1ca9a3d14e | |||
f23bec9a35 | |||
62a1acd1f4 | |||
fa6e3fe567 | |||
b71b62ee35 | |||
410b4939a4 | |||
62c0071f29 | |||
f043a41005 | |||
2e9da57036 | |||
d83cd37984 | |||
bad8b0ebbb | |||
4535e65948 | |||
3b413c2ee2 | |||
427ae56333 | |||
658fd5ad6e | |||
11830bb51c | |||
75c98429bf | |||
f77ea1b3a5 | |||
0a8bd96d33 | |||
68f37fc11f | |||
d6775cda69 | |||
43c6e07bac | |||
4901e9080c | |||
48049a5ea3 | |||
bd7260f0ff | |||
6c0d54394f | |||
ce5dacbf3f | |||
08aaa5e2c0 | |||
42c0e438d5 | |||
e4df146043 | |||
27b7dae113 | |||
293d574ce7 | |||
56b3b35556 | |||
a7a0e85a46 | |||
95c0106fdd | |||
6612338fc1 | |||
c276a1541f | |||
cc96a5bbdb | |||
0810561a8a |
@ -51,11 +51,47 @@
|
||||
"contributions": [
|
||||
"doc"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "Windman1320",
|
||||
"name": "Windman",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/9999486?v=4",
|
||||
"profile": "https://github.com/Windman1320",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "ericarena",
|
||||
"name": "ericarena",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/4518927?v=4",
|
||||
"profile": "https://github.com/ericarena",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "WntFlm",
|
||||
"name": "WntFlm",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/34620278?v=4",
|
||||
"profile": "https://github.com/WntFlm",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "XZB-1248",
|
||||
"name": "XZB-1248",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/28593573?v=4",
|
||||
"profile": "https://github.com/XZB-1248",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
}
|
||||
],
|
||||
"contributorsPerLine": 7,
|
||||
"projectName": "alist",
|
||||
"projectOwner": "Xhofe",
|
||||
"projectOwner": "alist-org",
|
||||
"repoType": "github",
|
||||
"repoHost": "https://github.com",
|
||||
"skipCi": true
|
||||
|
6
.github/workflows/build.yml
vendored
6
.github/workflows/build.yml
vendored
@ -30,10 +30,10 @@ jobs:
|
||||
with:
|
||||
path: alist
|
||||
|
||||
- name: Install upx
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
docker pull crazymax/xgo:latest
|
||||
go install github.com/crazy-max/xgo@latest
|
||||
docker pull techknowlogick/xgo:latest
|
||||
go install src.techknowlogick.com/xgo@latest
|
||||
sudo apt install upx
|
||||
|
||||
- name: Build
|
||||
|
16
.github/workflows/release.yml
vendored
16
.github/workflows/release.yml
vendored
@ -6,7 +6,19 @@ on:
|
||||
- '*'
|
||||
|
||||
jobs:
|
||||
changelog:
|
||||
name: Create Release
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- run: npx changelogithub # or changelogithub@0.12 if ensure the stable result
|
||||
env:
|
||||
GITHUB_TOKEN: ${{secrets.MY_TOKEN}}
|
||||
release:
|
||||
needs: changelog
|
||||
strategy:
|
||||
matrix:
|
||||
platform: [ubuntu-latest]
|
||||
@ -29,8 +41,8 @@ jobs:
|
||||
|
||||
- name: Install upx
|
||||
run: |
|
||||
docker pull crazymax/xgo:latest
|
||||
go install github.com/crazy-max/xgo@latest
|
||||
docker pull techknowlogick/xgo:latest
|
||||
go install src.techknowlogick.com/xgo@latest
|
||||
sudo apt install upx
|
||||
|
||||
- name: Build
|
||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -22,6 +22,7 @@ dist/
|
||||
# vendor/
|
||||
bin/*
|
||||
/alist
|
||||
/alist.exe
|
||||
*.json
|
||||
public/*.html
|
||||
public/assets/
|
||||
|
@ -7,7 +7,7 @@
|
||||
Prerequisites:
|
||||
|
||||
- [git](https://nodejs.org/zh-cn/)
|
||||
- [Go 1.17+](https://golang.org/doc/install)
|
||||
- [Go 1.18+](https://golang.org/doc/install)
|
||||
- [gcc](https://gcc.gnu.org/)
|
||||
- [nodejs](https://nodejs.org/)
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
||||
[](#contributors-)
|
||||
[](#contributors-)
|
||||
<!-- ALL-CONTRIBUTORS-BADGE:END -->
|
||||
|
||||
## Contributors ✨
|
||||
@ -11,11 +11,17 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
|
||||
<!-- markdownlint-disable -->
|
||||
<table>
|
||||
<tr>
|
||||
<td align="center"><a href="http://nn.ci"><img src="https://avatars.githubusercontent.com/u/36558727?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Xhofe</b></sub></a><br /><a href="https://github.com/Xhofe/alist/commits?author=Xhofe" title="Code">💻</a> <a href="#ideas-Xhofe" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/Xhofe/alist/commits?author=Xhofe" title="Documentation">📖</a></td>
|
||||
<td align="center"><a href="https://github.com/foxxorcat"><img src="https://avatars.githubusercontent.com/u/95907542?v=4?s=100" width="100px;" alt=""/><br /><sub><b>foxxorcat</b></sub></a><br /><a href="https://github.com/Xhofe/alist/commits?author=foxxorcat" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://www.iflu.cf/"><img src="https://avatars.githubusercontent.com/u/63903027?v=4?s=100" width="100px;" alt=""/><br /><sub><b>道辰</b></sub></a><br /><a href="https://github.com/Xhofe/alist/commits?author=DaoChen6" title="Documentation">📖</a></td>
|
||||
<td align="center"><a href="https://vg-land.github.io/"><img src="https://avatars.githubusercontent.com/u/16739728?v=4?s=100" width="100px;" alt=""/><br /><sub><b>vg-land</b></sub></a><br /><a href="https://github.com/Xhofe/alist/commits?author=vg-land" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://c5y.moe"><img src="https://avatars.githubusercontent.com/u/18461360?v=4?s=100" width="100px;" alt=""/><br /><sub><b>凌莞~(=^▽^=)</b></sub></a><br /><a href="https://github.com/Xhofe/alist/commits?author=Clansty" title="Documentation">📖</a></td>
|
||||
<td align="center"><a href="http://nn.ci"><img src="https://avatars.githubusercontent.com/u/36558727?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Xhofe</b></sub></a><br /><a href="https://github.com/alist-org/alist/commits?author=Xhofe" title="Code">💻</a> <a href="#ideas-Xhofe" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/alist-org/alist/commits?author=Xhofe" title="Documentation">📖</a></td>
|
||||
<td align="center"><a href="https://github.com/foxxorcat"><img src="https://avatars.githubusercontent.com/u/95907542?v=4?s=100" width="100px;" alt=""/><br /><sub><b>foxxorcat</b></sub></a><br /><a href="https://github.com/alist-org/alist/commits?author=foxxorcat" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://www.iflu.cf/"><img src="https://avatars.githubusercontent.com/u/63903027?v=4?s=100" width="100px;" alt=""/><br /><sub><b>道辰</b></sub></a><br /><a href="https://github.com/alist-org/alist/commits?author=DaoChen6" title="Documentation">📖</a></td>
|
||||
<td align="center"><a href="https://vg-land.github.io/"><img src="https://avatars.githubusercontent.com/u/16739728?v=4?s=100" width="100px;" alt=""/><br /><sub><b>vg-land</b></sub></a><br /><a href="https://github.com/alist-org/alist/commits?author=vg-land" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://c5y.moe"><img src="https://avatars.githubusercontent.com/u/18461360?v=4?s=100" width="100px;" alt=""/><br /><sub><b>凌莞~(=^▽^=)</b></sub></a><br /><a href="https://github.com/alist-org/alist/commits?author=Clansty" title="Documentation">📖</a></td>
|
||||
<td align="center"><a href="https://github.com/Windman1320"><img src="https://avatars.githubusercontent.com/u/9999486?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Windman</b></sub></a><br /><a href="https://github.com/alist-org/alist/commits?author=Windman1320" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://github.com/ericarena"><img src="https://avatars.githubusercontent.com/u/4518927?v=4?s=100" width="100px;" alt=""/><br /><sub><b>ericarena</b></sub></a><br /><a href="https://github.com/alist-org/alist/commits?author=ericarena" title="Code">💻</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center"><a href="https://github.com/WntFlm"><img src="https://avatars.githubusercontent.com/u/34620278?v=4?s=100" width="100px;" alt=""/><br /><sub><b>WntFlm</b></sub></a><br /><a href="https://github.com/alist-org/alist/commits?author=WntFlm" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://github.com/XZB-1248"><img src="https://avatars.githubusercontent.com/u/28593573?v=4?s=100" width="100px;" alt=""/><br /><sub><b>XZB-1248</b></sub></a><br /><a href="https://github.com/alist-org/alist/commits?author=XZB-1248" title="Code">💻</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
2
LICENSE
2
LICENSE
@ -658,4 +658,4 @@ specific requirements.
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
@ -39,6 +39,7 @@ English | [中文](./README_cn.md) | [Contributors](./CONTRIBUTORS.md) | [Contri
|
||||
- [x] [Quark](https://pan.quark.cn)
|
||||
- [x] [XunleiCloud](https://pan.xunlei.com/)
|
||||
- [x] SFTP
|
||||
- [x] [Baidu.Photo](https://photo.baidu.com/)
|
||||
- [x] Easy to deploy and out-of-the-box
|
||||
- [x] File preview (PDF, markdown, code, plain text, ...)
|
||||
- [x] Image preview in gallery mode
|
||||
@ -71,7 +72,8 @@ Available at: <https://alist.nn.ci>.
|
||||
<https://alist-doc.nn.ci/en/>
|
||||
|
||||
## Special sponsors
|
||||
- [Find Resources - Aliyundrive Resource Search Engine](https://zhaoziyuan.la/)
|
||||
- [找资源 - 阿里云盘资源搜索引擎](https://zhaoziyuan.la/)
|
||||
- [KinhDown 百度云盘不限速下载!永久免费!已稳定运行3年!非常可靠!](https://kinhdown.com/?Type=Tutorials)
|
||||
- [JetBrains: Essential tools for software developers and teams](https://www.jetbrains.com/)
|
||||
|
||||
## License
|
||||
@ -87,4 +89,4 @@ The `AList` is open-source software licensed under the AGPL-3.0 license.
|
||||
|
||||
---
|
||||
|
||||
> [@Blog](https://nn.ci/) · [@GitHub](https://github.com/Xhofe) · [@TelegramGroup](https://t.me/alist_chat) · [@QQGroup](https://jq.qq.com/?_wv=1027&k=OVPJcv2b)
|
||||
> [@Blog](https://nn.ci/) · [@GitHub](https://github.com/Xhofe) · [@TelegramGroup](https://t.me/alist_chat) · [@QQGroup](https://jq.qq.com/?_wv=1027&k=YJJj2Gwb)
|
@ -39,6 +39,7 @@
|
||||
- [x] [夸克网盘](https://pan.quark.cn)
|
||||
- [x] [迅雷云盘](https://pan.xunlei.com/)
|
||||
- [x] SFTP
|
||||
- [x] [一刻相册](https://photo.baidu.com/)
|
||||
- [x] 部署方便,开箱即用
|
||||
- [x] 文件预览(PDF、markdown、代码、纯文本……)
|
||||
- [x] 画廊模式下的图像预览
|
||||
@ -72,6 +73,7 @@
|
||||
|
||||
## 特别赞助
|
||||
- [找资源 - 阿里云盘资源搜索引擎](https://zhaoziyuan.la/)
|
||||
- [KinhDown 百度云盘不限速下载!永久免费!已稳定运行3年!非常可靠!](https://kinhdown.com/?Type=Tutorials)
|
||||
- [JetBrains: Essential tools for software developers and teams](https://www.jetbrains.com/)
|
||||
|
||||
## 许可
|
||||
@ -87,4 +89,4 @@
|
||||
|
||||
---
|
||||
|
||||
> [@Blog](https://nn.ci/) · [@GitHub](https://github.com/Xhofe) · [@TelegramGroup](https://t.me/alist_chat) · [@QQGroup](https://jq.qq.com/?_wv=1027&k=OVPJcv2b)
|
||||
> [@博客](https://nn.ci/) · [@GitHub](https://github.com/Xhofe) · [@Telegram群](https://t.me/alist_chat) · [@QQ群](https://jq.qq.com/?_wv=1027&k=YJJj2Gwb)
|
3
alist.go
3
alist.go
@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/Xhofe/alist/bootstrap"
|
||||
"github.com/Xhofe/alist/conf"
|
||||
_ "github.com/Xhofe/alist/drivers"
|
||||
@ -12,7 +13,6 @@ import (
|
||||
)
|
||||
|
||||
func Init() bool {
|
||||
//bootstrap.InitLog()
|
||||
bootstrap.InitConf()
|
||||
bootstrap.InitCron()
|
||||
bootstrap.InitModel()
|
||||
@ -27,6 +27,7 @@ func Init() bool {
|
||||
}
|
||||
server.InitIndex()
|
||||
bootstrap.InitSettings()
|
||||
bootstrap.InitAuth()
|
||||
bootstrap.InitAccounts()
|
||||
bootstrap.InitCache()
|
||||
return true
|
||||
|
51
bootstrap/auth.go
Normal file
51
bootstrap/auth.go
Normal file
@ -0,0 +1,51 @@
|
||||
package bootstrap
|
||||
|
||||
import (
|
||||
"github.com/Xhofe/alist/conf"
|
||||
"github.com/casdoor/casdoor-go-sdk/casdoorsdk"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type AuthConfig struct {
|
||||
OrganizationName string `json:"organization_name"`
|
||||
ApplicationName string `json:"application_name"`
|
||||
Endpoint string `json:"endpoint"`
|
||||
ClientId string `json:"client_id"`
|
||||
ClientSecret string `json:"client_secret"`
|
||||
JwtPublicKey string `json:"jwt_public_key"`
|
||||
}
|
||||
|
||||
// InitAuth init auth
|
||||
func InitAuth() {
|
||||
log.Infof("init auth...")
|
||||
enableCasdoor := conf.GetBool("Enable Casdoor")
|
||||
if !enableCasdoor {
|
||||
return
|
||||
}
|
||||
auth := readAuthConfig()
|
||||
if !CheckAuthConfig(auth) {
|
||||
panic("invalid auth config")
|
||||
}
|
||||
casdoorsdk.InitConfig(strings.TrimRight(auth.Endpoint, "/"), auth.ClientId, auth.ClientSecret, auth.JwtPublicKey, auth.OrganizationName, auth.ApplicationName)
|
||||
}
|
||||
|
||||
func readAuthConfig() AuthConfig {
|
||||
return AuthConfig{
|
||||
OrganizationName: conf.GetStr("Casdoor Organization name"),
|
||||
ApplicationName: conf.GetStr("Casdoor Application name"),
|
||||
Endpoint: conf.GetStr("Casdoor Endpoint"),
|
||||
ClientId: conf.GetStr("Casdoor Client id"),
|
||||
ClientSecret: conf.GetStr("Casdoor Client secret"),
|
||||
JwtPublicKey: conf.GetStr("Casdoor Jwt Public Key"),
|
||||
}
|
||||
}
|
||||
|
||||
func CheckAuthConfig(authConfig AuthConfig) bool {
|
||||
return authConfig.Endpoint != "" &&
|
||||
authConfig.ClientId != "" &&
|
||||
authConfig.ClientSecret != "" &&
|
||||
authConfig.OrganizationName != "" &&
|
||||
authConfig.ApplicationName != "" &&
|
||||
authConfig.JwtPublicKey != ""
|
||||
}
|
@ -2,6 +2,7 @@ package bootstrap
|
||||
|
||||
import (
|
||||
"flag"
|
||||
|
||||
"github.com/Xhofe/alist/conf"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
@ -1,12 +1,13 @@
|
||||
package bootstrap
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/Xhofe/alist/conf"
|
||||
"github.com/Xhofe/alist/model"
|
||||
"github.com/Xhofe/alist/utils"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"gorm.io/gorm"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func InitSettings() {
|
||||
@ -124,6 +125,13 @@ func InitSettings() {
|
||||
Access: model.PUBLIC,
|
||||
Group: model.FRONT,
|
||||
},
|
||||
{
|
||||
Key: "pdf viewer url",
|
||||
Type: "string",
|
||||
Value: "https://alist-org.github.io/pdf.js/web/viewer.html?file=$url",
|
||||
Access: model.PUBLIC,
|
||||
Group: model.FRONT,
|
||||
},
|
||||
{
|
||||
Key: "autoplay video",
|
||||
Value: "false",
|
||||
@ -228,7 +236,7 @@ func InitSettings() {
|
||||
},
|
||||
{
|
||||
Key: "Visitor WebDAV password",
|
||||
Value: "guest",
|
||||
Value: utils.RandomStr(8),
|
||||
Description: "Visitor WebDAV password",
|
||||
Type: "string",
|
||||
Access: model.PRIVATE,
|
||||
@ -252,7 +260,7 @@ func InitSettings() {
|
||||
},
|
||||
{
|
||||
Key: "ocr api",
|
||||
Value: "https://api.xhofe.top/ocr/file/json",
|
||||
Value: "https://api.nn.ci/ocr/file/json",
|
||||
Description: "Used to identify verification codes",
|
||||
Type: "string",
|
||||
Access: model.PRIVATE,
|
||||
@ -266,6 +274,78 @@ func InitSettings() {
|
||||
Group: model.BACK,
|
||||
Description: "Experimental function, not recommended as it's still under development",
|
||||
},
|
||||
{
|
||||
Key: "Aria2 RPC url",
|
||||
Value: "http://localhost:6800/jsonrpc",
|
||||
Description: "Aria2 RPC url, e.g. 'http://aria2.example.com:6800/jsonrpc'",
|
||||
Type: "string",
|
||||
Access: model.PRIVATE,
|
||||
Group: model.BACK,
|
||||
},
|
||||
{
|
||||
Key: "Aria2 RPC secret",
|
||||
Value: "",
|
||||
Description: "Aria2 RPC secret, e.g. '123456'",
|
||||
Type: "string",
|
||||
Access: model.PRIVATE,
|
||||
Group: model.BACK,
|
||||
},
|
||||
{
|
||||
Key: "Enable Casdoor",
|
||||
Value: "false",
|
||||
Description: "Enable Casdoor login",
|
||||
Type: "bool",
|
||||
Access: model.PRIVATE,
|
||||
Group: model.BACK,
|
||||
},
|
||||
{
|
||||
Key: "Casdoor Organization name",
|
||||
Value: "",
|
||||
Description: "Casdoor Organization name",
|
||||
Type: "string",
|
||||
Access: model.PRIVATE,
|
||||
Group: model.BACK,
|
||||
},
|
||||
{
|
||||
Key: "Casdoor Application name",
|
||||
Value: "",
|
||||
Description: "Casdoor Application name",
|
||||
Type: "string",
|
||||
Access: model.PRIVATE,
|
||||
Group: model.BACK,
|
||||
},
|
||||
{
|
||||
Key: "Casdoor Endpoint",
|
||||
Value: "",
|
||||
Description: "Casdoor Endpoint, e.g. 'http://localhost:8000'",
|
||||
Type: "string",
|
||||
Access: model.PRIVATE,
|
||||
Group: model.BACK,
|
||||
},
|
||||
{
|
||||
Key: "Casdoor Client id",
|
||||
Value: "",
|
||||
Description: "Casdoor Client id",
|
||||
Type: "string",
|
||||
Access: model.PRIVATE,
|
||||
Group: model.BACK,
|
||||
},
|
||||
{
|
||||
Key: "Casdoor Client secret",
|
||||
Value: "",
|
||||
Description: "Casdoor Client secret",
|
||||
Type: "string",
|
||||
Access: model.PRIVATE,
|
||||
Group: model.BACK,
|
||||
},
|
||||
{
|
||||
Key: "Casdoor Jwt Public Key",
|
||||
Value: "",
|
||||
Description: "Casdoor Jwt Public Key",
|
||||
Type: "string",
|
||||
Access: model.PRIVATE,
|
||||
Group: model.BACK,
|
||||
},
|
||||
}
|
||||
for i, _ := range settings {
|
||||
v := settings[i]
|
||||
|
19
build.sh
19
build.sh
@ -2,8 +2,8 @@
|
||||
|
||||
# 构建前端,在当前目录产生一个dist文件夹
|
||||
BUILD_WEB() {
|
||||
git clone https://github.com/alist-org/alist-web.git
|
||||
cd alist-web
|
||||
git clone https://github.com/alist-org/web-v2.git
|
||||
cd web-v2
|
||||
yarn
|
||||
yarn build
|
||||
sed -i -e "s/\/CDN_URL\//\//g" dist/index.html
|
||||
@ -11,11 +11,11 @@ BUILD_WEB() {
|
||||
rm -f dist/index.html-e
|
||||
mv dist ..
|
||||
cd .. || exit
|
||||
rm -rf alist-web
|
||||
rm -rf web-v2
|
||||
}
|
||||
|
||||
CDN_WEB() {
|
||||
curl -L https://github.com/alist-org/alist-web/releases/latest/download/dist.tar.gz -o dist.tar.gz
|
||||
curl -L https://github.com/alist-org/web-v2/releases/latest/download/dist.tar.gz -o dist.tar.gz
|
||||
tar -zxvf dist.tar.gz
|
||||
rm -f dist.tar.gz
|
||||
}
|
||||
@ -28,7 +28,7 @@ BUILD_DOCKER() {
|
||||
gitAuthor=$(git show -s --format='format:%aN <%ae>' HEAD)
|
||||
gitCommit=$(git log --pretty=format:"%h" -1)
|
||||
gitTag=$(git describe --long --tags --dirty --always)
|
||||
webTag=$(wget -qO- -t1 -T2 "https://api.github.com/repos/alist-org/alist-web/releases/latest" | grep "tag_name" | head -n 1 | awk -F ":" '{print $2}' | sed 's/\"//g;s/,//g;s/ //g')
|
||||
webTag=$(wget -qO- -t1 -T2 "https://api.github.com/repos/alist-org/web-v2/releases/latest" | grep "tag_name" | head -n 1 | awk -F ":" '{print $2}' | sed 's/\"//g;s/,//g;s/ //g')
|
||||
ldflags="\
|
||||
-w -s \
|
||||
-X 'github.com/Xhofe/alist/conf.BuiltAt=$builtAt' \
|
||||
@ -49,7 +49,7 @@ BUILD() {
|
||||
gitAuthor=$(git show -s --format='format:%aN <%ae>' HEAD)
|
||||
gitCommit=$(git log --pretty=format:"%h" -1)
|
||||
gitTag=$(git describe --long --tags --dirty --always)
|
||||
webTag=$(wget -qO- -t1 -T2 "https://api.github.com/repos/alist-org/alist-web/releases/latest" | grep "tag_name" | head -n 1 | awk -F ":" '{print $2}' | sed 's/\"//g;s/,//g;s/ //g')
|
||||
webTag=$(wget -qO- -t1 -T2 "https://api.github.com/repos/alist-org/web-v2/releases/latest" | grep "tag_name" | head -n 1 | awk -F ":" '{print $2}' | sed 's/\"//g;s/,//g;s/ //g')
|
||||
echo "build version: $gitTag"
|
||||
|
||||
ldflags="\
|
||||
@ -61,6 +61,7 @@ BUILD() {
|
||||
-X 'github.com/Xhofe/alist/conf.GitTag=$gitTag' \
|
||||
-X 'github.com/Xhofe/alist/conf.WebTag=$webTag' \
|
||||
"
|
||||
rm -rf .git/
|
||||
if [ "$1" == "release" ]; then
|
||||
xgo -out "$appName" -ldflags="$ldflags" -tags=jsoniter .
|
||||
else
|
||||
@ -80,7 +81,7 @@ BUILD() {
|
||||
}
|
||||
|
||||
BUILD_MUSL() {
|
||||
BASE="https://musl.cc/"
|
||||
BASE="https://musl.nn.ci/"
|
||||
FILES=(x86_64-linux-musl-cross aarch64-linux-musl-cross arm-linux-musleabihf-cross mips-linux-musl-cross mips64-linux-musl-cross mips64el-linux-musl-cross mipsel-linux-musl-cross powerpc64le-linux-musl-cross s390x-linux-musl-cross)
|
||||
for i in "${FILES[@]}"; do
|
||||
url="${BASE}${i}.tgz"
|
||||
@ -94,7 +95,7 @@ BUILD_MUSL() {
|
||||
gitAuthor=$(git show -s --format='format:%aN <%ae>' HEAD)
|
||||
gitCommit=$(git log --pretty=format:"%h" -1)
|
||||
gitTag=$(git describe --long --tags --dirty --always)
|
||||
webTag=$(wget -qO- -t1 -T2 "https://api.github.com/repos/alist-org/alist-web/releases/latest" | grep "tag_name" | head -n 1 | awk -F ":" '{print $2}' | sed 's/\"//g;s/,//g;s/ //g')
|
||||
webTag=$(wget -qO- -t1 -T2 "https://api.github.com/repos/alist-org/web-v2/releases/latest" | grep "tag_name" | head -n 1 | awk -F ":" '{print $2}' | sed 's/\"//g;s/,//g;s/ //g')
|
||||
ldflags="\
|
||||
-w -s --extldflags '-static -fpic' \
|
||||
-X 'github.com/Xhofe/alist/conf.BuiltAt=$builtAt' \
|
||||
@ -148,8 +149,8 @@ elif [ "$1" = "docker" ]; then
|
||||
elif [ "$1" = "build" ]; then
|
||||
BUILD build
|
||||
elif [ "$1" = "release" ]; then
|
||||
BUILD release
|
||||
BUILD_MUSL
|
||||
BUILD release
|
||||
RELEASE
|
||||
else
|
||||
echo -e "${RED_COLOR} Parameter error ${RES}"
|
||||
|
@ -24,22 +24,26 @@ type CacheConfig struct {
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
Force bool `json:"force"`
|
||||
Address string `json:"address" env:"ADDR"`
|
||||
Port int `json:"port" env:"PORT"`
|
||||
Assets string `json:"assets" env:"ASSETS"`
|
||||
Database Database `json:"database"`
|
||||
Scheme Scheme `json:"scheme"`
|
||||
Cache CacheConfig `json:"cache"`
|
||||
TempDir string `json:"temp_dir" env:"TEMP_DIR"`
|
||||
Force bool `json:"force"`
|
||||
Address string `json:"address" env:"ADDR"`
|
||||
Port int `json:"port" env:"PORT"`
|
||||
Assets string `json:"assets" env:"ASSETS"`
|
||||
LocalAssets string `json:"local_assets" env:"LOCAL_ASSETS"`
|
||||
SubFolder string `json:"sub_folder" env:"SUB_FOLDER"`
|
||||
Database Database `json:"database"`
|
||||
Scheme Scheme `json:"scheme"`
|
||||
Cache CacheConfig `json:"cache"`
|
||||
TempDir string `json:"temp_dir" env:"TEMP_DIR"`
|
||||
}
|
||||
|
||||
func DefaultConfig() *Config {
|
||||
return &Config{
|
||||
Address: "0.0.0.0",
|
||||
Port: 5244,
|
||||
Assets: "https://npm.elemecdn.com/alist-web@$version/dist",
|
||||
TempDir: "data/temp",
|
||||
Address: "0.0.0.0",
|
||||
Port: 5244,
|
||||
Assets: "/",
|
||||
SubFolder: "",
|
||||
LocalAssets: "",
|
||||
TempDir: "data/temp",
|
||||
Database: Database{
|
||||
Type: "sqlite3",
|
||||
Port: 0,
|
||||
|
@ -40,7 +40,7 @@ var (
|
||||
"go", "sh", "c", "cpp", "h", "hpp", "tsx", "vtt", "srt", "ass"}
|
||||
DProxyTypes = []string{"m3u8"}
|
||||
OfficeTypes = []string{"doc", "docx", "xls", "xlsx", "ppt", "pptx", "pdf"}
|
||||
VideoTypes = []string{"mp4", "mkv", "avi", "mov", "rmvb", "webm", "flv"}
|
||||
VideoTypes = []string{"mp4", "mkv", "avi", "mov", "rmvb", "webm", "flv", "m4v"}
|
||||
AudioTypes = []string{"mp3", "flac", "ogg", "m4a", "wav", "opus"}
|
||||
ImageTypes = []string{"jpg", "tiff", "jpeg", "png", "gif", "bmp", "svg", "ico", "swf", "webp"}
|
||||
)
|
||||
@ -86,6 +86,9 @@ var (
|
||||
"default page size", "load type",
|
||||
"ocr api", "favicon",
|
||||
"enable search",
|
||||
"Enable Casdoor", "Casdoor Organization name", "Casdoor Application name",
|
||||
"Casdoor Endpoint", "Casdoor Client id", "Casdoor Client secret",
|
||||
"Casdoor Jwt Public Key",
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -3,15 +3,15 @@ package _23
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/Xhofe/alist/conf"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
|
||||
"github.com/Xhofe/alist/drivers/base"
|
||||
"github.com/Xhofe/alist/model"
|
||||
"github.com/Xhofe/alist/utils"
|
||||
"github.com/go-resty/resty/v2"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func (driver Pan123) Login(account *model.Account) error {
|
||||
@ -40,21 +40,22 @@ func (driver Pan123) Login(account *model.Account) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (driver Pan123) FormatFile(file *Pan123File) *model.File {
|
||||
func (driver Pan123) FormatFile(file *File) *model.File {
|
||||
f := &model.File{
|
||||
Id: strconv.FormatInt(file.FileId, 10),
|
||||
Name: file.FileName,
|
||||
Size: file.Size,
|
||||
Driver: driver.Config().Name,
|
||||
UpdatedAt: file.UpdateAt,
|
||||
Thumbnail: file.DownloadUrl,
|
||||
}
|
||||
f.Type = file.GetType()
|
||||
return f
|
||||
}
|
||||
|
||||
func (driver Pan123) GetFiles(parentId string, account *model.Account) ([]Pan123File, error) {
|
||||
func (driver Pan123) GetFiles(parentId string, account *model.Account) ([]File, error) {
|
||||
next := "0"
|
||||
res := make([]Pan123File, 0)
|
||||
res := make([]File, 0)
|
||||
for next != "-1" {
|
||||
var resp Pan123Files
|
||||
query := map[string]string{
|
||||
@ -66,7 +67,7 @@ func (driver Pan123) GetFiles(parentId string, account *model.Account) ([]Pan123
|
||||
"parentFileId": parentId,
|
||||
"trashed": "false",
|
||||
}
|
||||
_, err := driver.Request("https://www.123pan.com/api/file/list",
|
||||
_, err := driver.Request("https://www.123pan.com/api/file/list/new",
|
||||
base.Get, nil, query, nil, &resp, false, account)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -139,7 +140,7 @@ func (driver Pan123) Request(url string, method int, headers, query map[string]s
|
||||
// return body, nil
|
||||
//}
|
||||
|
||||
func (driver Pan123) GetFile(path string, account *model.Account) (*Pan123File, error) {
|
||||
func (driver Pan123) GetFile(path string, account *model.Account) (*File, error) {
|
||||
dir, name := filepath.Split(path)
|
||||
dir = utils.ParsePath(dir)
|
||||
_, err := driver.Files(dir, account)
|
||||
@ -147,14 +148,15 @@ func (driver Pan123) GetFile(path string, account *model.Account) (*Pan123File,
|
||||
return nil, err
|
||||
}
|
||||
parentFiles_, _ := base.GetCache(dir, account)
|
||||
parentFiles, _ := parentFiles_.([]Pan123File)
|
||||
parentFiles, _ := parentFiles_.([]File)
|
||||
for _, file := range parentFiles {
|
||||
if file.FileName == name {
|
||||
if file.Type != conf.FOLDER {
|
||||
return &file, err
|
||||
} else {
|
||||
return nil, base.ErrNotFile
|
||||
}
|
||||
//if file.Type != conf.FOLDER {
|
||||
// return &file, err
|
||||
//} else {
|
||||
// return nil, base.ErrNotFile
|
||||
//}
|
||||
return &file, nil
|
||||
}
|
||||
}
|
||||
return nil, base.ErrPathNotFound
|
||||
|
@ -1,9 +1,18 @@
|
||||
package _23
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/md5"
|
||||
"encoding/binary"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
|
||||
"github.com/Xhofe/alist/conf"
|
||||
"github.com/Xhofe/alist/drivers/base"
|
||||
"github.com/Xhofe/alist/model"
|
||||
@ -13,12 +22,6 @@ import (
|
||||
"github.com/aws/aws-sdk-go/aws/session"
|
||||
"github.com/aws/aws-sdk-go/service/s3/s3manager"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type Pan123 struct{}
|
||||
@ -67,6 +70,12 @@ func (driver Pan123) Items() []base.Item {
|
||||
Required: true,
|
||||
Default: "asc",
|
||||
},
|
||||
{
|
||||
Name: "bool_1",
|
||||
Label: "stream upload",
|
||||
Type: base.TypeBool,
|
||||
Description: "io stream upload (test)",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@ -108,10 +117,10 @@ func (driver Pan123) File(path string, account *model.Account) (*model.File, err
|
||||
|
||||
func (driver Pan123) Files(path string, account *model.Account) ([]model.File, error) {
|
||||
path = utils.ParsePath(path)
|
||||
var rawFiles []Pan123File
|
||||
var rawFiles []File
|
||||
cache, err := base.GetCache(path, account)
|
||||
if err == nil {
|
||||
rawFiles, _ = cache.([]Pan123File)
|
||||
rawFiles, _ = cache.([]File)
|
||||
} else {
|
||||
file, err := driver.File(path, account)
|
||||
if err != nil {
|
||||
@ -125,7 +134,7 @@ func (driver Pan123) Files(path string, account *model.Account) ([]model.File, e
|
||||
_ = base.SetCache(path, rawFiles, account)
|
||||
}
|
||||
}
|
||||
files := make([]model.File, 0)
|
||||
files := make([]model.File, 0, len(rawFiles))
|
||||
for _, file := range rawFiles {
|
||||
files = append(files, *driver.FormatFile(&file))
|
||||
}
|
||||
@ -167,7 +176,7 @@ func (driver Pan123) Link(args base.Args, account *model.Account) (*base.Link, e
|
||||
return nil, err
|
||||
}
|
||||
u_ := fmt.Sprintf("https://%s%s", u.Host, u.Path)
|
||||
res, err := base.NoRedirectClient.R().SetQueryParamsFromValues(u.Query()).Get(u_)
|
||||
res, err := base.NoRedirectClient.R().SetQueryParamsFromValues(u.Query()).Head(u_)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -175,6 +184,7 @@ func (driver Pan123) Link(args base.Args, account *model.Account) (*base.Link, e
|
||||
link := base.Link{
|
||||
Url: resp.Data.DownloadUrl,
|
||||
}
|
||||
log.Debugln("res code: ", res.StatusCode())
|
||||
if res.StatusCode() == 302 {
|
||||
link.Url = res.Header().Get("location")
|
||||
}
|
||||
@ -278,12 +288,13 @@ func (driver Pan123) Delete(path string, account *model.Account) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
log.Debugln("delete 123 file: ", file)
|
||||
data := base.Json{
|
||||
"driveId": 0,
|
||||
"operation": true,
|
||||
"fileTrashInfoList": file,
|
||||
"fileTrashInfoList": []File{*file},
|
||||
}
|
||||
_, err = driver.Request("https://www.123pan.com/api/file/trash",
|
||||
_, err = driver.Request("https://www.123pan.com/b/api/file/trash",
|
||||
base.Post, nil, nil, &data, nil, false, account)
|
||||
return err
|
||||
}
|
||||
@ -299,46 +310,57 @@ func (driver Pan123) Upload(file *model.FileStream, account *model.Account) erro
|
||||
if !parentFile.IsDir() {
|
||||
return base.ErrNotFolder
|
||||
}
|
||||
parentFileId, _ := strconv.Atoi(parentFile.Id)
|
||||
tempFile, err := ioutil.TempFile(conf.Conf.TempDir, "file-*")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer func() {
|
||||
_ = tempFile.Close()
|
||||
_ = os.Remove(tempFile.Name())
|
||||
}()
|
||||
_, err = io.Copy(tempFile, file)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = tempFile.Seek(0, io.SeekStart)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
const DEFAULT int64 = 10485760
|
||||
var uploadFile io.Reader
|
||||
h := md5.New()
|
||||
_, err = io.Copy(h, tempFile)
|
||||
if err != nil {
|
||||
return err
|
||||
if account.Bool1 && file.GetSize() > uint64(DEFAULT) {
|
||||
// 只计算前10MIB
|
||||
buf := bytes.NewBuffer(make([]byte, 0, DEFAULT))
|
||||
if n, err := io.CopyN(io.MultiWriter(buf, h), file, DEFAULT); err != io.EOF && n == 0 {
|
||||
return err
|
||||
}
|
||||
// 增加额外参数防止MD5碰撞
|
||||
h.Write([]byte(file.Name))
|
||||
num := make([]byte, 8)
|
||||
binary.BigEndian.PutUint64(num, file.Size)
|
||||
h.Write(num)
|
||||
// 拼装
|
||||
uploadFile = io.MultiReader(buf, file)
|
||||
} else {
|
||||
// 计算完整文件MD5
|
||||
tempFile, err := ioutil.TempFile(conf.Conf.TempDir, "file-*")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer func() {
|
||||
_ = tempFile.Close()
|
||||
_ = os.Remove(tempFile.Name())
|
||||
}()
|
||||
|
||||
if _, err = io.Copy(io.MultiWriter(tempFile, h), file); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = tempFile.Seek(0, io.SeekStart)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
uploadFile = tempFile
|
||||
}
|
||||
etag := hex.EncodeToString(h.Sum(nil))
|
||||
log.Debugln("md5:", etag)
|
||||
_, err = tempFile.Seek(0, io.SeekStart)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
data := base.Json{
|
||||
"driveId": 0,
|
||||
"duplicate": true,
|
||||
"duplicate": 2, // 2->覆盖 1->重命名 0->默认
|
||||
"etag": etag,
|
||||
"fileName": file.GetFileName(),
|
||||
"parentFileId": parentFileId,
|
||||
"parentFileId": parentFile.Id,
|
||||
"size": file.GetSize(),
|
||||
"type": 0,
|
||||
}
|
||||
var resp UploadResp
|
||||
_, err = driver.Request("https://www.123pan.com/api/file/upload_request",
|
||||
base.Post, nil, nil, &data, &resp, false, account)
|
||||
base.Post, map[string]string{"app-version": "1.1"}, nil, &data, &resp, false, account)
|
||||
//res, err := driver.Post("https://www.123pan.com/api/file/upload_request", data, account)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -360,7 +382,7 @@ func (driver Pan123) Upload(file *model.FileStream, account *model.Account) erro
|
||||
input := &s3manager.UploadInput{
|
||||
Bucket: &resp.Data.Bucket,
|
||||
Key: &resp.Data.Key,
|
||||
Body: tempFile,
|
||||
Body: uploadFile,
|
||||
}
|
||||
_, err = uploader.Upload(input)
|
||||
if err != nil {
|
||||
|
@ -1,31 +1,33 @@
|
||||
package _23
|
||||
|
||||
import (
|
||||
"github.com/Xhofe/alist/conf"
|
||||
"github.com/Xhofe/alist/utils"
|
||||
"path"
|
||||
"time"
|
||||
|
||||
"github.com/Xhofe/alist/conf"
|
||||
"github.com/Xhofe/alist/utils"
|
||||
)
|
||||
|
||||
type Pan123File struct {
|
||||
FileName string `json:"FileName"`
|
||||
Size int64 `json:"Size"`
|
||||
UpdateAt *time.Time `json:"UpdateAt"`
|
||||
FileId int64 `json:"FileId"`
|
||||
Type int `json:"Type"`
|
||||
Etag string `json:"Etag"`
|
||||
S3KeyFlag string `json:"S3KeyFlag"`
|
||||
type File struct {
|
||||
FileName string `json:"FileName"`
|
||||
Size int64 `json:"Size"`
|
||||
UpdateAt *time.Time `json:"UpdateAt"`
|
||||
FileId int64 `json:"FileId"`
|
||||
Type int `json:"Type"`
|
||||
Etag string `json:"Etag"`
|
||||
S3KeyFlag string `json:"S3KeyFlag"`
|
||||
DownloadUrl string `json:"DownloadUrl"`
|
||||
}
|
||||
|
||||
func (f Pan123File) GetSize() uint64 {
|
||||
func (f File) GetSize() uint64 {
|
||||
return uint64(f.Size)
|
||||
}
|
||||
|
||||
func (f Pan123File) GetName() string {
|
||||
func (f File) GetName() string {
|
||||
return f.FileName
|
||||
}
|
||||
|
||||
func (f Pan123File) GetType() int {
|
||||
func (f File) GetType() int {
|
||||
if f.Type == 1 {
|
||||
return conf.FOLDER
|
||||
}
|
||||
@ -47,8 +49,8 @@ type Pan123TokenResp struct {
|
||||
type Pan123Files struct {
|
||||
BaseResp
|
||||
Data struct {
|
||||
InfoList []Pan123File `json:"InfoList"`
|
||||
Next string `json:"Next"`
|
||||
InfoList []File `json:"InfoList"`
|
||||
Next string `json:"Next"`
|
||||
} `json:"data"`
|
||||
}
|
||||
|
||||
|
@ -270,7 +270,7 @@ func (driver Cloud139) Rename(src string, dst string, account *model.Account) er
|
||||
"accountType": 1,
|
||||
},
|
||||
}
|
||||
pathname = "/orchestration/personalCloud/catalog/v1.0/updateContentInfo"
|
||||
pathname = "/orchestration/personalCloud/content/v1.0/updateContentInfo"
|
||||
}
|
||||
_, err = driver.Post(pathname, data, nil, account)
|
||||
return err
|
||||
@ -448,6 +448,7 @@ func (driver Cloud139) Upload(file *model.FileStream, account *model.Account) er
|
||||
return err
|
||||
}
|
||||
log.Debugf("%+v", res)
|
||||
res.Body.Close()
|
||||
start += byteSize
|
||||
}
|
||||
return nil
|
||||
|
@ -7,6 +7,14 @@ import (
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"math"
|
||||
"net/http"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/Xhofe/alist/conf"
|
||||
"github.com/Xhofe/alist/drivers/base"
|
||||
"github.com/Xhofe/alist/model"
|
||||
@ -14,14 +22,6 @@ import (
|
||||
"github.com/go-resty/resty/v2"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"io"
|
||||
"math"
|
||||
"net/http"
|
||||
"net/http/cookiejar"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
var client189Map map[string]*resty.Client
|
||||
@ -94,24 +94,20 @@ type LoginResp struct {
|
||||
|
||||
// Login refer to PanIndex
|
||||
func (driver Cloud189) Login(account *model.Account) error {
|
||||
client, ok := client189Map[account.Name]
|
||||
if !ok {
|
||||
//cookieJar, _ := cookiejar.New(&cookiejar.Options{PublicSuffixList: publicsuffix.List})
|
||||
client = resty.New()
|
||||
//client.SetCookieJar(cookieJar)
|
||||
client.SetTimeout(base.DefaultTimeout)
|
||||
client.SetRetryCount(3)
|
||||
client.SetHeader("Referer", "https://cloud.189.cn/")
|
||||
}
|
||||
// clear cookie
|
||||
jar, _ := cookiejar.New(nil)
|
||||
client.SetCookieJar(jar)
|
||||
client := resty.New()
|
||||
//client.SetCookieJar(cookieJar)
|
||||
client.SetTimeout(base.DefaultTimeout)
|
||||
client.SetRetryCount(3)
|
||||
client.SetHeader("Referer", "https://cloud.189.cn/")
|
||||
client.SetHeader("User-Agent", base.UserAgent)
|
||||
url := "https://cloud.189.cn/api/portal/loginUrl.action?redirectURL=https%3A%2F%2Fcloud.189.cn%2Fmain.action"
|
||||
b := ""
|
||||
lt := ""
|
||||
ltText := regexp.MustCompile(`lt = "(.+?)"`)
|
||||
var res *resty.Response
|
||||
var err error
|
||||
for i := 0; i < 3; i++ {
|
||||
res, err := client.R().Get(url)
|
||||
res, err = client.R().Get(url)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -129,7 +125,8 @@ func (driver Cloud189) Login(account *model.Account) error {
|
||||
}
|
||||
}
|
||||
if lt == "" {
|
||||
return errors.New("get page: " + b)
|
||||
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"))
|
||||
}
|
||||
captchaToken := regexp.MustCompile(`captchaToken' value='(.+?)'`).FindStringSubmatch(b)[1]
|
||||
returnUrl := regexp.MustCompile(`returnUrl = '(.+?)'`).FindStringSubmatch(b)[1]
|
||||
@ -169,7 +166,7 @@ func (driver Cloud189) Login(account *model.Account) error {
|
||||
passwordRsa := RsaEncode([]byte(account.Password), jRsakey, true)
|
||||
url = "https://open.e.189.cn/api/logbox/oauth2/loginSubmit.do"
|
||||
var loginResp LoginResp
|
||||
res, err := client.R().
|
||||
res, err = client.R().
|
||||
SetHeaders(map[string]string{
|
||||
"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",
|
||||
@ -575,6 +572,7 @@ func (driver Cloud189) NewUpload(file *model.FileStream, account *model.Account)
|
||||
|
||||
r, err := base.HttpClient.Do(req)
|
||||
log.Debugf("%+v %+v", r, r.Request.Header)
|
||||
r.Body.Close()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -2,15 +2,16 @@ package _89
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/Xhofe/alist/conf"
|
||||
"github.com/Xhofe/alist/drivers/base"
|
||||
"github.com/Xhofe/alist/model"
|
||||
"github.com/Xhofe/alist/utils"
|
||||
"github.com/go-resty/resty/v2"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Cloud189 struct{}
|
||||
@ -179,23 +180,27 @@ func (driver Cloud189) Link(args base.Args, account *model.Account) (*base.Link,
|
||||
resty.RedirectPolicyFunc(func(req *http.Request, via []*http.Request) error {
|
||||
return http.ErrUseLastResponse
|
||||
}))
|
||||
res, err := client.R().Get("https:" + resp.FileDownloadUrl)
|
||||
res, err := client.R().SetHeader("User-Agent", base.UserAgent).Get("https:" + resp.FileDownloadUrl)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
log.Debugln(res.Status())
|
||||
log.Debugln(res.String())
|
||||
link := base.Link{
|
||||
Headers: []base.Header{
|
||||
{Name: "User-Agent", Value: base.UserAgent},
|
||||
//{Name: "Authorization", Value: ""},
|
||||
},
|
||||
}
|
||||
log.Debugln("first url:", resp.FileDownloadUrl)
|
||||
if res.StatusCode() == 302 {
|
||||
link.Url = res.Header().Get("location")
|
||||
res, err = client.R().Get(link.Url)
|
||||
log.Debugln("second url:", link.Url)
|
||||
_, _ = client.R().Get(link.Url)
|
||||
if res.StatusCode() == 302 {
|
||||
link.Url = res.Header().Get("location")
|
||||
}
|
||||
log.Debugln("third url:", link.Url)
|
||||
} else {
|
||||
link.Url = resp.FileDownloadUrl
|
||||
}
|
||||
|
@ -291,6 +291,13 @@ func (s *State) Request(method string, fullUrl string, params Params, callback f
|
||||
return nil, fmt.Errorf(erron.Msg)
|
||||
}
|
||||
if erron.ErrorCode != "" {
|
||||
switch erron.ErrorCode {
|
||||
case "InvalidSessionKey":
|
||||
if err := s.RefreshSession(account); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return s.Request(method, fullUrl, params, callback, account)
|
||||
}
|
||||
return nil, fmt.Errorf(erron.ErrorMsg)
|
||||
}
|
||||
|
||||
|
@ -607,6 +607,7 @@ func (driver Cloud189) CommonUpload(file *model.FileStream, parentFile *model.Fi
|
||||
|
||||
uploadData := uploadUrl.UploadUrls[fmt.Sprint("partNumber_", i)]
|
||||
req, _ := http.NewRequest(http.MethodPut, uploadData.RequestURL, byteData)
|
||||
req.Header.Set("User-Agent", "")
|
||||
for k, v := range ParseHttpHeader(uploadData.RequestHeader) {
|
||||
req.Header.Set(k, v)
|
||||
}
|
||||
@ -619,8 +620,10 @@ func (driver Cloud189) CommonUpload(file *model.FileStream, parentFile *model.Fi
|
||||
}
|
||||
if r.StatusCode != http.StatusOK {
|
||||
data, _ := io.ReadAll(r.Body)
|
||||
r.Body.Close()
|
||||
return fmt.Errorf(string(data))
|
||||
}
|
||||
r.Body.Close()
|
||||
}
|
||||
|
||||
fileMd5Hex := strings.ToUpper(hex.EncodeToString(fileMd5.Sum(nil)))
|
||||
@ -647,9 +650,10 @@ func (driver Cloud189) FastUpload(file *model.FileStream, parentFile *model.File
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer tempFile.Close()
|
||||
defer os.Remove(tempFile.Name())
|
||||
|
||||
defer func() {
|
||||
_ = tempFile.Close()
|
||||
_ = os.Remove(tempFile.Name())
|
||||
}()
|
||||
// 初始化上传
|
||||
state := GetState(account)
|
||||
|
||||
@ -715,6 +719,7 @@ func (driver Cloud189) FastUpload(file *model.FileStream, parentFile *model.File
|
||||
for i := 1; i <= count; i++ {
|
||||
uploadData := uploadUrls.UploadUrls[fmt.Sprint("partNumber_", i)]
|
||||
req, _ := http.NewRequest(http.MethodPut, uploadData.RequestURL, io.NewSectionReader(tempFile, int64(i-1)*DEFAULT, DEFAULT))
|
||||
req.Header.Set("User-Agent", "")
|
||||
for k, v := range ParseHttpHeader(uploadData.RequestHeader) {
|
||||
req.Header.Set(k, v)
|
||||
}
|
||||
@ -727,8 +732,10 @@ func (driver Cloud189) FastUpload(file *model.FileStream, parentFile *model.File
|
||||
}
|
||||
if r.StatusCode != http.StatusOK {
|
||||
data, _ := io.ReadAll(r.Body)
|
||||
r.Body.Close()
|
||||
return fmt.Errorf(string(data))
|
||||
}
|
||||
r.Body.Close()
|
||||
}
|
||||
}
|
||||
|
||||
@ -750,8 +757,10 @@ func (driver Cloud189) uploadFamily(file *model.FileStream, parentFile *model.Fi
|
||||
return err
|
||||
}
|
||||
|
||||
defer tempFile.Close()
|
||||
defer os.Remove(tempFile.Name())
|
||||
defer func() {
|
||||
_ = tempFile.Close()
|
||||
_ = os.Remove(tempFile.Name())
|
||||
}()
|
||||
|
||||
fileMd5 := md5.New()
|
||||
if _, err = io.Copy(io.MultiWriter(fileMd5, tempFile), file); err != nil {
|
||||
@ -799,8 +808,10 @@ func (driver Cloud189) uploadPerson(file *model.FileStream, parentFile *model.Fi
|
||||
return err
|
||||
}
|
||||
|
||||
defer tempFile.Close()
|
||||
defer os.Remove(tempFile.Name())
|
||||
defer func() {
|
||||
_ = tempFile.Close()
|
||||
_ = os.Remove(tempFile.Name())
|
||||
}()
|
||||
|
||||
fileMd5 := md5.New()
|
||||
if _, err = io.Copy(io.MultiWriter(fileMd5, tempFile), file); err != nil {
|
||||
|
@ -424,10 +424,17 @@ func (driver AliDrive) Upload(file *model.FileStream, account *model.Account) er
|
||||
}
|
||||
|
||||
if account.Bool1 {
|
||||
buf := make([]byte, 1024)
|
||||
n, _ := file.Read(buf[:])
|
||||
reqBody["pre_hash"] = utils.GetSHA1Encode(string(buf[:n]))
|
||||
file.File = io.NopCloser(io.MultiReader(bytes.NewReader(buf[:n]), file.File))
|
||||
buf := bytes.NewBuffer(make([]byte, 0, 1024))
|
||||
io.CopyN(buf, file, 1024)
|
||||
reqBody["pre_hash"] = utils.GetSHA1Encode(buf.String())
|
||||
// 把头部拼接回去
|
||||
file.File = struct {
|
||||
io.Reader
|
||||
io.Closer
|
||||
}{
|
||||
Reader: io.MultiReader(buf, file.File),
|
||||
Closer: file.File,
|
||||
}
|
||||
} else {
|
||||
reqBody["content_hash_name"] = "none"
|
||||
reqBody["proof_version"] = "v1"
|
||||
@ -454,14 +461,16 @@ func (driver AliDrive) Upload(file *model.FileStream, account *model.Account) er
|
||||
return fmt.Errorf("%s", e.Message)
|
||||
}
|
||||
|
||||
if e.Code == "PreHashMatched" && account.Bool1 {
|
||||
if account.Bool1 && e.Code == "PreHashMatched" {
|
||||
tempFile, err := ioutil.TempFile(conf.Conf.TempDir, "file-*")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
defer tempFile.Close()
|
||||
defer os.Remove(tempFile.Name())
|
||||
defer func() {
|
||||
_ = tempFile.Close()
|
||||
_ = os.Remove(tempFile.Name())
|
||||
}()
|
||||
|
||||
delete(reqBody, "pre_hash")
|
||||
h := sha1.New()
|
||||
@ -499,6 +508,7 @@ func (driver AliDrive) Upload(file *model.FileStream, account *model.Account) er
|
||||
return nil
|
||||
}
|
||||
|
||||
// 秒传失败
|
||||
if _, err = tempFile.Seek(0, io.SeekStart); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -515,6 +525,7 @@ func (driver AliDrive) Upload(file *model.FileStream, account *model.Account) er
|
||||
return err
|
||||
}
|
||||
log.Debugf("%+v", res)
|
||||
res.Body.Close()
|
||||
//res, err := base.BaseClient.R().
|
||||
// SetHeader("Content-Type","").
|
||||
// SetBody(byteData).Put(resp.PartInfoList[i].UploadUrl)
|
||||
|
@ -29,7 +29,7 @@ func (driver *Alist) Login(account *model.Account) error {
|
||||
var resp BaseResp
|
||||
_, err := base.RestyClient.R().SetResult(&resp).
|
||||
SetHeader("Authorization", account.AccessToken).
|
||||
Get(account.SiteUrl + "/api/admin/login")
|
||||
Get(account.SiteUrl + "/api/admin/verify")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ func (driver Alist) Link(args base.Args, account *model.Account) (*base.Link, er
|
||||
flag = "p"
|
||||
}
|
||||
link := base.Link{}
|
||||
link.Url = fmt.Sprintf("%s/%s%s?sign=%s", account.SiteUrl, flag, path, utils.SignWithToken(name, conf.Token))
|
||||
link.Url = fmt.Sprintf("%s/%s%s?sign=%s", account.SiteUrl, flag, utils.Join(utils.ParsePath(account.RootFolder), path), utils.SignWithToken(name, conf.Token))
|
||||
return &link, nil
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,9 @@ import (
|
||||
_ "github.com/Xhofe/alist/drivers/alidrive"
|
||||
_ "github.com/Xhofe/alist/drivers/alist"
|
||||
_ "github.com/Xhofe/alist/drivers/baidu"
|
||||
_ "github.com/Xhofe/alist/drivers/baiduphoto"
|
||||
"github.com/Xhofe/alist/drivers/base"
|
||||
_ "github.com/Xhofe/alist/drivers/chaoxing"
|
||||
_ "github.com/Xhofe/alist/drivers/ftp"
|
||||
_ "github.com/Xhofe/alist/drivers/google"
|
||||
_ "github.com/Xhofe/alist/drivers/lanzou"
|
||||
|
259
drivers/baiduphoto/baidu.go
Normal file
259
drivers/baiduphoto/baidu.go
Normal file
@ -0,0 +1,259 @@
|
||||
package baiduphoto
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/Xhofe/alist/drivers/base"
|
||||
"github.com/Xhofe/alist/model"
|
||||
"github.com/Xhofe/alist/utils"
|
||||
"github.com/go-resty/resty/v2"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func (driver Baidu) RefreshToken(account *model.Account) error {
|
||||
err := driver.refreshToken(account)
|
||||
if err != nil && err == base.ErrEmptyToken {
|
||||
err = driver.refreshToken(account)
|
||||
}
|
||||
if err != nil {
|
||||
account.Status = err.Error()
|
||||
}
|
||||
_ = model.SaveAccount(account)
|
||||
return err
|
||||
}
|
||||
|
||||
func (driver Baidu) refreshToken(account *model.Account) error {
|
||||
u := "https://openapi.baidu.com/oauth/2.0/token"
|
||||
var resp base.TokenResp
|
||||
var e TokenErrResp
|
||||
_, err := base.RestyClient.R().
|
||||
SetResult(&resp).
|
||||
SetError(&e).
|
||||
SetQueryParams(map[string]string{
|
||||
"grant_type": "refresh_token",
|
||||
"refresh_token": account.RefreshToken,
|
||||
"client_id": account.ClientId,
|
||||
"client_secret": account.ClientSecret,
|
||||
}).Get(u)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if e.ErrorMsg != "" {
|
||||
return &e
|
||||
}
|
||||
if resp.RefreshToken == "" {
|
||||
return base.ErrEmptyToken
|
||||
}
|
||||
account.Status = "work"
|
||||
account.AccessToken, account.RefreshToken = resp.AccessToken, resp.RefreshToken
|
||||
return nil
|
||||
}
|
||||
|
||||
func (driver Baidu) Request(method string, url string, callback func(*resty.Request), account *model.Account) (*resty.Response, error) {
|
||||
req := base.RestyClient.R()
|
||||
req.SetQueryParam("access_token", account.AccessToken)
|
||||
if callback != nil {
|
||||
callback(req)
|
||||
}
|
||||
|
||||
res, err := req.Execute(method, url)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
log.Debug(res.String())
|
||||
|
||||
var erron Erron
|
||||
if err = utils.Json.Unmarshal(res.Body(), &erron); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
switch erron.Errno {
|
||||
case 0:
|
||||
return res, nil
|
||||
case -6:
|
||||
if err = driver.RefreshToken(account); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
default:
|
||||
return nil, fmt.Errorf("errno: %d, refer to https://photo.baidu.com/union/doc", erron.Errno)
|
||||
}
|
||||
return driver.Request(method, url, callback, account)
|
||||
}
|
||||
|
||||
// 获取所有根文件
|
||||
func (driver Baidu) GetAllFile(account *model.Account) (files []File, err error) {
|
||||
var cursor string
|
||||
|
||||
for {
|
||||
var resp FileListResp
|
||||
_, err = driver.Request(http.MethodGet, FILE_API_URL_V1+"/list", func(r *resty.Request) {
|
||||
r.SetQueryParams(map[string]string{
|
||||
"need_thumbnail": "1",
|
||||
"need_filter_hidden": "0",
|
||||
"cursor": cursor,
|
||||
})
|
||||
r.SetResult(&resp)
|
||||
}, account)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
cursor = resp.Cursor
|
||||
files = append(files, resp.List...)
|
||||
|
||||
if !resp.HasNextPage() {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 获取所有相册
|
||||
func (driver Baidu) GetAllAlbum(account *model.Account) (albums []Album, err error) {
|
||||
var cursor string
|
||||
for {
|
||||
var resp AlbumListResp
|
||||
_, err = driver.Request(http.MethodGet, ALBUM_API_URL+"/list", func(r *resty.Request) {
|
||||
r.SetQueryParams(map[string]string{
|
||||
"need_amount": "1",
|
||||
"limit": "100",
|
||||
"cursor": cursor,
|
||||
})
|
||||
r.SetResult(&resp)
|
||||
}, account)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if albums == nil {
|
||||
albums = make([]Album, 0, resp.TotalCount)
|
||||
}
|
||||
|
||||
cursor = resp.Cursor
|
||||
albums = append(albums, resp.List...)
|
||||
|
||||
if !resp.HasNextPage() {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 获取相册中所有文件
|
||||
func (driver Baidu) GetAllAlbumFile(albumID string, account *model.Account) (files []AlbumFile, err error) {
|
||||
var cursor string
|
||||
for {
|
||||
var resp AlbumFileListResp
|
||||
_, err = driver.Request(http.MethodGet, ALBUM_API_URL+"/listfile", func(r *resty.Request) {
|
||||
r.SetQueryParams(map[string]string{
|
||||
"album_id": splitID(albumID)[0],
|
||||
"need_amount": "1",
|
||||
"limit": "1000",
|
||||
"cursor": cursor,
|
||||
})
|
||||
r.SetResult(&resp)
|
||||
}, account)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if files == nil {
|
||||
files = make([]AlbumFile, 0, resp.TotalCount)
|
||||
}
|
||||
|
||||
cursor = resp.Cursor
|
||||
files = append(files, resp.List...)
|
||||
|
||||
if !resp.HasNextPage() {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 创建相册
|
||||
func (driver Baidu) CreateAlbum(name string, account *model.Account) error {
|
||||
if !checkName(name) {
|
||||
return ErrNotSupportName
|
||||
}
|
||||
_, err := driver.Request(http.MethodPost, ALBUM_API_URL+"/create", func(r *resty.Request) {
|
||||
r.SetQueryParams(map[string]string{
|
||||
"title": name,
|
||||
"tid": getTid(),
|
||||
"source": "0",
|
||||
})
|
||||
}, account)
|
||||
return err
|
||||
}
|
||||
|
||||
// 相册改名
|
||||
func (driver Baidu) SetAlbumName(albumID string, name string, account *model.Account) error {
|
||||
if !checkName(name) {
|
||||
return ErrNotSupportName
|
||||
}
|
||||
|
||||
e := splitID(albumID)
|
||||
_, err := driver.Request(http.MethodPost, ALBUM_API_URL+"/settitle", func(r *resty.Request) {
|
||||
r.SetFormData(map[string]string{
|
||||
"title": name,
|
||||
"album_id": e[0],
|
||||
"tid": e[1],
|
||||
})
|
||||
}, account)
|
||||
return err
|
||||
}
|
||||
|
||||
// 删除相册
|
||||
func (driver Baidu) DeleteAlbum(albumID string, account *model.Account) error {
|
||||
e := splitID(albumID)
|
||||
_, err := driver.Request(http.MethodPost, ALBUM_API_URL+"/delete", func(r *resty.Request) {
|
||||
r.SetFormData(map[string]string{
|
||||
"album_id": e[0],
|
||||
"tid": e[1],
|
||||
"delete_origin_image": "0", // 是否删除原图 0 不删除
|
||||
})
|
||||
}, account)
|
||||
return err
|
||||
}
|
||||
|
||||
// 删除相册文件
|
||||
func (driver Baidu) DeleteAlbumFile(albumID string, account *model.Account, fileIDs ...string) error {
|
||||
e := splitID(albumID)
|
||||
_, err := driver.Request(http.MethodPost, ALBUM_API_URL+"/delfile", func(r *resty.Request) {
|
||||
r.SetFormData(map[string]string{
|
||||
"album_id": e[0],
|
||||
"tid": e[1],
|
||||
"list": fsidsFormat(fileIDs...),
|
||||
"del_origin": "0", // 是否删除原图 0 不删除 1 删除
|
||||
})
|
||||
}, account)
|
||||
return err
|
||||
}
|
||||
|
||||
// 增加相册文件
|
||||
func (driver Baidu) AddAlbumFile(albumID string, account *model.Account, fileIDs ...string) error {
|
||||
e := splitID(albumID)
|
||||
_, err := driver.Request(http.MethodGet, ALBUM_API_URL+"/addfile", func(r *resty.Request) {
|
||||
r.SetQueryParams(map[string]string{
|
||||
"album_id": e[0],
|
||||
"tid": e[1],
|
||||
"list": fsidsFormatNotUk(fileIDs...),
|
||||
})
|
||||
}, account)
|
||||
return err
|
||||
}
|
||||
|
||||
// 保存相册文件为根文件
|
||||
func (driver Baidu) CopyAlbumFile(albumID string, account *model.Account, fileID string) (*CopyFile, error) {
|
||||
var resp CopyFileResp
|
||||
e := splitID(fileID)
|
||||
_, err := driver.Request(http.MethodPost, ALBUM_API_URL+"/copyfile", func(r *resty.Request) {
|
||||
r.SetFormData(map[string]string{
|
||||
"album_id": splitID(albumID)[0],
|
||||
"tid": e[2],
|
||||
"uk": e[1],
|
||||
"list": fsidsFormatNotUk(fileID),
|
||||
})
|
||||
r.SetResult(&resp)
|
||||
}, account)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &resp.List[0], err
|
||||
}
|
502
drivers/baiduphoto/driver.go
Normal file
502
drivers/baiduphoto/driver.go
Normal file
@ -0,0 +1,502 @@
|
||||
package baiduphoto
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"github.com/Xhofe/alist/conf"
|
||||
"github.com/Xhofe/alist/drivers/base"
|
||||
"github.com/Xhofe/alist/model"
|
||||
"github.com/Xhofe/alist/utils"
|
||||
"github.com/go-resty/resty/v2"
|
||||
)
|
||||
|
||||
type Baidu struct{}
|
||||
|
||||
func init() {
|
||||
base.RegisterDriver(new(Baidu))
|
||||
}
|
||||
|
||||
func (driver Baidu) Config() base.DriverConfig {
|
||||
return base.DriverConfig{
|
||||
Name: "Baidu.Photo",
|
||||
LocalSort: true,
|
||||
}
|
||||
}
|
||||
|
||||
func (driver Baidu) Items() []base.Item {
|
||||
return []base.Item{
|
||||
{
|
||||
Name: "refresh_token",
|
||||
Label: "refresh token",
|
||||
Type: base.TypeString,
|
||||
Required: true,
|
||||
},
|
||||
{
|
||||
Name: "root_folder",
|
||||
Label: "album_id",
|
||||
Type: base.TypeString,
|
||||
},
|
||||
{
|
||||
Name: "internal_type",
|
||||
Label: "download api",
|
||||
Type: base.TypeSelect,
|
||||
Required: true,
|
||||
Values: "file,album",
|
||||
Default: "album",
|
||||
},
|
||||
{
|
||||
Name: "client_id",
|
||||
Label: "client id",
|
||||
Default: "iYCeC9g08h5vuP9UqvPHKKSVrKFXGa1v",
|
||||
Type: base.TypeString,
|
||||
Required: true,
|
||||
},
|
||||
{
|
||||
Name: "client_secret",
|
||||
Label: "client secret",
|
||||
Default: "jXiFMOPVPCWlO2M5CwWQzffpNPaGTRBG",
|
||||
Type: base.TypeString,
|
||||
Required: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (driver Baidu) Save(account *model.Account, old *model.Account) error {
|
||||
if account == nil {
|
||||
return nil
|
||||
}
|
||||
return driver.RefreshToken(account)
|
||||
}
|
||||
|
||||
func (driver Baidu) File(path string, account *model.Account) (*model.File, error) {
|
||||
path = utils.ParsePath(path)
|
||||
if path == "/" {
|
||||
return &model.File{
|
||||
Id: account.RootFolder,
|
||||
Name: account.Name,
|
||||
Size: 0,
|
||||
Type: conf.FOLDER,
|
||||
Driver: driver.Config().Name,
|
||||
UpdatedAt: account.UpdatedAt,
|
||||
}, nil
|
||||
}
|
||||
|
||||
dir, name := utils.Split(path)
|
||||
files, err := driver.Files(dir, account)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, file := range files {
|
||||
if file.Name == name {
|
||||
return &file, nil
|
||||
}
|
||||
}
|
||||
return nil, base.ErrPathNotFound
|
||||
}
|
||||
|
||||
func (driver Baidu) Files(path string, account *model.Account) ([]model.File, error) {
|
||||
path = utils.ParsePath(path)
|
||||
var files []model.File
|
||||
cache, err := base.GetCache(path, account)
|
||||
if err == nil {
|
||||
files, _ = cache.([]model.File)
|
||||
return files, nil
|
||||
}
|
||||
|
||||
file, err := driver.File(path, account)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if IsAlbum(file) {
|
||||
albumFiles, err := driver.GetAllAlbumFile(file.Id, account)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
files = make([]model.File, 0, len(albumFiles))
|
||||
for _, file := range albumFiles {
|
||||
var thumbnail string
|
||||
if len(file.Thumburl) > 0 {
|
||||
thumbnail = file.Thumburl[0]
|
||||
}
|
||||
files = append(files, model.File{
|
||||
Id: joinID(file.Fsid, file.Uk, file.Tid),
|
||||
Name: file.Name(),
|
||||
Size: file.Size,
|
||||
Type: utils.GetFileType(utils.Ext(file.Path)),
|
||||
Driver: driver.Config().Name,
|
||||
UpdatedAt: getTime(file.Mtime),
|
||||
Thumbnail: thumbnail,
|
||||
})
|
||||
}
|
||||
} else if IsRoot(file) {
|
||||
albums, err := driver.GetAllAlbum(account)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
files = make([]model.File, 0, len(albums))
|
||||
for _, album := range albums {
|
||||
files = append(files, model.File{
|
||||
Id: joinID(album.AlbumID, album.Tid),
|
||||
Name: album.Title,
|
||||
Size: 0,
|
||||
Type: conf.FOLDER,
|
||||
Driver: driver.Config().Name,
|
||||
UpdatedAt: getTime(album.Mtime),
|
||||
})
|
||||
}
|
||||
} else {
|
||||
return nil, base.ErrNotSupport
|
||||
}
|
||||
|
||||
if len(files) > 0 {
|
||||
_ = base.SetCache(path, files, account)
|
||||
}
|
||||
return files, nil
|
||||
}
|
||||
|
||||
func (driver Baidu) Link(args base.Args, account *model.Account) (*base.Link, error) {
|
||||
if account.InternalType == "file" {
|
||||
return driver.LinkFile(args, account)
|
||||
}
|
||||
return driver.LinkAlbum(args, account)
|
||||
}
|
||||
|
||||
func (driver Baidu) LinkAlbum(args base.Args, account *model.Account) (*base.Link, error) {
|
||||
file, err := driver.File(args.Path, account)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !IsAlbumFile(file) {
|
||||
return nil, base.ErrNotSupport
|
||||
}
|
||||
|
||||
album, err := driver.File(utils.Dir(utils.ParsePath(args.Path)), account)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
e := splitID(file.Id)
|
||||
res, err := base.NoRedirectClient.R().
|
||||
SetQueryParams(map[string]string{
|
||||
"access_token": account.AccessToken,
|
||||
"album_id": splitID(album.Id)[0],
|
||||
"tid": e[2],
|
||||
"fsid": e[0],
|
||||
"uk": e[1],
|
||||
}).
|
||||
Head(ALBUM_API_URL + "/download")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &base.Link{
|
||||
Headers: []base.Header{
|
||||
{Name: "User-Agent", Value: base.UserAgent},
|
||||
},
|
||||
Url: res.Header().Get("location"),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (driver Baidu) LinkFile(args base.Args, account *model.Account) (*base.Link, error) {
|
||||
file, err := driver.File(args.Path, account)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if !IsAlbumFile(file) {
|
||||
return nil, base.ErrNotSupport
|
||||
}
|
||||
|
||||
album, err := driver.File(utils.Dir(utils.ParsePath(args.Path)), account)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// 拷贝到根目录
|
||||
cfile, err := driver.CopyAlbumFile(album.Id, account, file.Id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
res, err := driver.Request(http.MethodGet, FILE_API_URL_V2+"/download", func(r *resty.Request) {
|
||||
r.SetQueryParams(map[string]string{
|
||||
"fsid": fmt.Sprint(cfile.Fsid),
|
||||
})
|
||||
}, account)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &base.Link{
|
||||
Headers: []base.Header{
|
||||
{Name: "User-Agent", Value: base.UserAgent},
|
||||
},
|
||||
Url: utils.Json.Get(res.Body(), "dlink").ToString(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (driver Baidu) Path(path string, account *model.Account) (*model.File, []model.File, error) {
|
||||
path = utils.ParsePath(path)
|
||||
file, err := driver.File(path, account)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
if !file.IsDir() {
|
||||
return file, nil, nil
|
||||
}
|
||||
files, err := driver.Files(path, account)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
return nil, files, nil
|
||||
}
|
||||
|
||||
func (driver Baidu) Preview(path string, account *model.Account) (interface{}, error) {
|
||||
return nil, base.ErrNotSupport
|
||||
}
|
||||
|
||||
func (driver Baidu) Rename(src string, dst string, account *model.Account) error {
|
||||
srcFile, err := driver.File(src, account)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if IsAlbum(srcFile) {
|
||||
return driver.SetAlbumName(srcFile.Id, utils.Base(dst), account)
|
||||
}
|
||||
return base.ErrNotSupport
|
||||
}
|
||||
|
||||
func (driver Baidu) MakeDir(path string, account *model.Account) error {
|
||||
dir, name := utils.Split(path)
|
||||
parentFile, err := driver.File(dir, account)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if !IsRoot(parentFile) {
|
||||
return base.ErrNotSupport
|
||||
}
|
||||
return driver.CreateAlbum(name, account)
|
||||
}
|
||||
|
||||
func (driver Baidu) Move(src string, dst string, account *model.Account) error {
|
||||
srcFile, err := driver.File(src, account)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if IsAlbumFile(srcFile) {
|
||||
// 移动相册文件
|
||||
dstAlbum, err := driver.File(utils.Dir(dst), account)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !IsAlbum(dstAlbum) {
|
||||
return base.ErrNotSupport
|
||||
}
|
||||
|
||||
srcAlbum, err := driver.File(utils.Dir(src), account)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
newFile, err := driver.CopyAlbumFile(srcAlbum.Id, account, srcFile.Id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = driver.DeleteAlbumFile(srcAlbum.Id, account, srcFile.Id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = driver.AddAlbumFile(dstAlbum.Id, account, joinID(newFile.Fsid))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
return base.ErrNotSupport
|
||||
}
|
||||
|
||||
func (driver Baidu) Copy(src string, dst string, account *model.Account) error {
|
||||
srcFile, err := driver.File(src, account)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if IsAlbumFile(srcFile) {
|
||||
// 复制相册文件
|
||||
dstAlbum, err := driver.File(utils.Dir(dst), account)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !IsAlbum(dstAlbum) {
|
||||
return base.ErrNotSupport
|
||||
}
|
||||
|
||||
srcAlbum, err := driver.File(utils.Dir(src), account)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
newFile, err := driver.CopyAlbumFile(srcAlbum.Id, account, srcFile.Id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = driver.AddAlbumFile(dstAlbum.Id, account, joinID(newFile.Fsid))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
return base.ErrNotSupport
|
||||
}
|
||||
|
||||
func (driver Baidu) Delete(path string, account *model.Account) error {
|
||||
file, err := driver.File(path, account)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// 删除相册
|
||||
if IsAlbum(file) {
|
||||
return driver.DeleteAlbum(file.Id, account)
|
||||
}
|
||||
|
||||
// 生成相册文件
|
||||
if IsAlbumFile(file) {
|
||||
// 删除相册文件
|
||||
album, err := driver.File(utils.Dir(path), account)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return driver.DeleteAlbumFile(album.Id, account, file.Id)
|
||||
}
|
||||
return base.ErrNotSupport
|
||||
}
|
||||
|
||||
func (driver Baidu) Upload(file *model.FileStream, account *model.Account) error {
|
||||
if file == nil {
|
||||
return base.ErrEmptyFile
|
||||
}
|
||||
|
||||
parentFile, err := driver.File(file.ParentPath, account)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if !IsAlbum(parentFile) {
|
||||
return base.ErrNotSupport
|
||||
}
|
||||
|
||||
tempFile, err := ioutil.TempFile(conf.Conf.TempDir, "file-*")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer func() {
|
||||
tempFile.Close()
|
||||
os.Remove(tempFile.Name())
|
||||
}()
|
||||
|
||||
// 计算需要的数据
|
||||
const DEFAULT = 1 << 22
|
||||
const SliceSize = 1 << 18
|
||||
count := int(math.Ceil(float64(file.Size) / float64(DEFAULT)))
|
||||
|
||||
sliceMD5List := make([]string, 0, count)
|
||||
fileMd5 := md5.New()
|
||||
sliceMd5 := md5.New()
|
||||
for i := 1; i <= count; i++ {
|
||||
if n, err := io.CopyN(io.MultiWriter(fileMd5, sliceMd5, tempFile), file, DEFAULT); err != io.EOF && n == 0 {
|
||||
return err
|
||||
}
|
||||
sliceMD5List = append(sliceMD5List, hex.EncodeToString(sliceMd5.Sum(nil)))
|
||||
sliceMd5.Reset()
|
||||
}
|
||||
|
||||
if _, err = tempFile.Seek(0, io.SeekStart); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
content_md5 := hex.EncodeToString(fileMd5.Sum(nil))
|
||||
slice_md5 := content_md5
|
||||
if file.GetSize() > SliceSize {
|
||||
sliceData := make([]byte, SliceSize)
|
||||
if _, err = io.ReadFull(tempFile, sliceData); err != nil {
|
||||
return err
|
||||
}
|
||||
sliceMd5.Write(sliceData)
|
||||
slice_md5 = hex.EncodeToString(sliceMd5.Sum(nil))
|
||||
if _, err = tempFile.Seek(0, io.SeekStart); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// 开始执行上传
|
||||
params := map[string]string{
|
||||
"autoinit": "1",
|
||||
"isdir": "0",
|
||||
"rtype": "1",
|
||||
"ctype": "11",
|
||||
"path": utils.ParsePath(file.Name),
|
||||
"size": fmt.Sprint(file.Size),
|
||||
"slice-md5": slice_md5,
|
||||
"content-md5": content_md5,
|
||||
"block_list": MustString(utils.Json.MarshalToString(sliceMD5List)),
|
||||
}
|
||||
|
||||
// 预上传
|
||||
var precreateResp PrecreateResp
|
||||
_, err = driver.Request(http.MethodPost, FILE_API_URL_V1+"/precreate", func(r *resty.Request) {
|
||||
r.SetFormData(params)
|
||||
r.SetResult(&precreateResp)
|
||||
}, account)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
switch precreateResp.ReturnType {
|
||||
case 1: // 上传文件
|
||||
uploadParams := map[string]string{
|
||||
"method": "upload",
|
||||
"path": params["path"],
|
||||
"uploadid": precreateResp.UploadID,
|
||||
}
|
||||
|
||||
for i := 0; i < count; i++ {
|
||||
uploadParams["partseq"] = fmt.Sprint(i)
|
||||
_, err = driver.Request(http.MethodPost, "https://c3.pcs.baidu.com/rest/2.0/pcs/superfile2", func(r *resty.Request) {
|
||||
r.SetQueryParams(uploadParams)
|
||||
r.SetFileReader("file", file.Name, io.LimitReader(tempFile, DEFAULT))
|
||||
}, account)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
fallthrough
|
||||
case 2: // 创建文件
|
||||
params["uploadid"] = precreateResp.UploadID
|
||||
_, err = driver.Request(http.MethodPost, FILE_API_URL_V1+"/create", func(r *resty.Request) {
|
||||
r.SetFormData(params)
|
||||
r.SetResult(&precreateResp)
|
||||
}, account)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fallthrough
|
||||
case 3: // 增加到相册
|
||||
err = driver.AddAlbumFile(parentFile.Id, account, joinID(precreateResp.Data.FsID))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var _ base.Driver = (*Baidu)(nil)
|
126
drivers/baiduphoto/types.go
Normal file
126
drivers/baiduphoto/types.go
Normal file
@ -0,0 +1,126 @@
|
||||
package baiduphoto
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/Xhofe/alist/utils"
|
||||
)
|
||||
|
||||
type TokenErrResp struct {
|
||||
ErrorDescription string `json:"error_description"`
|
||||
ErrorMsg string `json:"error"`
|
||||
}
|
||||
|
||||
func (e *TokenErrResp) Error() string {
|
||||
return fmt.Sprint(e.ErrorMsg, " : ", e.ErrorDescription)
|
||||
}
|
||||
|
||||
type Erron struct {
|
||||
Errno int `json:"errno"`
|
||||
RequestID int `json:"request_id"`
|
||||
}
|
||||
|
||||
type Page struct {
|
||||
HasMore int `json:"has_more"`
|
||||
Cursor string `json:"cursor"`
|
||||
}
|
||||
|
||||
func (p Page) HasNextPage() bool {
|
||||
return p.HasMore == 1
|
||||
}
|
||||
|
||||
type (
|
||||
FileListResp struct {
|
||||
Page
|
||||
List []File `json:"list"`
|
||||
}
|
||||
|
||||
File struct {
|
||||
Fsid int64 `json:"fsid"` // 文件ID
|
||||
Path string `json:"path"` // 文件路径
|
||||
Size int64 `json:"size"`
|
||||
Ctime int64 `json:"ctime"` // 创建时间 s
|
||||
Mtime int64 `json:"mtime"` // 修改时间 s
|
||||
Thumburl []string `json:"thumburl"`
|
||||
}
|
||||
)
|
||||
|
||||
func (f File) Name() string {
|
||||
return utils.Base(f.Path)
|
||||
}
|
||||
|
||||
/*相册部分*/
|
||||
type (
|
||||
AlbumListResp struct {
|
||||
Page
|
||||
List []Album `json:"list"`
|
||||
Reset int64 `json:"reset"`
|
||||
TotalCount int64 `json:"total_count"`
|
||||
}
|
||||
|
||||
Album struct {
|
||||
AlbumID string `json:"album_id"`
|
||||
Tid int64 `json:"tid"`
|
||||
Title string `json:"title"`
|
||||
JoinTime int64 `json:"join_time"`
|
||||
CreateTime int64 `json:"create_time"`
|
||||
Mtime int64 `json:"mtime"`
|
||||
}
|
||||
|
||||
AlbumFileListResp struct {
|
||||
Page
|
||||
List []AlbumFile `json:"list"`
|
||||
Reset int64 `json:"reset"`
|
||||
TotalCount int64 `json:"total_count"`
|
||||
}
|
||||
|
||||
AlbumFile struct {
|
||||
File
|
||||
Tid int64 `json:"tid"`
|
||||
Uk int64 `json:"uk"`
|
||||
}
|
||||
)
|
||||
|
||||
type (
|
||||
CopyFileResp struct {
|
||||
List []CopyFile `json:"list"`
|
||||
}
|
||||
CopyFile struct {
|
||||
FromFsid int64 `json:"from_fsid"` // 源ID
|
||||
Fsid int64 `json:"fsid"` // 目标ID
|
||||
Path string `json:"path"`
|
||||
ShootTime int `json:"shoot_time"`
|
||||
}
|
||||
)
|
||||
|
||||
/*上传部分*/
|
||||
type (
|
||||
UploadFile struct {
|
||||
FsID int64 `json:"fs_id"`
|
||||
Size int64 `json:"size"`
|
||||
Md5 string `json:"md5"`
|
||||
ServerFilename string `json:"server_filename"`
|
||||
Path string `json:"path"`
|
||||
Ctime int `json:"ctime"`
|
||||
Mtime int `json:"mtime"`
|
||||
Isdir int `json:"isdir"`
|
||||
Category int `json:"category"`
|
||||
ServerMd5 string `json:"server_md5"`
|
||||
ShootTime int `json:"shoot_time"`
|
||||
}
|
||||
|
||||
CreateFileResp struct {
|
||||
Data UploadFile `json:"data"`
|
||||
}
|
||||
|
||||
PrecreateResp struct {
|
||||
ReturnType int `json:"return_type"` //存在返回2 不存在返回1 已经保存3
|
||||
//存在返回
|
||||
CreateFileResp
|
||||
|
||||
//不存在返回
|
||||
Path string `json:"path"`
|
||||
UploadID string `json:"uploadid"`
|
||||
Blocklist []int64 `json:"block_list"`
|
||||
}
|
||||
)
|
84
drivers/baiduphoto/util.go
Normal file
84
drivers/baiduphoto/util.go
Normal file
@ -0,0 +1,84 @@
|
||||
package baiduphoto
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
"math/rand"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/Xhofe/alist/model"
|
||||
)
|
||||
|
||||
const (
|
||||
API_URL = "https://photo.baidu.com/youai"
|
||||
ALBUM_API_URL = API_URL + "/album/v1"
|
||||
FILE_API_URL_V1 = API_URL + "/file/v1"
|
||||
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")
|
||||
)
|
||||
|
||||
//Tid生成
|
||||
func getTid() string {
|
||||
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 getTime(t int64) *time.Time {
|
||||
tm := time.Unix(t, 0)
|
||||
return &tm
|
||||
}
|
||||
|
||||
func fsidsFormat(ids ...string) string {
|
||||
var buf []string
|
||||
for _, id := range ids {
|
||||
e := strings.Split(id, "|")
|
||||
buf = append(buf, fmt.Sprintf("{\"fsid\":%s,\"uk\":%s}", e[0], e[1]))
|
||||
}
|
||||
return fmt.Sprintf("[%s]", strings.Join(buf, ","))
|
||||
}
|
||||
|
||||
func fsidsFormatNotUk(ids ...string) string {
|
||||
var buf []string
|
||||
for _, id := range ids {
|
||||
buf = append(buf, fmt.Sprintf("{\"fsid\":%s}", strings.Split(id, "|")[0]))
|
||||
}
|
||||
return fmt.Sprintf("[%s]", strings.Join(buf, ","))
|
||||
}
|
||||
|
||||
func splitID(id string) []string {
|
||||
return strings.SplitN(id, "|", 3)[:3]
|
||||
}
|
||||
|
||||
func joinID(ids ...interface{}) string {
|
||||
idsStr := make([]string, 0, len(ids))
|
||||
for _, id := range ids {
|
||||
idsStr = append(idsStr, fmt.Sprint(id))
|
||||
}
|
||||
return strings.Join(idsStr, "|")
|
||||
}
|
||||
|
||||
func IsAlbum(file *model.File) bool {
|
||||
return file.Id != "" && file.IsDir()
|
||||
}
|
||||
|
||||
func IsAlbumFile(file *model.File) bool {
|
||||
return file.Id != "" && !file.IsDir()
|
||||
}
|
||||
|
||||
func IsRoot(file *model.File) bool {
|
||||
return file.Id == "" && file.IsDir()
|
||||
}
|
||||
|
||||
func MustString(str string, err error) string {
|
||||
return str
|
||||
}
|
61
drivers/base/base.go
Normal file
61
drivers/base/base.go
Normal file
@ -0,0 +1,61 @@
|
||||
package base
|
||||
|
||||
import "github.com/Xhofe/alist/model"
|
||||
|
||||
type Base struct{}
|
||||
|
||||
func (b Base) Config() DriverConfig {
|
||||
return DriverConfig{}
|
||||
}
|
||||
|
||||
func (b Base) Items() []Item {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b Base) Save(account *model.Account, old *model.Account) error {
|
||||
return ErrNotImplement
|
||||
}
|
||||
|
||||
func (b Base) File(path string, account *model.Account) (*model.File, error) {
|
||||
return nil, ErrNotImplement
|
||||
}
|
||||
|
||||
func (b Base) Files(path string, account *model.Account) ([]model.File, error) {
|
||||
return nil, ErrNotImplement
|
||||
}
|
||||
|
||||
func (b Base) Link(args Args, account *model.Account) (*Link, error) {
|
||||
return nil, ErrNotImplement
|
||||
}
|
||||
|
||||
func (b Base) Path(path string, account *model.Account) (*model.File, []model.File, error) {
|
||||
return nil, nil, ErrNotImplement
|
||||
}
|
||||
|
||||
func (b Base) Preview(path string, account *model.Account) (interface{}, error) {
|
||||
return nil, ErrNotImplement
|
||||
}
|
||||
|
||||
func (b Base) MakeDir(path string, account *model.Account) error {
|
||||
return ErrNotImplement
|
||||
}
|
||||
|
||||
func (b Base) Move(src string, dst string, account *model.Account) error {
|
||||
return ErrNotImplement
|
||||
}
|
||||
|
||||
func (b Base) Rename(src string, dst string, account *model.Account) error {
|
||||
return ErrNotImplement
|
||||
}
|
||||
|
||||
func (b Base) Copy(src string, dst string, account *model.Account) error {
|
||||
return ErrNotImplement
|
||||
}
|
||||
|
||||
func (b Base) Delete(path string, account *model.Account) error {
|
||||
return ErrNotImplement
|
||||
}
|
||||
|
||||
func (b Base) Upload(file *model.FileStream, account *model.Account) error {
|
||||
return ErrNotImplement
|
||||
}
|
@ -5,6 +5,7 @@ import (
|
||||
"github.com/Xhofe/alist/model"
|
||||
"github.com/Xhofe/alist/utils"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func KeyCache(path string, account *model.Account) string {
|
||||
@ -15,6 +16,9 @@ func KeyCache(path string, account *model.Account) string {
|
||||
}
|
||||
|
||||
func SaveSearchFiles[T model.ISearchFile](key string, obj []T) {
|
||||
if strings.Contains(key, ".balance") {
|
||||
return
|
||||
}
|
||||
err := model.DeleteSearchFilesByPath(key)
|
||||
if err != nil {
|
||||
log.Errorln("failed create search files", err)
|
||||
|
@ -19,8 +19,9 @@ type DriverConfig struct {
|
||||
}
|
||||
|
||||
type Args struct {
|
||||
Path string
|
||||
IP string
|
||||
Path string
|
||||
IP string
|
||||
Header http.Header
|
||||
}
|
||||
|
||||
type Driver interface {
|
||||
|
@ -3,6 +3,7 @@ package base
|
||||
import (
|
||||
"errors"
|
||||
"io"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -49,4 +50,6 @@ type Link struct {
|
||||
Headers []Header `json:"headers"`
|
||||
Data io.ReadCloser
|
||||
FilePath string `json:"path"` // for native
|
||||
Status int
|
||||
Header http.Header
|
||||
}
|
||||
|
90
drivers/chaoxing/chaoxing.go
Normal file
90
drivers/chaoxing/chaoxing.go
Normal file
@ -0,0 +1,90 @@
|
||||
package template
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/Xhofe/alist/conf"
|
||||
"github.com/Xhofe/alist/drivers/base"
|
||||
"github.com/Xhofe/alist/model"
|
||||
"github.com/Xhofe/alist/utils"
|
||||
"github.com/go-resty/resty/v2"
|
||||
"path"
|
||||
)
|
||||
|
||||
func LoginOrRefreshToken(account *model.Account) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func Request(u string, method int, headers, query, form map[string]string, data interface{}, resp interface{}, account *model.Account) ([]byte, error) {
|
||||
req := base.RestyClient.R()
|
||||
req.SetHeaders(map[string]string{
|
||||
"Authorization": "Bearer" + account.AccessToken,
|
||||
"Accept": "application/json, text/plain, */*",
|
||||
})
|
||||
if headers != nil {
|
||||
req.SetHeaders(headers)
|
||||
}
|
||||
if query != nil {
|
||||
req.SetQueryParams(query)
|
||||
}
|
||||
if form != nil {
|
||||
req.SetFormData(form)
|
||||
}
|
||||
if data != nil {
|
||||
req.SetBody(data)
|
||||
}
|
||||
if resp != nil {
|
||||
req.SetResult(resp)
|
||||
}
|
||||
var e Resp
|
||||
var err error
|
||||
var res *resty.Response
|
||||
req.SetError(&e)
|
||||
switch method {
|
||||
case base.Get:
|
||||
res, err = req.Get(u)
|
||||
case base.Post:
|
||||
res, err = req.Post(u)
|
||||
case base.Delete:
|
||||
res, err = req.Delete(u)
|
||||
case base.Patch:
|
||||
res, err = req.Patch(u)
|
||||
case base.Put:
|
||||
res, err = req.Put(u)
|
||||
default:
|
||||
return nil, base.ErrNotSupport
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if e.Code >= 400 {
|
||||
if e.Code == 401 {
|
||||
err = LoginOrRefreshToken(account)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return Request(u, method, headers, query, form, data, resp, account)
|
||||
}
|
||||
return nil, errors.New(e.Message)
|
||||
}
|
||||
return res.Body(), nil
|
||||
}
|
||||
|
||||
func (driver ChaoxingDrive) formatFile(f *File) *model.File {
|
||||
file := model.File{
|
||||
Id: f.Id,
|
||||
Name: f.FileName,
|
||||
Size: f.Size,
|
||||
Driver: driver.Config().Name,
|
||||
UpdatedAt: f.UpdatedAt,
|
||||
}
|
||||
if f.File {
|
||||
file.Type = utils.GetFileType(path.Ext(f.FileName))
|
||||
} else {
|
||||
file.Type = conf.FOLDER
|
||||
}
|
||||
return &file
|
||||
}
|
||||
|
||||
func init() {
|
||||
base.RegisterDriver(&ChaoxingDrive{})
|
||||
}
|
261
drivers/chaoxing/driver.go
Normal file
261
drivers/chaoxing/driver.go
Normal file
@ -0,0 +1,261 @@
|
||||
package template
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/Xhofe/alist/conf"
|
||||
"github.com/Xhofe/alist/drivers/base"
|
||||
"github.com/Xhofe/alist/model"
|
||||
"github.com/Xhofe/alist/utils"
|
||||
"github.com/robfig/cron/v3"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type ChaoxingDrive struct {
|
||||
base.Base
|
||||
}
|
||||
|
||||
func (driver ChaoxingDrive) Config() base.DriverConfig {
|
||||
return base.DriverConfig{
|
||||
Name: "ChaoXing",
|
||||
OnlyProxy: true,
|
||||
OnlyLocal: false,
|
||||
ApiProxy: false,
|
||||
NoNeedSetLink: false,
|
||||
NoCors: false,
|
||||
LocalSort: false,
|
||||
}
|
||||
}
|
||||
|
||||
func (driver ChaoxingDrive) Items() []base.Item {
|
||||
// TODO fill need info
|
||||
return []base.Item{
|
||||
{
|
||||
Name: "username",
|
||||
Label: "手机号/超星号",
|
||||
Type: base.TypeString,
|
||||
Required: true,
|
||||
},
|
||||
{
|
||||
Name: "password",
|
||||
Label: "enc (加密后的密码)",
|
||||
Type: base.TypeString,
|
||||
Required: true,
|
||||
},
|
||||
{
|
||||
Name: "root_folder",
|
||||
Label: "根目录id",
|
||||
Type: base.TypeString,
|
||||
Default: "",
|
||||
Required: false,
|
||||
},
|
||||
{
|
||||
Name: "limit",
|
||||
Label: "目录文件上限",
|
||||
Type: base.TypeNumber,
|
||||
Default: "50",
|
||||
Required: false,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// Save 用户更新账号信息
|
||||
func (driver ChaoxingDrive) Save(account *model.Account, old *model.Account) error {
|
||||
// TODO test available or init
|
||||
if old != nil {
|
||||
conf.Cron.Remove(cron.EntryID(old.CronId))
|
||||
}
|
||||
if account == nil {
|
||||
return nil
|
||||
}
|
||||
if account.Limit <= 0 {
|
||||
account.Limit = 50
|
||||
}
|
||||
|
||||
// 登录网盘并取得 Enc 字符串 ( enc保存在 account.AccessSecret 中; cookie 以键值对的形式保存在 account.AccessToken 中)
|
||||
err := driver.GetEnc(account)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// 每隔一天重新获取一次 Enc(和
|
||||
cronId, err := conf.Cron.AddFunc("@every 24h", func() {
|
||||
id := account.ID
|
||||
log.Debugf("ali account id: %d", id)
|
||||
newAccount, err := model.GetAccountById(id)
|
||||
log.Debugf("ali account: %+v", newAccount)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = driver.GetEnc(newAccount)
|
||||
_ = model.SaveAccount(newAccount)
|
||||
})
|
||||
|
||||
// 记录当前计划任务的id
|
||||
account.CronId = int(cronId)
|
||||
err = model.SaveAccount(account)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// File 通过用户路径获取到文件对象(主要是id号)
|
||||
func (driver ChaoxingDrive) File(path string, account *model.Account) (*model.File, error) {
|
||||
path = utils.ParsePath(path)
|
||||
if path == "/" {
|
||||
return &model.File{
|
||||
Id: "",
|
||||
Name: account.Name,
|
||||
Size: 0,
|
||||
Type: conf.FOLDER,
|
||||
Driver: driver.Config().Name,
|
||||
UpdatedAt: account.UpdatedAt,
|
||||
}, nil
|
||||
}
|
||||
// 将路径分割成 父文件夹 和 文件名
|
||||
dir, name := filepath.Split(path)
|
||||
// 等同于访问上级目录
|
||||
files, err := driver.Files(dir, account)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, file := range files {
|
||||
if file.Name == name {
|
||||
return &file, nil
|
||||
}
|
||||
}
|
||||
return nil, base.ErrPathNotFound
|
||||
}
|
||||
|
||||
// Files 列出所有文件
|
||||
func (driver ChaoxingDrive) Files(path string, account *model.Account) ([]model.File, error) {
|
||||
path = utils.ParsePath(path)
|
||||
// 先从缓存中获取结果
|
||||
cache, err := base.GetCache(path, account)
|
||||
var fileList []model.File
|
||||
if err == nil {
|
||||
// 缓存命中,将目录信息保存到变量中
|
||||
fileList = cache.([]model.File)
|
||||
} else {
|
||||
// 缓存未命中
|
||||
//尝试获取上级目录的id(递归地尝试从上级目录的缓存中读取信息,直到获取到根目录为止)
|
||||
file, err := driver.File(path, account)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
//列出上级目录的文件
|
||||
fileList, err = driver.ListFile(file.Id, account)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// 缓存数据
|
||||
if len(fileList) > 0 {
|
||||
_ = base.SetCache(path, fileList, account)
|
||||
}
|
||||
}
|
||||
files := make([]model.File, 0)
|
||||
for _, file := range fileList {
|
||||
files = append(files, file)
|
||||
}
|
||||
return files, nil
|
||||
}
|
||||
|
||||
var api_file_link = "https://pan-yz.chaoxing.com/download/downloadfile?fleid=%s&puid=1"
|
||||
|
||||
// Link 返回传入路径对应的文件的直链(本地除外),并包含需要携带的请求头
|
||||
func (driver ChaoxingDrive) Link(args base.Args, account *model.Account) (*base.Link, error) {
|
||||
// TODO get file link
|
||||
file, e := driver.File(args.Path, account)
|
||||
if e != nil {
|
||||
return nil, e
|
||||
}
|
||||
url := fmt.Sprintf(api_file_link, file.Id[:strings.Index(file.Id, "_")])
|
||||
//var resp base.Json
|
||||
//var err Resp
|
||||
|
||||
// https://pan-yz.chaoxing.com/download/downloadfile?fleid=582519780768600064&puid=1
|
||||
//_, e = chaoxingClient.R().SetResult(&resp).SetError(&err).
|
||||
// SetHeader("Cookie", account.AccessToken).
|
||||
// SetHeader("Referer", "https://pan-yz.chaoxing.com/").
|
||||
// Get(url)
|
||||
return &base.Link{
|
||||
Headers: []base.Header{
|
||||
{
|
||||
Name: "Referer",
|
||||
Value: "https://pan-yz.chaoxing.com/",
|
||||
},
|
||||
//{
|
||||
// Name: "Cookie",
|
||||
// Value: account.AccessToken,
|
||||
//},
|
||||
},
|
||||
Url: url,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Path 通过调用上述的File与Files函数判断是文件还是文件夹,并进行返回,当是文件时附带文件的直链。
|
||||
func (driver ChaoxingDrive) Path(path string, account *model.Account) (*model.File, []model.File, error) {
|
||||
path = utils.ParsePath(path)
|
||||
file, err := driver.File(path, account)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
if !file.IsDir() {
|
||||
return file, nil, nil
|
||||
}
|
||||
files, err := driver.Files(path, account)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
return nil, files, nil
|
||||
}
|
||||
|
||||
// Optional function
|
||||
//func (driver ChaoxingDrive) Preview(path string, account *model.Account) (interface{}, error) {
|
||||
// //TODO preview interface if driver support
|
||||
// return nil, base.ErrNotImplement
|
||||
//}
|
||||
|
||||
func (driver ChaoxingDrive) MakeDir(path string, account *model.Account) error {
|
||||
// 三个参数缺一不可,均不能写死
|
||||
// https://pan-yz.chaoxing.com/opt/newfolder?parentId=205255741446029312&name=test&puid=54351295
|
||||
|
||||
return base.ErrNotImplement
|
||||
}
|
||||
|
||||
func (driver ChaoxingDrive) Move(src string, dst string, account *model.Account) error {
|
||||
// 注意 folderid 是由 {id}_{puid} 组成的(截取前两段即可)
|
||||
// https://pan-yz.chaoxing.com/opt/moveres?folderid=762268051373813760_54351295&resids=762263362701209600,
|
||||
return base.ErrNotImplement
|
||||
}
|
||||
|
||||
func (driver ChaoxingDrive) Rename(src string, dst string, account *model.Account) error {
|
||||
// resid 就是 fileid
|
||||
// https://pan-yz.chaoxing.com/opt/rename?resid=762263362701209600&name=test.pdf&puid=54351295
|
||||
return base.ErrNotImplement
|
||||
}
|
||||
|
||||
// 超星网盘不支持复制
|
||||
//func (driver ChaoxingDrive) Copy(src string, dst string, account *model.Account) error {
|
||||
// //TODO copy file/dir
|
||||
// return base.ErrNotImplement
|
||||
//}
|
||||
|
||||
// Delete 这个函数太危险了,不想实现
|
||||
func (driver ChaoxingDrive) Delete(path string, account *model.Account) error {
|
||||
// 删除单个文件
|
||||
// https://pan-yz.chaoxing.com/opt/delres?resids=762268051373813760&resourcetype=0&puids=54351295
|
||||
// 删除多个文件
|
||||
// https://pan-yz.chaoxing.com/opt/delres?resids=762269933587513344,762269920078848000,&resourcetype=0,0,&puids=54351295,54351295,
|
||||
return base.ErrNotImplement
|
||||
}
|
||||
|
||||
//func (driver ChaoxingDrive) Upload(file *model.FileStream, account *model.Account) error {
|
||||
// //TODO upload file
|
||||
// return base.ErrNotImplement
|
||||
//}
|
||||
|
||||
var _ base.Driver = (*ChaoxingDrive)(nil)
|
27
drivers/chaoxing/types.go
Normal file
27
drivers/chaoxing/types.go
Normal file
@ -0,0 +1,27 @@
|
||||
package template
|
||||
|
||||
import "time"
|
||||
|
||||
// write all struct here
|
||||
|
||||
// TYPE_CX_FILE type=1 文件
|
||||
var TYPE_CX_FILE = int64(1)
|
||||
|
||||
// TYPE_CX_FOLDER type=2 文件夹
|
||||
var TYPE_CX_FOLDER = int64(2)
|
||||
|
||||
// TYPE_CX_SHARED_ROOT type=4 共享文件的根目录
|
||||
var TYPE_CX_SHARED_ROOT = int64(4)
|
||||
|
||||
type Resp struct {
|
||||
Code int `json:"code"`
|
||||
Message string `json:"message"`
|
||||
}
|
||||
|
||||
type File struct {
|
||||
Id string `json:"id"`
|
||||
FileName string `json:"file_name"`
|
||||
Size int64 `json:"size"`
|
||||
File bool `json:"file"`
|
||||
UpdatedAt *time.Time `json:"updated_at"`
|
||||
}
|
151
drivers/chaoxing/util.go
Normal file
151
drivers/chaoxing/util.go
Normal file
@ -0,0 +1,151 @@
|
||||
package template
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/Xhofe/alist/conf"
|
||||
"github.com/Xhofe/alist/drivers/base"
|
||||
"github.com/Xhofe/alist/model"
|
||||
"github.com/Xhofe/alist/utils"
|
||||
"github.com/bitly/go-simplejson"
|
||||
"github.com/go-resty/resty/v2"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// write util func here, such as cal sign
|
||||
|
||||
var chaoxingClient = resty.New()
|
||||
|
||||
var form_login_fmt = "fid=-1&uname=%s&password=%s&t=true&forbidotherlogin=0&validate=&doubleFactorLogin=0"
|
||||
|
||||
var api_list_root = "https://pan-yz.chaoxing.com/opt/listres?page=1&size=%d&enc=%s"
|
||||
var api_list_file = "https://pan-yz.chaoxing.com/opt/listres?puid=%s&shareid=%s&parentId=%s&page=1&size=%d&enc=%s"
|
||||
var api_list_shared_root = "https://pan-yz.chaoxing.com/opt/listres?puid=0&shareid=-1&parentId=0&page=1&size=%d&enc=%s"
|
||||
|
||||
var reg_enc_fmt = regexp.MustCompile("enc[ ]*=\"(.*)\"")
|
||||
|
||||
func (driver ChaoxingDrive) Login(account *model.Account) error {
|
||||
url := "https://passport2.chaoxing.com/fanyalogin"
|
||||
var resp base.Json
|
||||
var err Resp
|
||||
|
||||
req_body := fmt.Sprintf(form_login_fmt, account.Username, account.Password)
|
||||
|
||||
loginReq, e := chaoxingClient.R().SetBody(req_body).
|
||||
SetResult(&resp).SetError(&err).
|
||||
SetHeader("Content-Length", strconv.FormatInt(int64(len(req_body)), 10)).
|
||||
SetHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8").
|
||||
SetHeader("Host", "passport2.chaoxing.com").
|
||||
SetHeader("User-Agent", " Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36").
|
||||
SetHeader("X-Requested-With", "XMLHttpRequest").
|
||||
Post(url)
|
||||
|
||||
if e != nil {
|
||||
return e
|
||||
}
|
||||
|
||||
account.AccessToken = ""
|
||||
for _, cookie := range loginReq.Cookies() {
|
||||
//route=9d169c0aea4b7c89fa0d073417b5645f;
|
||||
account.AccessToken += fmt.Sprintf("%s=%s; ", cookie.Name, cookie.Value)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (driver ChaoxingDrive) GetEnc(account *model.Account) error {
|
||||
url := "https://pan-yz.chaoxing.com/"
|
||||
|
||||
encReq, e := chaoxingClient.R().SetHeader("Cookie", account.AccessToken).Get(url)
|
||||
if e != nil {
|
||||
return e
|
||||
}
|
||||
|
||||
//直接读取响应
|
||||
sresp := string(encReq.Body())
|
||||
submatch := reg_enc_fmt.FindAllStringSubmatch(sresp, 1)
|
||||
//第一次获取失败,可能是未登录
|
||||
if len(submatch) == 0 {
|
||||
e = driver.Login(account)
|
||||
if e != nil {
|
||||
return e
|
||||
}
|
||||
encReq, e = chaoxingClient.R().SetHeader("Cookie", account.AccessToken).Get(url)
|
||||
if e != nil {
|
||||
return e
|
||||
}
|
||||
sresp = string(encReq.Body())
|
||||
submatch = reg_enc_fmt.FindAllStringSubmatch(sresp, 1)
|
||||
if len(submatch) == 0 {
|
||||
account.Status = "failed"
|
||||
return fmt.Errorf("登录失败,服务器返回信息:%s", sresp)
|
||||
}
|
||||
}
|
||||
enc := submatch[0][1]
|
||||
account.AccessSecret = enc
|
||||
account.Status = "work"
|
||||
return nil
|
||||
}
|
||||
|
||||
func (driver ChaoxingDrive) ListFile(folder_id string, account *model.Account) ([]model.File, error) {
|
||||
var url string
|
||||
//按规则解析 id 号
|
||||
folder_id_info := strings.Split(folder_id, "_")
|
||||
if len(folder_id_info) == 3 {
|
||||
folder_id = folder_id_info[0]
|
||||
folder_puid := folder_id_info[1]
|
||||
folder_shareid := folder_id_info[2]
|
||||
if folder_id == "0" {
|
||||
//访问“共享给我的文件夹”
|
||||
url = fmt.Sprintf(api_list_shared_root, account.Limit, account.AccessSecret)
|
||||
} else {
|
||||
//访问其他目录
|
||||
url = fmt.Sprintf(api_list_file, folder_puid, folder_shareid, folder_id, account.Limit, account.AccessSecret)
|
||||
}
|
||||
} else {
|
||||
//id无法解析为三段,应当是访问根目录(此时为 "")
|
||||
url = fmt.Sprintf(api_list_root, account.Limit, account.AccessSecret)
|
||||
}
|
||||
|
||||
listFileReq, e := chaoxingClient.R().SetHeader("Cookie", account.AccessToken).Post(url)
|
||||
resp, e := simplejson.NewJson(listFileReq.Body())
|
||||
if e != nil || resp == nil {
|
||||
return nil, e
|
||||
}
|
||||
|
||||
files := make([]model.File, 0)
|
||||
array, _ := resp.Get("list").Array()
|
||||
|
||||
for _, file := range array {
|
||||
var f = model.File{}
|
||||
file_ := file.(map[string]interface{})
|
||||
//f.Id = file_["id"].(string)
|
||||
f.Id = fmt.Sprintf("%s_%s_%s", file_["id"].(string), file_["puid"].(json.Number).String(), file_["shareid"].(json.Number).String())
|
||||
f.Name = file_["name"].(string)
|
||||
f_server_type, _ := file_["type"].(json.Number).Int64()
|
||||
if f_server_type != TYPE_CX_SHARED_ROOT {
|
||||
f.Size, _ = file_["filesize"].(json.Number).Int64()
|
||||
}
|
||||
// 为文件分配类型
|
||||
switch f_server_type {
|
||||
case TYPE_CX_FILE:
|
||||
{
|
||||
f.Type = utils.GetFileType(file_["suffix"].(string))
|
||||
}
|
||||
case TYPE_CX_FOLDER:
|
||||
f.Type = conf.FOLDER
|
||||
case TYPE_CX_SHARED_ROOT:
|
||||
f.Type = conf.FOLDER
|
||||
}
|
||||
modifyDate, e := time.Parse("2006-01-02 15:04:05", file_["modifyDate"].(string))
|
||||
if e == nil {
|
||||
f.UpdatedAt = &modifyDate
|
||||
}
|
||||
f.Thumbnail = file_["thumbnail"].(string)
|
||||
files = append(files, f)
|
||||
}
|
||||
return files, nil
|
||||
}
|
@ -227,13 +227,21 @@ func (driver FTP) Copy(src string, dst string, account *model.Account) error {
|
||||
|
||||
func (driver FTP) Delete(path string, account *model.Account) error {
|
||||
path = utils.ParsePath(path)
|
||||
file, err := driver.File(path, account)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
realPath := utils.Join(account.RootFolder, path)
|
||||
conn, err := driver.Login(account)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
//defer func() { _ = conn.Quit() }()
|
||||
err = conn.Delete(realPath)
|
||||
if file.IsDir() {
|
||||
err = conn.RemoveDirRecur(realPath)
|
||||
} else {
|
||||
err = conn.Delete(realPath)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -53,6 +53,7 @@ func (driver Onedrive) Items() []base.Item {
|
||||
Label: "redirect uri",
|
||||
Type: base.TypeString,
|
||||
Required: true,
|
||||
Default: "https://tool.nn.ci/onedrive/callback",
|
||||
},
|
||||
{
|
||||
Name: "refresh_token",
|
||||
|
@ -307,8 +307,10 @@ func (driver Onedrive) UploadBig(file *model.FileStream, account *model.Account)
|
||||
res, err := base.HttpClient.Do(req)
|
||||
if res.StatusCode != 201 && res.StatusCode != 202 {
|
||||
data, _ := ioutil.ReadAll(res.Body)
|
||||
res.Body.Close()
|
||||
return errors.New(string(data))
|
||||
}
|
||||
res.Body.Close()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -51,37 +51,37 @@ type SortResp struct {
|
||||
type DownResp struct {
|
||||
Resp
|
||||
Data []struct {
|
||||
Fid string `json:"fid"`
|
||||
FileName string `json:"file_name"`
|
||||
PdirFid string `json:"pdir_fid"`
|
||||
Category int `json:"category"`
|
||||
FileType int `json:"file_type"`
|
||||
Size int `json:"size"`
|
||||
FormatType string `json:"format_type"`
|
||||
Status int `json:"status"`
|
||||
Tags string `json:"tags"`
|
||||
LCreatedAt int64 `json:"l_created_at"`
|
||||
LUpdatedAt int64 `json:"l_updated_at"`
|
||||
NameSpace int `json:"name_space"`
|
||||
Thumbnail string `json:"thumbnail"`
|
||||
DownloadUrl string `json:"download_url"`
|
||||
Md5 string `json:"md5"`
|
||||
RiskType int `json:"risk_type"`
|
||||
RangeSize int `json:"range_size"`
|
||||
BackupSign int `json:"backup_sign"`
|
||||
ObjCategory string `json:"obj_category"`
|
||||
Duration int `json:"duration"`
|
||||
FileSource string `json:"file_source"`
|
||||
File bool `json:"file"`
|
||||
CreatedAt int64 `json:"created_at"`
|
||||
UpdatedAt int64 `json:"updated_at"`
|
||||
PrivateExtra struct {
|
||||
} `json:"_private_extra"`
|
||||
//Fid string `json:"fid"`
|
||||
//FileName string `json:"file_name"`
|
||||
//PdirFid string `json:"pdir_fid"`
|
||||
//Category int `json:"category"`
|
||||
//FileType int `json:"file_type"`
|
||||
//Size int `json:"size"`
|
||||
//FormatType string `json:"format_type"`
|
||||
//Status int `json:"status"`
|
||||
//Tags string `json:"tags"`
|
||||
//LCreatedAt int64 `json:"l_created_at"`
|
||||
//LUpdatedAt int64 `json:"l_updated_at"`
|
||||
//NameSpace int `json:"name_space"`
|
||||
//Thumbnail string `json:"thumbnail"`
|
||||
DownloadUrl string `json:"download_url"`
|
||||
//Md5 string `json:"md5"`
|
||||
//RiskType int `json:"risk_type"`
|
||||
//RangeSize int `json:"range_size"`
|
||||
//BackupSign int `json:"backup_sign"`
|
||||
//ObjCategory string `json:"obj_category"`
|
||||
//Duration int `json:"duration"`
|
||||
//FileSource string `json:"file_source"`
|
||||
//File bool `json:"file"`
|
||||
//CreatedAt int64 `json:"created_at"`
|
||||
//UpdatedAt int64 `json:"updated_at"`
|
||||
//PrivateExtra struct {
|
||||
//} `json:"_private_extra"`
|
||||
} `json:"data"`
|
||||
Metadata struct {
|
||||
Acc2 string `json:"acc2"`
|
||||
Acc1 string `json:"acc1"`
|
||||
} `json:"metadata"`
|
||||
//Metadata struct {
|
||||
// Acc2 string `json:"acc2"`
|
||||
// Acc1 string `json:"acc1"`
|
||||
//} `json:"metadata"`
|
||||
}
|
||||
|
||||
type UpPreResp struct {
|
||||
|
@ -116,7 +116,7 @@ func (driver SFTP) Files(path string, account *model.Account) ([]model.File, err
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var files []model.File
|
||||
files := make([]model.File, 0)
|
||||
rawFiles, err := client.Files(remotePath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -195,7 +195,7 @@ func (driver SFTP) Delete(path string, account *model.Account) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return client.Remove(utils.Join(account.RootFolder, path))
|
||||
return client.remove(utils.Join(account.RootFolder, path))
|
||||
}
|
||||
|
||||
func (driver SFTP) Upload(file *model.FileStream, account *model.Account) error {
|
||||
|
@ -49,7 +49,7 @@ func (client *Client) Files(remotePath string) ([]os.FileInfo, error) {
|
||||
return client.ReadDir(remotePath)
|
||||
}
|
||||
|
||||
func (client *Client) Remove(remotePath string) error {
|
||||
func (client *Client) remove(remotePath string) error {
|
||||
f, err := client.Stat(remotePath)
|
||||
if err != nil {
|
||||
return nil
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
)
|
||||
|
||||
type Template struct {
|
||||
base.Base
|
||||
}
|
||||
|
||||
func (driver Template) Config() base.DriverConfig {
|
||||
@ -111,39 +112,40 @@ func (driver Template) Path(path string, account *model.Account) (*model.File, [
|
||||
return nil, files, nil
|
||||
}
|
||||
|
||||
func (driver Template) Preview(path string, account *model.Account) (interface{}, error) {
|
||||
//TODO preview interface if driver support
|
||||
return nil, base.ErrNotImplement
|
||||
}
|
||||
|
||||
func (driver Template) MakeDir(path string, account *model.Account) error {
|
||||
//TODO make dir
|
||||
return base.ErrNotImplement
|
||||
}
|
||||
|
||||
func (driver Template) Move(src string, dst string, account *model.Account) error {
|
||||
//TODO move file/dir
|
||||
return base.ErrNotImplement
|
||||
}
|
||||
|
||||
func (driver Template) Rename(src string, dst string, account *model.Account) error {
|
||||
//TODO rename file/dir
|
||||
return base.ErrNotImplement
|
||||
}
|
||||
|
||||
func (driver Template) Copy(src string, dst string, account *model.Account) error {
|
||||
//TODO copy file/dir
|
||||
return base.ErrNotImplement
|
||||
}
|
||||
|
||||
func (driver Template) Delete(path string, account *model.Account) error {
|
||||
//TODO delete file/dir
|
||||
return base.ErrNotImplement
|
||||
}
|
||||
|
||||
func (driver Template) Upload(file *model.FileStream, account *model.Account) error {
|
||||
//TODO upload file
|
||||
return base.ErrNotImplement
|
||||
}
|
||||
// Optional function
|
||||
//func (driver Template) Preview(path string, account *model.Account) (interface{}, error) {
|
||||
// //TODO preview interface if driver support
|
||||
// return nil, base.ErrNotImplement
|
||||
//}
|
||||
//
|
||||
//func (driver Template) MakeDir(path string, account *model.Account) error {
|
||||
// //TODO make dir
|
||||
// return base.ErrNotImplement
|
||||
//}
|
||||
//
|
||||
//func (driver Template) Move(src string, dst string, account *model.Account) error {
|
||||
// //TODO move file/dir
|
||||
// return base.ErrNotImplement
|
||||
//}
|
||||
//
|
||||
//func (driver Template) Rename(src string, dst string, account *model.Account) error {
|
||||
// //TODO rename file/dir
|
||||
// return base.ErrNotImplement
|
||||
//}
|
||||
//
|
||||
//func (driver Template) Copy(src string, dst string, account *model.Account) error {
|
||||
// //TODO copy file/dir
|
||||
// return base.ErrNotImplement
|
||||
//}
|
||||
//
|
||||
//func (driver Template) Delete(path string, account *model.Account) error {
|
||||
// //TODO delete file/dir
|
||||
// return base.ErrNotImplement
|
||||
//}
|
||||
//
|
||||
//func (driver Template) Upload(file *model.FileStream, account *model.Account) error {
|
||||
// //TODO upload file
|
||||
// return base.ErrNotImplement
|
||||
//}
|
||||
|
||||
var _ base.Driver = (*Template)(nil)
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
"github.com/Xhofe/alist/drivers/webdav/odrvcookie"
|
||||
"github.com/Xhofe/alist/model"
|
||||
"github.com/Xhofe/alist/utils"
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
@ -132,11 +133,27 @@ func (driver WebDav) Files(path string, account *model.Account) ([]model.File, e
|
||||
func (driver WebDav) Link(args base.Args, account *model.Account) (*base.Link, error) {
|
||||
path := args.Path
|
||||
c := driver.NewClient(account)
|
||||
reader, err := c.ReadStream(driver.WebDavPath(path))
|
||||
callback := func(r *http.Request) {
|
||||
if args.Header.Get("Range") != "" {
|
||||
r.Header.Set("Range", args.Header.Get("Range"))
|
||||
}
|
||||
if args.Header.Get("If-Range") != "" {
|
||||
r.Header.Set("If-Range", args.Header.Get("If-Range"))
|
||||
}
|
||||
}
|
||||
reader, header, err := c.ReadStream(driver.WebDavPath(path), callback)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &base.Link{Data: reader}, nil
|
||||
link := &base.Link{Data: reader}
|
||||
if header.Get("Content-Range") != "" {
|
||||
link.Status = 206
|
||||
link.Header = http.Header{
|
||||
"Content-Range": header.Values("Content-Range"),
|
||||
"Content-Length": header.Values("Content-Length"),
|
||||
}
|
||||
}
|
||||
return link, nil
|
||||
}
|
||||
|
||||
func (driver WebDav) Path(path string, account *model.Account) (*model.File, []model.File, error) {
|
||||
@ -196,7 +213,11 @@ func (driver WebDav) Upload(file *model.FileStream, account *model.Account) erro
|
||||
}
|
||||
c := driver.NewClient(account)
|
||||
path := utils.Join(file.ParentPath, file.Name)
|
||||
err := c.WriteStream(driver.WebDavPath(path), file, 0644)
|
||||
callback := func(r *http.Request) {
|
||||
r.Header.Set("Content-Type", file.GetMIMEType())
|
||||
r.ContentLength = int64(file.GetSize())
|
||||
}
|
||||
err := c.WriteStream(driver.WebDavPath(path), file, 0644, callback)
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ package odrvcookie
|
||||
|
||||
import (
|
||||
"github.com/Xhofe/alist/utils/cookie"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"net/http"
|
||||
"sync"
|
||||
"time"
|
||||
@ -13,7 +14,7 @@ type SpCookie struct {
|
||||
}
|
||||
|
||||
func (sp SpCookie) IsExpire() bool {
|
||||
return time.Now().Before(sp.expire)
|
||||
return time.Now().After(sp.expire)
|
||||
}
|
||||
|
||||
var cookiesMap = struct {
|
||||
@ -27,9 +28,11 @@ func GetCookie(username, password, siteUrl string) (string, error) {
|
||||
spCookie, ok := cookiesMap.m[username]
|
||||
if ok {
|
||||
if !spCookie.IsExpire() {
|
||||
log.Debugln("sp use old cookie.")
|
||||
return spCookie.Cookie, nil
|
||||
}
|
||||
}
|
||||
log.Debugln("fetch new cookie")
|
||||
ca := New(username, password, siteUrl)
|
||||
tokenConf, err := ca.Cookies()
|
||||
if err != nil {
|
||||
|
@ -4,9 +4,8 @@ import (
|
||||
"github.com/Xhofe/alist/drivers/base"
|
||||
"github.com/Xhofe/alist/drivers/webdav/odrvcookie"
|
||||
"github.com/Xhofe/alist/model"
|
||||
"github.com/Xhofe/alist/pkg/gowebdav"
|
||||
"github.com/Xhofe/alist/utils"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/studio-b12/gowebdav"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
@ -15,13 +14,10 @@ func (driver WebDav) NewClient(account *model.Account) *gowebdav.Client {
|
||||
c := gowebdav.NewClient(account.SiteUrl, account.Username, account.Password)
|
||||
if isSharePoint(account) {
|
||||
cookie, err := odrvcookie.GetCookie(account.Username, account.Password, account.SiteUrl)
|
||||
log.Debugln(cookie, err)
|
||||
if err == nil {
|
||||
log.Debugln("set interceptor")
|
||||
c.SetInterceptor(func(method string, rq *http.Request) {
|
||||
rq.Header.Del("Authorization")
|
||||
rq.Header.Set("Cookie", cookie)
|
||||
log.Debugf("sp webdav req: %+v", rq)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -1,21 +1,21 @@
|
||||
package xunlei
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
|
||||
"github.com/aliyun/aliyun-oss-go-sdk/oss"
|
||||
"github.com/go-resty/resty/v2"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/Xhofe/alist/conf"
|
||||
"github.com/Xhofe/alist/drivers/base"
|
||||
"github.com/Xhofe/alist/model"
|
||||
"github.com/Xhofe/alist/utils"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"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/google/uuid"
|
||||
)
|
||||
|
||||
type XunLeiCloud struct{}
|
||||
@ -48,8 +48,61 @@ func (driver XunLeiCloud) Items() []base.Item {
|
||||
Description: "account password",
|
||||
},
|
||||
{
|
||||
Name: "root_folder",
|
||||
Label: "root folder file_id",
|
||||
Name: "captcha_token",
|
||||
Label: "verified captcha token",
|
||||
Type: base.TypeString,
|
||||
},
|
||||
{
|
||||
Name: "root_folder",
|
||||
Label: "root folder file_id",
|
||||
Type: base.TypeString,
|
||||
},
|
||||
{
|
||||
Name: "client_version",
|
||||
Label: "client version",
|
||||
Default: "7.43.0.7998",
|
||||
Type: base.TypeString,
|
||||
Required: true,
|
||||
},
|
||||
{
|
||||
Name: "client_id",
|
||||
Label: "client id",
|
||||
Default: "Xp6vsxz_7IYVw2BB",
|
||||
Type: base.TypeString,
|
||||
Required: true,
|
||||
},
|
||||
{
|
||||
Name: "client_secret",
|
||||
Label: "client secret",
|
||||
Default: "Xp6vsy4tN9toTVdMSpomVdXpRmES",
|
||||
Type: base.TypeString,
|
||||
Required: true,
|
||||
},
|
||||
{
|
||||
Name: "algorithms",
|
||||
Label: "algorithms",
|
||||
Default: "hrVPGbeqYPs+CIscj05VpAtjalzY5yjpvlMS8bEo,DrI0uTP,HHK0VXyMgY0xk2K0o,BBaXsExvL3GadmIacjWv7ISUJp3ifAwqbJumu,5toJ7ejB+bh1,5LsZTFAFjgvFvIl1URBgOAJ,QcJ5Ry+,hYgZVz8r7REROaCYfd9,zw6gXgkk/8TtGrmx6EGfekPESLnbZfDFwqR,gtSwLnMBa8h12nF3DU6+LwEQPHxd,fMG8TvtAYbCkxuEbIm0Xi/Lb7Z",
|
||||
Type: base.TypeString,
|
||||
Required: true,
|
||||
},
|
||||
{
|
||||
Name: "package_name",
|
||||
Label: "package name",
|
||||
Default: "com.xunlei.downloadprovider",
|
||||
Type: base.TypeString,
|
||||
Required: true,
|
||||
},
|
||||
{
|
||||
Name: "user_agent",
|
||||
Label: "user agent",
|
||||
Default: "ANDROID-com.xunlei.downloadprovider/7.43.0.7998 netWorkType/WIFI appid/40 deviceName/Samsung_Sm-g9810 deviceModel/SM-G9810 OSVersion/7.1.2 protocolVersion/301 platformVersion/10 sdkVersion/220200 Oauth2Client/0.9 (Linux 4_0_9+) (JAVA 0)",
|
||||
Type: base.TypeString,
|
||||
Required: false,
|
||||
},
|
||||
{
|
||||
Name: "device_id",
|
||||
Label: "device id",
|
||||
Default: utils.GetMD5Encode(uuid.NewString()),
|
||||
Type: base.TypeString,
|
||||
Required: true,
|
||||
},
|
||||
@ -60,10 +113,18 @@ func (driver XunLeiCloud) Save(account *model.Account, old *model.Account) error
|
||||
if account == nil {
|
||||
return nil
|
||||
}
|
||||
state := GetState(account)
|
||||
if state.isTokensExpires() {
|
||||
return state.Login(account)
|
||||
|
||||
client := GetClient(account)
|
||||
// 指定验证通过的captchaToken
|
||||
if account.CaptchaToken != "" {
|
||||
client.UpdateCaptchaToken(strings.TrimSpace(account.CaptchaToken))
|
||||
account.CaptchaToken = ""
|
||||
}
|
||||
|
||||
if client.token == "" {
|
||||
return client.Login(account)
|
||||
}
|
||||
|
||||
account.Status = "work"
|
||||
model.SaveAccount(account)
|
||||
return nil
|
||||
@ -101,19 +162,23 @@ func (driver XunLeiCloud) Files(path string, account *model.Account) ([]model.Fi
|
||||
files, _ := cache.([]model.File)
|
||||
return files, nil
|
||||
}
|
||||
file, err := driver.File(path, account)
|
||||
|
||||
parentFile, err := driver.File(path, account)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
time.Sleep(time.Millisecond * 300)
|
||||
files := make([]model.File, 0)
|
||||
var pageToken string
|
||||
for {
|
||||
var fileList FileList
|
||||
_, err = GetState(account).Request("GET", FILE_API_URL, func(r *resty.Request) {
|
||||
_, err = GetClient(account).Request("GET", FILE_API_URL, func(r *resty.Request) {
|
||||
r.SetQueryParams(map[string]string{
|
||||
"parent_id": file.Id,
|
||||
"page_token": fileList.NextPageToken,
|
||||
"parent_id": parentFile.Id,
|
||||
"page_token": pageToken,
|
||||
"with_audit": "true",
|
||||
"limit": "100",
|
||||
"filters": `{"phase": {"eq": "PHASE_TYPE_COMPLETE"}, "trashed":{"eq":false}}`,
|
||||
})
|
||||
r.SetResult(&fileList)
|
||||
@ -129,6 +194,7 @@ func (driver XunLeiCloud) Files(path string, account *model.Account) ([]model.Fi
|
||||
if fileList.NextPageToken == "" {
|
||||
break
|
||||
}
|
||||
pageToken = fileList.NextPageToken
|
||||
}
|
||||
if len(files) > 0 {
|
||||
_ = base.SetCache(path, files, account)
|
||||
@ -162,8 +228,9 @@ func (driver XunLeiCloud) Link(args base.Args, account *model.Account) (*base.Li
|
||||
return nil, base.ErrNotFile
|
||||
}
|
||||
var lFile Files
|
||||
_, err = GetState(account).Request("GET", FILE_API_URL+"/{id}", func(r *resty.Request) {
|
||||
r.SetPathParam("id", file.Id)
|
||||
clinet := GetClient(account)
|
||||
_, err = clinet.Request("GET", FILE_API_URL+"/{fileID}", func(r *resty.Request) {
|
||||
r.SetPathParam("fileID", file.Id)
|
||||
r.SetQueryParam("with_audit", "true")
|
||||
r.SetResult(&lFile)
|
||||
}, account)
|
||||
@ -172,7 +239,7 @@ func (driver XunLeiCloud) Link(args base.Args, account *model.Account) (*base.Li
|
||||
}
|
||||
return &base.Link{
|
||||
Headers: []base.Header{
|
||||
{Name: "User-Agent", Value: base.UserAgent},
|
||||
{Name: "User-Agent", Value: clinet.userAgent},
|
||||
},
|
||||
Url: lFile.WebContentLink,
|
||||
}, nil
|
||||
@ -180,7 +247,6 @@ func (driver XunLeiCloud) Link(args base.Args, account *model.Account) (*base.Li
|
||||
|
||||
func (driver XunLeiCloud) Path(path string, account *model.Account) (*model.File, []model.File, error) {
|
||||
path = utils.ParsePath(path)
|
||||
log.Debugf("xunlei path: %s", path)
|
||||
file, err := driver.File(path, account)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
@ -199,6 +265,18 @@ func (driver XunLeiCloud) Preview(path string, account *model.Account) (interfac
|
||||
return nil, base.ErrNotSupport
|
||||
}
|
||||
|
||||
func (driver XunLeiCloud) Rename(src string, dst string, account *model.Account) error {
|
||||
srcFile, err := driver.File(src, account)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = GetClient(account).Request("PATCH", FILE_API_URL+"/{fileID}", func(r *resty.Request) {
|
||||
r.SetPathParam("fileID", srcFile.Id)
|
||||
r.SetBody(&base.Json{"name": filepath.Base(dst)})
|
||||
}, account)
|
||||
return err
|
||||
}
|
||||
|
||||
func (driver XunLeiCloud) MakeDir(path string, account *model.Account) error {
|
||||
dir, name := filepath.Split(path)
|
||||
parentFile, err := driver.File(dir, account)
|
||||
@ -208,7 +286,7 @@ func (driver XunLeiCloud) MakeDir(path string, account *model.Account) error {
|
||||
if !parentFile.IsDir() {
|
||||
return base.ErrNotFolder
|
||||
}
|
||||
_, err = GetState(account).Request("POST", FILE_API_URL, func(r *resty.Request) {
|
||||
_, err = GetClient(account).Request("POST", FILE_API_URL, func(r *resty.Request) {
|
||||
r.SetBody(&base.Json{
|
||||
"kind": FOLDER,
|
||||
"name": name,
|
||||
@ -229,7 +307,7 @@ func (driver XunLeiCloud) Move(src string, dst string, account *model.Account) e
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = GetState(account).Request("POST", FILE_API_URL+":batchMove", func(r *resty.Request) {
|
||||
_, err = GetClient(account).Request("POST", FILE_API_URL+":batchMove", func(r *resty.Request) {
|
||||
r.SetBody(&base.Json{
|
||||
"to": base.Json{"parent_id": dstDirFile.Id},
|
||||
"ids": []string{srcFile.Id},
|
||||
@ -248,7 +326,7 @@ func (driver XunLeiCloud) Copy(src string, dst string, account *model.Account) e
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = GetState(account).Request("POST", FILE_API_URL+":batchCopy", func(r *resty.Request) {
|
||||
_, err = GetClient(account).Request("POST", FILE_API_URL+":batchCopy", func(r *resty.Request) {
|
||||
r.SetBody(&base.Json{
|
||||
"to": base.Json{"parent_id": dstDirFile.Id},
|
||||
"ids": []string{srcFile.Id},
|
||||
@ -262,8 +340,8 @@ func (driver XunLeiCloud) Delete(path string, account *model.Account) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = GetState(account).Request("PATCH", FILE_API_URL+"/{id}/trash", func(r *resty.Request) {
|
||||
r.SetPathParam("id", srcFile.Id)
|
||||
_, err = GetClient(account).Request("PATCH", FILE_API_URL+"/{fileID}/trash", func(r *resty.Request) {
|
||||
r.SetPathParam("fileID", srcFile.Id)
|
||||
r.SetBody(&base.Json{})
|
||||
}, account)
|
||||
return err
|
||||
@ -279,28 +357,35 @@ func (driver XunLeiCloud) Upload(file *model.FileStream, account *model.Account)
|
||||
return err
|
||||
}
|
||||
|
||||
tempFile, err := ioutil.TempFile(conf.Conf.TempDir, "file-*")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
/*
|
||||
tempFile, err := ioutil.TempFile(conf.Conf.TempDir, "file-*")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
defer os.Remove(tempFile.Name())
|
||||
defer func() {
|
||||
_ = tempFile.Close()
|
||||
_ = os.Remove(tempFile.Name())
|
||||
}()
|
||||
|
||||
gcid, err := getGcid(io.TeeReader(file, tempFile), int64(file.Size))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
gcid, err := getGcid(io.TeeReader(file, tempFile), int64(file.Size))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
tempFile.Close()
|
||||
if _, err = tempFile.Seek(0, io.SeekStart); err != nil {
|
||||
return err
|
||||
}
|
||||
*/
|
||||
|
||||
var resp UploadTaskResponse
|
||||
_, err = GetState(account).Request("POST", FILE_API_URL, func(r *resty.Request) {
|
||||
_, err = GetClient(account).Request("POST", FILE_API_URL, func(r *resty.Request) {
|
||||
r.SetBody(&base.Json{
|
||||
"kind": FILE,
|
||||
"parent_id": parentFile.Id,
|
||||
"name": file.Name,
|
||||
"size": fmt.Sprint(file.Size),
|
||||
"hash": gcid,
|
||||
"size": file.Size,
|
||||
"hash": "1CF254FBC456E1B012CD45C546636AA62CF8350E",
|
||||
"upload_type": UPLOAD_TYPE_RESUMABLE,
|
||||
})
|
||||
r.SetResult(&resp)
|
||||
@ -311,30 +396,24 @@ func (driver XunLeiCloud) Upload(file *model.FileStream, account *model.Account)
|
||||
|
||||
param := resp.Resumable.Params
|
||||
if resp.UploadType == UPLOAD_TYPE_RESUMABLE {
|
||||
client, err := oss.New(param.Endpoint, param.AccessKeyID, param.AccessKeySecret, oss.SecurityToken(param.SecurityToken), oss.EnableMD5(true))
|
||||
param.Endpoint = strings.TrimLeft(param.Endpoint, param.Bucket+".")
|
||||
s, err := session.NewSession(&aws.Config{
|
||||
Credentials: credentials.NewStaticCredentials(param.AccessKeyID, param.AccessKeySecret, param.SecurityToken),
|
||||
Region: aws.String("xunlei"),
|
||||
Endpoint: aws.String(param.Endpoint),
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
bucket, err := client.Bucket(param.Bucket)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return bucket.UploadFile(param.Key, tempFile.Name(), 1<<22, oss.Routines(3), oss.Checkpoint(true, ""), oss.Expires(param.Expiration))
|
||||
_, err = s3manager.NewUploader(s).Upload(&s3manager.UploadInput{
|
||||
Bucket: aws.String(param.Bucket),
|
||||
Key: aws.String(param.Key),
|
||||
Expires: aws.Time(param.Expiration),
|
||||
Body: file,
|
||||
})
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (driver XunLeiCloud) Rename(src string, dst string, account *model.Account) error {
|
||||
_, dstName := filepath.Split(dst)
|
||||
srcFile, err := driver.File(src, account)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = GetState(account).Request("PATCH", FILE_API_URL+"/{id}", func(r *resty.Request) {
|
||||
r.SetPathParam("id", srcFile.Id)
|
||||
r.SetBody(&base.Json{"name": dstName})
|
||||
}, account)
|
||||
return err
|
||||
}
|
||||
|
||||
var _ base.Driver = (*XunLeiCloud)(nil)
|
||||
|
@ -1,23 +1,35 @@
|
||||
package xunlei
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Erron struct {
|
||||
Error string `json:"error"`
|
||||
ErrorCode int64 `json:"error_code"`
|
||||
ErrorMsg string `json:"error"`
|
||||
ErrorDescription string `json:"error_description"`
|
||||
// ErrorDetails interface{} `json:"error_details"`
|
||||
}
|
||||
|
||||
func (e *Erron) HasError() bool {
|
||||
return e.ErrorCode != 0 || e.ErrorMsg != "" || e.ErrorDescription != ""
|
||||
}
|
||||
|
||||
func (e *Erron) Error() string {
|
||||
return fmt.Sprintf("ErrorCode: %d ,Error: %s ,ErrorDescription: %s ", e.ErrorCode, e.ErrorMsg, e.ErrorDescription)
|
||||
}
|
||||
|
||||
/*
|
||||
* 验证码Token
|
||||
**/
|
||||
type CaptchaTokenRequest struct {
|
||||
Action string `json:"action"`
|
||||
CaptchaToken string `json:"captcha_token"`
|
||||
ClientID string `json:"client_id"`
|
||||
DeviceID string `json:"device_id"`
|
||||
Meta map[string]string `json:"meta"`
|
||||
//RedirectUri string `json:"redirect_uri"`
|
||||
RedirectUri string `json:"redirect_uri"`
|
||||
}
|
||||
|
||||
type CaptchaTokenResponse struct {
|
||||
@ -26,6 +38,9 @@ type CaptchaTokenResponse struct {
|
||||
Url string `json:"url"`
|
||||
}
|
||||
|
||||
/*
|
||||
* 登录
|
||||
**/
|
||||
type TokenResponse struct {
|
||||
TokenType string `json:"token_type"`
|
||||
AccessToken string `json:"access_token"`
|
||||
@ -36,6 +51,10 @@ type TokenResponse struct {
|
||||
UserID string `json:"user_id"`
|
||||
}
|
||||
|
||||
func (t *TokenResponse) Token() string {
|
||||
return fmt.Sprint(t.TokenType, " ", t.AccessToken)
|
||||
}
|
||||
|
||||
type SignInRequest struct {
|
||||
CaptchaToken string `json:"captcha_token"`
|
||||
|
||||
@ -46,6 +65,9 @@ type SignInRequest struct {
|
||||
Password string `json:"password"`
|
||||
}
|
||||
|
||||
/*
|
||||
* 文件
|
||||
**/
|
||||
type FileList struct {
|
||||
Kind string `json:"kind"`
|
||||
NextPageToken string `json:"next_page_token"`
|
||||
@ -116,6 +138,9 @@ type Files struct {
|
||||
//Collection interface{} `json:"collection"`
|
||||
}
|
||||
|
||||
/*
|
||||
* 上传
|
||||
**/
|
||||
type UploadTaskResponse struct {
|
||||
UploadType string `json:"upload_type"`
|
||||
|
||||
|
@ -3,40 +3,10 @@ package xunlei
|
||||
import (
|
||||
"crypto/sha1"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/url"
|
||||
|
||||
"github.com/Xhofe/alist/utils"
|
||||
)
|
||||
|
||||
const (
|
||||
// 小米浏览器
|
||||
CLIENT_ID = "X7MtiU0Gb5YqWv-6"
|
||||
CLIENT_SECRET = "84MYEih3Eeu2HF4RrGce3Q"
|
||||
CLIENT_VERSION = "5.1.0.51045"
|
||||
|
||||
ALG_VERSION = "1"
|
||||
PACKAGE_NAME = "com.xunlei.xcloud.lib"
|
||||
)
|
||||
|
||||
var Algorithms = []string{
|
||||
"",
|
||||
"BXza40wm+P4zw8rEFpHA",
|
||||
"UfZLfKfYRmKTA0",
|
||||
"OMBGVt/9Wcaln1XaBz",
|
||||
"Jn217F4rk5FPPWyhoeV",
|
||||
"w5OwkGo0pGpb0Xe/XZ5T3",
|
||||
"5guM3DNiY4F78x49zQ97q75",
|
||||
"QXwn4D2j884wJgrYXjGClM/IVrJX",
|
||||
"NXBRosYvbHIm6w8vEB",
|
||||
"2kZ8Ie1yW2ib4O2iAkNpJobP",
|
||||
"11CoVJJQEc",
|
||||
"xf3QWysVwnVsNv5DCxU+cgNT1rK",
|
||||
"9eEfKkrqkfw",
|
||||
"T78dnANexYRbiZy",
|
||||
}
|
||||
|
||||
const (
|
||||
API_URL = "https://api-pan.xunlei.com/drive/v1"
|
||||
FILE_API_URL = API_URL + "/files"
|
||||
@ -44,9 +14,8 @@ const (
|
||||
)
|
||||
|
||||
const (
|
||||
FOLDER = "drive#folder"
|
||||
FILE = "drive#file"
|
||||
|
||||
FOLDER = "drive#folder"
|
||||
FILE = "drive#file"
|
||||
RESUMABLE = "drive#resumable"
|
||||
)
|
||||
|
||||
@ -57,47 +26,32 @@ const (
|
||||
UPLOAD_TYPE_URL = "UPLOAD_TYPE_URL"
|
||||
)
|
||||
|
||||
func captchaSign(driverID string, time int64) string {
|
||||
str := fmt.Sprint(CLIENT_ID, CLIENT_VERSION, PACKAGE_NAME, driverID, time)
|
||||
for _, algorithm := range Algorithms {
|
||||
str = utils.GetMD5Encode(fmt.Sprint(str, algorithm))
|
||||
}
|
||||
return fmt.Sprint(ALG_VERSION, ".", str)
|
||||
}
|
||||
|
||||
func getAction(method string, u string) string {
|
||||
c, _ := url.Parse(u)
|
||||
return fmt.Sprint(method, ":", c.Path)
|
||||
return method + ":" + c.Path
|
||||
}
|
||||
|
||||
// 计算文件Gcid
|
||||
func getGcid(r io.Reader, size int64) (string, error) {
|
||||
calcBlockSize := func(j int64) int64 {
|
||||
if j >= 0 && j <= 134217728 {
|
||||
return 262144
|
||||
if j >= 0 && j <= 0x8000000 {
|
||||
return 0x40000
|
||||
}
|
||||
if j <= 134217728 || j > 268435456 {
|
||||
if j <= 268435456 || j > 536870912 {
|
||||
return 2097152
|
||||
if j <= 0x8000000 || j > 0x10000000 {
|
||||
if j <= 0x10000000 || j > 0x20000000 {
|
||||
return 0x200000
|
||||
}
|
||||
return 1048576
|
||||
return 0x100000
|
||||
}
|
||||
return 524288
|
||||
return 0x80000
|
||||
}
|
||||
/*
|
||||
calcBlockSize := func(j int64) int64 {
|
||||
psize := int64(0x40000)
|
||||
for j/psize > 0x200 {
|
||||
psize <<= 1
|
||||
}
|
||||
return psize
|
||||
}
|
||||
*/
|
||||
|
||||
hash1 := sha1.New()
|
||||
hash2 := sha1.New()
|
||||
readSize := calcBlockSize(size)
|
||||
for {
|
||||
hash2.Reset()
|
||||
if n, err := io.CopyN(hash2, r, calcBlockSize(size)); err != nil && n == 0 {
|
||||
if n, err := io.CopyN(hash2, r, readSize); err != nil && n == 0 {
|
||||
if err != io.EOF {
|
||||
return "", err
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package xunlei
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@ -13,275 +14,269 @@ import (
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
var xunleiClient = resty.New().SetHeaders(map[string]string{"Accept": "application/json;charset=UTF-8"}).SetTimeout(base.DefaultTimeout)
|
||||
// 缓存登录状态
|
||||
var userClients sync.Map
|
||||
|
||||
// 一个账户只允许登陆一次
|
||||
var userStateCache = struct {
|
||||
func GetClient(account *model.Account) *Client {
|
||||
if v, ok := userClients.Load(account.Username); ok {
|
||||
return v.(*Client)
|
||||
}
|
||||
|
||||
client := &Client{
|
||||
Client: base.RestyClient,
|
||||
|
||||
clientID: account.ClientId,
|
||||
clientSecret: account.ClientSecret,
|
||||
clientVersion: account.ClientVersion,
|
||||
packageName: account.PackageName,
|
||||
algorithms: strings.Split(account.Algorithms, ","),
|
||||
userAgent: account.UserAgent,
|
||||
deviceID: account.DeviceId,
|
||||
}
|
||||
userClients.Store(account.Username, client)
|
||||
return client
|
||||
}
|
||||
|
||||
type Client struct {
|
||||
*resty.Client
|
||||
sync.Mutex
|
||||
States map[string]*State
|
||||
}{States: make(map[string]*State)}
|
||||
|
||||
func GetState(account *model.Account) *State {
|
||||
userStateCache.Lock()
|
||||
defer userStateCache.Unlock()
|
||||
if v, ok := userStateCache.States[account.Username]; ok && v != nil {
|
||||
return v
|
||||
}
|
||||
state := new(State).Init()
|
||||
userStateCache.States[account.Username] = state
|
||||
return state
|
||||
clientID string
|
||||
clientSecret string
|
||||
clientVersion string
|
||||
packageName string
|
||||
algorithms []string
|
||||
userAgent string
|
||||
deviceID string
|
||||
|
||||
captchaToken string
|
||||
|
||||
token string
|
||||
refreshToken string
|
||||
userID string
|
||||
}
|
||||
|
||||
type State struct {
|
||||
sync.Mutex
|
||||
captchaToken string
|
||||
captchaTokenExpiresTime int64
|
||||
|
||||
tokenType string
|
||||
accessToken string
|
||||
refreshToken string
|
||||
tokenExpiresTime int64 //Milli
|
||||
|
||||
userID string
|
||||
}
|
||||
|
||||
func (s *State) init() *State {
|
||||
s.captchaToken = ""
|
||||
s.captchaTokenExpiresTime = 0
|
||||
s.tokenType = ""
|
||||
s.accessToken = ""
|
||||
s.refreshToken = ""
|
||||
s.tokenExpiresTime = 0
|
||||
s.userID = "0"
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *State) getToken(account *model.Account) (string, error) {
|
||||
if s.isTokensExpires() {
|
||||
if err := s.refreshToken_(account); err != nil {
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
return fmt.Sprint(s.tokenType, " ", s.accessToken), nil
|
||||
}
|
||||
|
||||
func (s *State) getCaptchaToken(action string, account *model.Account) (string, error) {
|
||||
if s.isCaptchaTokenExpires() {
|
||||
return s.newCaptchaToken(action, nil, account)
|
||||
}
|
||||
return s.captchaToken, nil
|
||||
}
|
||||
|
||||
func (s *State) isCaptchaTokenExpires() bool {
|
||||
return time.Now().UnixMilli() >= s.captchaTokenExpiresTime || s.captchaToken == "" || s.tokenType == ""
|
||||
}
|
||||
|
||||
func (s *State) isTokensExpires() bool {
|
||||
return time.Now().UnixMilli() >= s.tokenExpiresTime || s.accessToken == ""
|
||||
}
|
||||
|
||||
func (s *State) newCaptchaToken(action string, meta map[string]string, account *model.Account) (string, error) {
|
||||
ctime := time.Now().UnixMilli()
|
||||
driverID := utils.GetMD5Encode(account.Username)
|
||||
creq := CaptchaTokenRequest{
|
||||
// 请求验证码token
|
||||
func (c *Client) requestCaptchaToken(action string, meta map[string]string) error {
|
||||
param := CaptchaTokenRequest{
|
||||
Action: action,
|
||||
CaptchaToken: s.captchaToken,
|
||||
ClientID: CLIENT_ID,
|
||||
DeviceID: driverID,
|
||||
Meta: map[string]string{
|
||||
"captcha_sign": captchaSign(driverID, ctime),
|
||||
"client_version": CLIENT_VERSION,
|
||||
"package_name": PACKAGE_NAME,
|
||||
"timestamp": fmt.Sprint(ctime),
|
||||
"user_id": s.userID,
|
||||
},
|
||||
}
|
||||
for k, v := range meta {
|
||||
creq.Meta[k] = v
|
||||
CaptchaToken: c.captchaToken,
|
||||
ClientID: c.clientID,
|
||||
DeviceID: c.deviceID,
|
||||
Meta: meta,
|
||||
RedirectUri: "xlaccsdk01://xunlei.com/callback?state=harbor",
|
||||
}
|
||||
|
||||
var e Erron
|
||||
var resp CaptchaTokenResponse
|
||||
_, err := xunleiClient.R().
|
||||
SetBody(&creq).
|
||||
_, err := c.Client.R().
|
||||
SetBody(¶m).
|
||||
SetError(&e).
|
||||
SetResult(&resp).
|
||||
SetHeader("X-Device-Id", driverID).
|
||||
SetQueryParam("client_id", CLIENT_ID).
|
||||
SetHeader("X-Device-Id", c.deviceID).
|
||||
SetQueryParam("client_id", c.clientID).
|
||||
Post(XLUSER_API_URL + "/shield/captcha/init")
|
||||
if err != nil {
|
||||
return "", err
|
||||
return err
|
||||
}
|
||||
if e.ErrorCode != 0 {
|
||||
return "", fmt.Errorf("%s : %s", e.Error, e.ErrorDescription)
|
||||
if e.HasError() {
|
||||
return &e
|
||||
}
|
||||
|
||||
if resp.Url != "" {
|
||||
return "", fmt.Errorf("需要验证验证码")
|
||||
return fmt.Errorf("need verify:%s", resp.Url)
|
||||
}
|
||||
|
||||
s.captchaTokenExpiresTime = (ctime + resp.ExpiresIn*1000) - 30000
|
||||
s.captchaToken = resp.CaptchaToken
|
||||
return s.captchaToken, nil
|
||||
if resp.CaptchaToken == "" {
|
||||
return fmt.Errorf("empty captchaToken")
|
||||
}
|
||||
c.captchaToken = resp.CaptchaToken
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *State) refreshToken_(account *model.Account) error {
|
||||
var e Erron
|
||||
var resp TokenResponse
|
||||
_, err := xunleiClient.R().
|
||||
SetResult(&resp).SetError(&e).
|
||||
SetBody(&base.Json{
|
||||
"grant_type": "refresh_token",
|
||||
"refresh_token": s.refreshToken,
|
||||
"client_id": CLIENT_ID,
|
||||
"client_secret": CLIENT_SECRET,
|
||||
}).
|
||||
SetHeader("X-Device-Id", utils.GetMD5Encode(account.Username)).SetQueryParam("client_id", CLIENT_ID).
|
||||
Post(XLUSER_API_URL + "/auth/token")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
switch e.ErrorCode {
|
||||
case 4122, 4121:
|
||||
return s.login(account)
|
||||
case 0:
|
||||
s.tokenExpiresTime = (time.Now().UnixMilli() + resp.ExpiresIn*1000) - 30000
|
||||
s.tokenType = resp.TokenType
|
||||
s.accessToken = resp.AccessToken
|
||||
s.refreshToken = resp.RefreshToken
|
||||
s.userID = resp.UserID
|
||||
return nil
|
||||
default:
|
||||
return fmt.Errorf("%s : %s", e.Error, e.ErrorDescription)
|
||||
// 验证码签名
|
||||
func (c *Client) captchaSign(time string) string {
|
||||
str := fmt.Sprint(c.clientID, c.clientVersion, c.packageName, c.deviceID, time)
|
||||
for _, algorithm := range c.algorithms {
|
||||
str = utils.GetMD5Encode(str + algorithm)
|
||||
}
|
||||
return "1." + str
|
||||
}
|
||||
|
||||
func (s *State) login(account *model.Account) error {
|
||||
s.init()
|
||||
ctime := time.Now().UnixMilli()
|
||||
// 登录
|
||||
func (c *Client) Login(account *model.Account) (err error) {
|
||||
c.Lock()
|
||||
defer c.Unlock()
|
||||
|
||||
defer func() {
|
||||
if err != nil {
|
||||
account.Status = err.Error()
|
||||
} else {
|
||||
account.Status = "work"
|
||||
}
|
||||
model.SaveAccount(account)
|
||||
}()
|
||||
|
||||
meta := make(map[string]string)
|
||||
if strings.Contains(account.Username, "@") {
|
||||
meta["email"] = account.Username
|
||||
} else if len(account.Username) >= 11 {
|
||||
if !strings.Contains(account.Username, "+") {
|
||||
account.Username = "+86 " + account.Username
|
||||
}
|
||||
meta["phone_number"] = account.Username
|
||||
} else {
|
||||
meta["username"] = account.Username
|
||||
}
|
||||
|
||||
url := XLUSER_API_URL + "/auth/signin"
|
||||
captchaToken, err := s.newCaptchaToken(getAction("POST", url), map[string]string{"username": account.Username}, account)
|
||||
err = c.requestCaptchaToken(getAction(http.MethodPost, url), meta)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
signReq := SignInRequest{
|
||||
CaptchaToken: captchaToken,
|
||||
ClientID: CLIENT_ID,
|
||||
ClientSecret: CLIENT_SECRET,
|
||||
Username: account.Username,
|
||||
Password: account.Password,
|
||||
}
|
||||
|
||||
var e Erron
|
||||
var resp TokenResponse
|
||||
_, err = xunleiClient.R().
|
||||
_, err = c.Client.R().
|
||||
SetResult(&resp).
|
||||
SetError(&e).
|
||||
SetBody(&signReq).
|
||||
SetHeader("X-Device-Id", utils.GetMD5Encode(account.Username)).
|
||||
SetQueryParam("client_id", CLIENT_ID).
|
||||
SetBody(&SignInRequest{
|
||||
CaptchaToken: c.captchaToken,
|
||||
ClientID: c.clientID,
|
||||
ClientSecret: c.clientSecret,
|
||||
Username: account.Username,
|
||||
Password: account.Password,
|
||||
}).
|
||||
SetHeader("X-Device-Id", c.deviceID).
|
||||
SetQueryParam("client_id", c.clientID).
|
||||
Post(url)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
defer model.SaveAccount(account)
|
||||
if e.ErrorCode != 0 {
|
||||
account.Status = e.Error
|
||||
return fmt.Errorf("%s : %s", e.Error, e.ErrorDescription)
|
||||
if e.HasError() {
|
||||
return &e
|
||||
}
|
||||
account.Status = "work"
|
||||
s.tokenExpiresTime = (ctime + resp.ExpiresIn*1000) - 30000
|
||||
s.tokenType = resp.TokenType
|
||||
s.accessToken = resp.AccessToken
|
||||
s.refreshToken = resp.RefreshToken
|
||||
s.userID = resp.UserID
|
||||
|
||||
if resp.RefreshToken == "" {
|
||||
return base.ErrEmptyToken
|
||||
}
|
||||
|
||||
c.token = resp.Token()
|
||||
c.refreshToken = resp.RefreshToken
|
||||
c.userID = resp.UserID
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *State) Request(method string, url string, callback func(*resty.Request), account *model.Account) (*resty.Response, error) {
|
||||
s.Lock()
|
||||
token, err := s.getToken(account)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// 刷新验证码token
|
||||
func (c *Client) RefreshCaptchaToken(action string) error {
|
||||
c.Lock()
|
||||
defer c.Unlock()
|
||||
|
||||
captchaToken, err := s.getCaptchaToken(getAction(method, url), account)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
timestamp := fmt.Sprint(time.Now().UnixMilli())
|
||||
param := map[string]string{
|
||||
"client_version": c.clientVersion,
|
||||
"package_name": c.packageName,
|
||||
"user_id": c.userID,
|
||||
"captcha_sign": c.captchaSign(timestamp),
|
||||
"timestamp": timestamp,
|
||||
}
|
||||
return c.requestCaptchaToken(action, param)
|
||||
}
|
||||
|
||||
req := xunleiClient.R().
|
||||
SetHeaders(map[string]string{
|
||||
"X-Device-Id": utils.GetMD5Encode(account.Username),
|
||||
"Authorization": token,
|
||||
"X-Captcha-Token": captchaToken,
|
||||
// 刷新token
|
||||
func (c *Client) RefreshToken() error {
|
||||
c.Lock()
|
||||
defer c.Unlock()
|
||||
|
||||
var e Erron
|
||||
var resp TokenResponse
|
||||
_, err := c.Client.R().
|
||||
SetError(&e).
|
||||
SetResult(&resp).
|
||||
SetBody(&base.Json{
|
||||
"grant_type": "refresh_token",
|
||||
"refresh_token": c.refreshToken,
|
||||
"client_id": c.clientID,
|
||||
"client_secret": c.clientSecret,
|
||||
}).
|
||||
SetQueryParam("client_id", CLIENT_ID)
|
||||
|
||||
callback(req)
|
||||
s.Unlock()
|
||||
|
||||
var res *resty.Response
|
||||
switch method {
|
||||
case "GET":
|
||||
res, err = req.Get(url)
|
||||
case "POST":
|
||||
res, err = req.Post(url)
|
||||
case "DELETE":
|
||||
res, err = req.Delete(url)
|
||||
case "PATCH":
|
||||
res, err = req.Patch(url)
|
||||
case "PUT":
|
||||
res, err = req.Put(url)
|
||||
default:
|
||||
return nil, base.ErrNotSupport
|
||||
SetHeader("X-Device-Id", c.deviceID).
|
||||
SetQueryParam("client_id", c.clientID).
|
||||
Post(XLUSER_API_URL + "/auth/token")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if e.HasError() {
|
||||
return &e
|
||||
}
|
||||
|
||||
if resp.RefreshToken == "" {
|
||||
return base.ErrEmptyToken
|
||||
}
|
||||
|
||||
c.token = resp.TokenType + " " + resp.AccessToken
|
||||
c.refreshToken = resp.RefreshToken
|
||||
c.userID = resp.UserID
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Client) Request(method string, url string, callback func(*resty.Request), account *model.Account) (*resty.Response, error) {
|
||||
c.Lock()
|
||||
req := c.Client.R().
|
||||
SetHeaders(map[string]string{
|
||||
"X-Device-Id": c.deviceID,
|
||||
"Authorization": c.token,
|
||||
"X-Captcha-Token": c.captchaToken,
|
||||
"User-Agent": c.userAgent,
|
||||
"client_id": c.clientID,
|
||||
}).
|
||||
SetQueryParam("client_id", c.clientID)
|
||||
if callback != nil {
|
||||
callback(req)
|
||||
}
|
||||
c.Unlock()
|
||||
|
||||
res, err := req.Execute(method, url)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
log.Debug(res.String())
|
||||
|
||||
var e Erron
|
||||
utils.Json.Unmarshal(res.Body(), &e)
|
||||
switch e.ErrorCode {
|
||||
case 9:
|
||||
s.newCaptchaToken(getAction(method, url), nil, account)
|
||||
fallthrough
|
||||
case 4122, 4121:
|
||||
return s.Request(method, url, callback, account)
|
||||
case 0:
|
||||
if res.StatusCode() == http.StatusOK {
|
||||
return res, nil
|
||||
}
|
||||
return nil, fmt.Errorf(res.String())
|
||||
default:
|
||||
return nil, fmt.Errorf("%s : %s", e.Error, e.ErrorDescription)
|
||||
if err = utils.Json.Unmarshal(res.Body(), &e); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 处理错误
|
||||
switch e.ErrorCode {
|
||||
case 0:
|
||||
return res, nil
|
||||
case 4122, 4121, 10: // token过期
|
||||
if err = c.RefreshToken(); err == nil {
|
||||
break
|
||||
}
|
||||
fallthrough
|
||||
case 16: // 登录失效
|
||||
if err = c.Login(account); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
case 9: // 验证码token过期
|
||||
if err = c.RefreshCaptchaToken(getAction(method, url)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
default:
|
||||
return nil, &e
|
||||
}
|
||||
return c.Request(method, url, callback, account)
|
||||
}
|
||||
|
||||
func (s *State) Init() *State {
|
||||
s.Lock()
|
||||
defer s.Unlock()
|
||||
return s.init()
|
||||
}
|
||||
func (c *Client) UpdateCaptchaToken(captchaToken string) bool {
|
||||
c.Lock()
|
||||
defer c.Unlock()
|
||||
|
||||
func (s *State) GetCaptchaToken(action string, account *model.Account) (string, error) {
|
||||
s.Lock()
|
||||
defer s.Unlock()
|
||||
return s.getCaptchaToken(action, account)
|
||||
}
|
||||
|
||||
func (s *State) GetToken(account *model.Account) (string, error) {
|
||||
s.Lock()
|
||||
defer s.Unlock()
|
||||
return s.getToken(account)
|
||||
}
|
||||
|
||||
func (s *State) Login(account *model.Account) error {
|
||||
s.Lock()
|
||||
defer s.Unlock()
|
||||
return s.login(account)
|
||||
if captchaToken != "" {
|
||||
c.captchaToken = captchaToken
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
@ -213,7 +213,8 @@ func (driver Yandex) Upload(file *model.FileStream, account *model.Account) erro
|
||||
}
|
||||
req.Header.Set("Content-Length", strconv.FormatUint(file.Size, 10))
|
||||
req.Header.Set("Content-Type", "application/octet-stream")
|
||||
_, err = base.HttpClient.Do(req)
|
||||
res, err := base.HttpClient.Do(req)
|
||||
res.Body.Close()
|
||||
//res, err := base.RestyClient.R().
|
||||
// SetHeader("Content-Length", strconv.FormatUint(file.Size, 10)).
|
||||
// SetBody(file).Put(resp.Href)
|
||||
|
19
go.mod
19
go.mod
@ -5,6 +5,7 @@ go 1.18
|
||||
require (
|
||||
github.com/aws/aws-sdk-go v1.27.0
|
||||
github.com/caarlos0/env/v6 v6.9.1
|
||||
github.com/casdoor/casdoor-go-sdk v0.7.0
|
||||
github.com/eko/gocache/v2 v2.1.0
|
||||
github.com/gin-contrib/cors v1.3.1
|
||||
github.com/gin-gonic/gin v1.7.4
|
||||
@ -16,7 +17,6 @@ require (
|
||||
github.com/pkg/sftp v1.13.4
|
||||
github.com/robfig/cron/v3 v3.0.0
|
||||
github.com/sirupsen/logrus v1.8.1
|
||||
github.com/studio-b12/gowebdav v0.0.0-20211109083228-3f8721cd4b6f
|
||||
github.com/upyun/go-sdk/v3 v3.0.2
|
||||
golang.org/x/text v0.3.7
|
||||
gorm.io/driver/mysql v1.3.2
|
||||
@ -25,18 +25,20 @@ require (
|
||||
gorm.io/gorm v1.23.1
|
||||
)
|
||||
|
||||
require github.com/kr/fs v0.1.0 // indirect
|
||||
require (
|
||||
github.com/golang-jwt/jwt/v4 v4.1.0 // indirect
|
||||
github.com/kr/fs v0.1.0 // indirect
|
||||
golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c // indirect
|
||||
google.golang.org/appengine v1.6.6 // indirect
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f // indirect
|
||||
github.com/fatih/color v1.13.0
|
||||
github.com/mattn/go-colorable v0.1.9 // indirect
|
||||
golang.org/x/time v0.0.0-20191024005414-555d28b269f0 // indirect
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/XiaoMi/pegasus-go-client v0.0.0-20210427083443-f3b6b08bc4c2 // indirect
|
||||
github.com/aliyun/aliyun-oss-go-sdk v2.2.1+incompatible
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/bradfitz/gomemcache v0.0.0-20190913173617-a41fca850d0b // indirect
|
||||
github.com/cenkalti/backoff/v4 v4.1.0 // indirect
|
||||
@ -77,7 +79,7 @@ require (
|
||||
go.opentelemetry.io/otel/metric v0.20.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v0.20.0 // indirect
|
||||
golang.org/x/crypto v0.0.0-20220331220935-ae2d96664a29
|
||||
golang.org/x/net v0.0.0-20211209124913-491a49abca63 // indirect
|
||||
golang.org/x/net v0.0.0-20211209124913-491a49abca63
|
||||
golang.org/x/sys v0.0.0-20220330033206-e17cdc41300f // indirect
|
||||
google.golang.org/protobuf v1.27.1 // indirect
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
|
||||
@ -85,3 +87,8 @@ require (
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
k8s.io/apimachinery v0.0.0-20191123233150-4c4803ed55e3 // indirect
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/bitly/go-simplejson v0.5.0
|
||||
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 // indirect
|
||||
)
|
263
go.sum
263
go.sum
@ -1,7 +1,39 @@
|
||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=
|
||||
cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU=
|
||||
cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY=
|
||||
cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc=
|
||||
cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0=
|
||||
cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To=
|
||||
cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4=
|
||||
cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M=
|
||||
cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc=
|
||||
cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk=
|
||||
cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs=
|
||||
cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc=
|
||||
cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY=
|
||||
cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o=
|
||||
cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE=
|
||||
cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc=
|
||||
cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg=
|
||||
cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc=
|
||||
cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ=
|
||||
cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE=
|
||||
cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk=
|
||||
cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I=
|
||||
cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw=
|
||||
cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA=
|
||||
cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU=
|
||||
cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw=
|
||||
cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos=
|
||||
cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk=
|
||||
cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs=
|
||||
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
|
||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
|
||||
github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc=
|
||||
github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs=
|
||||
@ -20,8 +52,6 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuy
|
||||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho=
|
||||
github.com/aliyun/aliyun-oss-go-sdk v2.2.1+incompatible h1:uuJIwCFhbZy+zdvLy5zrcIToPEQP0s5CFOZ0Zj03O/w=
|
||||
github.com/aliyun/aliyun-oss-go-sdk v2.2.1+incompatible/go.mod h1:T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8=
|
||||
github.com/allegro/bigcache/v2 v2.2.5 h1:mRc8r6GQjuJsmSKQNPsR5jQVXc8IJ1xsW5YXUYMLfqI=
|
||||
github.com/allegro/bigcache/v2 v2.2.5/go.mod h1:FppZsIO+IZk7gCuj5FiIDHGygD9xvWQcqg1uIPMb6tY=
|
||||
github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
|
||||
@ -34,8 +64,6 @@ github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQ
|
||||
github.com/aws/aws-sdk-go v1.27.0 h1:0xphMHGMLBrPMfxR2AmVjZKcMEESEgWF8Kru94BNByk=
|
||||
github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
|
||||
github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g=
|
||||
github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f h1:ZNv7On9kyUzm7fvRZumSyy/IUiSC7AzL0I1jKKtwooA=
|
||||
github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f/go.mod h1:AuiFmCCPBSrqvVMvuqFuk0qogytodnVFVSN5CeJB8Gc=
|
||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
||||
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
||||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||
@ -46,7 +74,8 @@ github.com/bradfitz/gomemcache v0.0.0-20190913173617-a41fca850d0b/go.mod h1:H0wQ
|
||||
github.com/caarlos0/env/v6 v6.9.1 h1:zOkkjM0F6ltnQ5eBX6IPI41UP/KDGEK7rRPwGCNos8k=
|
||||
github.com/caarlos0/env/v6 v6.9.1/go.mod h1:hvp/ryKXKipEkcuYjs9mI4bBCg+UI0Yhgm5Zu0ddvwc=
|
||||
github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ=
|
||||
github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4=
|
||||
github.com/casdoor/casdoor-go-sdk v0.7.0 h1:T+KkiLit0xA5aYHffyv26+qG6tcRen83CmOR41PUyME=
|
||||
github.com/casdoor/casdoor-go-sdk v0.7.0/go.mod h1:MBed3ISHQfXTtoOCAk5T8l5lt4wFvsyynrw0awggydY=
|
||||
github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
|
||||
github.com/cenkalti/backoff/v4 v4.1.0 h1:c8LkOFQTzuO0WBM/ae5HdGQuZPfPxp7lqBRwQRm4fSc=
|
||||
github.com/cenkalti/backoff/v4 v4.1.0/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw=
|
||||
@ -55,8 +84,12 @@ github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko=
|
||||
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
|
||||
github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY=
|
||||
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
|
||||
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
|
||||
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
|
||||
github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4dUb/I5gc9Hdhagfvm9+RyrPryS/auMzxE=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
||||
github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I=
|
||||
github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ=
|
||||
github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8=
|
||||
@ -92,7 +125,9 @@ github.com/eko/gocache/v2 v2.1.0/go.mod h1:u+EpYjCVsOpeqvDLzinOVLjLxwHJjO+NT4LS2
|
||||
github.com/elazarl/goproxy v0.0.0-20170405201442-c4fc26588b6e/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc=
|
||||
github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs=
|
||||
github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g=
|
||||
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||
github.com/evanphx/json-patch v4.2.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
|
||||
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
||||
@ -114,6 +149,9 @@ github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm
|
||||
github.com/gin-gonic/gin v1.5.0/go.mod h1:Nd6IXA8m5kNZdNEHMBd93KT+mdY3+bewLgRvmCsR2Do=
|
||||
github.com/gin-gonic/gin v1.7.4 h1:QmUZXrvJ9qZ3GfWvQ+2wnW/1ePrTEJqPKMYEU3lD/DM=
|
||||
github.com/gin-gonic/gin v1.7.4/go.mod h1:jD2toBW3GZUr5UMcdrwQA10I7RuaFOl/SGeDjXkfUtY=
|
||||
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
|
||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
||||
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o=
|
||||
@ -154,10 +192,20 @@ github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7a
|
||||
github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
|
||||
github.com/gogo/protobuf v1.2.2-0.20190723190241-65acae22fc9d/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
|
||||
github.com/golang-jwt/jwt/v4 v4.1.0 h1:XUgk2Ex5veyVFVeLm0xhusUTQybEbexJXrvPNOKkSY0=
|
||||
github.com/golang-jwt/jwt/v4 v4.1.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y=
|
||||
github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
|
||||
github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
|
||||
github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
|
||||
github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4=
|
||||
github.com/golang/mock v1.5.0 h1:jlYHihg//f7RRwuPfptm04yp4s7O6Kw8EZiVYIGcH0g=
|
||||
github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8=
|
||||
github.com/golang/protobuf v0.0.0-20161109072736-4bd1920723d7/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
@ -165,11 +213,14 @@ github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5y
|
||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
|
||||
github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
|
||||
github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk=
|
||||
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
|
||||
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
|
||||
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
|
||||
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
|
||||
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
||||
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
|
||||
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||
@ -182,16 +233,30 @@ github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5a
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
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/gofuzz v0.0.0-20161122191042-44d81051d367/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
|
||||
github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
|
||||
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
|
||||
github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
|
||||
github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
||||
github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
||||
github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
||||
github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
||||
github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
||||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
||||
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
|
||||
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
|
||||
github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY=
|
||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
|
||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
||||
@ -224,9 +289,9 @@ github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2p
|
||||
github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc=
|
||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||
github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg=
|
||||
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||
github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo=
|
||||
github.com/jackc/chunkreader v1.0.0 h1:4s39bBR8ByfqH+DKm8rQA3E1LHZWB9XWcrz8fqaZbe0=
|
||||
github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo=
|
||||
github.com/jackc/chunkreader/v2 v2.0.0/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk=
|
||||
github.com/jackc/chunkreader/v2 v2.0.1 h1:i+RDz65UE+mmpjTfyz0MoVTnzeYxroil2G82ki7MGG8=
|
||||
@ -248,7 +313,6 @@ github.com/jackc/pgmock v0.0.0-20210724152146-4ad1a8207f65 h1:DadwsjnMwFjfWc9y5W
|
||||
github.com/jackc/pgmock v0.0.0-20210724152146-4ad1a8207f65/go.mod h1:5R2h2EEX+qri8jOWMbJCtaPWkrrNc7OHwsp2TCqp7ak=
|
||||
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/pgproto3 v1.1.0 h1:FYYE4yRw+AgI8wXIinMlNjBbp/UitDJwfj5LqqewP1A=
|
||||
github.com/jackc/pgproto3 v1.1.0/go.mod h1:eR5FA3leWg7p9aeAqi37XOTgTIbkABlvcPB3E5rlc78=
|
||||
github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190420180111-c116219b62db/go.mod h1:bhq50y+xrl9n5mRYyCBFKkpRVTLYJVWeCc+mEAI3yXA=
|
||||
github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190609003834-432c2951c711/go.mod h1:uH0AWtUmuShn0bcesswc4aBTWGvw0cAxIJp+6OB//Wg=
|
||||
@ -297,6 +361,8 @@ github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/u
|
||||
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
|
||||
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
|
||||
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
|
||||
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
|
||||
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
||||
@ -469,7 +535,6 @@ github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThC
|
||||
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
|
||||
github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E=
|
||||
github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww=
|
||||
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
|
||||
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
|
||||
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4=
|
||||
@ -509,11 +574,8 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5
|
||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/studio-b12/gowebdav v0.0.0-20211109083228-3f8721cd4b6f h1:L2NE7BXnSlSLoNYZ0lCwZDjdnYjCNYC71k9ClZUTFTs=
|
||||
github.com/studio-b12/gowebdav v0.0.0-20211109083228-3f8721cd4b6f/go.mod h1:bHA7t77X/QFExdeAnDzK6vKM34kEZAcE1OX4MfiwjkE=
|
||||
github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
|
||||
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
|
||||
github.com/ugorji/go v1.2.6 h1:tGiWC9HENWE2tqYycIqFTNorMmFRVhNwCpDOpWqnk8E=
|
||||
github.com/ugorji/go v1.2.6/go.mod h1:anCg0y61KIhDlPZmnH+so+RQbysYVyDko0IMgJv0Nn0=
|
||||
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
|
||||
github.com/ugorji/go/codec v1.2.6 h1:7kbGefxLoDBuYXOms4yD7223OpNMMPNPZxXk5TvFcyQ=
|
||||
@ -524,13 +586,20 @@ github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijb
|
||||
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
|
||||
github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
|
||||
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
|
||||
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q=
|
||||
go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
|
||||
go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg=
|
||||
go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
|
||||
go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
|
||||
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
|
||||
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
|
||||
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||
go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||
go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||
go.opentelemetry.io/otel v0.20.0 h1:eaP0Fqu7SXHwvjiqDq83zImeehOHX8doTvU9AwXON8g=
|
||||
go.opentelemetry.io/otel v0.20.0/go.mod h1:Y3ugLH2oa81t5QO+Lty+zXf8zC9L26ax4Nzoxm/dooo=
|
||||
go.opentelemetry.io/otel/metric v0.20.0 h1:4kzhXFP+btKm4jwxpjIqjs41A7MakRFUS86bqLHTIw8=
|
||||
@ -555,6 +624,7 @@ golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnf
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190411191339-88737f569e3a/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE=
|
||||
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
@ -567,13 +637,34 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y
|
||||
golang.org/x/crypto v0.0.0-20220331220935-ae2d96664a29 h1:tkVvjkPTB7pnW3jnid7kNyAMPVWllTNOf/qKDze4p9o=
|
||||
golang.org/x/crypto v0.0.0-20220331220935-ae2d96664a29/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
|
||||
golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek=
|
||||
golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY=
|
||||
golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
|
||||
golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
|
||||
golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
|
||||
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
|
||||
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
|
||||
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
|
||||
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs=
|
||||
golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
|
||||
golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
|
||||
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
|
||||
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
|
||||
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
|
||||
golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY=
|
||||
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
|
||||
golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
|
||||
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
@ -588,29 +679,52 @@ golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73r
|
||||
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
|
||||
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20191004110552-13f9640d40b9/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20191105084925-a882066a44e0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
|
||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20211209124913-491a49abca63 h1:iocB37TsdFuN6IBRZ+ry36wrkoV51/tl5vOWqkcPGvY=
|
||||
golang.org/x/net v0.0.0-20211209124913-491a49abca63/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c h1:pkQiBZBvdos9qq4wBAHqlzuZHEXo07pqV06ef90u1WI=
|
||||
golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/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-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20170830134202-bb24a47a89ea/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
@ -624,32 +738,49 @@ golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5h
|
||||
golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191010194322-b09406accb47/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191220142924-d4481acd189f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210309074719-68d13333faf2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
@ -660,7 +791,9 @@ golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXR
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/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.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
@ -668,7 +801,8 @@ golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20191024005414-555d28b269f0 h1:/5xXl8Y5W96D+TtHSlonuFqGHIWVuyCkGJLwGh9JJFs=
|
||||
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
@ -678,16 +812,48 @@ golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGm
|
||||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/tools v0.0.0-20190425163242-31fd60d6bfdc/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20190823170909-c4a336ef6a2f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw=
|
||||
golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw=
|
||||
golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8=
|
||||
golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||
golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||
golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||
golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||
golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
||||
golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
||||
golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
||||
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
@ -697,29 +863,87 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk=
|
||||
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
|
||||
google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M=
|
||||
google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
|
||||
google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
|
||||
google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
|
||||
google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
|
||||
google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
|
||||
google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
|
||||
google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
|
||||
google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
|
||||
google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
|
||||
google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
|
||||
google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE=
|
||||
google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE=
|
||||
google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM=
|
||||
google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc=
|
||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||
google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0=
|
||||
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||
google.golang.org/appengine v1.6.6 h1:lMO5rYAqUxkmaj76jAkRUvt5JZgFymx/+Q5Mzfivuhc=
|
||||
google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto v0.0.0-20190530194941-fb225487d101/go.mod h1:z3L6/3dTEVtUr6QSP8miRzeRqwQOioJ9I66odjN4I7s=
|
||||
google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||
google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8=
|
||||
google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
||||
google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
||||
google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
||||
google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
||||
google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
||||
google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
||||
google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA=
|
||||
google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U=
|
||||
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
|
||||
google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA=
|
||||
google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs=
|
||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||
google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM=
|
||||
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
|
||||
google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
|
||||
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
|
||||
google.golang.org/grpc v1.22.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||
google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
|
||||
google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||
google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||
google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60=
|
||||
google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk=
|
||||
google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
|
||||
google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
|
||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
|
||||
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
|
||||
google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4=
|
||||
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
|
||||
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.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ=
|
||||
@ -768,14 +992,25 @@ gorm.io/gorm v1.23.1 h1:aj5IlhDzEPsoIyOPtTRVI+SyaN1u6k613sbt4pwbxG0=
|
||||
gorm.io/gorm v1.23.1/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk=
|
||||
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
||||
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
||||
k8s.io/apimachinery v0.0.0-20191123233150-4c4803ed55e3 h1:FErmbNIJruD5GT2oVEjtPn5Ar5+rcWJsC8/PPUkR0s4=
|
||||
k8s.io/apimachinery v0.0.0-20191123233150-4c4803ed55e3/go.mod h1:b9qmWdKlLuU9EBh+06BtLcSf/Mu89rWL33naRxs1uZg=
|
||||
k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0=
|
||||
k8s.io/klog v0.0.0-20181102134211-b9b56d5dfc92/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk=
|
||||
k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I=
|
||||
k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E=
|
||||
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
|
||||
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
|
||||
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
|
||||
sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI=
|
||||
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
|
||||
sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU=
|
||||
github.com/bitly/go-simplejson v0.5.0 h1:6IH+V8/tVMab511d5bn4M7EwGXZf9Hj6i2xSwkNEM+Y=
|
||||
github.com/bitly/go-simplejson v0.5.0/go.mod h1:cXHtHw4XUPsvGaxgjIAn8PhEWG9NfngEKAMDJEczWVA=
|
||||
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 h1:DDGfHa7BWjL4YnC6+E63dPcxHo2sUxDIu8g3QgEJdRY=
|
||||
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4=
|
@ -50,6 +50,13 @@ type Account struct {
|
||||
CustomHost string `json:"custom_host"`
|
||||
ExtractFolder string `json:"extract_folder"`
|
||||
Bool1 bool `json:"bool_1"`
|
||||
// for xunlei
|
||||
Algorithms string `json:"algorithms"`
|
||||
ClientVersion string `json:"client_version"`
|
||||
PackageName string `json:"package_name"`
|
||||
UserAgent string `json:"user_agent"`
|
||||
CaptchaToken string `json:"captcha_token"`
|
||||
DeviceId string `json:"device_id"`
|
||||
}
|
||||
|
||||
var accountsMap = make(map[string]Account)
|
||||
|
21
pkg/gowebdav/.gitignore
vendored
Normal file
21
pkg/gowebdav/.gitignore
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
# Folders to ignore
|
||||
/src
|
||||
/bin
|
||||
/pkg
|
||||
/gowebdav
|
||||
/.idea
|
||||
|
||||
# Binaries for programs and plugins
|
||||
*.exe
|
||||
*.exe~
|
||||
*.dll
|
||||
*.so
|
||||
*.dylib
|
||||
|
||||
# Test binary, build with `go test -c`
|
||||
*.test
|
||||
|
||||
# Output of the go coverage tool, specifically when used with LiteIDE
|
||||
*.out
|
||||
|
||||
.vscode/
|
10
pkg/gowebdav/.travis.yml
Normal file
10
pkg/gowebdav/.travis.yml
Normal file
@ -0,0 +1,10 @@
|
||||
language: go
|
||||
|
||||
go:
|
||||
- "1.x"
|
||||
|
||||
install:
|
||||
- go get ./...
|
||||
|
||||
script:
|
||||
- go test -v --short ./...
|
27
pkg/gowebdav/LICENSE
Normal file
27
pkg/gowebdav/LICENSE
Normal file
@ -0,0 +1,27 @@
|
||||
Copyright (c) 2014, Studio B12 GmbH
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
33
pkg/gowebdav/Makefile
Normal file
33
pkg/gowebdav/Makefile
Normal file
@ -0,0 +1,33 @@
|
||||
BIN := gowebdav
|
||||
SRC := $(wildcard *.go) cmd/gowebdav/main.go
|
||||
|
||||
all: test cmd
|
||||
|
||||
cmd: ${BIN}
|
||||
|
||||
${BIN}: ${SRC}
|
||||
go build -o $@ ./cmd/gowebdav
|
||||
|
||||
test:
|
||||
go test -v --short ./...
|
||||
|
||||
api:
|
||||
@sed '/^## API$$/,$$d' -i README.md
|
||||
@echo '## API' >> README.md
|
||||
@godoc2md github.com/studio-b12/gowebdav | sed '/^$$/N;/^\n$$/D' |\
|
||||
sed '2d' |\
|
||||
sed 's/\/src\/github.com\/studio-b12\/gowebdav\//https:\/\/github.com\/studio-b12\/gowebdav\/blob\/master\//g' |\
|
||||
sed 's/\/src\/target\//https:\/\/github.com\/studio-b12\/gowebdav\/blob\/master\//g' |\
|
||||
sed 's/^#/##/g' >> README.md
|
||||
|
||||
check:
|
||||
gofmt -w -s $(SRC)
|
||||
@echo
|
||||
gocyclo -over 15 .
|
||||
@echo
|
||||
golint ./...
|
||||
|
||||
clean:
|
||||
@rm -f ${BIN}
|
||||
|
||||
.PHONY: all cmd clean test api check
|
564
pkg/gowebdav/README.md
Normal file
564
pkg/gowebdav/README.md
Normal file
@ -0,0 +1,564 @@
|
||||
# GoWebDAV
|
||||
|
||||
[](https://travis-ci.org/studio-b12/gowebdav)
|
||||
[](https://godoc.org/github.com/studio-b12/gowebdav)
|
||||
[](https://goreportcard.com/report/github.com/studio-b12/gowebdav)
|
||||
|
||||
A golang WebDAV client library.
|
||||
|
||||
## Main features
|
||||
`gowebdav` library allows to perform following actions on the remote WebDAV server:
|
||||
* [create path](#create-path-on-a-webdav-server)
|
||||
* [get files list](#get-files-list)
|
||||
* [download file](#download-file-to-byte-array)
|
||||
* [upload file](#upload-file-from-byte-array)
|
||||
* [get information about specified file/folder](#get-information-about-specified-filefolder)
|
||||
* [move file to another location](#move-file-to-another-location)
|
||||
* [copy file to another location](#copy-file-to-another-location)
|
||||
* [delete file](#delete-file)
|
||||
|
||||
## Usage
|
||||
|
||||
First of all you should create `Client` instance using `NewClient()` function:
|
||||
|
||||
```go
|
||||
root := "https://webdav.mydomain.me"
|
||||
user := "user"
|
||||
password := "password"
|
||||
|
||||
c := gowebdav.NewClient(root, user, password)
|
||||
```
|
||||
|
||||
After you can use this `Client` to perform actions, described below.
|
||||
|
||||
**NOTICE:** we will not check errors in examples, to focus you on the `gowebdav` library's code, but you should do it in your code!
|
||||
|
||||
### Create path on a WebDAV server
|
||||
```go
|
||||
err := c.Mkdir("folder", 0644)
|
||||
```
|
||||
In case you want to create several folders you can use `c.MkdirAll()`:
|
||||
```go
|
||||
err := c.MkdirAll("folder/subfolder/subfolder2", 0644)
|
||||
```
|
||||
|
||||
### Get files list
|
||||
```go
|
||||
files, _ := c.ReadDir("folder/subfolder")
|
||||
for _, file := range files {
|
||||
//notice that [file] has os.FileInfo type
|
||||
fmt.Println(file.Name())
|
||||
}
|
||||
```
|
||||
|
||||
### Download file to byte array
|
||||
```go
|
||||
webdavFilePath := "folder/subfolder/file.txt"
|
||||
localFilePath := "/tmp/webdav/file.txt"
|
||||
|
||||
bytes, _ := c.Read(webdavFilePath)
|
||||
ioutil.WriteFile(localFilePath, bytes, 0644)
|
||||
```
|
||||
|
||||
### Download file via reader
|
||||
Also you can use `c.ReadStream()` method:
|
||||
```go
|
||||
webdavFilePath := "folder/subfolder/file.txt"
|
||||
localFilePath := "/tmp/webdav/file.txt"
|
||||
|
||||
reader, _ := c.ReadStream(webdavFilePath)
|
||||
|
||||
file, _ := os.Create(localFilePath)
|
||||
defer file.Close()
|
||||
|
||||
io.Copy(file, reader)
|
||||
```
|
||||
|
||||
### Upload file from byte array
|
||||
```go
|
||||
webdavFilePath := "folder/subfolder/file.txt"
|
||||
localFilePath := "/tmp/webdav/file.txt"
|
||||
|
||||
bytes, _ := ioutil.ReadFile(localFilePath)
|
||||
|
||||
c.Write(webdavFilePath, bytes, 0644)
|
||||
```
|
||||
|
||||
### Upload file via writer
|
||||
```go
|
||||
webdavFilePath := "folder/subfolder/file.txt"
|
||||
localFilePath := "/tmp/webdav/file.txt"
|
||||
|
||||
file, _ := os.Open(localFilePath)
|
||||
defer file.Close()
|
||||
|
||||
c.WriteStream(webdavFilePath, file, 0644)
|
||||
```
|
||||
|
||||
### Get information about specified file/folder
|
||||
```go
|
||||
webdavFilePath := "folder/subfolder/file.txt"
|
||||
|
||||
info := c.Stat(webdavFilePath)
|
||||
//notice that [info] has os.FileInfo type
|
||||
fmt.Println(info)
|
||||
```
|
||||
|
||||
### Move file to another location
|
||||
```go
|
||||
oldPath := "folder/subfolder/file.txt"
|
||||
newPath := "folder/subfolder/moved.txt"
|
||||
isOverwrite := true
|
||||
|
||||
c.Rename(oldPath, newPath, isOverwrite)
|
||||
```
|
||||
|
||||
### Copy file to another location
|
||||
```go
|
||||
oldPath := "folder/subfolder/file.txt"
|
||||
newPath := "folder/subfolder/file-copy.txt"
|
||||
isOverwrite := true
|
||||
|
||||
c.Copy(oldPath, newPath, isOverwrite)
|
||||
```
|
||||
|
||||
### Delete file
|
||||
```go
|
||||
webdavFilePath := "folder/subfolder/file.txt"
|
||||
|
||||
c.Remove(webdavFilePath)
|
||||
```
|
||||
|
||||
## Links
|
||||
|
||||
More details about WebDAV server you can read from following resources:
|
||||
|
||||
* [RFC 4918 - HTTP Extensions for Web Distributed Authoring and Versioning (WebDAV)](https://tools.ietf.org/html/rfc4918)
|
||||
* [RFC 5689 - Extended MKCOL for Web Distributed Authoring and Versioning (WebDAV)](https://tools.ietf.org/html/rfc5689)
|
||||
* [RFC 2616 - HTTP/1.1 Status Code Definitions](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html "HTTP/1.1 Status Code Definitions")
|
||||
* [WebDav: Next Generation Collaborative Web Authoring By Lisa Dusseaul](https://books.google.de/books?isbn=0130652083 "WebDav: Next Generation Collaborative Web Authoring By Lisa Dusseault")
|
||||
|
||||
**NOTICE**: RFC 2518 is obsoleted by RFC 4918 in June 2007
|
||||
|
||||
## Contributing
|
||||
All contributing are welcome. If you have any suggestions or find some bug - please create an Issue to let us make this project better. We appreciate your help!
|
||||
|
||||
## License
|
||||
This library is distributed under the BSD 3-Clause license found in the [LICENSE](https://github.com/studio-b12/gowebdav/blob/master/LICENSE) file.
|
||||
## API
|
||||
|
||||
`import "github.com/studio-b12/gowebdav"`
|
||||
|
||||
* [Overview](#pkg-overview)
|
||||
* [Index](#pkg-index)
|
||||
* [Examples](#pkg-examples)
|
||||
* [Subdirectories](#pkg-subdirectories)
|
||||
|
||||
### <a name="pkg-overview">Overview</a>
|
||||
Package gowebdav is a WebDAV client library with a command line tool
|
||||
included.
|
||||
|
||||
### <a name="pkg-index">Index</a>
|
||||
* [func FixSlash(s string) string](#FixSlash)
|
||||
* [func FixSlashes(s string) string](#FixSlashes)
|
||||
* [func Join(path0 string, path1 string) string](#Join)
|
||||
* [func PathEscape(path string) string](#PathEscape)
|
||||
* [func ReadConfig(uri, netrc string) (string, string)](#ReadConfig)
|
||||
* [func String(r io.Reader) string](#String)
|
||||
* [type Authenticator](#Authenticator)
|
||||
* [type BasicAuth](#BasicAuth)
|
||||
* [func (b *BasicAuth) Authorize(req *http.Request, method string, path string)](#BasicAuth.Authorize)
|
||||
* [func (b *BasicAuth) Pass() string](#BasicAuth.Pass)
|
||||
* [func (b *BasicAuth) Type() string](#BasicAuth.Type)
|
||||
* [func (b *BasicAuth) User() string](#BasicAuth.User)
|
||||
* [type Client](#Client)
|
||||
* [func NewClient(uri, user, pw string) *Client](#NewClient)
|
||||
* [func (c *Client) Connect() error](#Client.Connect)
|
||||
* [func (c *Client) Copy(oldpath, newpath string, overwrite bool) error](#Client.Copy)
|
||||
* [func (c *Client) Mkdir(path string, _ os.FileMode) error](#Client.Mkdir)
|
||||
* [func (c *Client) MkdirAll(path string, _ os.FileMode) error](#Client.MkdirAll)
|
||||
* [func (c *Client) Read(path string) ([]byte, error)](#Client.Read)
|
||||
* [func (c *Client) ReadDir(path string) ([]os.FileInfo, error)](#Client.ReadDir)
|
||||
* [func (c *Client) ReadStream(path string) (io.ReadCloser, error)](#Client.ReadStream)
|
||||
* [func (c *Client) ReadStreamRange(path string, offset, length int64) (io.ReadCloser, error)](#Client.ReadStreamRange)
|
||||
* [func (c *Client) Remove(path string) error](#Client.Remove)
|
||||
* [func (c *Client) RemoveAll(path string) error](#Client.RemoveAll)
|
||||
* [func (c *Client) Rename(oldpath, newpath string, overwrite bool) error](#Client.Rename)
|
||||
* [func (c *Client) SetHeader(key, value string)](#Client.SetHeader)
|
||||
* [func (c *Client) SetInterceptor(interceptor func(method string, rq *http.Request))](#Client.SetInterceptor)
|
||||
* [func (c *Client) SetTimeout(timeout time.Duration)](#Client.SetTimeout)
|
||||
* [func (c *Client) SetTransport(transport http.RoundTripper)](#Client.SetTransport)
|
||||
* [func (c *Client) Stat(path string) (os.FileInfo, error)](#Client.Stat)
|
||||
* [func (c *Client) Write(path string, data []byte, _ os.FileMode) error](#Client.Write)
|
||||
* [func (c *Client) WriteStream(path string, stream io.Reader, _ os.FileMode) error](#Client.WriteStream)
|
||||
* [type DigestAuth](#DigestAuth)
|
||||
* [func (d *DigestAuth) Authorize(req *http.Request, method string, path string)](#DigestAuth.Authorize)
|
||||
* [func (d *DigestAuth) Pass() string](#DigestAuth.Pass)
|
||||
* [func (d *DigestAuth) Type() string](#DigestAuth.Type)
|
||||
* [func (d *DigestAuth) User() string](#DigestAuth.User)
|
||||
* [type File](#File)
|
||||
* [func (f File) ContentType() string](#File.ContentType)
|
||||
* [func (f File) ETag() string](#File.ETag)
|
||||
* [func (f File) IsDir() bool](#File.IsDir)
|
||||
* [func (f File) ModTime() time.Time](#File.ModTime)
|
||||
* [func (f File) Mode() os.FileMode](#File.Mode)
|
||||
* [func (f File) Name() string](#File.Name)
|
||||
* [func (f File) Path() string](#File.Path)
|
||||
* [func (f File) Size() int64](#File.Size)
|
||||
* [func (f File) String() string](#File.String)
|
||||
* [func (f File) Sys() interface{}](#File.Sys)
|
||||
* [type NoAuth](#NoAuth)
|
||||
* [func (n *NoAuth) Authorize(req *http.Request, method string, path string)](#NoAuth.Authorize)
|
||||
* [func (n *NoAuth) Pass() string](#NoAuth.Pass)
|
||||
* [func (n *NoAuth) Type() string](#NoAuth.Type)
|
||||
* [func (n *NoAuth) User() string](#NoAuth.User)
|
||||
|
||||
##### <a name="pkg-examples">Examples</a>
|
||||
* [PathEscape](#example_PathEscape)
|
||||
|
||||
##### <a name="pkg-files">Package files</a>
|
||||
[basicAuth.go](https://github.com/studio-b12/gowebdav/blob/master/basicAuth.go) [client.go](https://github.com/studio-b12/gowebdav/blob/master/client.go) [digestAuth.go](https://github.com/studio-b12/gowebdav/blob/master/digestAuth.go) [doc.go](https://github.com/studio-b12/gowebdav/blob/master/doc.go) [file.go](https://github.com/studio-b12/gowebdav/blob/master/file.go) [netrc.go](https://github.com/studio-b12/gowebdav/blob/master/netrc.go) [requests.go](https://github.com/studio-b12/gowebdav/blob/master/requests.go) [utils.go](https://github.com/studio-b12/gowebdav/blob/master/utils.go)
|
||||
|
||||
### <a name="FixSlash">func</a> [FixSlash](https://github.com/studio-b12/gowebdav/blob/master/utils.go?s=707:737#L45)
|
||||
``` go
|
||||
func FixSlash(s string) string
|
||||
```
|
||||
FixSlash appends a trailing / to our string
|
||||
|
||||
### <a name="FixSlashes">func</a> [FixSlashes](https://github.com/studio-b12/gowebdav/blob/master/utils.go?s=859:891#L53)
|
||||
``` go
|
||||
func FixSlashes(s string) string
|
||||
```
|
||||
FixSlashes appends and prepends a / if they are missing
|
||||
|
||||
### <a name="Join">func</a> [Join](https://github.com/studio-b12/gowebdav/blob/master/utils.go?s=992:1036#L62)
|
||||
``` go
|
||||
func Join(path0 string, path1 string) string
|
||||
```
|
||||
Join joins two paths
|
||||
|
||||
### <a name="PathEscape">func</a> [PathEscape](https://github.com/studio-b12/gowebdav/blob/master/utils.go?s=506:541#L36)
|
||||
``` go
|
||||
func PathEscape(path string) string
|
||||
```
|
||||
PathEscape escapes all segments of a given path
|
||||
|
||||
### <a name="ReadConfig">func</a> [ReadConfig](https://github.com/studio-b12/gowebdav/blob/master/netrc.go?s=428:479#L27)
|
||||
``` go
|
||||
func ReadConfig(uri, netrc string) (string, string)
|
||||
```
|
||||
ReadConfig reads login and password configuration from ~/.netrc
|
||||
machine foo.com login username password 123456
|
||||
|
||||
### <a name="String">func</a> [String](https://github.com/studio-b12/gowebdav/blob/master/utils.go?s=1166:1197#L67)
|
||||
``` go
|
||||
func String(r io.Reader) string
|
||||
```
|
||||
String pulls a string out of our io.Reader
|
||||
|
||||
### <a name="Authenticator">type</a> [Authenticator](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=388:507#L29)
|
||||
``` go
|
||||
type Authenticator interface {
|
||||
Type() string
|
||||
User() string
|
||||
Pass() string
|
||||
Authorize(*http.Request, string, string)
|
||||
}
|
||||
```
|
||||
Authenticator stub
|
||||
|
||||
### <a name="BasicAuth">type</a> [BasicAuth](https://github.com/studio-b12/gowebdav/blob/master/basicAuth.go?s=106:157#L9)
|
||||
``` go
|
||||
type BasicAuth struct {
|
||||
// contains filtered or unexported fields
|
||||
}
|
||||
```
|
||||
BasicAuth structure holds our credentials
|
||||
|
||||
#### <a name="BasicAuth.Authorize">func</a> (\*BasicAuth) [Authorize](https://github.com/studio-b12/gowebdav/blob/master/basicAuth.go?s=473:549#L30)
|
||||
``` go
|
||||
func (b *BasicAuth) Authorize(req *http.Request, method string, path string)
|
||||
```
|
||||
Authorize the current request
|
||||
|
||||
#### <a name="BasicAuth.Pass">func</a> (\*BasicAuth) [Pass](https://github.com/studio-b12/gowebdav/blob/master/basicAuth.go?s=388:421#L25)
|
||||
``` go
|
||||
func (b *BasicAuth) Pass() string
|
||||
```
|
||||
Pass holds the BasicAuth password
|
||||
|
||||
#### <a name="BasicAuth.Type">func</a> (\*BasicAuth) [Type](https://github.com/studio-b12/gowebdav/blob/master/basicAuth.go?s=201:234#L15)
|
||||
``` go
|
||||
func (b *BasicAuth) Type() string
|
||||
```
|
||||
Type identifies the BasicAuthenticator
|
||||
|
||||
#### <a name="BasicAuth.User">func</a> (\*BasicAuth) [User](https://github.com/studio-b12/gowebdav/blob/master/basicAuth.go?s=297:330#L20)
|
||||
``` go
|
||||
func (b *BasicAuth) User() string
|
||||
```
|
||||
User holds the BasicAuth username
|
||||
|
||||
### <a name="Client">type</a> [Client](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=172:364#L18)
|
||||
``` go
|
||||
type Client struct {
|
||||
// contains filtered or unexported fields
|
||||
}
|
||||
```
|
||||
Client defines our structure
|
||||
|
||||
#### <a name="NewClient">func</a> [NewClient](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=1019:1063#L62)
|
||||
``` go
|
||||
func NewClient(uri, user, pw string) *Client
|
||||
```
|
||||
NewClient creates a new instance of client
|
||||
|
||||
#### <a name="Client.Connect">func</a> (\*Client) [Connect](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=1843:1875#L87)
|
||||
``` go
|
||||
func (c *Client) Connect() error
|
||||
```
|
||||
Connect connects to our dav server
|
||||
|
||||
#### <a name="Client.Copy">func</a> (\*Client) [Copy](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=6702:6770#L313)
|
||||
``` go
|
||||
func (c *Client) Copy(oldpath, newpath string, overwrite bool) error
|
||||
```
|
||||
Copy copies a file from A to B
|
||||
|
||||
#### <a name="Client.Mkdir">func</a> (\*Client) [Mkdir](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=5793:5849#L272)
|
||||
``` go
|
||||
func (c *Client) Mkdir(path string, _ os.FileMode) error
|
||||
```
|
||||
Mkdir makes a directory
|
||||
|
||||
#### <a name="Client.MkdirAll">func</a> (\*Client) [MkdirAll](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=6028:6087#L283)
|
||||
``` go
|
||||
func (c *Client) MkdirAll(path string, _ os.FileMode) error
|
||||
```
|
||||
MkdirAll like mkdir -p, but for webdav
|
||||
|
||||
#### <a name="Client.Read">func</a> (\*Client) [Read](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=6876:6926#L318)
|
||||
``` go
|
||||
func (c *Client) Read(path string) ([]byte, error)
|
||||
```
|
||||
Read reads the contents of a remote file
|
||||
|
||||
#### <a name="Client.ReadDir">func</a> (\*Client) [ReadDir](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=2869:2929#L130)
|
||||
``` go
|
||||
func (c *Client) ReadDir(path string) ([]os.FileInfo, error)
|
||||
```
|
||||
ReadDir reads the contents of a remote directory
|
||||
|
||||
#### <a name="Client.ReadStream">func</a> (\*Client) [ReadStream](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=7237:7300#L336)
|
||||
``` go
|
||||
func (c *Client) ReadStream(path string) (io.ReadCloser, error)
|
||||
```
|
||||
ReadStream reads the stream for a given path
|
||||
|
||||
#### <a name="Client.ReadStreamRange">func</a> (\*Client) [ReadStreamRange](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=8049:8139#L358)
|
||||
``` go
|
||||
func (c *Client) ReadStreamRange(path string, offset, length int64) (io.ReadCloser, error)
|
||||
```
|
||||
ReadStreamRange reads the stream representing a subset of bytes for a given path,
|
||||
utilizing HTTP Range Requests if the server supports it.
|
||||
The range is expressed as offset from the start of the file and length, for example
|
||||
offset=10, length=10 will return bytes 10 through 19.
|
||||
|
||||
If the server does not support partial content requests and returns full content instead,
|
||||
this function will emulate the behavior by skipping `offset` bytes and limiting the result
|
||||
to `length`.
|
||||
|
||||
#### <a name="Client.Remove">func</a> (\*Client) [Remove](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=5299:5341#L249)
|
||||
``` go
|
||||
func (c *Client) Remove(path string) error
|
||||
```
|
||||
Remove removes a remote file
|
||||
|
||||
#### <a name="Client.RemoveAll">func</a> (\*Client) [RemoveAll](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=5407:5452#L254)
|
||||
``` go
|
||||
func (c *Client) RemoveAll(path string) error
|
||||
```
|
||||
RemoveAll removes remote files
|
||||
|
||||
#### <a name="Client.Rename">func</a> (\*Client) [Rename](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=6536:6606#L308)
|
||||
``` go
|
||||
func (c *Client) Rename(oldpath, newpath string, overwrite bool) error
|
||||
```
|
||||
Rename moves a file from A to B
|
||||
|
||||
#### <a name="Client.SetHeader">func</a> (\*Client) [SetHeader](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=1235:1280#L67)
|
||||
``` go
|
||||
func (c *Client) SetHeader(key, value string)
|
||||
```
|
||||
SetHeader lets us set arbitrary headers for a given client
|
||||
|
||||
#### <a name="Client.SetInterceptor">func</a> (\*Client) [SetInterceptor](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=1387:1469#L72)
|
||||
``` go
|
||||
func (c *Client) SetInterceptor(interceptor func(method string, rq *http.Request))
|
||||
```
|
||||
SetInterceptor lets us set an arbitrary interceptor for a given client
|
||||
|
||||
#### <a name="Client.SetTimeout">func</a> (\*Client) [SetTimeout](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=1571:1621#L77)
|
||||
``` go
|
||||
func (c *Client) SetTimeout(timeout time.Duration)
|
||||
```
|
||||
SetTimeout exposes the ability to set a time limit for requests
|
||||
|
||||
#### <a name="Client.SetTransport">func</a> (\*Client) [SetTransport](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=1714:1772#L82)
|
||||
``` go
|
||||
func (c *Client) SetTransport(transport http.RoundTripper)
|
||||
```
|
||||
SetTransport exposes the ability to define custom transports
|
||||
|
||||
#### <a name="Client.Stat">func</a> (\*Client) [Stat](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=4255:4310#L197)
|
||||
``` go
|
||||
func (c *Client) Stat(path string) (os.FileInfo, error)
|
||||
```
|
||||
Stat returns the file stats for a specified path
|
||||
|
||||
#### <a name="Client.Write">func</a> (\*Client) [Write](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=9051:9120#L388)
|
||||
``` go
|
||||
func (c *Client) Write(path string, data []byte, _ os.FileMode) error
|
||||
```
|
||||
Write writes data to a given path
|
||||
|
||||
#### <a name="Client.WriteStream">func</a> (\*Client) [WriteStream](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=9476:9556#L411)
|
||||
``` go
|
||||
func (c *Client) WriteStream(path string, stream io.Reader, _ os.FileMode) error
|
||||
```
|
||||
WriteStream writes a stream
|
||||
|
||||
### <a name="DigestAuth">type</a> [DigestAuth](https://github.com/studio-b12/gowebdav/blob/master/digestAuth.go?s=157:254#L14)
|
||||
``` go
|
||||
type DigestAuth struct {
|
||||
// contains filtered or unexported fields
|
||||
}
|
||||
```
|
||||
DigestAuth structure holds our credentials
|
||||
|
||||
#### <a name="DigestAuth.Authorize">func</a> (\*DigestAuth) [Authorize](https://github.com/studio-b12/gowebdav/blob/master/digestAuth.go?s=577:654#L36)
|
||||
``` go
|
||||
func (d *DigestAuth) Authorize(req *http.Request, method string, path string)
|
||||
```
|
||||
Authorize the current request
|
||||
|
||||
#### <a name="DigestAuth.Pass">func</a> (\*DigestAuth) [Pass](https://github.com/studio-b12/gowebdav/blob/master/digestAuth.go?s=491:525#L31)
|
||||
``` go
|
||||
func (d *DigestAuth) Pass() string
|
||||
```
|
||||
Pass holds the DigestAuth password
|
||||
|
||||
#### <a name="DigestAuth.Type">func</a> (\*DigestAuth) [Type](https://github.com/studio-b12/gowebdav/blob/master/digestAuth.go?s=299:333#L21)
|
||||
``` go
|
||||
func (d *DigestAuth) Type() string
|
||||
```
|
||||
Type identifies the DigestAuthenticator
|
||||
|
||||
#### <a name="DigestAuth.User">func</a> (\*DigestAuth) [User](https://github.com/studio-b12/gowebdav/blob/master/digestAuth.go?s=398:432#L26)
|
||||
``` go
|
||||
func (d *DigestAuth) User() string
|
||||
```
|
||||
User holds the DigestAuth username
|
||||
|
||||
### <a name="File">type</a> [File](https://github.com/studio-b12/gowebdav/blob/master/file.go?s=93:253#L10)
|
||||
``` go
|
||||
type File struct {
|
||||
// contains filtered or unexported fields
|
||||
}
|
||||
```
|
||||
File is our structure for a given file
|
||||
|
||||
#### <a name="File.ContentType">func</a> (File) [ContentType](https://github.com/studio-b12/gowebdav/blob/master/file.go?s=476:510#L31)
|
||||
``` go
|
||||
func (f File) ContentType() string
|
||||
```
|
||||
ContentType returns the content type of a file
|
||||
|
||||
#### <a name="File.ETag">func</a> (File) [ETag](https://github.com/studio-b12/gowebdav/blob/master/file.go?s=929:956#L56)
|
||||
``` go
|
||||
func (f File) ETag() string
|
||||
```
|
||||
ETag returns the ETag of a file
|
||||
|
||||
#### <a name="File.IsDir">func</a> (File) [IsDir](https://github.com/studio-b12/gowebdav/blob/master/file.go?s=1035:1061#L61)
|
||||
``` go
|
||||
func (f File) IsDir() bool
|
||||
```
|
||||
IsDir let us see if a given file is a directory or not
|
||||
|
||||
#### <a name="File.ModTime">func</a> (File) [ModTime](https://github.com/studio-b12/gowebdav/blob/master/file.go?s=836:869#L51)
|
||||
``` go
|
||||
func (f File) ModTime() time.Time
|
||||
```
|
||||
ModTime returns the modified time of a file
|
||||
|
||||
#### <a name="File.Mode">func</a> (File) [Mode](https://github.com/studio-b12/gowebdav/blob/master/file.go?s=665:697#L41)
|
||||
``` go
|
||||
func (f File) Mode() os.FileMode
|
||||
```
|
||||
Mode will return the mode of a given file
|
||||
|
||||
#### <a name="File.Name">func</a> (File) [Name](https://github.com/studio-b12/gowebdav/blob/master/file.go?s=378:405#L26)
|
||||
``` go
|
||||
func (f File) Name() string
|
||||
```
|
||||
Name returns the name of a file
|
||||
|
||||
#### <a name="File.Path">func</a> (File) [Path](https://github.com/studio-b12/gowebdav/blob/master/file.go?s=295:322#L21)
|
||||
``` go
|
||||
func (f File) Path() string
|
||||
```
|
||||
Path returns the full path of a file
|
||||
|
||||
#### <a name="File.Size">func</a> (File) [Size](https://github.com/studio-b12/gowebdav/blob/master/file.go?s=573:599#L36)
|
||||
``` go
|
||||
func (f File) Size() int64
|
||||
```
|
||||
Size returns the size of a file
|
||||
|
||||
#### <a name="File.String">func</a> (File) [String](https://github.com/studio-b12/gowebdav/blob/master/file.go?s=1183:1212#L71)
|
||||
``` go
|
||||
func (f File) String() string
|
||||
```
|
||||
String lets us see file information
|
||||
|
||||
#### <a name="File.Sys">func</a> (File) [Sys](https://github.com/studio-b12/gowebdav/blob/master/file.go?s=1095:1126#L66)
|
||||
``` go
|
||||
func (f File) Sys() interface{}
|
||||
```
|
||||
Sys ????
|
||||
|
||||
### <a name="NoAuth">type</a> [NoAuth](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=551:599#L37)
|
||||
``` go
|
||||
type NoAuth struct {
|
||||
// contains filtered or unexported fields
|
||||
}
|
||||
```
|
||||
NoAuth structure holds our credentials
|
||||
|
||||
#### <a name="NoAuth.Authorize">func</a> (\*NoAuth) [Authorize](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=894:967#L58)
|
||||
``` go
|
||||
func (n *NoAuth) Authorize(req *http.Request, method string, path string)
|
||||
```
|
||||
Authorize the current request
|
||||
|
||||
#### <a name="NoAuth.Pass">func</a> (\*NoAuth) [Pass](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=812:842#L53)
|
||||
``` go
|
||||
func (n *NoAuth) Pass() string
|
||||
```
|
||||
Pass returns the current password
|
||||
|
||||
#### <a name="NoAuth.Type">func</a> (\*NoAuth) [Type](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=638:668#L43)
|
||||
``` go
|
||||
func (n *NoAuth) Type() string
|
||||
```
|
||||
Type identifies the authenticator
|
||||
|
||||
#### <a name="NoAuth.User">func</a> (\*NoAuth) [User](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=724:754#L48)
|
||||
``` go
|
||||
func (n *NoAuth) User() string
|
||||
```
|
||||
User returns the current user
|
||||
|
||||
- - -
|
||||
Generated by [godoc2md](http://godoc.org/github.com/davecheney/godoc2md)
|
34
pkg/gowebdav/basicAuth.go
Normal file
34
pkg/gowebdav/basicAuth.go
Normal file
@ -0,0 +1,34 @@
|
||||
package gowebdav
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// BasicAuth structure holds our credentials
|
||||
type BasicAuth struct {
|
||||
user string
|
||||
pw string
|
||||
}
|
||||
|
||||
// Type identifies the BasicAuthenticator
|
||||
func (b *BasicAuth) Type() string {
|
||||
return "BasicAuth"
|
||||
}
|
||||
|
||||
// User holds the BasicAuth username
|
||||
func (b *BasicAuth) User() string {
|
||||
return b.user
|
||||
}
|
||||
|
||||
// Pass holds the BasicAuth password
|
||||
func (b *BasicAuth) Pass() string {
|
||||
return b.pw
|
||||
}
|
||||
|
||||
// Authorize the current request
|
||||
func (b *BasicAuth) Authorize(req *http.Request, method string, path string) {
|
||||
a := b.user + ":" + b.pw
|
||||
auth := "Basic " + base64.StdEncoding.EncodeToString([]byte(a))
|
||||
req.Header.Set("Authorization", auth)
|
||||
}
|
447
pkg/gowebdav/client.go
Normal file
447
pkg/gowebdav/client.go
Normal file
@ -0,0 +1,447 @@
|
||||
package gowebdav
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/xml"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
pathpkg "path"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Client defines our structure
|
||||
type Client struct {
|
||||
root string
|
||||
headers http.Header
|
||||
interceptor func(method string, rq *http.Request)
|
||||
c *http.Client
|
||||
|
||||
authMutex sync.Mutex
|
||||
auth Authenticator
|
||||
}
|
||||
|
||||
// Authenticator stub
|
||||
type Authenticator interface {
|
||||
Type() string
|
||||
User() string
|
||||
Pass() string
|
||||
Authorize(*http.Request, string, string)
|
||||
}
|
||||
|
||||
// NoAuth structure holds our credentials
|
||||
type NoAuth struct {
|
||||
user string
|
||||
pw string
|
||||
}
|
||||
|
||||
// Type identifies the authenticator
|
||||
func (n *NoAuth) Type() string {
|
||||
return "NoAuth"
|
||||
}
|
||||
|
||||
// User returns the current user
|
||||
func (n *NoAuth) User() string {
|
||||
return n.user
|
||||
}
|
||||
|
||||
// Pass returns the current password
|
||||
func (n *NoAuth) Pass() string {
|
||||
return n.pw
|
||||
}
|
||||
|
||||
// Authorize the current request
|
||||
func (n *NoAuth) Authorize(req *http.Request, method string, path string) {
|
||||
}
|
||||
|
||||
// NewClient creates a new instance of client
|
||||
func NewClient(uri, user, pw string) *Client {
|
||||
return &Client{FixSlash(uri), make(http.Header), nil, &http.Client{}, sync.Mutex{}, &NoAuth{user, pw}}
|
||||
}
|
||||
|
||||
// SetHeader lets us set arbitrary headers for a given client
|
||||
func (c *Client) SetHeader(key, value string) {
|
||||
c.headers.Add(key, value)
|
||||
}
|
||||
|
||||
// SetInterceptor lets us set an arbitrary interceptor for a given client
|
||||
func (c *Client) SetInterceptor(interceptor func(method string, rq *http.Request)) {
|
||||
c.interceptor = interceptor
|
||||
}
|
||||
|
||||
// SetTimeout exposes the ability to set a time limit for requests
|
||||
func (c *Client) SetTimeout(timeout time.Duration) {
|
||||
c.c.Timeout = timeout
|
||||
}
|
||||
|
||||
// SetTransport exposes the ability to define custom transports
|
||||
func (c *Client) SetTransport(transport http.RoundTripper) {
|
||||
c.c.Transport = transport
|
||||
}
|
||||
|
||||
// Connect connects to our dav server
|
||||
func (c *Client) Connect() error {
|
||||
rs, err := c.options("/")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = rs.Body.Close()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if rs.StatusCode != 200 {
|
||||
return newPathError("Connect", c.root, rs.StatusCode)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type props struct {
|
||||
Status string `xml:"DAV: status"`
|
||||
Name string `xml:"DAV: prop>displayname,omitempty"`
|
||||
Type xml.Name `xml:"DAV: prop>resourcetype>collection,omitempty"`
|
||||
Size string `xml:"DAV: prop>getcontentlength,omitempty"`
|
||||
ContentType string `xml:"DAV: prop>getcontenttype,omitempty"`
|
||||
ETag string `xml:"DAV: prop>getetag,omitempty"`
|
||||
Modified string `xml:"DAV: prop>getlastmodified,omitempty"`
|
||||
}
|
||||
|
||||
type response struct {
|
||||
Href string `xml:"DAV: href"`
|
||||
Props []props `xml:"DAV: propstat"`
|
||||
}
|
||||
|
||||
func getProps(r *response, status string) *props {
|
||||
for _, prop := range r.Props {
|
||||
if strings.Contains(prop.Status, status) {
|
||||
return &prop
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ReadDir reads the contents of a remote directory
|
||||
func (c *Client) ReadDir(path string) ([]os.FileInfo, error) {
|
||||
path = FixSlashes(path)
|
||||
files := make([]os.FileInfo, 0)
|
||||
skipSelf := true
|
||||
parse := func(resp interface{}) error {
|
||||
r := resp.(*response)
|
||||
|
||||
if skipSelf {
|
||||
skipSelf = false
|
||||
if p := getProps(r, "200"); p != nil && p.Type.Local == "collection" {
|
||||
r.Props = nil
|
||||
return nil
|
||||
}
|
||||
return newPathError("ReadDir", path, 405)
|
||||
}
|
||||
|
||||
if p := getProps(r, "200"); p != nil {
|
||||
f := new(File)
|
||||
if ps, err := url.PathUnescape(r.Href); err == nil {
|
||||
f.name = pathpkg.Base(ps)
|
||||
} else {
|
||||
f.name = p.Name
|
||||
}
|
||||
f.path = path + f.name
|
||||
f.modified = parseModified(&p.Modified)
|
||||
f.etag = p.ETag
|
||||
f.contentType = p.ContentType
|
||||
|
||||
if p.Type.Local == "collection" {
|
||||
f.path += "/"
|
||||
f.size = 0
|
||||
f.isdir = true
|
||||
} else {
|
||||
f.size = parseInt64(&p.Size)
|
||||
f.isdir = false
|
||||
}
|
||||
|
||||
files = append(files, *f)
|
||||
}
|
||||
|
||||
r.Props = nil
|
||||
return nil
|
||||
}
|
||||
|
||||
err := c.propfind(path, false,
|
||||
`<d:propfind xmlns:d='DAV:'>
|
||||
<d:prop>
|
||||
<d:displayname/>
|
||||
<d:resourcetype/>
|
||||
<d:getcontentlength/>
|
||||
<d:getcontenttype/>
|
||||
<d:getetag/>
|
||||
<d:getlastmodified/>
|
||||
</d:prop>
|
||||
</d:propfind>`,
|
||||
&response{},
|
||||
parse)
|
||||
|
||||
if err != nil {
|
||||
if _, ok := err.(*os.PathError); !ok {
|
||||
err = newPathErrorErr("ReadDir", path, err)
|
||||
}
|
||||
}
|
||||
return files, err
|
||||
}
|
||||
|
||||
// Stat returns the file stats for a specified path
|
||||
func (c *Client) Stat(path string) (os.FileInfo, error) {
|
||||
var f *File
|
||||
parse := func(resp interface{}) error {
|
||||
r := resp.(*response)
|
||||
if p := getProps(r, "200"); p != nil && f == nil {
|
||||
f = new(File)
|
||||
f.name = p.Name
|
||||
f.path = path
|
||||
f.etag = p.ETag
|
||||
f.contentType = p.ContentType
|
||||
|
||||
if p.Type.Local == "collection" {
|
||||
if !strings.HasSuffix(f.path, "/") {
|
||||
f.path += "/"
|
||||
}
|
||||
f.size = 0
|
||||
f.modified = time.Unix(0, 0)
|
||||
f.isdir = true
|
||||
} else {
|
||||
f.size = parseInt64(&p.Size)
|
||||
f.modified = parseModified(&p.Modified)
|
||||
f.isdir = false
|
||||
}
|
||||
}
|
||||
|
||||
r.Props = nil
|
||||
return nil
|
||||
}
|
||||
|
||||
err := c.propfind(path, true,
|
||||
`<d:propfind xmlns:d='DAV:'>
|
||||
<d:prop>
|
||||
<d:displayname/>
|
||||
<d:resourcetype/>
|
||||
<d:getcontentlength/>
|
||||
<d:getcontenttype/>
|
||||
<d:getetag/>
|
||||
<d:getlastmodified/>
|
||||
</d:prop>
|
||||
</d:propfind>`,
|
||||
&response{},
|
||||
parse)
|
||||
|
||||
if err != nil {
|
||||
if _, ok := err.(*os.PathError); !ok {
|
||||
err = newPathErrorErr("ReadDir", path, err)
|
||||
}
|
||||
}
|
||||
return f, err
|
||||
}
|
||||
|
||||
// Remove removes a remote file
|
||||
func (c *Client) Remove(path string) error {
|
||||
return c.RemoveAll(path)
|
||||
}
|
||||
|
||||
// RemoveAll removes remote files
|
||||
func (c *Client) RemoveAll(path string) error {
|
||||
rs, err := c.req("DELETE", path, nil, nil)
|
||||
if err != nil {
|
||||
return newPathError("Remove", path, 400)
|
||||
}
|
||||
err = rs.Body.Close()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if rs.StatusCode == 200 || rs.StatusCode == 204 || rs.StatusCode == 404 {
|
||||
return nil
|
||||
}
|
||||
|
||||
return newPathError("Remove", path, rs.StatusCode)
|
||||
}
|
||||
|
||||
// Mkdir makes a directory
|
||||
func (c *Client) Mkdir(path string, _ os.FileMode) (err error) {
|
||||
path = FixSlashes(path)
|
||||
status, err := c.mkcol(path)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if status == 201 {
|
||||
return nil
|
||||
}
|
||||
|
||||
return newPathError("Mkdir", path, status)
|
||||
}
|
||||
|
||||
// MkdirAll like mkdir -p, but for webdav
|
||||
func (c *Client) MkdirAll(path string, _ os.FileMode) (err error) {
|
||||
path = FixSlashes(path)
|
||||
status, err := c.mkcol(path)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if status == 201 {
|
||||
return nil
|
||||
}
|
||||
if status == 409 {
|
||||
paths := strings.Split(path, "/")
|
||||
sub := "/"
|
||||
for _, e := range paths {
|
||||
if e == "" {
|
||||
continue
|
||||
}
|
||||
sub += e + "/"
|
||||
status, err = c.mkcol(sub)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if status != 201 {
|
||||
return newPathError("MkdirAll", sub, status)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
return newPathError("MkdirAll", path, status)
|
||||
}
|
||||
|
||||
// Rename moves a file from A to B
|
||||
func (c *Client) Rename(oldpath, newpath string, overwrite bool) error {
|
||||
return c.copymove("MOVE", oldpath, newpath, overwrite)
|
||||
}
|
||||
|
||||
// Copy copies a file from A to B
|
||||
func (c *Client) Copy(oldpath, newpath string, overwrite bool) error {
|
||||
return c.copymove("COPY", oldpath, newpath, overwrite)
|
||||
}
|
||||
|
||||
// Read reads the contents of a remote file
|
||||
func (c *Client) Read(path string) ([]byte, error) {
|
||||
var stream io.ReadCloser
|
||||
var err error
|
||||
|
||||
if stream, _, err = c.ReadStream(path, nil); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer stream.Close()
|
||||
|
||||
buf := new(bytes.Buffer)
|
||||
_, err = buf.ReadFrom(stream)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return buf.Bytes(), nil
|
||||
}
|
||||
|
||||
// ReadStream reads the stream for a given path
|
||||
func (c *Client) ReadStream(path string, callback func(rq *http.Request)) (io.ReadCloser, http.Header, error) {
|
||||
rs, err := c.req("GET", path, nil, callback)
|
||||
if err != nil {
|
||||
return nil, nil, newPathErrorErr("ReadStream", path, err)
|
||||
}
|
||||
|
||||
if rs.StatusCode < 400 {
|
||||
return rs.Body, rs.Header, nil
|
||||
}
|
||||
|
||||
rs.Body.Close()
|
||||
return nil, nil, newPathError("ReadStream", path, rs.StatusCode)
|
||||
}
|
||||
|
||||
// ReadStreamRange reads the stream representing a subset of bytes for a given path,
|
||||
// utilizing HTTP Range Requests if the server supports it.
|
||||
// The range is expressed as offset from the start of the file and length, for example
|
||||
// offset=10, length=10 will return bytes 10 through 19.
|
||||
//
|
||||
// If the server does not support partial content requests and returns full content instead,
|
||||
// this function will emulate the behavior by skipping `offset` bytes and limiting the result
|
||||
// to `length`.
|
||||
func (c *Client) ReadStreamRange(path string, offset, length int64) (io.ReadCloser, error) {
|
||||
rs, err := c.req("GET", path, nil, func(r *http.Request) {
|
||||
r.Header.Add("Range", fmt.Sprintf("bytes=%v-%v", offset, offset+length-1))
|
||||
})
|
||||
if err != nil {
|
||||
return nil, newPathErrorErr("ReadStreamRange", path, err)
|
||||
}
|
||||
|
||||
if rs.StatusCode == http.StatusPartialContent {
|
||||
// server supported partial content, return as-is.
|
||||
return rs.Body, nil
|
||||
}
|
||||
|
||||
// server returned success, but did not support partial content, so we have the whole
|
||||
// stream in rs.Body
|
||||
if rs.StatusCode == 200 {
|
||||
// discard first 'offset' bytes.
|
||||
if _, err := io.Copy(io.Discard, io.LimitReader(rs.Body, offset)); err != nil {
|
||||
return nil, newPathErrorErr("ReadStreamRange", path, err)
|
||||
}
|
||||
|
||||
// return a io.ReadCloser that is limited to `length` bytes.
|
||||
return &limitedReadCloser{rs.Body, int(length)}, nil
|
||||
}
|
||||
|
||||
rs.Body.Close()
|
||||
return nil, newPathError("ReadStream", path, rs.StatusCode)
|
||||
}
|
||||
|
||||
// Write writes data to a given path
|
||||
func (c *Client) Write(path string, data []byte, _ os.FileMode) (err error) {
|
||||
s, err := c.put(path, bytes.NewReader(data), nil)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
switch s {
|
||||
|
||||
case 200, 201, 204:
|
||||
return nil
|
||||
|
||||
case 409:
|
||||
err = c.createParentCollection(path)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
s, err = c.put(path, bytes.NewReader(data), nil)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if s == 200 || s == 201 || s == 204 {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
return newPathError("Write", path, s)
|
||||
}
|
||||
|
||||
// WriteStream writes a stream
|
||||
func (c *Client) WriteStream(path string, stream io.Reader, _ os.FileMode, callback func(r *http.Request)) (err error) {
|
||||
|
||||
err = c.createParentCollection(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
s, err := c.put(path, stream, callback)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
switch s {
|
||||
case 200, 201, 204:
|
||||
return nil
|
||||
|
||||
default:
|
||||
return newPathError("WriteStream", path, s)
|
||||
}
|
||||
}
|
103
pkg/gowebdav/cmd/gowebdav/README.md
Normal file
103
pkg/gowebdav/cmd/gowebdav/README.md
Normal file
@ -0,0 +1,103 @@
|
||||
# Description
|
||||
Command line tool for [gowebdav](https://github.com/studio-b12/gowebdav) library.
|
||||
|
||||
# Prerequisites
|
||||
## Software
|
||||
* **OS**: all, which are supported by `Golang`
|
||||
* **Golang**: version 1.x
|
||||
* **Git**: version 2.14.2 at higher (required to install via `go get`)
|
||||
|
||||
# Install
|
||||
```sh
|
||||
go get -u github.com/studio-b12/gowebdav/cmd/gowebdav
|
||||
```
|
||||
|
||||
# Usage
|
||||
It is recommended to set following environment variables to improve your experience with this tool:
|
||||
* `ROOT` is an URL of target WebDAV server (e.g. `https://webdav.mydomain.me/user_root_folder`)
|
||||
* `USER` is a login to connect to specified server (e.g. `user`)
|
||||
* `PASSWORD` is a password to connect to specified server (e.g. `p@s$w0rD`)
|
||||
|
||||
In following examples we suppose that:
|
||||
* environment variable `ROOT` is set to `https://webdav.mydomain.me/ufolder`
|
||||
* environment variable `USER` is set to `user`
|
||||
* environment variable `PASSWORD` is set `p@s$w0rD`
|
||||
* folder `/ufolder/temp` exists on the server
|
||||
* file `/ufolder/temp/file.txt` exists on the server
|
||||
* file `/ufolder/temp/document.rtf` exists on the server
|
||||
* file `/tmp/webdav/to_upload.txt` exists on the local machine
|
||||
* folder `/tmp/webdav/` is used to download files from the server
|
||||
|
||||
## Examples
|
||||
|
||||
#### Get content of specified folder
|
||||
```sh
|
||||
gowebdav -X LS temp
|
||||
```
|
||||
|
||||
#### Get info about file/folder
|
||||
```sh
|
||||
gowebdav -X STAT temp
|
||||
gowebdav -X STAT temp/file.txt
|
||||
```
|
||||
|
||||
#### Create folder on the remote server
|
||||
```sh
|
||||
gowebdav -X MKDIR temp2
|
||||
gowebdav -X MKDIRALL all/folders/which-you-want/to_create
|
||||
```
|
||||
|
||||
#### Download file
|
||||
```sh
|
||||
gowebdav -X GET temp/document.rtf /tmp/webdav/document.rtf
|
||||
```
|
||||
|
||||
You may do not specify target local path, in this case file will be downloaded to the current folder with the
|
||||
|
||||
#### Upload file
|
||||
```sh
|
||||
gowebdav -X PUT temp/uploaded.txt /tmp/webdav/to_upload.txt
|
||||
```
|
||||
|
||||
#### Move file on the remote server
|
||||
```sh
|
||||
gowebdav -X MV temp/file.txt temp/moved_file.txt
|
||||
```
|
||||
|
||||
#### Copy file to another location
|
||||
```sh
|
||||
gowebdav -X MV temp/file.txt temp/file-copy.txt
|
||||
```
|
||||
|
||||
#### Delete file from the remote server
|
||||
```sh
|
||||
gowebdav -X DEL temp/file.txt
|
||||
```
|
||||
|
||||
# Wrapper script
|
||||
|
||||
You can create wrapper script for your server (via `$EDITOR ./dav && chmod a+x ./dav`) and add following content to it:
|
||||
```sh
|
||||
#!/bin/sh
|
||||
|
||||
ROOT="https://my.dav.server/" \
|
||||
USER="foo" \
|
||||
PASSWORD="$(pass dav/foo@my.dav.server)" \
|
||||
gowebdav $@
|
||||
```
|
||||
|
||||
It allows you to use [pass](https://www.passwordstore.org/ "the standard unix password manager") or similar tools to retrieve the password.
|
||||
|
||||
## Examples
|
||||
|
||||
Using the `dav` wrapper:
|
||||
|
||||
```sh
|
||||
$ ./dav -X LS /
|
||||
|
||||
$ echo hi dav! > hello && ./dav -X PUT /hello
|
||||
$ ./dav -X STAT /hello
|
||||
$ ./dav -X PUT /hello_dav hello
|
||||
$ ./dav -X GET /hello_dav
|
||||
$ ./dav -X GET /hello_dav hello.txt
|
||||
```
|
263
pkg/gowebdav/cmd/gowebdav/main.go
Normal file
263
pkg/gowebdav/cmd/gowebdav/main.go
Normal file
@ -0,0 +1,263 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/fs"
|
||||
"os"
|
||||
"os/user"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
d "github.com/Xhofe/alist/pkg/gowebdav"
|
||||
)
|
||||
|
||||
func main() {
|
||||
root := flag.String("root", os.Getenv("ROOT"), "WebDAV Endpoint [ENV.ROOT]")
|
||||
user := flag.String("user", os.Getenv("USER"), "User [ENV.USER]")
|
||||
password := flag.String("pw", os.Getenv("PASSWORD"), "Password [ENV.PASSWORD]")
|
||||
netrc := flag.String("netrc-file", filepath.Join(getHome(), ".netrc"), "read login from netrc file")
|
||||
method := flag.String("X", "", `Method:
|
||||
LS <PATH>
|
||||
STAT <PATH>
|
||||
|
||||
MKDIR <PATH>
|
||||
MKDIRALL <PATH>
|
||||
|
||||
GET <PATH> [<FILE>]
|
||||
PUT <PATH> [<FILE>]
|
||||
|
||||
MV <OLD> <NEW>
|
||||
CP <OLD> <NEW>
|
||||
|
||||
DEL <PATH>
|
||||
`)
|
||||
flag.Parse()
|
||||
|
||||
if *root == "" {
|
||||
fail("Set WebDAV ROOT")
|
||||
}
|
||||
|
||||
if argsLength := len(flag.Args()); argsLength == 0 || argsLength > 2 {
|
||||
fail("Unsupported arguments")
|
||||
}
|
||||
|
||||
if *password == "" {
|
||||
if u, p := d.ReadConfig(*root, *netrc); u != "" && p != "" {
|
||||
user = &u
|
||||
password = &p
|
||||
}
|
||||
}
|
||||
|
||||
c := d.NewClient(*root, *user, *password)
|
||||
|
||||
cmd := getCmd(*method)
|
||||
|
||||
if e := cmd(c, flag.Arg(0), flag.Arg(1)); e != nil {
|
||||
fail(e)
|
||||
}
|
||||
}
|
||||
|
||||
func fail(err interface{}) {
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
os.Exit(-1)
|
||||
}
|
||||
|
||||
func getHome() string {
|
||||
u, e := user.Current()
|
||||
if e != nil {
|
||||
return os.Getenv("HOME")
|
||||
}
|
||||
|
||||
if u != nil {
|
||||
return u.HomeDir
|
||||
}
|
||||
|
||||
switch runtime.GOOS {
|
||||
case "windows":
|
||||
return ""
|
||||
default:
|
||||
return "~/"
|
||||
}
|
||||
}
|
||||
|
||||
func getCmd(method string) func(c *d.Client, p0, p1 string) error {
|
||||
switch strings.ToUpper(method) {
|
||||
case "LS", "LIST", "PROPFIND":
|
||||
return cmdLs
|
||||
|
||||
case "STAT":
|
||||
return cmdStat
|
||||
|
||||
case "GET", "PULL", "READ":
|
||||
return cmdGet
|
||||
|
||||
case "DELETE", "RM", "DEL":
|
||||
return cmdRm
|
||||
|
||||
case "MKCOL", "MKDIR":
|
||||
return cmdMkdir
|
||||
|
||||
case "MKCOLALL", "MKDIRALL", "MKDIRP":
|
||||
return cmdMkdirAll
|
||||
|
||||
case "RENAME", "MV", "MOVE":
|
||||
return cmdMv
|
||||
|
||||
case "COPY", "CP":
|
||||
return cmdCp
|
||||
|
||||
case "PUT", "PUSH", "WRITE":
|
||||
return cmdPut
|
||||
|
||||
default:
|
||||
return func(c *d.Client, p0, p1 string) (err error) {
|
||||
return errors.New("Unsupported method: " + method)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func cmdLs(c *d.Client, p0, _ string) (err error) {
|
||||
files, err := c.ReadDir(p0)
|
||||
if err == nil {
|
||||
fmt.Println(fmt.Sprintf("ReadDir: '%s' entries: %d ", p0, len(files)))
|
||||
for _, f := range files {
|
||||
fmt.Println(f)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func cmdStat(c *d.Client, p0, _ string) (err error) {
|
||||
file, err := c.Stat(p0)
|
||||
if err == nil {
|
||||
fmt.Println(file)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func cmdGet(c *d.Client, p0, p1 string) (err error) {
|
||||
bytes, err := c.Read(p0)
|
||||
if err == nil {
|
||||
if p1 == "" {
|
||||
p1 = filepath.Join(".", p0)
|
||||
}
|
||||
err = writeFile(p1, bytes, 0644)
|
||||
if err == nil {
|
||||
fmt.Println(fmt.Sprintf("Written %d bytes to: %s", len(bytes), p1))
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func cmdRm(c *d.Client, p0, _ string) (err error) {
|
||||
if err = c.Remove(p0); err == nil {
|
||||
fmt.Println("Remove: " + p0)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func cmdMkdir(c *d.Client, p0, _ string) (err error) {
|
||||
if err = c.Mkdir(p0, 0755); err == nil {
|
||||
fmt.Println("Mkdir: " + p0)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func cmdMkdirAll(c *d.Client, p0, _ string) (err error) {
|
||||
if err = c.MkdirAll(p0, 0755); err == nil {
|
||||
fmt.Println("MkdirAll: " + p0)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func cmdMv(c *d.Client, p0, p1 string) (err error) {
|
||||
if err = c.Rename(p0, p1, true); err == nil {
|
||||
fmt.Println("Rename: " + p0 + " -> " + p1)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func cmdCp(c *d.Client, p0, p1 string) (err error) {
|
||||
if err = c.Copy(p0, p1, true); err == nil {
|
||||
fmt.Println("Copy: " + p0 + " -> " + p1)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func cmdPut(c *d.Client, p0, p1 string) (err error) {
|
||||
if p1 == "" {
|
||||
p1 = path.Join(".", p0)
|
||||
} else {
|
||||
var fi fs.FileInfo
|
||||
fi, err = c.Stat(p0)
|
||||
if err != nil && !d.IsErrNotFound(err) {
|
||||
return
|
||||
}
|
||||
if !d.IsErrNotFound(err) && fi.IsDir() {
|
||||
p0 = path.Join(p0, p1)
|
||||
}
|
||||
}
|
||||
|
||||
stream, err := getStream(p1)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
defer stream.Close()
|
||||
|
||||
if err = c.WriteStream(p0, stream, 0644, nil); err == nil {
|
||||
fmt.Println("Put: " + p1 + " -> " + p0)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func writeFile(path string, bytes []byte, mode os.FileMode) error {
|
||||
parent := filepath.Dir(path)
|
||||
if _, e := os.Stat(parent); os.IsNotExist(e) {
|
||||
if e := os.MkdirAll(parent, os.ModePerm); e != nil {
|
||||
return e
|
||||
}
|
||||
}
|
||||
|
||||
f, err := os.Create(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
_, err = f.Write(bytes)
|
||||
return err
|
||||
}
|
||||
|
||||
func getStream(pathOrString string) (io.ReadCloser, error) {
|
||||
|
||||
fi, err := os.Stat(pathOrString)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if fi.IsDir() {
|
||||
return nil, &os.PathError{
|
||||
Op: "Open",
|
||||
Path: pathOrString,
|
||||
Err: errors.New("Path: '" + pathOrString + "' is a directory"),
|
||||
}
|
||||
}
|
||||
|
||||
f, err := os.Open(pathOrString)
|
||||
if err == nil {
|
||||
return f, nil
|
||||
}
|
||||
|
||||
return nil, &os.PathError{
|
||||
Op: "Open",
|
||||
Path: pathOrString,
|
||||
Err: err,
|
||||
}
|
||||
}
|
146
pkg/gowebdav/digestAuth.go
Normal file
146
pkg/gowebdav/digestAuth.go
Normal file
@ -0,0 +1,146 @@
|
||||
package gowebdav
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"crypto/rand"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// DigestAuth structure holds our credentials
|
||||
type DigestAuth struct {
|
||||
user string
|
||||
pw string
|
||||
digestParts map[string]string
|
||||
}
|
||||
|
||||
// Type identifies the DigestAuthenticator
|
||||
func (d *DigestAuth) Type() string {
|
||||
return "DigestAuth"
|
||||
}
|
||||
|
||||
// User holds the DigestAuth username
|
||||
func (d *DigestAuth) User() string {
|
||||
return d.user
|
||||
}
|
||||
|
||||
// Pass holds the DigestAuth password
|
||||
func (d *DigestAuth) Pass() string {
|
||||
return d.pw
|
||||
}
|
||||
|
||||
// Authorize the current request
|
||||
func (d *DigestAuth) Authorize(req *http.Request, method string, path string) {
|
||||
d.digestParts["uri"] = path
|
||||
d.digestParts["method"] = method
|
||||
d.digestParts["username"] = d.user
|
||||
d.digestParts["password"] = d.pw
|
||||
req.Header.Set("Authorization", getDigestAuthorization(d.digestParts))
|
||||
}
|
||||
|
||||
func digestParts(resp *http.Response) map[string]string {
|
||||
result := map[string]string{}
|
||||
if len(resp.Header["Www-Authenticate"]) > 0 {
|
||||
wantedHeaders := []string{"nonce", "realm", "qop", "opaque", "algorithm", "entityBody"}
|
||||
responseHeaders := strings.Split(resp.Header["Www-Authenticate"][0], ",")
|
||||
for _, r := range responseHeaders {
|
||||
for _, w := range wantedHeaders {
|
||||
if strings.Contains(r, w) {
|
||||
result[w] = strings.Trim(
|
||||
strings.SplitN(r, `=`, 2)[1],
|
||||
`"`,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func getMD5(text string) string {
|
||||
hasher := md5.New()
|
||||
hasher.Write([]byte(text))
|
||||
return hex.EncodeToString(hasher.Sum(nil))
|
||||
}
|
||||
|
||||
func getCnonce() string {
|
||||
b := make([]byte, 8)
|
||||
io.ReadFull(rand.Reader, b)
|
||||
return fmt.Sprintf("%x", b)[:16]
|
||||
}
|
||||
|
||||
func getDigestAuthorization(digestParts map[string]string) string {
|
||||
d := digestParts
|
||||
// These are the correct ha1 and ha2 for qop=auth. We should probably check for other types of qop.
|
||||
|
||||
var (
|
||||
ha1 string
|
||||
ha2 string
|
||||
nonceCount = 00000001
|
||||
cnonce = getCnonce()
|
||||
response string
|
||||
)
|
||||
|
||||
// 'ha1' value depends on value of "algorithm" field
|
||||
switch d["algorithm"] {
|
||||
case "MD5", "":
|
||||
ha1 = getMD5(d["username"] + ":" + d["realm"] + ":" + d["password"])
|
||||
case "MD5-sess":
|
||||
ha1 = getMD5(
|
||||
fmt.Sprintf("%s:%v:%s",
|
||||
getMD5(d["username"]+":"+d["realm"]+":"+d["password"]),
|
||||
nonceCount,
|
||||
cnonce,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
// 'ha2' value depends on value of "qop" field
|
||||
switch d["qop"] {
|
||||
case "auth", "":
|
||||
ha2 = getMD5(d["method"] + ":" + d["uri"])
|
||||
case "auth-int":
|
||||
if d["entityBody"] != "" {
|
||||
ha2 = getMD5(d["method"] + ":" + d["uri"] + ":" + getMD5(d["entityBody"]))
|
||||
}
|
||||
}
|
||||
|
||||
// 'response' value depends on value of "qop" field
|
||||
switch d["qop"] {
|
||||
case "":
|
||||
response = getMD5(
|
||||
fmt.Sprintf("%s:%s:%s",
|
||||
ha1,
|
||||
d["nonce"],
|
||||
ha2,
|
||||
),
|
||||
)
|
||||
case "auth", "auth-int":
|
||||
response = getMD5(
|
||||
fmt.Sprintf("%s:%s:%v:%s:%s:%s",
|
||||
ha1,
|
||||
d["nonce"],
|
||||
nonceCount,
|
||||
cnonce,
|
||||
d["qop"],
|
||||
ha2,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
authorization := fmt.Sprintf(`Digest username="%s", realm="%s", nonce="%s", uri="%s", nc=%v, cnonce="%s", response="%s"`,
|
||||
d["username"], d["realm"], d["nonce"], d["uri"], nonceCount, cnonce, response)
|
||||
|
||||
if d["qop"] != "" {
|
||||
authorization += fmt.Sprintf(`, qop=%s`, d["qop"])
|
||||
}
|
||||
|
||||
if d["opaque"] != "" {
|
||||
authorization += fmt.Sprintf(`, opaque="%s"`, d["opaque"])
|
||||
}
|
||||
|
||||
return authorization
|
||||
}
|
3
pkg/gowebdav/doc.go
Normal file
3
pkg/gowebdav/doc.go
Normal file
@ -0,0 +1,3 @@
|
||||
// Package gowebdav is a WebDAV client library with a command line tool
|
||||
// included.
|
||||
package gowebdav
|
49
pkg/gowebdav/errors.go
Normal file
49
pkg/gowebdav/errors.go
Normal file
@ -0,0 +1,49 @@
|
||||
package gowebdav
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
// StatusError implements error and wraps
|
||||
// an erroneous status code.
|
||||
type StatusError struct {
|
||||
Status int
|
||||
}
|
||||
|
||||
func (se StatusError) Error() string {
|
||||
return fmt.Sprintf("%d", se.Status)
|
||||
}
|
||||
|
||||
// IsErrCode returns true if the given error
|
||||
// is an os.PathError wrapping a StatusError
|
||||
// with the given status code.
|
||||
func IsErrCode(err error, code int) bool {
|
||||
if pe, ok := err.(*os.PathError); ok {
|
||||
se, ok := pe.Err.(StatusError)
|
||||
return ok && se.Status == code
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// IsErrNotFound is shorthand for IsErrCode
|
||||
// for status 404.
|
||||
func IsErrNotFound(err error) bool {
|
||||
return IsErrCode(err, 404)
|
||||
}
|
||||
|
||||
func newPathError(op string, path string, statusCode int) error {
|
||||
return &os.PathError{
|
||||
Op: op,
|
||||
Path: path,
|
||||
Err: StatusError{statusCode},
|
||||
}
|
||||
}
|
||||
|
||||
func newPathErrorErr(op string, path string, err error) error {
|
||||
return &os.PathError{
|
||||
Op: op,
|
||||
Path: path,
|
||||
Err: err,
|
||||
}
|
||||
}
|
77
pkg/gowebdav/file.go
Normal file
77
pkg/gowebdav/file.go
Normal file
@ -0,0 +1,77 @@
|
||||
package gowebdav
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
||||
// File is our structure for a given file
|
||||
type File struct {
|
||||
path string
|
||||
name string
|
||||
contentType string
|
||||
size int64
|
||||
modified time.Time
|
||||
etag string
|
||||
isdir bool
|
||||
}
|
||||
|
||||
// Path returns the full path of a file
|
||||
func (f File) Path() string {
|
||||
return f.path
|
||||
}
|
||||
|
||||
// Name returns the name of a file
|
||||
func (f File) Name() string {
|
||||
return f.name
|
||||
}
|
||||
|
||||
// ContentType returns the content type of a file
|
||||
func (f File) ContentType() string {
|
||||
return f.contentType
|
||||
}
|
||||
|
||||
// Size returns the size of a file
|
||||
func (f File) Size() int64 {
|
||||
return f.size
|
||||
}
|
||||
|
||||
// Mode will return the mode of a given file
|
||||
func (f File) Mode() os.FileMode {
|
||||
// TODO check webdav perms
|
||||
if f.isdir {
|
||||
return 0775 | os.ModeDir
|
||||
}
|
||||
|
||||
return 0664
|
||||
}
|
||||
|
||||
// ModTime returns the modified time of a file
|
||||
func (f File) ModTime() time.Time {
|
||||
return f.modified
|
||||
}
|
||||
|
||||
// ETag returns the ETag of a file
|
||||
func (f File) ETag() string {
|
||||
return f.etag
|
||||
}
|
||||
|
||||
// IsDir let us see if a given file is a directory or not
|
||||
func (f File) IsDir() bool {
|
||||
return f.isdir
|
||||
}
|
||||
|
||||
// Sys ????
|
||||
func (f File) Sys() interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
// String lets us see file information
|
||||
func (f File) String() string {
|
||||
if f.isdir {
|
||||
return fmt.Sprintf("Dir : '%s' - '%s'", f.path, f.name)
|
||||
}
|
||||
|
||||
return fmt.Sprintf("File: '%s' SIZE: %d MODIFIED: %s ETAG: %s CTYPE: %s", f.path, f.size, f.modified.String(), f.etag, f.contentType)
|
||||
}
|
54
pkg/gowebdav/netrc.go
Normal file
54
pkg/gowebdav/netrc.go
Normal file
@ -0,0 +1,54 @@
|
||||
package gowebdav
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"os"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func parseLine(s string) (login, pass string) {
|
||||
fields := strings.Fields(s)
|
||||
for i, f := range fields {
|
||||
if f == "login" {
|
||||
login = fields[i+1]
|
||||
}
|
||||
if f == "password" {
|
||||
pass = fields[i+1]
|
||||
}
|
||||
}
|
||||
return login, pass
|
||||
}
|
||||
|
||||
// ReadConfig reads login and password configuration from ~/.netrc
|
||||
// machine foo.com login username password 123456
|
||||
func ReadConfig(uri, netrc string) (string, string) {
|
||||
u, err := url.Parse(uri)
|
||||
if err != nil {
|
||||
return "", ""
|
||||
}
|
||||
|
||||
file, err := os.Open(netrc)
|
||||
if err != nil {
|
||||
return "", ""
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
re := fmt.Sprintf(`^.*machine %s.*$`, u.Host)
|
||||
scanner := bufio.NewScanner(file)
|
||||
for scanner.Scan() {
|
||||
s := scanner.Text()
|
||||
|
||||
matched, err := regexp.MatchString(re, s)
|
||||
if err != nil {
|
||||
return "", ""
|
||||
}
|
||||
if matched {
|
||||
return parseLine(s)
|
||||
}
|
||||
}
|
||||
|
||||
return "", ""
|
||||
}
|
214
pkg/gowebdav/requests.go
Normal file
214
pkg/gowebdav/requests.go
Normal file
@ -0,0 +1,214 @@
|
||||
package gowebdav
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"path"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func (c *Client) req(method, path string, body io.Reader, intercept func(*http.Request)) (req *http.Response, err error) {
|
||||
var r *http.Request
|
||||
var retryBuf io.Reader
|
||||
|
||||
if body != nil {
|
||||
// If the authorization fails, we will need to restart reading
|
||||
// from the passed body stream.
|
||||
// When body is seekable, use seek to reset the streams
|
||||
// cursor to the start.
|
||||
// Otherwise, copy the stream into a buffer while uploading
|
||||
// and use the buffers content on retry.
|
||||
if sk, ok := body.(io.Seeker); ok {
|
||||
if _, err = sk.Seek(0, io.SeekStart); err != nil {
|
||||
return
|
||||
}
|
||||
retryBuf = body
|
||||
} else {
|
||||
buff := &bytes.Buffer{}
|
||||
retryBuf = buff
|
||||
body = io.TeeReader(body, buff)
|
||||
}
|
||||
r, err = http.NewRequest(method, PathEscape(Join(c.root, path)), body)
|
||||
} else {
|
||||
r, err = http.NewRequest(method, PathEscape(Join(c.root, path)), nil)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for k, vals := range c.headers {
|
||||
for _, v := range vals {
|
||||
r.Header.Add(k, v)
|
||||
}
|
||||
}
|
||||
|
||||
// make sure we read 'c.auth' only once since it will be substituted below
|
||||
// and that is unsafe to do when multiple goroutines are running at the same time.
|
||||
c.authMutex.Lock()
|
||||
auth := c.auth
|
||||
c.authMutex.Unlock()
|
||||
|
||||
auth.Authorize(r, method, path)
|
||||
|
||||
if intercept != nil {
|
||||
intercept(r)
|
||||
}
|
||||
|
||||
if c.interceptor != nil {
|
||||
c.interceptor(method, r)
|
||||
}
|
||||
|
||||
rs, err := c.c.Do(r)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if rs.StatusCode == 401 && auth.Type() == "NoAuth" {
|
||||
wwwAuthenticateHeader := strings.ToLower(rs.Header.Get("Www-Authenticate"))
|
||||
|
||||
if strings.Index(wwwAuthenticateHeader, "digest") > -1 {
|
||||
c.authMutex.Lock()
|
||||
c.auth = &DigestAuth{auth.User(), auth.Pass(), digestParts(rs)}
|
||||
c.authMutex.Unlock()
|
||||
} else if strings.Index(wwwAuthenticateHeader, "basic") > -1 {
|
||||
c.authMutex.Lock()
|
||||
c.auth = &BasicAuth{auth.User(), auth.Pass()}
|
||||
c.authMutex.Unlock()
|
||||
} else {
|
||||
return rs, newPathError("Authorize", c.root, rs.StatusCode)
|
||||
}
|
||||
|
||||
// retryBuf will be nil if body was nil initially so no check
|
||||
// for body == nil is required here.
|
||||
return c.req(method, path, retryBuf, intercept)
|
||||
} else if rs.StatusCode == 401 {
|
||||
return rs, newPathError("Authorize", c.root, rs.StatusCode)
|
||||
}
|
||||
|
||||
return rs, err
|
||||
}
|
||||
|
||||
func (c *Client) mkcol(path string) (status int, err error) {
|
||||
rs, err := c.req("MKCOL", path, nil, nil)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
defer rs.Body.Close()
|
||||
|
||||
status = rs.StatusCode
|
||||
if status == 405 {
|
||||
status = 201
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (c *Client) options(path string) (*http.Response, error) {
|
||||
return c.req("OPTIONS", path, nil, func(rq *http.Request) {
|
||||
rq.Header.Add("Depth", "0")
|
||||
})
|
||||
}
|
||||
|
||||
func (c *Client) propfind(path string, self bool, body string, resp interface{}, parse func(resp interface{}) error) error {
|
||||
rs, err := c.req("PROPFIND", path, strings.NewReader(body), func(rq *http.Request) {
|
||||
if self {
|
||||
rq.Header.Add("Depth", "0")
|
||||
} else {
|
||||
rq.Header.Add("Depth", "1")
|
||||
}
|
||||
rq.Header.Add("Content-Type", "application/xml;charset=UTF-8")
|
||||
rq.Header.Add("Accept", "application/xml,text/xml")
|
||||
rq.Header.Add("Accept-Charset", "utf-8")
|
||||
// TODO add support for 'gzip,deflate;q=0.8,q=0.7'
|
||||
rq.Header.Add("Accept-Encoding", "")
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer rs.Body.Close()
|
||||
|
||||
if rs.StatusCode != 207 {
|
||||
return newPathError("PROPFIND", path, rs.StatusCode)
|
||||
}
|
||||
|
||||
return parseXML(rs.Body, resp, parse)
|
||||
}
|
||||
|
||||
func (c *Client) doCopyMove(
|
||||
method string,
|
||||
oldpath string,
|
||||
newpath string,
|
||||
overwrite bool,
|
||||
) (
|
||||
status int,
|
||||
r io.ReadCloser,
|
||||
err error,
|
||||
) {
|
||||
rs, err := c.req(method, oldpath, nil, func(rq *http.Request) {
|
||||
rq.Header.Add("Destination", PathEscape(Join(c.root, newpath)))
|
||||
if overwrite {
|
||||
rq.Header.Add("Overwrite", "T")
|
||||
} else {
|
||||
rq.Header.Add("Overwrite", "F")
|
||||
}
|
||||
})
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
status = rs.StatusCode
|
||||
r = rs.Body
|
||||
return
|
||||
}
|
||||
|
||||
func (c *Client) copymove(method string, oldpath string, newpath string, overwrite bool) (err error) {
|
||||
s, data, err := c.doCopyMove(method, oldpath, newpath, overwrite)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if data != nil {
|
||||
defer data.Close()
|
||||
}
|
||||
|
||||
switch s {
|
||||
case 201, 204:
|
||||
return nil
|
||||
|
||||
case 207:
|
||||
// TODO handle multistat errors, worst case ...
|
||||
log(fmt.Sprintf(" TODO handle %s - %s multistatus result %s", method, oldpath, String(data)))
|
||||
|
||||
case 409:
|
||||
err := c.createParentCollection(newpath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return c.copymove(method, oldpath, newpath, overwrite)
|
||||
}
|
||||
|
||||
return newPathError(method, oldpath, s)
|
||||
}
|
||||
|
||||
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)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
defer rs.Body.Close()
|
||||
//all, _ := io.ReadAll(rs.Body)
|
||||
//logrus.Debugln("put res: ", string(all))
|
||||
status = rs.StatusCode
|
||||
return
|
||||
}
|
||||
|
||||
func (c *Client) createParentCollection(itemPath string) (err error) {
|
||||
parentPath := path.Dir(itemPath)
|
||||
if parentPath == "." || parentPath == "/" {
|
||||
return nil
|
||||
}
|
||||
|
||||
return c.MkdirAll(parentPath, 0755)
|
||||
}
|
118
pkg/gowebdav/utils.go
Normal file
118
pkg/gowebdav/utils.go
Normal file
@ -0,0 +1,118 @@
|
||||
package gowebdav
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/xml"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
func log(msg interface{}) {
|
||||
fmt.Println(msg)
|
||||
}
|
||||
|
||||
// PathEscape escapes all segments of a given path
|
||||
func PathEscape(path string) string {
|
||||
s := strings.Split(path, "/")
|
||||
for i, e := range s {
|
||||
s[i] = url.PathEscape(e)
|
||||
}
|
||||
return strings.Join(s, "/")
|
||||
}
|
||||
|
||||
// FixSlash appends a trailing / to our string
|
||||
func FixSlash(s string) string {
|
||||
if !strings.HasSuffix(s, "/") {
|
||||
s += "/"
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
// FixSlashes appends and prepends a / if they are missing
|
||||
func FixSlashes(s string) string {
|
||||
if !strings.HasPrefix(s, "/") {
|
||||
s = "/" + s
|
||||
}
|
||||
|
||||
return FixSlash(s)
|
||||
}
|
||||
|
||||
// Join joins two paths
|
||||
func Join(path0 string, path1 string) string {
|
||||
return strings.TrimSuffix(path0, "/") + "/" + strings.TrimPrefix(path1, "/")
|
||||
}
|
||||
|
||||
// String pulls a string out of our io.Reader
|
||||
func String(r io.Reader) string {
|
||||
buf := new(bytes.Buffer)
|
||||
// TODO - make String return an error as well
|
||||
_, _ = buf.ReadFrom(r)
|
||||
return buf.String()
|
||||
}
|
||||
|
||||
func parseUint(s *string) uint {
|
||||
if n, e := strconv.ParseUint(*s, 10, 32); e == nil {
|
||||
return uint(n)
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func parseInt64(s *string) int64 {
|
||||
if n, e := strconv.ParseInt(*s, 10, 64); e == nil {
|
||||
return n
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func parseModified(s *string) time.Time {
|
||||
if t, e := time.Parse(time.RFC1123, *s); e == nil {
|
||||
return t
|
||||
}
|
||||
return time.Unix(0, 0)
|
||||
}
|
||||
|
||||
func parseXML(data io.Reader, resp interface{}, parse func(resp interface{}) error) error {
|
||||
decoder := xml.NewDecoder(data)
|
||||
for t, _ := decoder.Token(); t != nil; t, _ = decoder.Token() {
|
||||
switch se := t.(type) {
|
||||
case xml.StartElement:
|
||||
if se.Name.Local == "response" {
|
||||
if e := decoder.DecodeElement(resp, &se); e == nil {
|
||||
if err := parse(resp); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// limitedReadCloser wraps a io.ReadCloser and limits the number of bytes that can be read from it.
|
||||
type limitedReadCloser struct {
|
||||
rc io.ReadCloser
|
||||
remaining int
|
||||
}
|
||||
|
||||
func (l *limitedReadCloser) Read(buf []byte) (int, error) {
|
||||
if l.remaining <= 0 {
|
||||
return 0, io.EOF
|
||||
}
|
||||
|
||||
if len(buf) > l.remaining {
|
||||
buf = buf[0:l.remaining]
|
||||
}
|
||||
|
||||
n, err := l.rc.Read(buf)
|
||||
l.remaining -= n
|
||||
|
||||
return n, err
|
||||
}
|
||||
|
||||
func (l *limitedReadCloser) Close() error {
|
||||
return l.rc.Close()
|
||||
}
|
67
pkg/gowebdav/utils_test.go
Normal file
67
pkg/gowebdav/utils_test.go
Normal file
@ -0,0 +1,67 @@
|
||||
package gowebdav
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestJoin(t *testing.T) {
|
||||
eq(t, "/", "", "")
|
||||
eq(t, "/", "/", "/")
|
||||
eq(t, "/foo", "", "/foo")
|
||||
eq(t, "foo/foo", "foo/", "/foo")
|
||||
eq(t, "foo/foo", "foo/", "foo")
|
||||
}
|
||||
|
||||
func eq(t *testing.T, expected string, s0 string, s1 string) {
|
||||
s := Join(s0, s1)
|
||||
if s != expected {
|
||||
t.Error("For", "'"+s0+"','"+s1+"'", "expeted", "'"+expected+"'", "got", "'"+s+"'")
|
||||
}
|
||||
}
|
||||
|
||||
func ExamplePathEscape() {
|
||||
fmt.Println(PathEscape(""))
|
||||
fmt.Println(PathEscape("/"))
|
||||
fmt.Println(PathEscape("/web"))
|
||||
fmt.Println(PathEscape("/web/"))
|
||||
fmt.Println(PathEscape("/w e b/d a v/s%u&c#k:s/"))
|
||||
|
||||
// Output:
|
||||
//
|
||||
// /
|
||||
// /web
|
||||
// /web/
|
||||
// /w%20e%20b/d%20a%20v/s%25u&c%23k:s/
|
||||
}
|
||||
|
||||
func TestEscapeURL(t *testing.T) {
|
||||
ex := "https://foo.com/w%20e%20b/d%20a%20v/s%25u&c%23k:s/"
|
||||
u, _ := url.Parse("https://foo.com" + PathEscape("/w e b/d a v/s%u&c#k:s/"))
|
||||
if ex != u.String() {
|
||||
t.Error("expected: " + ex + " got: " + u.String())
|
||||
}
|
||||
}
|
||||
|
||||
func TestFixSlashes(t *testing.T) {
|
||||
expected := "/"
|
||||
|
||||
if got := FixSlashes(""); got != expected {
|
||||
t.Errorf("expected: %q, got: %q", expected, got)
|
||||
}
|
||||
|
||||
expected = "/path/"
|
||||
|
||||
if got := FixSlashes("path"); got != expected {
|
||||
t.Errorf("expected: %q, got: %q", expected, got)
|
||||
}
|
||||
|
||||
if got := FixSlashes("/path"); got != expected {
|
||||
t.Errorf("expected: %q, got: %q", expected, got)
|
||||
}
|
||||
|
||||
if got := FixSlashes("path/"); got != expected {
|
||||
t.Errorf("expected: %q, got: %q", expected, got)
|
||||
}
|
||||
}
|
@ -4,9 +4,3 @@ import "embed"
|
||||
|
||||
//go:embed *
|
||||
var Public embed.FS
|
||||
|
||||
////go:embed index.html
|
||||
//var Index embed.FS
|
||||
//
|
||||
////go:embed assets/**
|
||||
//var Assets embed.FS
|
||||
|
@ -4,14 +4,9 @@ import (
|
||||
"github.com/Xhofe/alist/conf"
|
||||
"github.com/Xhofe/alist/model"
|
||||
"github.com/Xhofe/alist/utils"
|
||||
"github.com/gin-gonic/gin"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func Login(c *gin.Context) {
|
||||
SuccessResp(c)
|
||||
}
|
||||
|
||||
func CheckParent(path string, password string) bool {
|
||||
meta, err := model.GetMetaByPath(path)
|
||||
if err == nil {
|
||||
|
@ -26,9 +26,18 @@ func Proxy(w http.ResponseWriter, r *http.Request, link *base.Link, file *model.
|
||||
_ = link.Data.Close()
|
||||
}()
|
||||
w.Header().Set("Content-Type", "application/octet-stream")
|
||||
w.Header().Set("Content-Disposition", fmt.Sprintf(`attachment; filename=%s`, url.QueryEscape(file.Name)))
|
||||
w.Header().Set("Content-Disposition", fmt.Sprintf(`attachment; filename="%s"; filename*=UTF-8''%s`, file.Name, url.QueryEscape(file.Name)))
|
||||
w.Header().Set("Content-Length", strconv.FormatInt(file.Size, 10))
|
||||
w.WriteHeader(http.StatusOK)
|
||||
if link.Header != nil {
|
||||
for h, val := range link.Header {
|
||||
w.Header()[h] = val
|
||||
}
|
||||
}
|
||||
if link.Status == 0 {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
} else {
|
||||
w.WriteHeader(link.Status)
|
||||
}
|
||||
_, err = io.Copy(w, link.Data)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -48,7 +57,7 @@ func Proxy(w http.ResponseWriter, r *http.Request, link *base.Link, file *model.
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
w.Header().Set("Content-Disposition", fmt.Sprintf(`attachment; filename=%s`, url.QueryEscape(file.Name)))
|
||||
w.Header().Set("Content-Disposition", fmt.Sprintf(`attachment; filename="%s"; filename*=UTF-8''%s`, file.Name, url.QueryEscape(file.Name)))
|
||||
http.ServeContent(w, r, file.Name, fileStat.ModTime(), f)
|
||||
return nil
|
||||
} else {
|
||||
|
69
server/controllers/auth.go
Normal file
69
server/controllers/auth.go
Normal file
@ -0,0 +1,69 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/Xhofe/alist/conf"
|
||||
"github.com/Xhofe/alist/server/common"
|
||||
"github.com/Xhofe/alist/utils"
|
||||
"github.com/casdoor/casdoor-go-sdk/casdoorsdk"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type OAuthReq struct {
|
||||
Code string `json:"code"`
|
||||
State string `json:"state"`
|
||||
}
|
||||
|
||||
func Verify(c *gin.Context) {
|
||||
token := c.GetHeader("Authorization")
|
||||
if token != conf.Token {
|
||||
common.ErrorStrResp(c, "Invalid token", 401)
|
||||
return
|
||||
}
|
||||
common.SuccessResp(c)
|
||||
}
|
||||
func GetRedirectUrl(c *gin.Context) {
|
||||
if !conf.GetBool("Enable Casdoor") {
|
||||
common.ErrorStrResp(c, "Casdoor is not enabled", 1001)
|
||||
return
|
||||
}
|
||||
redirectUri := generateRedirectUri(c.Request)
|
||||
common.SuccessResp(c, utils.GetSignInUrl(redirectUri))
|
||||
}
|
||||
|
||||
func generateRedirectUri(r *http.Request) string {
|
||||
protocol := "http"
|
||||
host := r.Host
|
||||
if r.TLS != nil {
|
||||
protocol = "https"
|
||||
}
|
||||
return fmt.Sprintf("%s://%s/@manage", protocol, host)
|
||||
}
|
||||
|
||||
func OAuth(c *gin.Context) {
|
||||
var req OAuthReq
|
||||
if err := c.ShouldBind(&req); err != nil {
|
||||
common.ErrorResp(c, err, 401)
|
||||
return
|
||||
}
|
||||
|
||||
if req.Code == "" || req.State == "" {
|
||||
common.ErrorStrResp(c, "Invalid code or state", 400)
|
||||
return
|
||||
}
|
||||
|
||||
token, err := casdoorsdk.GetOAuthToken(req.Code, req.State)
|
||||
if err != nil {
|
||||
common.ErrorResp(c, err, 401)
|
||||
return
|
||||
}
|
||||
|
||||
_, err = casdoorsdk.ParseJwtToken(token.AccessToken)
|
||||
if err != nil {
|
||||
common.ErrorResp(c, err, 401)
|
||||
return
|
||||
}
|
||||
|
||||
common.SuccessResp(c, conf.Token)
|
||||
}
|
@ -55,7 +55,7 @@ func Proxy(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
// 对于中转,不需要重设IP
|
||||
link, err := driver.Link(base.Args{Path: path}, account)
|
||||
link, err := driver.Link(base.Args{Path: path, Header: c.Request.Header}, account)
|
||||
if err != nil {
|
||||
common.ErrorResp(c, err, 500)
|
||||
return
|
||||
|
@ -8,16 +8,6 @@ import (
|
||||
|
||||
func Auth(c *gin.Context) {
|
||||
token := c.GetHeader("Authorization")
|
||||
//password, err := model.GetSettingByKey("password")
|
||||
//if err != nil {
|
||||
// if err == gorm.ErrRecordNotFound {
|
||||
// common.ErrorResp(c, fmt.Errorf("password not set"), 400)
|
||||
// return
|
||||
// }
|
||||
// common.ErrorResp(c, err, 500)
|
||||
// return
|
||||
//}
|
||||
//if token != utils.GetMD5Encode(password.Value) {
|
||||
if token != conf.Token {
|
||||
common.ErrorStrResp(c, "Invalid token", 401)
|
||||
return
|
||||
|
@ -1,7 +1,6 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"github.com/Xhofe/alist/server/common"
|
||||
"github.com/Xhofe/alist/server/controllers"
|
||||
"github.com/Xhofe/alist/server/controllers/file"
|
||||
"github.com/Xhofe/alist/server/middlewares"
|
||||
@ -35,8 +34,11 @@ func InitApiRouter(r *gin.Engine) {
|
||||
|
||||
admin := api.Group("/admin")
|
||||
{
|
||||
admin.GET("/verify", controllers.Verify)
|
||||
admin.GET("/get_redirect_url", controllers.GetRedirectUrl)
|
||||
admin.POST("/oauth", controllers.OAuth)
|
||||
|
||||
admin.Use(middlewares.Auth)
|
||||
admin.Any("/login", common.Login)
|
||||
admin.GET("/settings", controllers.GetSettings)
|
||||
admin.POST("/settings", controllers.SaveSettings)
|
||||
admin.DELETE("/setting", controllers.DeleteSetting)
|
||||
|
@ -1,14 +1,19 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"io/fs"
|
||||
"os"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/http/pprof"
|
||||
"strings"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/Xhofe/alist/utils"
|
||||
"github.com/Xhofe/alist/conf"
|
||||
"github.com/Xhofe/alist/public"
|
||||
"github.com/gin-gonic/gin"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"io/fs"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func InitIndex() {
|
||||
@ -17,37 +22,73 @@ func InitIndex() {
|
||||
if !strings.Contains(conf.Conf.Assets, "/") {
|
||||
conf.Conf.Assets = conf.DefaultConfig().Assets
|
||||
}
|
||||
index, err = public.Public.Open("index.html")
|
||||
// if LocalAssets is local path, read local index.html.
|
||||
if (utils.IsDir(filepath.Dir(conf.Conf.LocalAssets))) && utils.Exists(filepath.Join(conf.Conf.LocalAssets, "index.html")) {
|
||||
index, err = os.Open(filepath.Join(conf.Conf.LocalAssets, "index.html"))
|
||||
defer index.Close()
|
||||
log.Infof("used local index.html")
|
||||
} else {
|
||||
index, err = public.Public.Open("index.html")
|
||||
}
|
||||
if err != nil {
|
||||
log.Fatal(err.Error())
|
||||
}
|
||||
data, _ := ioutil.ReadAll(index)
|
||||
data, _ := ioutil.ReadAll(index)
|
||||
conf.RawIndexHtml = string(data)
|
||||
// if exist SUB_FOLDER, replace it by config: SubFolder
|
||||
subfolder := strings.Trim(conf.Conf.SubFolder, "/")
|
||||
if strings.Contains(conf.RawIndexHtml, "SUB_FOLDER") {
|
||||
conf.RawIndexHtml = strings.ReplaceAll(conf.RawIndexHtml, "SUB_FOLDER", subfolder)
|
||||
}
|
||||
cdnUrl := strings.ReplaceAll(conf.Conf.Assets, "$version", conf.WebTag)
|
||||
cdnUrl = strings.TrimRight(cdnUrl, "/")
|
||||
conf.RawIndexHtml = string(data)
|
||||
if strings.Contains(conf.RawIndexHtml, "CDN_URL") {
|
||||
conf.RawIndexHtml = strings.ReplaceAll(conf.RawIndexHtml, "/CDN_URL", cdnUrl)
|
||||
conf.RawIndexHtml = strings.ReplaceAll(conf.RawIndexHtml, "assets/", cdnUrl+"/assets/")
|
||||
if (cdnUrl == "") && (subfolder != "") {
|
||||
conf.RawIndexHtml = strings.ReplaceAll(conf.RawIndexHtml, "CDN_URL", subfolder)
|
||||
conf.RawIndexHtml = strings.ReplaceAll(conf.RawIndexHtml, "assets/", "/" + subfolder+"/assets/")
|
||||
} else {
|
||||
conf.RawIndexHtml = strings.ReplaceAll(conf.RawIndexHtml, "/CDN_URL", cdnUrl)
|
||||
conf.RawIndexHtml = strings.ReplaceAll(conf.RawIndexHtml, "assets/", cdnUrl+"/assets/")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func Static(r *gin.Engine) {
|
||||
var assets fs.FS
|
||||
var pub fs.FS
|
||||
var err error
|
||||
var fsys fs.FS
|
||||
//InitIndex()
|
||||
assets, err := fs.Sub(public.Public, "assets")
|
||||
// if LocalAssets is local path, read local assets.
|
||||
fsys = os.DirFS(conf.Conf.LocalAssets)
|
||||
if (utils.IsDir(filepath.Dir(conf.Conf.LocalAssets))) && utils.Exists(filepath.Join(conf.Conf.LocalAssets, "assets")) {
|
||||
assets, err = fs.Sub(fsys, "assets")
|
||||
log.Infof("used local assets")
|
||||
} else {
|
||||
assets, err = fs.Sub(public.Public, "assets")
|
||||
}
|
||||
if err != nil {
|
||||
log.Fatalf("can't find assets folder")
|
||||
}
|
||||
pub, err := fs.Sub(public.Public, "public")
|
||||
r.StaticFS("/assets/", http.FS(assets))
|
||||
// if LocalAssets is local path, read local assets.
|
||||
if (utils.IsDir(filepath.Dir(conf.Conf.LocalAssets))) && utils.Exists(filepath.Join(conf.Conf.LocalAssets, "public")) {
|
||||
pub, err = fs.Sub(fsys, "public")
|
||||
log.Infof("used local public")
|
||||
} else {
|
||||
pub, err = fs.Sub(public.Public, "public")
|
||||
}
|
||||
if err != nil {
|
||||
log.Fatalf("can't find public folder")
|
||||
}
|
||||
r.StaticFS("/assets/", http.FS(assets))
|
||||
r.StaticFS("/public/", http.FS(pub))
|
||||
r.NoRoute(func(c *gin.Context) {
|
||||
c.Header("Content-Type", "text/html")
|
||||
c.Status(200)
|
||||
if strings.HasPrefix(c.Request.URL.Path, "/@manage") {
|
||||
_, _ = c.Writer.WriteString(conf.ManageHtml)
|
||||
} else if strings.HasPrefix(c.Request.URL.Path, "/debug/pprof") && conf.Debug {
|
||||
pprof.Index(c.Writer, c.Request)
|
||||
} else {
|
||||
_, _ = c.Writer.WriteString(conf.IndexHtml)
|
||||
}
|
||||
|
@ -7,6 +7,14 @@ package webdav
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"mime"
|
||||
"net"
|
||||
"net/http"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/Xhofe/alist/conf"
|
||||
"github.com/Xhofe/alist/drivers/base"
|
||||
"github.com/Xhofe/alist/drivers/operate"
|
||||
@ -14,12 +22,6 @@ import (
|
||||
"github.com/Xhofe/alist/server/common"
|
||||
"github.com/Xhofe/alist/utils"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"net"
|
||||
"net/http"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
type FileSystem struct{}
|
||||
@ -133,7 +135,7 @@ func (fs *FileSystem) Link(w http.ResponseWriter, r *http.Request, rawPath strin
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
link_, err := driver.Link(base.Args{Path: path_}, account)
|
||||
link_, err := driver.Link(base.Args{Path: path_, Header: r.Header}, account)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@ -197,8 +199,17 @@ func (fs *FileSystem) Upload(ctx context.Context, r *http.Request, rawPath strin
|
||||
} else {
|
||||
delete(upFileMap, rawPath)
|
||||
}
|
||||
mimeType := r.Header.Get("Content-Type")
|
||||
if mimeType == "" || strings.ToLower(mimeType) == "application/octet-stream" {
|
||||
mimeTypeTmp := mime.TypeByExtension(path.Ext(fileName))
|
||||
if mimeTypeTmp != "" {
|
||||
mimeType = mimeTypeTmp
|
||||
} else {
|
||||
mimeType = "application/octet-stream"
|
||||
}
|
||||
}
|
||||
fileData := model.FileStream{
|
||||
MIMEType: r.Header.Get("Content-Type"),
|
||||
MIMEType: mimeType,
|
||||
File: r.Body,
|
||||
Size: fileSize,
|
||||
Name: fileName,
|
||||
|
9
utils/auth.go
Normal file
9
utils/auth.go
Normal file
@ -0,0 +1,9 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"github.com/casdoor/casdoor-go-sdk/casdoorsdk"
|
||||
)
|
||||
|
||||
func GetSignInUrl(redirectUri string) string {
|
||||
return casdoorsdk.GetSigninUrl(redirectUri)
|
||||
}
|
Reference in New Issue
Block a user