control

package
v0.0.0-...-af321b4 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2023 License: MPL-2.0 Imports: 64 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultFlowTopSize = 100
View Source
const DefaultListAccountsLimit = 100

Variables

View Source
var ErrBadAuthentication = errors.New("bad authentication information presented")
View Source
var ErrInvalidRequest = errors.New("invalid request")
View Source
var ErrLocked = errors.New("locked")
View Source
var LogPruneInterval = "6 hours"

Functions

func ExplodeLabelSetss

func ExplodeLabelSetss(in []string) []*pb.LabelSet

func ExplodeLabels

func ExplodeLabels(list string) *pb.LabelSet

func FlattenLabelSets

func FlattenLabelSets(sets []*pb.LabelSet) []string

func FlattenLabels

func FlattenLabels(labels *pb.LabelSet) string

func GenerateSelfSignedTLS

func GenerateSelfSignedTLS() (*tls.Certificate, error)

func K8SConfig

func K8SConfig(path string) (*rest.Config, error)

K8SConfig returns a *restclient.Config for initializing a K8S client. This configuration first attempts to load a local kubeconfig if a path is given. If that doesn't work, then in-cluster auth is used.

func NewConsulLockManager

func NewConsulLockManager(ctx context.Context) (*consulLockMgr, error)

Types

type Account

type Account struct {
	ID        []byte `gorm:"primary_key"`
	Namespace string

	Data sqljson.Data

	CreatedAt time.Time
	UpdatedAt time.Time
}

type ActivityInjector

type ActivityInjector struct {
	// contains filtered or unexported fields
}

func NewActivityInjector

func NewActivityInjector(db *gorm.DB) (*ActivityInjector, error)

func (*ActivityInjector) Inject

func (ai *ActivityInjector) Inject(ctx context.Context, v interface{}) error

type ActivityLog

type ActivityLog struct {
	Id        int64 `gorm:"primary_key"`
	Event     []byte
	CreatedAt time.Time
}

type ActivityReader

type ActivityReader struct {
	C chan []*ActivityLog
	// contains filtered or unexported fields
}

func NewActivityReader

func NewActivityReader(ctx context.Context, dbtype, conn string) (*ActivityReader, error)

func (*ActivityReader) Close

func (ar *ActivityReader) Close() error

type Client

type Client struct {
	L hclog.Logger
	// contains filtered or unexported fields
}

func NewClient

func NewClient(ctx context.Context, cfg ClientConfig) (*Client, error)

func (*Client) AddService

func (c *Client) AddService(ctx context.Context, serv *pb.ServiceRequest) error

func (*Client) AllHubs

func (c *Client) AllHubs(ctx context.Context) ([]*pb.HubInfo, error)

func (*Client) AuthToken

func (c *Client) AuthToken() string

func (*Client) BootstrapConfig

func (c *Client) BootstrapConfig(ctx context.Context) error

func (*Client) Close

func (c *Client) Close(ctx context.Context) error

func (*Client) ConnectToKubernetes

func (c *Client) ConnectToKubernetes() error

func (*Client) ForceLabelLinkUpdate

func (c *Client) ForceLabelLinkUpdate(ctx context.Context, L hclog.Logger) error

func (*Client) GetHubAddresses

func (c *Client) GetHubAddresses(ctx context.Context, id *pb.ULID) ([]*pb.NetworkLocation, error)

func (*Client) Id

func (c *Client) Id() *pb.ULID

func (*Client) LearnLocations

func (c *Client) LearnLocations(def *pb.LabelSet) ([]*pb.NetworkLocation, error)

func (*Client) Locations

func (c *Client) Locations() []*pb.NetworkLocation

func (*Client) LookupService

func (c *Client) LookupService(ctx context.Context, account *pb.Account, labels *pb.LabelSet) (*RouteCalculation, error)

func (*Client) NumLocalServices

func (c *Client) NumLocalServices() int

func (*Client) RemoveService

func (c *Client) RemoveService(ctx context.Context, serv *pb.ServiceRequest) error

func (*Client) RequestServiceToken

func (c *Client) RequestServiceToken(ctx context.Context, namespace string) (string, error)
func (c *Client) ResolveLabelLink(label *pb.LabelSet) (*pb.Account, *pb.LabelSet, *pb.Account_Limits, error)

