endpoint

package
v0.0.0-...-4c8c030 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: AGPL-3.0 Imports: 36 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func KeyID

func KeyID(key []byte) string

Types

type AdminReader

type AdminReader interface {
	AdminDevices(context.Context, []byte, int, int) ([][]byte, error)
	AdminDeviceOverview(context.Context, []byte) ([]byte, error)
}

AdminReader keeps the administrator inventory separate from per-user device management.

type Authenticator

type Authenticator interface {
	Credential(*http.Request) (Credential, bool)
	Valid(context.Context, Credential) (bool, error)
}

type Credential

type Credential struct {
	UserID, Reference string
	ExpiresAt         time.Time
}

type Details

type Details struct {
	ClientType      *string `json:"client_type"`
	ClientName      *string `json:"client_name"`
	Channel         *string `json:"channel"`
	Locale          *string `json:"locale"`
	SystemLocale    *string `json:"system_locale"`
	Timezone        *string `json:"timezone"`
	RuntimeVersion  *string `json:"runtime_version"`
	EngineVersion   *string `json:"engine_version"`
	ElectronVersion *string `json:"electron_version"`
}

type DeviceAuthorizer

type DeviceAuthorizer interface {
	BindDevice(context.Context, pgx.Tx, identity.Principal, string, string) (bool, error)
	ConsumeRuntimeRestore(context.Context, pgx.Tx, identity.Principal) (bool, error)
	RevokeRuntimeGrant(context.Context, pgx.Tx, string, string, string) (bool, error)
	NotifyGrantRevoked(string)
	AuthorizeDevice(context.Context, pgx.Tx, identity.Principal, string) (bool, error)
}

type Endpoint

type Endpoint struct {
	View
	Status    string `json:"status"`
	CreatedAt int64  `json:"created_at"`
	UpdatedAt int64  `json:"updated_at"`
	RevokedAt *int64 `json:"revoked_at"`
	// contains filtered or unexported fields
}

type Enrollment

type Enrollment struct {
	Protocols      map[string][]int
	RuntimeVersion string
	EngineVersion  string
	MachineID      string
	PublicKey      []byte
	DisplayName    string
	Platform       string
	Arch           string
	Intent         string
	DeploymentMode string
	RestoreRevoked bool
}

type Execution

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

func NewExecution

func NewExecution(pool *pgxpool.Pool, auth DeviceAuthorizer) *Execution

func (*Execution) AuthenticateHost

func (e *Execution) AuthenticateHost(ctx context.Context, tx pgx.Tx, p identity.Principal, machineID string) (bool, error)

func (*Execution) Enroll

func (e *Execution) Enroll(ctx context.Context, p identity.Principal, in Enrollment, version int64) (ExecutionState, error)

func (*Execution) ReadState

func (e *Execution) ReadState(ctx context.Context, tx pgx.Tx, userID, machineID string) (ExecutionState, error)

func (*Execution) Revoke

func (e *Execution) Revoke(ctx context.Context, p identity.Principal, machineID string, version int64) (ExecutionState, error)

func (*Execution) Snapshot

func (e *Execution) Snapshot(ctx context.Context, userID string, executeOnly bool) ([]ExecutionState, error)

func (*Execution) State

func (e *Execution) State(ctx context.Context, userID, machineID string) (ExecutionState, error)

func (*Execution) VerifyDeviceRequest

func (e *Execution) VerifyDeviceRequest(ctx context.Context, tx pgx.Tx, user, machine string, public []byte) (bool, error)

type ExecutionState

type ExecutionState struct {
	Protocols           map[string][]int
	LastSeenAt          *time.Time
	RuntimeVersion      *string
	EngineVersion       *string
	MachineID           string
	DisplayName         string
	Platform            string
	Arch                string
	PublicKey           []byte
	KeyID               string
	RemoteAccessState   string
	DeploymentMode      string
	ActiveGrantID       string
	RegistrationVersion int64
	GrantVersion        int64
	LeaseEpoch          int64
}

type Hello

