Skip to content

Commit

Permalink
build: update to transmissionrpc v3
Browse files Browse the repository at this point in the history
  • Loading branch information
Michsior14 committed Nov 30, 2023
1 parent fff1da4 commit d97e119
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ go 1.21

require (
github.com/go-resty/resty/v2 v2.10.0
github.com/hekmon/transmissionrpc/v2 v2.0.1
github.com/hekmon/transmissionrpc/v3 v3.0.0
)

Expand Down
3 changes: 1 addition & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9n
github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48=
github.com/hekmon/cunits/v2 v2.1.0 h1:k6wIjc4PlacNOHwKEMBgWV2/c8jyD4eRMs5mR1BBhI0=
github.com/hekmon/cunits/v2 v2.1.0/go.mod h1:9r1TycXYXaTmEWlAIfFV8JT+Xo59U96yUJAYHxzii2M=
github.com/hekmon/transmissionrpc/v2 v2.0.1 h1:WkILCEdbNy3n/N/w7mi449waMPdH2AA1THyw7TfnN/w=
github.com/hekmon/transmissionrpc/v2 v2.0.1/go.mod h1:+s96Pkg7dIP3h2PT3fzhXPvNb3OdLryh5J8PIvQg3aA=
github.com/hekmon/transmissionrpc/v3 v3.0.0 h1:0Fb11qE0IBh4V4GlOwHNYpqpjcYDp5GouolwrpmcUDQ=
github.com/hekmon/transmissionrpc/v3 v3.0.0/go.mod h1:38SlNhFzinVUuY87wGj3acOmRxeYZAZfrj6Re7UgCDg=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
Expand Down
16 changes: 12 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import (
"flag"
"fmt"
"log"
"net/url"
"os"
"time"

"github.com/go-resty/resty/v2"
"github.com/hekmon/transmissionrpc/v2"
"github.com/hekmon/transmissionrpc/v3"
)

type GluetunResponse struct {
Expand Down Expand Up @@ -50,10 +51,17 @@ func main() {
time.Sleep(initialDelay)

httpClient := resty.New()
transmissionClient, err := transmissionrpc.New(*transmissionHostname, transmissionUsername, transmissionPassword, &transmissionrpc.AdvancedConfig{
Port: uint16(*transmissionPort),
})
authInfo := ""
if transmissionUsername != "" && transmissionPassword != "" {
authInfo = fmt.Sprintf("%s:%s@", transmissionUsername, transmissionPassword)
}

endpoint, err := url.Parse(fmt.Sprintf("http://%s%s:%d/transmission/rpc", authInfo, *transmissionHostname, *transmissionPort))
if err != nil {
log.Fatalf("failed to parse transmission endpoint: %v", err)
}

transmissionClient, err := transmissionrpc.New(endpoint, nil)
if err != nil {
log.Fatalf("failed to create transmission client: %v", err)
}
Expand Down

0 comments on commit d97e119

Please sign in to comment.