func (*Client) Run

func (c *Client) Run(ctx context.Context) error

func (*Client) RunIngress

func (c *Client) RunIngress(ctx context.Context, li net.Listener, npn map[string]NPNHandler, h http.Handler) error

func (*Client) SendFlow

func (c *Client) SendFlow(rec *pb.FlowRecord)

func (*Client) SetLocations

func (c *Client) SetLocations(netloc []*pb.NetworkLocation)

func (*Client) StableId

func (c *Client) StableId() *pb.ULID

func (*Client) TokenPub

func (c *Client) TokenPub() ed25519.PublicKey

type ClientConfig

type ClientConfig struct {
	Logger     hclog.Logger
	InstanceId *pb.ULID
	Id         *pb.ULID
	GRPCConn   *grpc.ClientConn
	Client     pb.ControlServicesClient
	Token      string
	Addr       string
	Version    string
	S3Bucket   string
	Session    *session.Session
	WorkDir    string
	Insecure   bool

	// The kubernetes deployment name used for the service using this client
	K8Deployment string

	// Where hub integrates it's handler for the hzn protocol
	NextProto map[string]func(hs *http.Server, tlsConn *tls.Conn, h http.Handler)

	FilterRoute        func(*pb.ServiceRoute) bool
	InsecureSkipVerify bool
}

type FlowTop

type FlowTop struct {
	// contains filtered or unexported fields
}

func NewFlowTop

func NewFlowTop(count int) (*FlowTop, error)

func (*FlowTop) Add

func (f *FlowTop) Add(rec *pb.FlowStream)

func (*FlowTop) Export

func (f *FlowTop) Export() ([]*FlowTopEntry, error)

type FlowTopEntry

type FlowTopEntry struct {
	// contains filtered or unexported fields
}

type Hub

type Hub struct {
	StableID   []byte `gorm:"primary_key"`
	InstanceID []byte

	ConnectionInfo []byte
	LastCheckin    time.Time

	CreatedAt time.Time
}

func (*Hub) StableIdULID

func (h *Hub) StableIdULID() *pb.ULID
type LabelLink struct {
	ID int `gorm:"primary_key"`

	Account   *Account
	AccountID []byte

	Labels string
	Target string

	CreatedAt time.Time
	UpdatedAt time.Time
}

type LockManager

type LockManager interface {
	GetLock(id, val string) (io.Closer, error)
	GetValue(id string) (string, error)
}

Returns a lock for the given id.

type LogCleaner

type LogCleaner struct {
	DB *gorm.DB
}

func (*LogCleaner) CleanupActivityLog

func (l *LogCleaner) CleanupActivityLog(ctx context.Context, jobType string, _ *struct{}) error

type ManagementClient

type ManagementClient struct {
	ID        []byte `gorm:"primary_key"`
	Namespace string
}

type NPNHandler

type NPNHandler func(hs *http.Server, c *tls.Conn, h http.Handler)

type Peer

type Peer struct {
	PublicKey []byte
}

type RouteCalculation

type RouteCalculation struct {
	All  []*pb.ServiceRoute
	Best []*pb.ServiceRoute
	// contains filtered or unexported fields
}

func (*RouteCalculation) Empty

func (c *RouteCalculation) Empty() bool

func (*RouteCalculation) FindBest

func (c *RouteCalculation) FindBest()

func (*RouteCalculation) Services

func (c *RouteCalculation) Services() []*pb.ServiceRoute

type Server

type Server struct {
	L hclog.Logger
	// contains filtered or unexported fields
}

func NewServer

func NewServer(cfg ServerConfig) (*Server, error)

func (*Server) AddAccount

func (s *Server) AddAccount(ctx context.Context, req *pb.AddAccountRequest) (*pb.Noop, error)
func (s *Server) AddLabelLink(ctx context.Context, req *pb.AddLabelLinkRequest) (*pb.Noop, error)

func (*Server) AddService

func (s *Server) AddService(ctx context.Context, service *pb.ServiceRequest) (*pb.ServiceResponse, error)

func (*Server) AllHubs

func (s *Server) AllHubs(ctx context.Context, _ *pb.Noop) (*pb.ListOfHubs, error)

func (*Server) CreateToken

