Documentation
¶
Overview ¶
Package fshttp contains the common http parts of the config, Transport and Client
Index ¶
- Variables
- func LoadKeyPair(certFile, keyFile, password string) (cert tls.Certificate, err error)
- func NewClient(ctx context.Context) *http.Client
- func NewClientCustom(ctx context.Context, customize func(*http.Transport)) *http.Client
- func NewClientWithUnixSocket(ctx context.Context, path string) *http.Client
- func ResetTransport()
- type Dialer
- type Metrics
- type Transport
Constants ¶
This section is empty.
Variables ¶
var DefaultMetrics = (*Metrics)(nil)
DefaultMetrics specifies metrics used for new Transports.
var ( // UnixSocketConfig describes the option to configure the path to a unix domain socket to connect to UnixSocketConfig = fs.Option{ Name: "unix_socket", Help: "Path to a unix domain socket to dial to, instead of opening a TCP connection directly", Advanced: true, Default: "", } )
Functions ¶
func LoadKeyPair ¶
func LoadKeyPair(certFile, keyFile, password string) (cert tls.Certificate, err error)
LoadKeyPair loads a TLS certificate and private key from PEM-encoded files, with extended support for encrypted private keys.
This function is designed as a robust replacement for tls.X509KeyPair, providing the same core functionality but adding support for password-protected private keys.
The certificate file (certFile) must contain one or more PEM-encoded certificates. The first certificate is treated as the leaf certificate, and any subsequent certificates are treated as its chain.
The key file (keyFile) must contain a PEM-encoded private key. Supported formats are:
- Unencrypted PKCS#1 ("BEGIN RSA PRIVATE KEY")
- Unencrypted PKCS#8 ("BEGIN PRIVATE KEY")
- Encrypted PKCS#8 ("BEGIN ENCRYPTED PRIVATE KEY")
- Legacy PEM encryption (e.g., DEK-Info headers), which are automatically detected.
The password parameter is used to decrypt the private key. If the key is not encrypted, this parameter is ignored and can be an empty string. The password should be an obscured string.
On success, it returns a fully populated tls.Certificate struct, including the Leaf certificate field.
func NewClientCustom ¶
NewClientCustom returns an http.Client with the correct timeouts. It allows customizing the transport, using NewTransportCustom.
func NewClientWithUnixSocket ¶
NewClientWithUnixSocket returns an http.Client with the correct timeout. It internally uses NewClientCustom with a custom dialer connecting to the specified unix domain socket.
func ResetTransport ¶
func ResetTransport()
ResetTransport resets the existing transport, allowing it to take new settings. Should only be used for testing.
Types ¶
type Dialer ¶
Dialer structure contains default dialer and timeout, tclass support
func NewDialer ¶
NewDialer creates a Dialer structure with Timeout, Keepalive, LocalAddr and DSCP set from rclone flags.
type Metrics ¶
type Metrics struct {
StatusCode *prometheus.CounterVec
}
Metrics provide Transport HTTP level metrics.
func NewMetrics ¶
NewMetrics creates a new metrics instance, the instance shall be assigned to DefaultMetrics before any processing takes place.
func (*Metrics) Collectors ¶
func (m *Metrics) Collectors() []prometheus.Collector
Collectors returns all prometheus metrics as collectors for registration.
type Transport ¶
Transport is our http Transport which wraps an http.Transport * Sets the User Agent * Does logging * Updates metrics
func NewTransport ¶
NewTransport returns an http.RoundTripper with the correct timeouts
func NewTransportCustom ¶
NewTransportCustom returns an http.RoundTripper with the correct timeouts. The customize function is called if set to give the caller an opportunity to customize any defaults in the Transport.
func (*Transport) SetRequestFilter ¶
SetRequestFilter sets a filter to be used on each request