type Hello struct {
	Type      string  `json:"type"`
	Versions  []int   `json:"protocol_versions"`
	MachineID string  `json:"machine_id"`
	Profile   Profile `json:"profile"`
}

type Message

type Message struct {
	Type     string          `json:"type"`
	ID       string          `json:"message_id"`
	Target   string          `json:"target"`
	Method   string          `json:"method,omitempty"`
	ReplyTo  string          `json:"reply_to,omitempty"`
	Payload  json.RawMessage `json:"payload"`
	Source   string          `json:"source,omitempty"`
	RoutedAt int64           `json:"routed_at,omitempty"`
}

type Page

type Page struct {
	Items []Endpoint `json:"items"`
	Total int64      `json:"total"`
	Page  int        `json:"page"`
	Size  int        `json:"page_size"`
}

type Postgres

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

func NewPostgres

func NewPostgres(pool *pgxpool.Pool) *Postgres

func (*Postgres) Active

func (p *Postgres) Active(ctx context.Context, user string) ([]Endpoint, error)

func (*Postgres) AdminDeviceOverview

func (p *Postgres) AdminDeviceOverview(ctx context.Context, filters []byte) ([]byte, error)

func (*Postgres) AdminDevices

func (p *Postgres) AdminDevices(ctx context.Context, filters []byte, offset, limit int) ([][]byte, error)

func (*Postgres) Get

func (p *Postgres) Get(ctx context.Context, user, machine string) (Endpoint, error)

func (*Postgres) Page

func (p *Postgres) Page(ctx context.Context, user string, page, size int) (Page, error)

func (*Postgres) Register

func (p *Postgres) Register(ctx context.Context, user string, h Hello) (Endpoint, error)

func (*Postgres) RegisterDevice

func (p *Postgres) RegisterDevice(ctx context.Context, user, machine string, r Registration) (Endpoint, error)

func (*Postgres) Touch

func (p *Postgres) Touch(ctx context.Context, user, machine string, at time.Time) error

func (*Postgres) Update

func (p *Postgres) Update(ctx context.Context, user, machine, action string, alias *string) (Endpoint, error)

func (*Postgres) WithDeviceAuthorizer

func (p *Postgres) WithDeviceAuthorizer(auth DeviceAuthorizer) *Postgres

func (*Postgres) WithExecutionRevoker

func (p *Postgres) WithExecutionRevoker(revoke func(string, string, int64)) *Postgres

type Profile

type Profile struct {
	DeviceName    string `json:"device_name"`
	Platform      string `json:"platform"`
	OSVersion     string `json:"os_version"`
	Arch          string `json:"arch"`
	ClientVersion string `json:"client_version"`
}

type Registrar

type Registrar interface {
	RegisterDevice(context.Context, string, string, Registration) (Endpoint, error)
}

type Registration

type Registration struct {
	Profile
	Details
	ProtocolVersion *int32 `json:"protocol_version"`
}

type Service

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

func NewService

func NewService(store Store, auth Authenticator, logger *slog.Logger, publicURL string) *Service

func (*Service) Observe

func (s *Service) Observe(ctx context.Context)

func (*Service) Ready

func (s *Service) Ready() bool

func (*Service) RegisterAdmin

func (s *Service) RegisterAdmin(r chi.Router)

func (*Service) RegisterAgent

func (s *Service) RegisterAgent(router chi.Router)

func (*Service) Shutdown

func (s *Service) Shutdown(ctx context.Context) error

func (*Service) WithMaxConnections

func (s *Service) WithMaxConnections(n int) *Service

func (*Service) WithRuntimeDirectory

func (s *Service) WithRuntimeDirectory(handler http.Handler) *Service

type View

type View struct {
	MachineID string `json:"machine_id"`
	Registration
	Alias          *string `json:"alias"`
	DisplayName    string  `json:"display_name"`
	Online         bool    `json:"online"`
	LastSeenAt     *int64  `json:"last_seen_at"`
	LastReportedAt *int64  `json:"last_reported_at"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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