func (s *Server) CreateToken(ctx context.Context, req *pb.CreateTokenRequest) (*pb.CreateTokenResponse, error)

func (*Server) CurrentFlowTop

func (s *Server) CurrentFlowTop(ctx context.Context, req *pb.FlowTopRequest) (*pb.FlowTopSnapshot, error)

func (*Server) FetchConfig

func (s *Server) FetchConfig(ctx context.Context, req *pb.ConfigRequest) (*pb.ConfigResponse, error)

func (*Server) GetAllNetworkLocations

func (s *Server) GetAllNetworkLocations() ([]*pb.NetworkLocation, error)

func (*Server) GetManagementToken

func (s *Server) GetManagementToken(ctx context.Context, namespace string) (string, error)

func (*Server) GetTokenPublicKey

func (s *Server) GetTokenPublicKey(ctx context.Context, _ *pb.Noop) (*pb.TokenInfo, error)

For management clients to be able valid horizon tokens themselves without having to ask the control tier. This allows management clients to piggy back their authentication off the horizon tokens as well.

func (*Server) HubDisconnect

func (s *Server) HubDisconnect(ctx context.Context, req *pb.HubDisconnectRequest) (*pb.Noop, error)

func (*Server) IssueHubToken

func (s *Server) IssueHubToken(ctx context.Context, _ *pb.Noop) (*pb.CreateTokenResponse, error)

func (*Server) ListAccounts

func (s *Server) ListAccounts(ctx context.Context, req *pb.ListAccountsRequest) (*pb.ListAccountsResponse, error)

func (*Server) ListServices

func (s *Server) ListServices(ctx context.Context, req *pb.ListServicesRequest) (*pb.ListServicesResponse, error)

func (*Server) LookupEndpoints

func (s *Server) LookupEndpoints(ctx context.Context, req *pb.LookupEndpointsRequest) (*pb.LookupEndpointsResponse, error)

func (*Server) Register

func (s *Server) Register(ctx context.Context, reg *pb.ControlRegister) (*pb.ControlToken, error)
func (s *Server) RemoveLabelLink(ctx context.Context, req *pb.RemoveLabelLinkRequest) (*pb.Noop, error)

func (*Server) RemoveService

func (s *Server) RemoveService(ctx context.Context, service *pb.ServiceRequest) (*pb.ServiceResponse, error)

func (*Server) RequestServiceToken

func (s *Server) RequestServiceToken(ctx context.Context, req *pb.ServiceTokenRequest) (*pb.ServiceTokenResponse, error)
func (s *Server) ResolveLabelLink(ctx context.Context, req *pb.ResolveLabelLinkRequest) (*pb.ResolveLabelLinkResponse, error)

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, req *http.Request)

func (*Server) SetHubTLS

func (s *Server) SetHubTLS(cert, key []byte, domain string)

func (*Server) StartActivityReader

func (s *Server) StartActivityReader(ctx context.Context, dbtype, conn string) error

func (*Server) StreamActivity

func (s *Server) StreamActivity(stream pb.ControlServices_StreamActivityServer) error

func (*Server) SyncHub

func (s *Server) SyncHub(ctx context.Context, sync *pb.HubSync) (*pb.HubSyncResponse, error)

func (*Server) TokenPub

func (s *Server) TokenPub() ed25519.PublicKey

type ServerConfig

type ServerConfig struct {
	DB *gorm.DB

	Logger hclog.Logger

	RegisterToken string
	OpsToken      string

	VaultClient *api.Client
	VaultPath   string
	KeyId       string

	// If no vault client is specified, this is used instead.
	SigningKey ed25519.PrivateKey

	AwsSession *session.Session
	Bucket     string

	ASNDB string

	HubAccessKey string
	HubSecretKey string

	// The docker image that hubs should be used, this is advertised to the hubs
	// so they can act on it.
	HubImageTag string

	DataDogAddr       string
	DisablePrometheus bool

	LockManager LockManager
}

type Service

type Service struct {
	ID int64 `gorm:"primary_key"`

	ServiceId []byte

	HubId []byte

	Account   *Account
	AccountId []byte

	Type        string
	Description string
	Labels      pq.StringArray

	CreatedAt time.Time
	UpdatedAt time.Time
}

Jump to

Keyboard shortcuts

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