Skip to content

Commit

Permalink
fix(feiji): unable to get link (close #6082)
Browse files Browse the repository at this point in the history
  • Loading branch information
xhofe committed Feb 24, 2024
1 parent e66abb3 commit 94a80bc
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 18 deletions.
17 changes: 14 additions & 3 deletions drivers/ilanzou/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,14 @@ func (d *ILanZou) Link(ctx context.Context, file model.Obj, args model.LinkArgs)
query.Set("devType", "6")
query.Set("devCode", d.UUID)
query.Set("devModel", "chrome")
query.Set("devVersion", "120")
query.Set("devVersion", d.conf.devVersion)
query.Set("appVersion", "")
ts, err := getTimestamp(d.conf.secret)
if err != nil {
return nil, err
}
query.Set("timestamp", ts)
//query.Set("appToken", d.Token)
query.Set("appToken", d.Token)
query.Set("enable", "1")
downloadId, err := mopan.AesEncrypt([]byte(fmt.Sprintf("%s|%s", file.GetID(), d.userID)), d.conf.secret)
if err != nil {
Expand All @@ -143,7 +143,18 @@ func (d *ILanZou) Link(ctx context.Context, file model.Obj, args model.LinkArgs)
}
query.Set("auth", hex.EncodeToString(auth))
u.RawQuery = query.Encode()
link := model.Link{URL: u.String()}
realURL := u.String()
// get the url after redirect
res, err := base.NoRedirectClient.R().Get(realURL)
if err != nil {
return nil, err
}
if res.StatusCode() == 302 {
realURL = res.Header().Get("location")
} else {
return nil, fmt.Errorf("redirect failed, status: %d", res.StatusCode())
}
link := model.Link{URL: realURL}
return &link, nil
}

Expand Down
33 changes: 18 additions & 15 deletions drivers/ilanzou/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ type Addition struct {
}

type Conf struct {
base string
secret []byte
bucket string
unproved string
proved string
base string
secret []byte
bucket string
unproved string
proved string
devVersion string
}

func init() {
Expand All @@ -39,11 +40,12 @@ func init() {
NoOverwriteUpload: false,
},
conf: Conf{
base: "https://api.ilanzou.com",
secret: []byte("lanZouY-disk-app"),
bucket: "wpanstore-lanzou",
unproved: "unproved",
proved: "proved",
base: "https://api.ilanzou.com",
secret: []byte("lanZouY-disk-app"),
bucket: "wpanstore-lanzou",
unproved: "unproved",
proved: "proved",
devVersion: "120",
},
}
})
Expand All @@ -63,11 +65,12 @@ func init() {
NoOverwriteUpload: false,
},
conf: Conf{
base: "https://api.feijipan.com",
secret: []byte("dingHao-disk-app"),
bucket: "wpanstore",
unproved: "ws",
proved: "app",
base: "https://api.feijipan.com",
secret: []byte("dingHao-disk-app"),
bucket: "wpanstore",
unproved: "ws",
proved: "app",
devVersion: "121",
},
}
})
Expand Down

0 comments on commit 94a80bc

Please sign in to comment.