ziti

package
v0.18.3 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2022 License: Apache-2.0 Imports: 33 Imported by: 86

Documentation

Overview

Package ziti provides methods for loading ziti contexts from identity JSON files Identity files specifies in `ZITI_IDENTITIES` environment variable (semicolon separates) are loaded automatically at startup

Index

Constants

View Source
const (
	LatencyCheckInterval = 30 * time.Second
	LatencyCheckTimeout  = 10 * time.Second
)
View Source
const (
	PrecedenceDefault  Precedence = 0
	PrecedenceRequired Precedence = 1
	PrecedenceFailed   Precedence = 2

	PrecedenceDefaultLabel  = "default"
	PrecedenceRequiredLabel = "required"
	PrecedenceFailedLabel   = "failed"
)
View Source
const (
	MfaProviderZiti = "ziti"
)

Variables

View Source
var DefaultOptions = &Options{
	RefreshInterval: 5 * time.Minute,
	OnServiceUpdate: nil,
}

Functions

func ForAllContexts added in v0.17.0

func ForAllContexts(f func(ctx Context) bool)

ForAllContexts iterates over all Ziti contexts loaded from ZITI_IDENTITIES environment variable, or with LoadContext() call

func SetAppInfo added in v0.15.11

func SetAppInfo(appId, appVersion string)

SetAppInfo sets the `appId` and `appVersion` to provide in SDK Information during all Ziti context authentications

func SetApplication added in v0.15.24

func SetApplication(theAppId, theAppVersion string)

Types

type Context

type Context interface {
	Authenticate() error
	GetCurrentIdentity() (*edge.CurrentIdentity, error)
	Dial(serviceName string) (edge.Conn, error)
	DialWithOptions(serviceName string, options *DialOptions) (edge.Conn, error)
	// DialAddr finds the service for given address and creates a connection to it
	DialAddr(network string, addr string) (edge.Conn, error)
	Listen(serviceName string) (edge.Listener, error)
	ListenWithOptions(serviceName string, options *ListenOptions) (edge.Listener, error)
	GetServiceId(serviceName string) (string, bool, error)
	GetServices() ([]edge.Service, error)
	GetService(serviceName string) (*edge.Service, bool)

	// GetServiceForAddr finds the service with intercept that matches best to given address
	GetServiceForAddr(network, hostname string, port uint16) (*edge.Service, int, error)
	RefreshServices() error
	GetServiceTerminators(serviceName string, offset, limit int) ([]*edge.Terminator, int, error)
	GetSession(id string) (*edge.Session, error)

	Metrics() metrics.Registry
	// Close closes any connections open to edge routers
	Close()

	// Add a Ziti MFA handler, invoked during authentication
	AddZitiMfaHandler(handler func(query *edge.AuthQuery, resp func(code string) error) error)
	EnrollZitiMfa() (*api.MfaEnrollment, error)
	VerifyZitiMfa(code string) error
	RemoveZitiMfa(code string) error

	Reload() error
}

func LoadContext added in v0.17.0

func LoadContext(config_ string) (Context, error)

LoadContext returns Ziti context for the given identity file loading it if needed

func NewContext

func NewContext() Context

func NewContextWithConfig

func NewContextWithConfig(cfg *config.Config) Context

func NewContextWithOpts added in v0.13.0

func NewContextWithOpts(cfg *config.Config, options *Options) Context

type ContextDialer added in v0.17.0

type ContextDialer interface {
	DialContext(ctx context.Context, network, address string) (net.Conn, error)
}

type ContextImplTest added in v0.15.32

type ContextImplTest struct {
	Context
}

func (*ContextImplTest) GetApiSession added in v0.15.32

func (self *ContextImplTest) GetApiSession() (*edge.ApiSession, error)

func (*ContextImplTest) GetPostureCache added in v0.15.32

func (self *ContextImplTest) GetPostureCache() (*posture.Cache, error)

func (*ContextImplTest) GetSessions added in v0.15.32

func (self *ContextImplTest) GetSessions() ([]*edge.Session, error)

type DialOptions added in v0.13.47

type DialOptions struct {
	ConnectTimeout time.Duration
	Identity       string
	AppData        []byte
}

func (DialOptions) GetConnectTimeout added in v0.13.47

func (d DialOptions) GetConnectTimeout() time.Duration

type Dialer added in v0.17.0

type Dialer interface {
	Dial(network, address string) (net.Conn, error)
}

func NewDialer added in v0.17.0

func NewDialer() Dialer

func NewDialerWithFallback added in v0.17.0

func NewDialerWithFallback(ctx context.Context, fallback Dialer) Dialer

type ListenOptions added in v0.13.47

type ListenOptions struct {
	Cost                  uint16
	Precedence            Precedence
	ConnectTimeout        time.Duration
	MaxConnections        int
	Identity              string
	BindUsingEdgeIdentity bool
	ManualStart           bool
}

func DefaultListenOptions added in v0.13.47

func DefaultListenOptions() *ListenOptions

type Options added in v0.15.17

type Options struct {
	RefreshInterval time.Duration
	OnContextReady  func(ctx Context)
	OnServiceUpdate serviceCB
}

type Precedence added in v0.13.47

type Precedence byte

func GetPrecedenceForLabel added in v0.15.3

func GetPrecedenceForLabel(p string) Precedence

func (Precedence) String added in v0.15.3

func (p Precedence) String() string

type ServiceEventType added in v0.15.17

type ServiceEventType string
const (
	ServiceAdded   ServiceEventType = "Added"
	ServiceRemoved ServiceEventType = "Removed"
	ServiceChanged ServiceEventType = "Changed"
)

Directories

Path Synopsis
api

Jump to

Keyboard shortcuts

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