common

package
v0.0.0-...-aa46c71 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2019 License: GPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateCACert

func CreateCACert(cn string) (cert string, key string, err error)

CreateCACert creates a certificate authority.

func CreateClientCert

func CreateClientCert(ca *tls.Certificate, cn string, days int) (cert string, key string, err error)

CreateClientCert creates a client authentication cert from a certificate authority.

func CreateServerCert

func CreateServerCert(ca *tls.Certificate, cn string, hosts []string, days int) (cert string, key string, err error)

CreateServerCert creates a server cert from a certificate authority.

func DirExists

func DirExists(path string) bool

DirExists returns whether the path exists and is a directory.

func Exists

func Exists(path string) bool

Exists returns whether the path exists.

func FileExists

func FileExists(path string) bool

FileExists returns whether the path exists and is a plain file.

func HostIP

func HostIP() string

HostIP returns the primary IP address of the machine.

func HostToIP

func HostToIP(host string) net.IP

HostToIP resolves a hostname/IP to an IP (if possible).

func IsLocalHost

func IsLocalHost(host string) bool

IsLocalHost returns whether the given host resolves within a local IP range.

func IsLocalIP

func IsLocalIP(ip net.IP) bool

IsLocalIP returns whether the given IP is within a local IP range.

func IsPrivateHost

func IsPrivateHost(host string) bool

IsPrivateHost returns whether the given host resolves within a IANA private IP range.

func IsPrivateIP

func IsPrivateIP(ip net.IP) bool

IsPrivateIP returns whether the given IP is within a IANA private IP range.

func LoadCertificate

func LoadCertificate(certEnc, keyEnc string) (crt *tls.Certificate, err error)

LoadCertificate will load a TLS certificate from the provided base 64 encoded derBytes.

func Logger

func Logger() grpclog.LoggerV2

Logger returns the global logger.

func Pemify

func Pemify(variant string, data []byte) []byte

Pemify returns a PEM formatted version of the derBytes provided.

func RunCmd

func RunCmd(name string, args ...string) error

RunCmd runs the command you tell it to.

func SetLogger

func SetLogger(log grpclog.LoggerV2)

SetLogger sets the global logger.

func TLSCertKey

func TLSCertKey(crt *tls.Certificate) (cert, key string)

TLSCertKey returns the cert and key derBytes from the certificate.

Types

type Config

type Config struct {
	Server      string                   `json:"server,omitempty"`
	Names       []string                 `json:"names,omitempty"`
	Root        string                   `json:"root,omitempty"`
	Authority   *ConfigCertificate       `json:"authority,omitempty"`
	Certificate *ConfigCertificate       `json:"certificate,omitempty"`
	Brokers     map[string]*ConfigBroker `json:"brokers,omitempty"`
	// contains filtered or unexported fields
}

Config contains the config file details.

func LoadConfig

func LoadConfig(log grpclog.LoggerV2, filename string) (*Config, error)

LoadConfig reads the passed in config filename, parses it and returns the config object.

func (*Config) CertPool

func (c *Config) CertPool() (pool *x509.CertPool, err error)

CertPool returns a pool of certificates that we will trust for connections.

func (*Config) ClientCert

func (c *Config) ClientCert(days int) (crt *tls.Certificate, err error)

ClientCert returns a valid client certificate (or generates one if possible and none available).

func (*Config) Log

func (c *Config) Log() grpclog.LoggerV2

Log returns the logger that things running from this config should use to output info.

func (*Config) ServerCert

func (c *Config) ServerCert(days int) (crt *tls.Certificate, err error)

ServerCert returns a valid server certificate (or generates one if possible and none available).

type ConfigBroker

type ConfigBroker struct {
	Kind   string              `json:"kind,omitempty"`
	Config ConfigBrokerConfigs `json:"config,omitempty"`
}

ConfigBroker specifies the broker kind for the config file.

type ConfigBrokerConfigs

type ConfigBrokerConfigs struct {
	Default    StringMap            `json:"default,omitempty"`
	Namespaced map[string]StringMap `json:"namespaced,omitempty"`
}

ConfigBrokerConfigs contains the broker configuration for the config file.

type ConfigCertificate

type ConfigCertificate struct {
	CA   string `json:"ca,omitempty"`
	Cert string `json:"cert,omitempty"`
	Key  string `json:"key,omitempty"`
}

ConfigCertificate contains the certificate details for the config file.

type CynoError

type CynoError struct {
	Err error
	Msg string
}

CynoError can wrap a generic error with our own messages.

func Error

func Error(err error, msg string, args ...interface{}) *CynoError

Error wraps a generic error with our own message.

func ErrorMsg

func ErrorMsg(msg string, args ...interface{}) *CynoError

ErrorMsg returns our message as an error.

func (*CynoError) Error

func (e *CynoError) Error() string

Error returns the error from our CynoError (making it an `error` object).

type ObjMap

type ObjMap map[string]interface{}

ObjMap is a map[string]interface{} that has a JSON method.

func (*ObjMap) JSON

func (o *ObjMap) JSON() string

JSON returns the json encoded string from the map (or "").

type StringMap

type StringMap map[string]string

StringMap is a map[string]string that has a JSON method.

func (*StringMap) JSON

func (o *StringMap) JSON() string

JSON returns the json encoded string from the map (or "").

Jump to

Keyboard shortcuts

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