config

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CompressionStub adds the (empty) compression stub to the packets.
	CompressionStub = Compression("stub")

	// CompressionEmpty is the empty compression.
	CompressionEmpty = Compression("empty")

	// CompressionLZONo is lzo-no (another type of no-compression, older).
	CompressionLZONo = Compression("lzo-no")
)
View Source
const ProtoTCP = Proto("tcp")

ProtoTCP is used for vpn in TCP mode.

View Source
const ProtoUDP = Proto("udp")

ProtoUDP is used for vpn in UDP mode.

Variables

View Source
var ErrBadConfig = errors.New("openvpn: bad config")

ErrBadConfig is the generic error returned for invalid config files

View Source
var SupportedAuth = []string{
	"SHA1",
	"SHA256",
	"SHA512",
}

SupportedAuth defines the supported authentication methods.

View Source
var SupportedCiphers = []string{
	"AES-128-CBC",
	"AES-192-CBC",
	"AES-256-CBC",
	"AES-128-GCM",
	"AES-192-GCM",
	"AES-256-GCM",
}

SupportedCiphers defines the supported ciphers.

Functions

This section is empty.

Types

type Compression

type Compression string

Compression describes a Compression type (e.g., stub).

type Config

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

Config contains options to initialize the OpenVPN tunnel.

func NewConfig

func NewConfig(options ...Option) *Config

NewConfig returns a Config ready to intialize a vpn tunnel.

func (*Config) Logger

func (c *Config) Logger() model.Logger

Logger returns the configured logger.

func (*Config) OpenVPNOptions

func (c *Config) OpenVPNOptions() *OpenVPNOptions

OpenVPNOptions returns the configured openvpn options.

func (*Config) Remote

func (c *Config) Remote() *Remote

Remote returns the OpenVPN remote.

func (*Config) Tracer

func (c *Config) Tracer() model.HandshakeTracer

Tracer returns the handshake tracer.

type OpenVPNOptions

type OpenVPNOptions struct {
	// These options have the same name of OpenVPN options referenced in the official documentation:
	Remote    string
	Port      string
	Proto     Proto
	Username  string
	Password  string
	CAPath    string
	CertPath  string
	KeyPath   string
	CA        []byte
	Cert      []byte
	Key       []byte
	Cipher    string
	Auth      string
	TLSMaxVer string

	Compress   Compression
	ProxyOBFS4 string
}

OpenVPNOptions make all the relevant openvpn configuration options accessible to the different modules that need it.

func ReadConfigFile

func ReadConfigFile(filePath string) (*OpenVPNOptions, error)

ReadConfigFile expects a string with a path to a valid config file, and returns a pointer to a Options struct after parsing the file, and an error if the operation could not be completed.

func (*OpenVPNOptions) HasAuthInfo

func (o *OpenVPNOptions) HasAuthInfo() bool

HasAuthInfo returns true if: - we have paths for cert, key and ca; or - we have inline byte arrays for cert, key and ca; or - we have username + password info. TODO(ainghazal): add sanity checks for valid/existing credentials.

func (*OpenVPNOptions) ServerOptionsString

func (o *OpenVPNOptions) ServerOptionsString() string

ServerOptionsString produces a comma-separated representation of the options, in the same order and format that the OpenVPN server expects from us.

func (*OpenVPNOptions) ShouldLoadCertsFromPath

func (o *OpenVPNOptions) ShouldLoadCertsFromPath() bool

ShouldLoadCertsFromPath returns true when the options object is configured to load certificates from paths; false when we have inline certificates.

type Option

type Option func(config *Config)

Option is an option you can pass to initialize minivpn.

func WithConfigFile

func WithConfigFile(configPath string) Option

WithConfigFile configures OpenVPNOptions parsed from the given file.

func WithHandshakeTracer

func WithHandshakeTracer(tracer model.HandshakeTracer) Option

WithHandshakeTracer configures the passed [HandshakeTracer].

func WithLogger

func WithLogger(logger model.Logger) Option

WithLogger configures the passed [Logger].

func WithOpenVPNOptions

func WithOpenVPNOptions(openvpnOptions *OpenVPNOptions) Option

WithOpenVPNOptions configures the passed OpenVPN options.

type Proto

type Proto string

Proto is the main vpn mode (e.g., TCP or UDP).

func (Proto) String

func (p Proto) String() string

String implements fmt.Stringer

type Remote

type Remote struct {
	// IPAddr is the IP Address for the remote.
	IPAddr string

	// Endpoint is in the form ip:port.
	Endpoint string

	// Protocol is either "tcp" or "udp"
	Protocol string
}

Remote has info about the OpenVPN remote, useful to pass to the external dialer.

Jump to

Keyboard shortcuts

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