Documentation
¶
Index ¶
- func BuildClientArchive(name string, ovpn OpenVPNServer, rsa EasyRSA, publicAddresses ...string) (string, error)
- func BuildSimpleDebian(server string, targetDir string) (EasyRSA, OpenVPNServer, error)
- type ClientKeyFiles
- type EasyRSA
- func (er EasyRSA) BuildAllServerKeys() error
- func (er EasyRSA) BuildClientKeys(name string) (ClientKeyFiles, error)
- func (er EasyRSA) BuildDH() error
- func (er EasyRSA) BuildKeyCa() error
- func (er EasyRSA) BuildKeyServer() error
- func (er EasyRSA) CleanAll() error
- func (er EasyRSA) HomeDir() string
- func (er EasyRSA) KeyFiles() KeyFiles
- func (er EasyRSA) KeysDir() string
- func (er EasyRSA) PkiTool() string
- type KeyFiles
- type KeyPair
- type OpenVPNServer
- func (ovpn OpenVPNServer) AddStaticIP(client string, ip string) error
- func (ovpn OpenVPNServer) BaseCACertFile() string
- func (ovpn OpenVPNServer) BaseTLSKeyFile() string
- func (ovpn OpenVPNServer) BuildClientConf(targetDir string, clientCert, clientKey string) error
- func (ovpn *OpenVPNServer) BuildTLSKey(keysDir string) error
- func (ovpn OpenVPNServer) CheckRequiredFields() error
- func (ovpn OpenVPNServer) InitialConfig(targetDir string) error
- func (ovpn OpenVPNServer) ListStaticIP() (map[string]string, error)
- func (ovpn OpenVPNServer) RemoveStaticIP(client string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildClientArchive ¶
func BuildClientArchive(name string, ovpn OpenVPNServer, rsa EasyRSA, publicAddresses ...string) (string, error)
Create client archive (ZIP) whith all required files: CA, cert, key and configuration
func BuildSimpleDebian ¶
func BuildSimpleDebian(server string, targetDir string) (EasyRSA, OpenVPNServer, error)
Create server configuration with defaults for DEBIAN systems Generates config into targetDir for specified server
Types ¶
type ClientKeyFiles ¶
type EasyRSA ¶
type EasyRSA struct { BinDir string // Home of easy-rsa tools KeyDir string // Location of key files KeySize int // Diffie-Hellman key size CaExpire int // CA expires in day KeyExpire int // Server key expires in day Server string // Server name Province string CountryCode string City string State string Organization string Email string }
func DefaultEasyRSA ¶
Get default Easy-rsa instance
func (EasyRSA) BuildAllServerKeys ¶
Clean all and generate CA, server and Diffie-Hellman keys
func (EasyRSA) BuildClientKeys ¶
func (er EasyRSA) BuildClientKeys(name string) (ClientKeyFiles, error)
Make a certificate/private key pair using a locally generated root certificate.
Returns list of all generated files
func (EasyRSA) BuildDH ¶
Build Diffie-Hellman parameters for the server side of an SSL/TLS connection.
func (EasyRSA) BuildKeyServer ¶
Make a certificate/private key pair using a locally generated root certificate.
Explicitly set nsCertType to server using the "server" extension in the openssl.cnf file.
func (EasyRSA) HomeDir ¶
Home directory of easy-rsa tools. Returns default Debian location if not present
type OpenVPNServer ¶
type OpenVPNServer struct { LocalAddr string // Bind to specific local address. Optional Addresses []string // Public addresses of server. Required for client configuration Port uint16 // Public port Protocol string // Network protocol. Could be tcp or udp Keys KeyFiles // Keys files generated by easy-rsa: CA, server.key and e.t.c. PersistIPFile string // List of clients and their static ips. Optional TlsKey string // Location of TLS key. Automatically sets after BuildTLSKey(). If set, server and clients config will use TLS ClientToClient bool // Enable client to client communication }
func OpenServerConf ¶
func OpenServerConf(serverConf string) (OpenVPNServer, error)
Read necessary parameters from OpenSSL server configuration file
func (OpenVPNServer) AddStaticIP ¶
func (ovpn OpenVPNServer) AddStaticIP(client string, ip string) error
Append static ip for client to PersistIPFile. It doesn't check unique (use ListStaticIP before)
func (OpenVPNServer) BaseCACertFile ¶
func (ovpn OpenVPNServer) BaseCACertFile() string
Base file name of CA certificate
func (OpenVPNServer) BaseTLSKeyFile ¶
func (ovpn OpenVPNServer) BaseTLSKeyFile() string
Base file name of TLS key
func (OpenVPNServer) BuildClientConf ¶
func (ovpn OpenVPNServer) BuildClientConf(targetDir string, clientCert, clientKey string) error
Create client configuration based on easy-rsa keys. It copies (really it links) all required files into targetDir and creates client.conf
func (*OpenVPNServer) BuildTLSKey ¶
func (ovpn *OpenVPNServer) BuildTLSKey(keysDir string) error
Create TLS key into keysDir as ta.key file and sets TlsKey property. This enables TLS connection for server and future clients
func (OpenVPNServer) CheckRequiredFields ¶
func (ovpn OpenVPNServer) CheckRequiredFields() error
Check required parameters like port, protocol and others
func (OpenVPNServer) InitialConfig ¶
func (ovpn OpenVPNServer) InitialConfig(targetDir string) error
Create initial server configuration file into targetDir
func (OpenVPNServer) ListStaticIP ¶
func (ovpn OpenVPNServer) ListStaticIP() (map[string]string, error)
Read and parse PersistIPFile - list of client and static ip pairs
func (OpenVPNServer) RemoveStaticIP ¶
func (ovpn OpenVPNServer) RemoveStaticIP(client string) error
Read, parse, exclude client and save PersistIPFile