fix: Alibaba Cloud Disk ignores tls verification (#8812)

This commit is contained in:
ssongliu
2025-05-25 16:15:34 +08:00
committed by GitHub
parent c65eb7fac8
commit 548929b2e8
2 changed files with 44 additions and 0 deletions
+25
View File
@@ -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,
+19
View File
@@ -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,