Documentation ¶
Index ¶
- Constants
- type Server
- func (s *Server) ActionConnect(n, l, r string)
- func (s *Server) ActionDisconnect(n, l string, d time.Duration)
- func (s *Server) AddClientOption(client, value string) error
- func (s *Server) AddNotify(email, events string) error
- func (s *Server) AddOption(value string, push, config bool)
- func (s *Server) CRL() error
- func (s *Server) ChangeName(n string) error
- func (s *Server) Init(m manager) *Server
- func (s *Server) NewClient(name, email string, days int) ([]byte, *pki.Certificate, []byte, error)
- func (s *Server) Pid() uint64
- func (s *Server) Print(w writer)
- func (s *Server) Reload(b []byte) error
- func (s *Server) RemoveClientOption(client, value string) error
- func (s *Server) RemoveNotify(email string)
- func (s *Server) RemoveOption(value string, push, config bool)
- func (s *Server) Renew() error
- func (s *Server) Restart() error
- func (s *Server) Running() bool
- func (s *Server) Start() error
- func (s *Server) Status() ([]Status, error)
- func (s *Server) Stop() error
- type Status
Constants ¶
const ( TCP = protocol(true) UDP = protocol(false) )
Protocol Type Constants
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Server ¶
type Server struct { CA *pki.Authority `json:"ca"` Config struct { Override struct { Client string `json:"client,omitempty"` Server string `json:"server,omitempty"` } `json:"override"` Notify []notification `json:"notify,omitempty"` Options []option `json:"options,omitempty"` Limits struct { Max uint16 `json:"max_clients"` KeepAlive struct { Timeout uint16 `json:"timeout"` Interval uint16 `json:"interval"` } `json:"keep_alive"` } `json:"limits"` Auto bool `json:"autostart"` } `json:"config"` Service struct { Clients map[string][]string `json:"client_config,omitempty"` Hostname string `json:"hostname"` Auth struct { File string `json:"file,omitempty"` Data []byte `json:"data,omitempty"` } `json:"auth"` Port uint16 `json:"port"` Protocol protocol `json:"protocol"` } `json:"server"` DH struct { File string `json:"file,omitempty"` Data []byte `json:"data,omitempty"` Size uint16 `json:"size"` } `json:"dh"` ID string `json:"id"` Network struct { Range struct { End string `json:"end,omitempty"` Mask string `json:"mask"` Base string `json:"base"` Start string `json:"start,omitempty"` } `json:"range"` Saved []string `json:"saved,omitempty"` Crosstalk bool `json:"crosstalk"` } `json:"network"` // contains filtered or unexported fields }
Server is a struct that contains the configuration information for a OpenVPN server. This can be used to control a running server or start a new one.
func Load ¶
Load will create and set up the initial properties of a Server struct from the provided arguments and the data contained in the JSON byte array. This function returns any errors made during reading/parsing.
func (*Server) ActionConnect ¶
ActionConnect is a function that will send out the connect notification email.
func (*Server) ActionDisconnect ¶
ActionDisconnect is a function that will send out the disconnect notification email.
func (*Server) AddClientOption ¶
AddClientOption will add the specified value into a client specific config for the server.
The changes will be effective immediately and do NOT require a server restart.
func (*Server) AddNotify ¶
AddNotify will add the email address to the server to be notified on the supplied events. This function returns an error if the event names are not valid.
Empty events are considered to be "all".
func (*Server) AddOption ¶
AddOption will add the server option value to appear in the generated configuration files and profiles. The push option will add the option as a "push" value and config will add the value to each newly generated client profile.
The changes will be applied on a server restart.
func (*Server) CRL ¶
CRL will attempt to generate the CRL file for this Server. This will also send any emails for notifications that are configured.
func (*Server) ChangeName ¶
ChangeName will attempt to renew the Server's certificate with a new hostname.
func (*Server) Init ¶
Init is a function only to called on a newly created server instance. This sets up the un-exported properties of the struct. This function returns the server instance.
func (*Server) NewClient ¶
NewClient will generate the client key material based on the server TLS data and will return the VPN profile as a byte array
func (*Server) Pid ¶
Pid returns the Server process ID. If the server is not running, this function returns zero.
func (*Server) Print ¶
func (s *Server) Print(w writer)
Print will write the server details to the specified writer.
func (*Server) Reload ¶
Reload will update the Server's info with the new data supplied. This function will trigger a certificate renew if the hostname changes.
func (*Server) RemoveClientOption ¶
RemoveClientOption will remove the specified value from a client specific config for the server.
The changes will be effective immediately and do NOT require a server restart.
func (*Server) RemoveNotify ¶
RemoveNotify will remove the email address associated with any notification events, if it exists.
func (*Server) RemoveOption ¶
RemoveOption will attempt to remove the specified option value from the server. This function will need to match the original push and config values in order to remove the correct option.
func (*Server) Restart ¶
Restart will gracefully stop the server and save any stored IP options in the struct. Once complete, this function will regenerate the server configuration files and will start up the server.
func (*Server) Start ¶
Start will begin the process of creating the server directory, generating the server config and starting the primary server process.