feat: download clients skip tls verify option (#181)

This commit is contained in:
Ludvig Lundgren 2022-03-17 20:57:27 +01:00 committed by GitHub
parent 8bf43dc1e0
commit bb9e51f9d3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 166 additions and 150 deletions

View file

@ -2,6 +2,7 @@ package qbittorrent
import (
"bytes"
"crypto/tls"
"fmt"
"io"
"mime/multipart"
@ -32,12 +33,13 @@ type Client struct {
}
type Settings struct {
Hostname string
Port uint
Username string
Password string
SSL bool
protocol string
Hostname string
Port uint
Username string
Password string
TLS bool
TLSSkipVerify bool
protocol string
}
func NewClient(s Settings) *Client {
@ -58,10 +60,19 @@ func NewClient(s Settings) *Client {
}
c.settings.protocol = "http"
if c.settings.SSL {
if c.settings.TLS {
c.settings.protocol = "https"
}
if c.settings.TLSSkipVerify {
//skip TLS verification
tr := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
c.http.Transport = tr
}
return c
}