Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions drivers/123/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,9 @@ func (d *Pan123) List(ctx context.Context, dir model.Obj, args model.ListArgs) (
})
}

func (d *Pan123) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (*model.Link, error) {
func (d *Pan123) Link(ctx context.Context, file model.Obj, _ model.LinkArgs) (*model.Link, error) {
if f, ok := file.(File); ok {
//var resp DownResp
var headers map[string]string
if !utils.IsLocalIPAddr(args.IP) {
headers = map[string]string{
//"X-Real-IP": "1.1.1.1",
"X-Forwarded-For": args.IP,
}
}
data := base.Json{
"driveId": 0,
"etag": f.Etag,
Expand All @@ -101,8 +94,7 @@ func (d *Pan123) Link(ctx context.Context, file model.Obj, args model.LinkArgs)
"type": f.Type,
}
resp, err := d.Request(DownloadInfo, http.MethodPost, func(req *resty.Request) {

req.SetBody(data).SetHeaders(headers)
req.SetBody(data)
}, nil)
if err != nil {
return nil, err
Expand Down
2 changes: 2 additions & 0 deletions drivers/123/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ var config = driver.Config{
Name: "123Pan",
DefaultRoot: "0",
LocalSort: true,
// Download URLs are bound to the IP that requests them from 123Pan.
OnlyProxy: true,
}

func init() {
Expand Down
9 changes: 9 additions & 0 deletions drivers/123/meta_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package _123

import "testing"

func TestConfigRequiresProxy(t *testing.T) {
if !config.MustProxy() {
t.Fatal("123Pan downloads must be proxied because direct links are bound to the requester's IP")
}
}
2 changes: 1 addition & 1 deletion drivers/123/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func (d *Pan123) login() error {
return err
}
if utils.Json.Get(res.Body(), "code").ToInt() != 200 {
err = fmt.Errorf(utils.Json.Get(res.Body(), "message").ToString())
err = errors.New(utils.Json.Get(res.Body(), "message").ToString())
} else {
d.AccessToken = utils.Json.Get(res.Body(), "data", "token").ToString()
}
Expand Down
Loading