Documentation ¶
Overview ¶
Package client contains code for OC-Daemon clients.
Index ¶
- Variables
- func SystemConfig() string
- func UserConfig() string
- type Client
- type Config
- type DBusClient
- func (d *DBusClient) Authenticate() error
- func (d *DBusClient) Close() error
- func (d *DBusClient) Connect() error
- func (d *DBusClient) Disconnect() error
- func (d *DBusClient) GetConfig() *Config
- func (d *DBusClient) GetEnv() []string
- func (d *DBusClient) GetLogin() *logininfo.LoginInfo
- func (d *DBusClient) Ping() error
- func (d *DBusClient) Query() (*vpnstatus.Status, error)
- func (d *DBusClient) SetConfig(config *Config)
- func (d *DBusClient) SetEnv(env []string)
- func (d *DBusClient) SetLogin(login *logininfo.LoginInfo)
- func (d *DBusClient) Subscribe() (chan *vpnstatus.Status, error)
Constants ¶
This section is empty.
Variables ¶
var ( // ConfigName is the name of the configuration file. ConfigName = "oc-client.json" // ConfigDirName is the name of the directory where the configuration // file is stored. ConfigDirName = "oc-daemon" // SystemConfigDirPath is the path of the directory where the directory // of the system configuration is stored. SystemConfigDirPath = "/var/lib" // OpenConnect is the openconnect executable. OpenConnect = "openconnect" // Protocol is the protocol used by openconnect. Protocol = "anyconnect" // UserAgent is the user agent used by openconnect. UserAgent = "AnyConnect" // Quiet specifies whether the quiet flag is set in openconnect. Quiet = true // NoProxy specifies whether the no proxy flag is set in openconnect. NoProxy = true // ExtraEnv are extra environment variables used by openconnect. ExtraEnv = []string{} // ExtraArgs are extra command line arguments used by openconnect. ExtraArgs = []string{} )
Functions ¶
func SystemConfig ¶
func SystemConfig() string
SystemConfig returns the default file path of the system configuration.
func UserConfig ¶
func UserConfig() string
UserConfig returns the default file path of the current user's configuration.
Types ¶
type Client ¶
type Client interface { SetConfig(config *Config) GetConfig() *Config SetEnv(env []string) GetEnv() []string SetLogin(login *logininfo.LoginInfo) GetLogin() *logininfo.LoginInfo Ping() error Query() (*vpnstatus.Status, error) Subscribe() (chan *vpnstatus.Status, error) Authenticate() error Connect() error Disconnect() error Close() error }
Client is an OC-Daemon client.
type Config ¶
type Config struct { ClientCertificate string ClientKey string UserCertificate string UserKey string CACertificate string XMLProfile string VPNServer string User string Password string `json:"-"` OpenConnect string Protocol string UserAgent string Quiet bool NoProxy bool ExtraEnv []string ExtraArgs []string }
Config is a configuration for the OC client.
func LoadConfig ¶
LoadConfig loads a Config from file.
func LoadUserSystemConfig ¶
func LoadUserSystemConfig() *Config
LoadUserSystemConfig loads the user or system configuration from its default location, expands variables in config.
type DBusClient ¶
type DBusClient struct {
// contains filtered or unexported fields
}
DBusClient is an OC-Daemon client that uses the D-Bus API of OC-Daemon.
func NewDBusClient ¶
func NewDBusClient(config *Config) (*DBusClient, error)
NewDBusClient returns a new DBusClient.
func (*DBusClient) Authenticate ¶
func (d *DBusClient) Authenticate() error
Authenticate authenticates the client on the VPN server.
func (*DBusClient) Connect ¶
func (d *DBusClient) Connect() error
Connect connects the client with the VPN server, requires successful authentication with Authenticate.
func (*DBusClient) Disconnect ¶
func (d *DBusClient) Disconnect() error
Disconnect disconnects the client from the VPN server.
func (*DBusClient) GetConfig ¶
func (d *DBusClient) GetConfig() *Config
GetConfig returns the client config.
func (*DBusClient) GetEnv ¶
func (d *DBusClient) GetEnv() []string
GetEnv returns the additional environment variables.
func (*DBusClient) GetLogin ¶
func (d *DBusClient) GetLogin() *logininfo.LoginInfo
GetLogin returns the login information.
func (*DBusClient) Ping ¶
func (d *DBusClient) Ping() error
Ping pings the OC-Daemon to check if it is running.
func (*DBusClient) Query ¶
func (d *DBusClient) Query() (*vpnstatus.Status, error)
Query retrieves the VPN status.
func (*DBusClient) SetConfig ¶
func (d *DBusClient) SetConfig(config *Config)
SetConfig sets the client config.
func (*DBusClient) SetEnv ¶
func (d *DBusClient) SetEnv(env []string)
SetEnv sets additional environment variables.
func (*DBusClient) SetLogin ¶
func (d *DBusClient) SetLogin(login *logininfo.LoginInfo)
SetLogin sets the login information.