Skip to content

Commit 195da23

Browse files
committed
fix(123_open): add xff in Link
Signed-off-by: MadDogOwner <[email protected]>
1 parent c0d8448 commit 195da23

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

drivers/123_open/driver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func (d *Open123) Link(ctx context.Context, file model.Obj, args model.LinkArgs)
103103
}, nil
104104
}
105105

106-
res, err := d.GetDownloadInfo(fileId)
106+
res, err := d.GetDownloadInfo(fileId, args.IP)
107107
if err != nil {
108108
return nil, err
109109
}

drivers/123_open/util.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,13 @@ func (d *Open123) getFiles(parentFileId int64, limit int, lastFileId int64) (*Fi
196196
return &resp, nil
197197
}
198198

199-
func (d *Open123) GetDownloadInfo(fileId int64) (*DownloadInfoResp, error) {
199+
func (d *Open123) GetDownloadInfo(fileId int64, ip string) (*DownloadInfoResp, error) {
200200
var resp DownloadInfoResp
201201

202202
_, err := d.Request(DownloadInfo, http.MethodGet, func(req *resty.Request) {
203+
if ip != "" {
204+
req.SetHeader("X-Forwarded-For", ip)
205+
}
203206
req.SetQueryParams(map[string]string{
204207
"fileId": strconv.FormatInt(fileId, 10),
205208
})

drivers/123_share/driver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func (d *Pan123Share) Link(ctx context.Context, file model.Obj, args model.LinkA
8484
return nil, fmt.Errorf("failed to transfer share file")
8585
}
8686
// 2. 获取直链
87-
res, err := d.refOpen.GetDownloadInfo(s.Data.FileID)
87+
res, err := d.refOpen.GetDownloadInfo(s.Data.FileID, args.IP)
8888
if err != nil {
8989
return nil, err
9090
}

0 commit comments

Comments
 (0)