fix(123): get real url (#2135)

123 今天更新多加了一层跳转`https://web-pro.cjjd18.com/download/?params=base64encode(rawurl)`,导致ip如果不符则可能下载返回403,在服务器端处理获取rawurl
pull/2140/head
浅秋枫影 2022-10-27 17:02:35 +08:00 committed by GitHub
parent 061c462f0b
commit 18165eb50d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 0 deletions

View File

@ -6,6 +6,7 @@ import (
"crypto/md5"
"encoding/binary"
"encoding/hex"
"encoding/base64"
"fmt"
"io"
"net/http"
@ -96,6 +97,14 @@ func (d *Pan123) Link(ctx context.Context, file model.Obj, args model.LinkArgs)
if err != nil {
return nil, err
}
nu := u.Query().Get("params")
if nu != "" {
du, _ := base64.StdEncoding.DecodeString(nu)
u, err = url.Parse(string(du))
if err != nil {
return nil, err
}
}
u_ := fmt.Sprintf("https://%s%s", u.Host, u.Path)
res, err := base.NoRedirectClient.R().SetQueryParamsFromValues(u.Query()).Head(u_)
if err != nil {