fix: make TlsInsecureSkipVerify enable for all request (#4386)

This commit is contained in:
XYUU
2023-05-14 17:05:47 +08:00
committed by GitHub
parent 3c4c2ad4e0
commit a3446720a2
11 changed files with 65 additions and 39 deletions

View File

@ -5,7 +5,6 @@ import (
"fmt"
"net/http"
"regexp"
"time"
"github.com/alist-org/alist/v3/drivers/base"
"github.com/alist-org/alist/v3/internal/driver"
@ -15,8 +14,6 @@ import (
"github.com/go-resty/resty/v2"
)
var upClient = base.NewRestyClient().SetTimeout(120 * time.Second)
type LanZou struct {
Addition
model.Storage
@ -209,11 +206,11 @@ func (d *LanZou) Put(ctx context.Context, dstDir model.Obj, stream model.FileStr
var resp RespText[[]FileOrFolder]
_, err := d._post(d.BaseUrl+"/fileup.php", func(req *resty.Request) {
req.SetFormData(map[string]string{
"task": "1",
"vie": "2",
"ve": "2",
"id": "WU_FILE_0",
"name": stream.GetName(),
"task": "1",
"vie": "2",
"ve": "2",
"id": "WU_FILE_0",
"name": stream.GetName(),
"folder_id_bb_n": dstDir.GetID(),
}).SetFileReader("upload_file", stream.GetName(), stream).SetContext(ctx)
}, &resp, true)

View File

@ -7,6 +7,7 @@ import (
"regexp"
"strconv"
"strings"
"sync"
"time"
"github.com/alist-org/alist/v3/drivers/base"
@ -16,6 +17,9 @@ import (
log "github.com/sirupsen/logrus"
)
var upClient *resty.Client
var once sync.Once
func (d *LanZou) doupload(callback base.ReqCallback, resp interface{}) ([]byte, error) {
return d.post(d.BaseUrl+"/doupload.php", func(req *resty.Request) {
req.SetQueryParam("uid", d.uid)
@ -64,6 +68,9 @@ func (d *LanZou) _post(url string, callback base.ReqCallback, resp interface{},
func (d *LanZou) request(url string, method string, callback base.ReqCallback, up bool) ([]byte, error) {
var req *resty.Request
if up {
once.Do(func() {
upClient = base.NewRestyClient().SetTimeout(120 * time.Second)
})
req = upClient.R()
} else {
req = base.RestyClient.R()