2020-06-13 14:08:29 -04:00
|
|
|
package provider
|
|
|
|
|
|
|
|
|
|
import (
|
2020-10-12 10:55:08 -04:00
|
|
|
"context"
|
|
|
|
|
"net/http"
|
2023-05-20 19:58:18 +00:00
|
|
|
"net/netip"
|
2020-10-12 10:55:08 -04:00
|
|
|
|
2022-01-06 06:40:23 -05:00
|
|
|
"github.com/qdm12/gluetun/internal/configuration/settings"
|
2020-07-26 12:07:06 +00:00
|
|
|
"github.com/qdm12/gluetun/internal/models"
|
2021-09-23 16:58:21 +00:00
|
|
|
"github.com/qdm12/gluetun/internal/provider/utils"
|
2020-06-13 14:08:29 -04:00
|
|
|
)
|
|
|
|
|
|
2020-10-20 02:45:28 +00:00
|
|
|
// Provider contains methods to read and modify the openvpn configuration to connect as a client.
|
2020-06-13 14:08:29 -04:00
|
|
|
type Provider interface {
|
2022-09-12 21:31:37 +00:00
|
|
|
GetConnection(selection settings.ServerSelection, ipv6Supported bool) (connection models.Connection, err error)
|
2022-09-06 12:16:29 +00:00
|
|
|
OpenVPNConfig(connection models.Connection, settings settings.OpenVPN, ipv6Supported bool) (lines []string)
|
2022-06-07 16:58:08 +00:00
|
|
|
Name() string
|
2021-07-28 08:35:44 -07:00
|
|
|
PortForwarder
|
2022-06-09 23:47:12 +00:00
|
|
|
FetchServers(ctx context.Context, minServers int) (
|
|
|
|
|
servers []models.Server, err error)
|
2021-07-28 08:35:44 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type PortForwarder interface {
|
2020-10-12 10:55:08 -04:00
|
|
|
PortForward(ctx context.Context, client *http.Client,
|
2023-05-20 19:58:18 +00:00
|
|
|
logger utils.Logger, gateway netip.Addr, serverName string) (
|
2021-07-28 08:35:44 -07:00
|
|
|
port uint16, err error)
|
2023-06-30 20:09:44 +02:00
|
|
|
KeepPortForward(ctx context.Context, port uint16, gateway netip.Addr,
|
|
|
|
|
serverName string, _ utils.Logger) (err error)
|
2020-06-13 14:08:29 -04:00
|
|
|
}
|