Documentation ¶
Index ¶
- Constants
- Variables
- func Bootstrap()
- func NewClient(openvpnBinary, scriptDir, runtimeDir string, ...) (connection.Connection, error)
- func SignatureCredentialsProvider(sessionID session.ID, signer identity.Signer) func() (username string, password string, err error)
- type Client
- func (c *Client) GetConfig() (connection.ConsumerConfig, error)
- func (c *Client) OnStats(cnt openvpn_bytescount.Bytecount) error
- func (c *Client) Reconnect(ctx context.Context, options connection.ConnectOptions) error
- func (c *Client) Start(ctx context.Context, options connection.ConnectOptions) error
- func (c *Client) State() <-chan connectionstate.State
- func (c *Client) Statistics() (connectionstate.Statistics, error)
- func (c *Client) Stop()
- type ClientConfig
- type ConfigValidator
- type ConsumerConfig
- type VPNConfig
- type ValidateConfig
Constants ¶
const AuthSignaturePrefix = "MystVpnSessionId:"
AuthSignaturePrefix is used to prefix with each session string before calculating signature or extracting identity
const ServiceType = "openvpn"
ServiceType indicates "openvpn" service type
Variables ¶
var ErrProcessNotStarted = errors.New("process not started yet")
ErrProcessNotStarted represents the error we return when the process is not started yet
Functions ¶
func Bootstrap ¶
func Bootstrap()
Bootstrap is called on program initialization time and registers various deserializers related to OpenVPN service
func NewClient ¶
func NewClient(openvpnBinary, scriptDir, runtimeDir string, signerFactory identity.SignerFactory, ipResolver ip.Resolver, ) (connection.Connection, error)
NewClient creates a new openvpn connection
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client takes in the openvpn process and works with it
func (*Client) GetConfig ¶
func (c *Client) GetConfig() (connection.ConsumerConfig, error)
GetConfig returns the consumer-side configuration.
func (*Client) OnStats ¶
func (c *Client) OnStats(cnt openvpn_bytescount.Bytecount) error
OnStats updates connection statistics.
func (*Client) Reconnect ¶
func (c *Client) Reconnect(ctx context.Context, options connection.ConnectOptions) error
Reconnect restarts a connection with a new options.
func (*Client) Start ¶
func (c *Client) Start(ctx context.Context, options connection.ConnectOptions) error
Start starts the connection
func (*Client) State ¶
func (c *Client) State() <-chan connectionstate.State
State returns connection state channel.
func (*Client) Statistics ¶
func (c *Client) Statistics() (connectionstate.Statistics, error)
Statistics returns connection statistics channel.
type ClientConfig ¶
type ClientConfig struct { *config.GenericConfig VpnConfig *VPNConfig }
ClientConfig represents specific "openvpn as client" configuration
func NewClientConfigFromSession ¶
func NewClientConfigFromSession(vpnConfig VPNConfig, scriptDir string, runtimeDir string, options connection.ConnectOptions) (*ClientConfig, error)
NewClientConfigFromSession creates client configuration structure for given VPNConfig, configuration dir to store serialized file args, and configuration filename to store other args TODO this will become the part of openvpn service consumer separate package
func (*ClientConfig) SetClientMode ¶
func (c *ClientConfig) SetClientMode(serverIP string, serverPort, localPort int)
SetClientMode adds config arguments for openvpn behave as client
func (*ClientConfig) SetProtocol ¶
func (c *ClientConfig) SetProtocol(protocol string)
SetProtocol specifies openvpn connection protocol type (tcp or udp)
type ConfigValidator ¶
type ConfigValidator struct {
// contains filtered or unexported fields
}
ConfigValidator represents structure which contains list of validating functions
func NewDefaultValidator ¶
func NewDefaultValidator() *ConfigValidator
NewDefaultValidator returns ConfigValidator with predefined list of validating functions
func (*ConfigValidator) IsValid ¶
func (v *ConfigValidator) IsValid(config VPNConfig) error
IsValid function checks if provided config is valid against given config validator and returns first encountered error
type ConsumerConfig ¶
ConsumerConfig is used for sending some configuration from consumer to provider
type VPNConfig ¶
type VPNConfig struct { DNSIPs string `json:"dns_ips"` RemoteIP string `json:"remote"` RemotePort int `json:"port"` LocalPort int `json:"lport"` Ports []int `json:"ports"` RemoteProtocol string `json:"protocol"` CACertificate string `json:"CACertificate"` }
VPNConfig structure represents VPN configuration options for given session
func FormatTLSPresharedKey ¶
FormatTLSPresharedKey formats preshared key (PEM blocks with data encoded to hex) are taken from openvpn --genkey --secret static.key, which is openvpn specific. it reformats key from single line to multiline fixed length strings.
type ValidateConfig ¶
ValidateConfig is function which takes VPNConfig as argument, checks it and returns error if validation fails