feat(downloadclients): rtorrent improve basic auth handling (#914)

* feat: wrap rtorrent client with custom transport

* refactor: move to autobrr/go-rtorrent

* feat: wrap rtorrent client with custom transport

* refactor: move to autobrr/go-rtorrent

* feat(web): update forms
This commit is contained in:
ze0s 2023-05-06 18:16:34 +02:00 committed by GitHub
parent 605ceaf5f4
commit 96e38e649a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 58 additions and 24 deletions

View file

@ -16,11 +16,11 @@ import (
"github.com/autobrr/autobrr/pkg/sabnzbd"
"github.com/autobrr/autobrr/pkg/sonarr"
"github.com/autobrr/autobrr/pkg/whisparr"
"github.com/autobrr/go-qbittorrent"
"github.com/autobrr/go-qbittorrent"
"github.com/autobrr/go-rtorrent"
delugeClient "github.com/gdm85/go-libdeluge"
"github.com/hekmon/transmissionrpc/v2"
"github.com/mrobinsn/go-rtorrent/rtorrent"
)
func (s *service) testConnection(ctx context.Context, client domain.DownloadClient) error {
@ -32,7 +32,7 @@ func (s *service) testConnection(ctx context.Context, client domain.DownloadClie
return s.testDelugeConnection(client)
case domain.DownloadClientTypeRTorrent:
return s.testRTorrentConnection(client)
return s.testRTorrentConnection(ctx, client)
case domain.DownloadClientTypeTransmission:
return s.testTransmissionConnection(ctx, client)
@ -135,17 +135,24 @@ func (s *service) testDelugeConnection(client domain.DownloadClient) error {
return nil
}
func (s *service) testRTorrentConnection(client domain.DownloadClient) error {
func (s *service) testRTorrentConnection(ctx context.Context, client domain.DownloadClient) error {
// create client
rt := rtorrent.New(client.Host, true)
name, err := rt.Name()
rt := rtorrent.NewClient(rtorrent.Config{
Addr: client.Host,
TLSSkipVerify: client.TLSSkipVerify,
BasicUser: client.Settings.Basic.Username,
BasicPass: client.Settings.Basic.Password,
Log: nil,
})
name, err := rt.Name(ctx)
if err != nil {
return errors.Wrap(err, "error logging into client: %v", client.Host)
return errors.Wrap(err, "error logging into client: %s", client.Host)
}
s.log.Trace().Msgf("test client connection for rTorrent: got client: %v", name)
s.log.Trace().Msgf("test client connection for rTorrent: got client: %s", name)
s.log.Debug().Msgf("test client connection for rTorrent: success")
s.log.Debug().Msg("test client connection for rTorrent: success")
return nil
}