utils

package
v0.0.0-...-1e25372 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 10, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrFetcherNotSupported = errors.New("fetching of servers is not supported")
View Source
var ErrNoConnectionToPickFrom = errors.New("no connection to pick from")

Functions

func BuildWireguardSettings

func BuildWireguardSettings(connection models.Connection,
	userSettings settings.Wireguard, ipv6Supported bool) (settings wireguard.Settings)

func CipherLines

func CipherLines(ciphers []string) (lines []string)

func GetConnection

func GetConnection(provider string,
	storage Storage,
	selection settings.ServerSelection,
	defaults ConnectionDefaults,
	ipv6Supported bool,
	randSource rand.Source) (
	connection models.Connection, err error)

func OpenVPNConfig

func OpenVPNConfig(provider OpenVPNProviderSettings,
	connection models.Connection,
	settings settings.OpenVPN, ipv6Supported bool) []string

func WrapOpenvpnCA

func WrapOpenvpnCA(certificate string) (lines []string)

func WrapOpenvpnCRLVerify

func WrapOpenvpnCRLVerify(x509CRL string) (lines []string)

func WrapOpenvpnCert

func WrapOpenvpnCert(clientCertificate string) (lines []string)

func WrapOpenvpnEncryptedKey

func WrapOpenvpnEncryptedKey(encryptedKey string) (lines []string)

func WrapOpenvpnKey

func WrapOpenvpnKey(clientKey string) (lines []string)

func WrapOpenvpnRSAKey

func WrapOpenvpnRSAKey(rsaPrivateKey string) (lines []string)

func WrapOpenvpnTLSAuth

func WrapOpenvpnTLSAuth(staticKeyV1 string) (lines []string)

func WrapOpenvpnTLSCrypt

func WrapOpenvpnTLSCrypt(staticKeyV1 string) (lines []string)

Types

type ConnectionDefaults

type ConnectionDefaults struct {
	OpenVPNTCPPort uint16
	OpenVPNUDPPort uint16
	WireguardPort  uint16
}

func NewConnectionDefaults

func NewConnectionDefaults(openvpnTCPPort, openvpnUDPPort,
	wireguardPort uint16) ConnectionDefaults

type Logger

type Logger interface {
	Debug(s string)
	Info(s string)
	Warn(s string)
	Error(s string)
}

type NoFetcher

type NoFetcher struct {
	// contains filtered or unexported fields
}

func NewNoFetcher

func NewNoFetcher(providerName string) *NoFetcher

func (*NoFetcher) FetchServers

func (n *NoFetcher) FetchServers(context.Context, int) (
	servers []models.Server, err error)

type OpenVPNProviderSettings

type OpenVPNProviderSettings struct {
	Ping          int
	RemoteCertTLS bool
	Ciphers       []string
	Auth          string
	CAs           []string
	CRLVerify     string
	Cert          string
	Key           string
	RSAKey        string
	TLSAuth       string
	TLSCrypt      string
	MssFix        uint16
	FastIO        bool
	AuthUserPass  bool
	AuthToken     bool
	Fragment      uint16
	SndBuf        uint32
	RcvBuf        uint32
	// VerifyX509Name can be set to a custom name to verify against.
	// Note VerifyX509Type has to be set for it to be verified.
	// If it is left unset, the code will deduce a name to verify against
	// using the connection hostname and according to VerifyX509Type.
	VerifyX509Name string
	// VerifyX509Type can be "name-prefix", "name"
	VerifyX509Type string
	TLSCipher      string
	TunMTU         uint16
	TunMTUExtra    uint16
	RenegDisabled  bool
	RenegSec       uint16
	KeyDirection   string
	SetEnv         map[string]string
	ExtraLines     []string
	UDPLines       []string
	IPv6Lines      []string
}

type PortForwardObjects

type PortForwardObjects struct {
	// Logger is a logger, used by both Private Internet Access and ProtonVPN.
	Logger Logger
	// Gateway is the VPN gateway IP address, used by Private Internet Access
	// and ProtonVPN.
	Gateway netip.Addr
	// Client is used to query the VPN gateway for Private Internet Access.
	Client *http.Client
	// ServerName is used by Private Internet Access for port forwarding.
	ServerName string
	// CanPortForward is used by Private Internet Access for port forwarding.
	CanPortForward bool
}

PortForwardObjects contains fields that may or may not need to be set depending on the port forwarding provider code.

type Routing

type Routing interface {
	VPNLocalGatewayIP(vpnInterface string) (gateway netip.Addr, err error)
}

type Storage

type Storage interface {
	FilterServers(provider string, selection settings.ServerSelection) (
		servers []models.Server, err error)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL