Files
gluetun/internal/provider/provider.go
Quentin McGaw 0378fe4a7b chore(all): Providers containing all provider objects
- Share the same providers for updater and vpn
- Initialise all providers at start
- Get from `Providers` instead of constructing on every run
2022-06-10 00:47:56 +00:00

31 lines
1017 B
Go

// Package provider defines interfaces to interact with each VPN provider.
package provider
import (
"context"
"net"
"net/http"
"github.com/qdm12/gluetun/internal/configuration/settings"
"github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/internal/provider/utils"
)
// Provider contains methods to read and modify the openvpn configuration to connect as a client.
type Provider interface {
GetConnection(selection settings.ServerSelection) (connection models.Connection, err error)
OpenVPNConfig(connection models.Connection, settings settings.OpenVPN) (lines []string)
Name() string
PortForwarder
FetchServers(ctx context.Context, minServers int) (
servers []models.Server, err error)
}
type PortForwarder interface {
PortForward(ctx context.Context, client *http.Client,
logger utils.Logger, gateway net.IP, serverName string) (
port uint16, err error)
KeepPortForward(ctx context.Context, client *http.Client,
port uint16, gateway net.IP, serverName string) (err error)
}