mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2026-09-22 16:00:51 +00:00
fix: Alibaba Cloud Disk ignores tls verification (#8812)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
@@ -57,6 +58,9 @@ func (a aliClient) Delete(pathItem string) (bool, error) {
|
||||
return false, err
|
||||
}
|
||||
client := resty.New()
|
||||
client.SetTLSClientConfig(&tls.Config{
|
||||
InsecureSkipVerify: true,
|
||||
})
|
||||
data := map[string]interface{}{
|
||||
"drive_id": a.driveID,
|
||||
"file_id": fileInfo.FileID,
|
||||
@@ -104,6 +108,9 @@ func (a aliClient) Upload(src, target string) (bool, error) {
|
||||
"check_name_mode": "auto_rename",
|
||||
}
|
||||
client := resty.New()
|
||||
client.SetTLSClientConfig(&tls.Config{
|
||||
InsecureSkipVerify: true,
|
||||
})
|
||||
url := "https://api.alipan.com/v2/file/create"
|
||||
|
||||
resp, err := client.R().
|
||||
@@ -138,6 +145,9 @@ func (a aliClient) Download(src, target string) (bool, error) {
|
||||
return false, err
|
||||
}
|
||||
client := resty.New()
|
||||
client.SetTLSClientConfig(&tls.Config{
|
||||
InsecureSkipVerify: true,
|
||||
})
|
||||
if fileInfo.Size > 100*1024*1024 {
|
||||
return false, fmt.Errorf("The translation file %s exceeds 100MB, please download it through the client.", src)
|
||||
}
|
||||
@@ -255,6 +265,9 @@ func (a aliClient) loadDirWithPath(path string) ([]fileInfo, error) {
|
||||
|
||||
func (a aliClient) loadFileWithParentID(parentID string) ([]fileInfo, error) {
|
||||
client := resty.New()
|
||||
client.SetTLSClientConfig(&tls.Config{
|
||||
InsecureSkipVerify: true,
|
||||
})
|
||||
data := map[string]interface{}{
|
||||
"drive_id": a.driveID,
|
||||
"fields": "*",
|
||||
@@ -324,6 +337,9 @@ func (a aliClient) mkdirWithPath(target string) (string, error) {
|
||||
|
||||
func (a aliClient) mkdir(parentID, name string) (string, error) {
|
||||
client := resty.New()
|
||||
client.SetTLSClientConfig(&tls.Config{
|
||||
InsecureSkipVerify: true,
|
||||
})
|
||||
data := map[string]interface{}{
|
||||
"drive_id": a.driveID,
|
||||
"name": name,
|
||||
@@ -455,6 +471,9 @@ func (a aliClient) handleDownload(uri string, target string) error {
|
||||
|
||||
func (a *aliClient) completeUpload(uploadID, fileID string) error {
|
||||
client := resty.New()
|
||||
client.SetTLSClientConfig(&tls.Config{
|
||||
InsecureSkipVerify: true,
|
||||
})
|
||||
data := map[string]interface{}{
|
||||
"drive_id": a.driveID,
|
||||
"upload_id": uploadID,
|
||||
@@ -482,6 +501,9 @@ type tokenResp struct {
|
||||
|
||||
func loadToken(refresh_token string) (string, error) {
|
||||
client := resty.New()
|
||||
client.SetTLSClientConfig(&tls.Config{
|
||||
InsecureSkipVerify: true,
|
||||
})
|
||||
data := map[string]interface{}{
|
||||
"grant_type": "refresh_token",
|
||||
"refresh_token": refresh_token,
|
||||
@@ -511,6 +533,9 @@ func RefreshALIToken(varMap map[string]interface{}) (string, error) {
|
||||
return "", errors.New("no such refresh token find in db")
|
||||
}
|
||||
client := resty.New()
|
||||
client.SetTLSClientConfig(&tls.Config{
|
||||
InsecureSkipVerify: true,
|
||||
})
|
||||
data := map[string]interface{}{
|
||||
"grant_type": "refresh_token",
|
||||
"refresh_token": refresh_token,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
@@ -61,6 +62,9 @@ func (a aliClient) Upload(src, target string) (bool, error) {
|
||||
"check_name_mode": "auto_rename",
|
||||
}
|
||||
client := resty.New()
|
||||
client.SetTLSClientConfig(&tls.Config{
|
||||
InsecureSkipVerify: true,
|
||||
})
|
||||
url := "https://api.alipan.com/v2/file/create"
|
||||
|
||||
resp, err := client.R().
|
||||
@@ -95,6 +99,9 @@ func (a aliClient) Delete(pathItem string) (bool, error) {
|
||||
return false, err
|
||||
}
|
||||
client := resty.New()
|
||||
client.SetTLSClientConfig(&tls.Config{
|
||||
InsecureSkipVerify: true,
|
||||
})
|
||||
data := map[string]interface{}{
|
||||
"drive_id": a.driveID,
|
||||
"file_id": fileInfo.FileID,
|
||||
@@ -153,6 +160,9 @@ func (a aliClient) loadFileWithName(pathItem string) (fileInfo, error) {
|
||||
|
||||
func (a aliClient) loadFileWithParentID(parentID string) ([]fileInfo, error) {
|
||||
client := resty.New()
|
||||
client.SetTLSClientConfig(&tls.Config{
|
||||
InsecureSkipVerify: true,
|
||||
})
|
||||
data := map[string]interface{}{
|
||||
"drive_id": a.driveID,
|
||||
"fields": "*",
|
||||
@@ -222,6 +232,9 @@ func (a aliClient) mkdirWithPath(target string) (string, error) {
|
||||
|
||||
func (a aliClient) mkdir(parentID, name string) (string, error) {
|
||||
client := resty.New()
|
||||
client.SetTLSClientConfig(&tls.Config{
|
||||
InsecureSkipVerify: true,
|
||||
})
|
||||
data := map[string]interface{}{
|
||||
"drive_id": a.driveID,
|
||||
"name": name,
|
||||
@@ -316,6 +329,9 @@ func (a aliClient) uploadPart(uri string, reader io.Reader) error {
|
||||
|
||||
func (a *aliClient) completeUpload(uploadID, fileID string) error {
|
||||
client := resty.New()
|
||||
client.SetTLSClientConfig(&tls.Config{
|
||||
InsecureSkipVerify: true,
|
||||
})
|
||||
data := map[string]interface{}{
|
||||
"drive_id": a.driveID,
|
||||
"upload_id": uploadID,
|
||||
@@ -347,6 +363,9 @@ func RefreshALIToken(varMap map[string]interface{}) (string, error) {
|
||||
return "", errors.New("no such refresh token find in db")
|
||||
}
|
||||
client := resty.New()
|
||||
client.SetTLSClientConfig(&tls.Config{
|
||||
InsecureSkipVerify: true,
|
||||
})
|
||||
data := map[string]interface{}{
|
||||
"grant_type": "refresh_token",
|
||||
"refresh_token": refresh_token,
|
||||
|
||||
Reference in New Issue
Block a user