Skip to content

Commit

Permalink
add option to set if the user want their ua be passed to upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
Sakura-Byte committed May 11, 2024
1 parent a8c68a0 commit 483041f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
10 changes: 7 additions & 3 deletions drivers/alist_v3/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,13 @@ func (d *AListV3) List(ctx context.Context, dir model.Obj, args model.ListArgs)

func (d *AListV3) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (*model.Link, error) {
var resp common.Resp[FsGetResp]
userAgent := args.Header.Get("user-agent")
if userAgent == "" {
userAgent = base.UserAgent
// if PassUAToUpsteam is true, then pass the user-agent to the upstream
userAgent := base.UserAgent
if d.PassUAToUpsteam {
userAgent = args.Header.Get("user-agent")
if userAgent == "" {
userAgent = base.UserAgent
}
}
_, err := d.request("/fs/get", http.MethodPost, func(req *resty.Request) {
req.SetResult(&resp).SetBody(FsGetReq{
Expand Down
11 changes: 6 additions & 5 deletions drivers/alist_v3/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import (

type Addition struct {
driver.RootPath
Address string `json:"url" required:"true"`
MetaPassword string `json:"meta_password"`
Username string `json:"username"`
Password string `json:"password"`
Token string `json:"token"`
Address string `json:"url" required:"true"`
MetaPassword string `json:"meta_password"`
Username string `json:"username"`
Password string `json:"password"`
Token string `json:"token"`
PassUAToUpsteam bool `json:"pass_ua_to_upsteam" default:"true"`
}

var config = driver.Config{
Expand Down

0 comments on commit 483041f

Please sign in to comment.