util

package
v0.0.39 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateClientFromConfig

func CreateClientFromConfig(ConfigFile []string) (*router.Client, error)

CreateClientFromConfig creates a client from `ConfigFile`.

func CreateClientFromNetConfig added in v0.0.22

func CreateClientFromNetConfig(ClientConfig *ClientConfig) (*router.Client, error)

CreateClientFromNetConfig creates a client from `ClientConfig`.

func CreateListenerFromConfig

func CreateListenerFromConfig(ConfigFile []string, ListenChannel string) (*router.Listener, error)

CreateListenerFromConfig creates a listener on `ListenChannel` from `ConfigFile`.

func CreateListenerFromNetConfig added in v0.0.22

func CreateListenerFromNetConfig(ClientConfig *ClientConfig, ListenChannel string) (*router.Listener, error)

CreateListenerFromNetConfig creates a listener on `ListenChannel` from `ClientConfig`.

func CreateOrLoadKeyStore

func CreateOrLoadKeyStore(tokenFile string) (*keystore.KeyStore, error)

CreateOrLoadKeyStore loads a KeyStore from `tokenFile`. If this file does not exist, a new config will be generated. If `tokenFile` is empty, a (nil, nil) will be returned indicating no permission check will be performed.

func LoadClientTLSConfig

func LoadClientTLSConfig(ConfigFile []string) (string, *tls.Config, error)

LoadClientTLSConfig returns only the RouterAddress and TLSConfig part from `ConfigFile`.

func LoadRouterTLSConfig

func LoadRouterTLSConfig(config *ClientConfig) (*tls.Config, error)

LoadRouterTLSConfig returns the tls config used by a router. If `EnableTLS` is false, a nil will be returned.

func MakeClientTLSConfig added in v0.0.39

func MakeClientTLSConfig(Certificates []tls.Certificate, CAPool *x509.CertPool, ServerName string) *tls.Config

MakeClientTLSConfig creates a TLS config for client and listener.

Types

type ClientConfig

type ClientConfig struct {
	// RouterAddress is the network address of the Router.
	RouterAddress string `json:"router-address"`

	// EnableTLS -- If true, `CaCert`, `ClientCert` and `ClientKey` will be used to communicate with the Router. Must be the same to the router.
	EnableTLS bool `json:"tls"`

	// CaCert stores the filename to load a PEM CA cert. Used for server authentication.
	CaCert string `json:"ca-file"`

	// ServerNameOverride overrides the server name used for the client to authenticate the Router if not empty.
	ServerNameOverride string `json:"server-name"`

	// CertFile stores the filename to the client's cert file in PEM format, used for providing an identity to the server.
	CertFile string `json:"cert-file"`

	// KeyFile stores the filename to the client's key file in PEM format.
	KeyFile string `json:"key-file"`

	// TokenFile provides the Router extra ACL control in application layer.
	TokenFile string `json:"token-file"`
	// contains filtered or unexported fields
}

ClientConfig stores the configuration to connect to the Router network.

func LoadNetConfig added in v0.0.15

func LoadNetConfig(ConfigFile []string) (*ClientConfig, error)

LoadNetConfig loads client configuration from `ConfigFile`, returns any error encountered.

func LoadNetConfigRaw added in v0.0.39

func LoadNetConfigRaw(ConfigFile string) (*ClientConfig, error)

LoadNetConfigRaw loads a configuration from a json file.

func LoadNetConfigZip added in v0.0.39

func LoadNetConfigZip(ConfigFile string) (*ClientConfig, error)

LoadNetConfigZip loads a configuration from a zip file.

Jump to

Keyboard shortcuts

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