mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 16:59:12 +00:00
feat: add support for proxies to use with IRC and Indexers (#1421)
* feat: add support for proxies * fix(http): release handler * fix(migrations): define proxy early * fix(migrations): pg proxy * fix(proxy): list update delete * fix(proxy): remove log and imports * feat(irc): use proxy * feat(irc): tests * fix(web): update imports for ProxyForms.tsx * fix(database): migration * feat(proxy): test * feat(proxy): validate proxy type * feat(proxy): validate and test * feat(proxy): improve validate and test * feat(proxy): fix db schema * feat(proxy): add db tests * feat(proxy): handle http errors * fix(http): imports * feat(proxy): use proxy for indexer downloads * feat(proxy): indexerforms select proxy * feat(proxy): handle torrent download * feat(proxy): skip if disabled * feat(proxy): imports * feat(proxy): implement in Feeds * feat(proxy): update helper text indexer proxy * feat(proxy): add internal cache
This commit is contained in:
parent
472d327308
commit
bc0f4cc055
59 changed files with 2533 additions and 371 deletions
|
@ -25,6 +25,7 @@ type Client interface {
|
|||
GetFeed(ctx context.Context) (*Feed, error)
|
||||
GetCaps(ctx context.Context) (*Caps, error)
|
||||
Caps() *Caps
|
||||
WithHTTPClient(client *http.Client)
|
||||
}
|
||||
|
||||
type client struct {
|
||||
|
@ -41,6 +42,10 @@ type client struct {
|
|||
Log *log.Logger
|
||||
}
|
||||
|
||||
func (c *client) WithHTTPClient(client *http.Client) {
|
||||
c.http = client
|
||||
}
|
||||
|
||||
type BasicAuth struct {
|
||||
Username string
|
||||
Password string
|
||||
|
@ -99,6 +104,9 @@ func (c *client) get(ctx context.Context, endpoint string, queryParams map[strin
|
|||
}
|
||||
|
||||
u, err := url.Parse(c.Host)
|
||||
if err != nil {
|
||||
return 0, nil, err
|
||||
}
|
||||
u.Path = strings.TrimSuffix(u.Path, "/")
|
||||
u.RawQuery = params.Encode()
|
||||
reqUrl := u.String()
|
||||
|
@ -273,6 +281,9 @@ func (c *client) getCaps(ctx context.Context, endpoint string, opts map[string]s
|
|||
}
|
||||
|
||||
u, err := url.Parse(c.Host)
|
||||
if err != nil {
|
||||
return 0, nil, err
|
||||
}
|
||||
u.Path = strings.TrimSuffix(u.Path, "/")
|
||||
u.RawQuery = params.Encode()
|
||||
reqUrl := u.String()
|
||||
|
@ -325,7 +336,6 @@ func (c *client) getCaps(ctx context.Context, endpoint string, opts map[string]s
|
|||
}
|
||||
|
||||
func (c *client) GetCaps(ctx context.Context) (*Caps, error) {
|
||||
|
||||
status, res, err := c.getCaps(ctx, "?t=caps", nil)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not get caps for feed")
|
||||
|
|
|
@ -23,6 +23,7 @@ type Client interface {
|
|||
FetchFeed(ctx context.Context) (*Feed, error)
|
||||
FetchCaps(ctx context.Context) (*Caps, error)
|
||||
GetCaps() *Caps
|
||||
WithHTTPClient(client *http.Client)
|
||||
}
|
||||
|
||||
type client struct {
|
||||
|
@ -39,6 +40,10 @@ type client struct {
|
|||
Log *log.Logger
|
||||
}
|
||||
|
||||
func (c *client) WithHTTPClient(client *http.Client) {
|
||||
c.http = client
|
||||
}
|
||||
|
||||
type BasicAuth struct {
|
||||
Username string
|
||||
Password string
|
||||
|
@ -90,6 +95,10 @@ func (c *client) get(ctx context.Context, endpoint string, opts map[string]strin
|
|||
}
|
||||
|
||||
u, err := url.Parse(c.Host)
|
||||
if err != nil {
|
||||
return 0, nil, err
|
||||
}
|
||||
|
||||
u.Path = strings.TrimSuffix(u.Path, "/")
|
||||
u.RawQuery = params.Encode()
|
||||
reqUrl := u.String()
|
||||
|
@ -177,6 +186,9 @@ func (c *client) getCaps(ctx context.Context, endpoint string, opts map[string]s
|
|||
}
|
||||
|
||||
u, err := url.Parse(c.Host)
|
||||
if err != nil {
|
||||
return 0, nil, err
|
||||
}
|
||||
u.Path = strings.TrimSuffix(u.Path, "/")
|
||||
u.RawQuery = params.Encode()
|
||||
reqUrl := u.String()
|
||||
|
@ -229,7 +241,6 @@ func (c *client) getCaps(ctx context.Context, endpoint string, opts map[string]s
|
|||
}
|
||||
|
||||
func (c *client) FetchCaps(ctx context.Context) (*Caps, error) {
|
||||
|
||||
status, res, err := c.getCaps(ctx, "?t=caps", nil)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not get caps for feed")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue