ipc

package
v3.12.0 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// client-to-server commands
	CmdEnroll = "enroll"
	CmdAttest = "attest"
	CmdSetLog = "setLog"

	// server-to-client commands
	CmdEnrollReply = "enrollReply"
	CmdAttestReply = "attestReply"
	CmdLog         = "log"
	CmdHello       = "hello"
	CmdBusy        = "busy"
)

Variables

View Source
var (
	ErrProtocol = errors.New("protocol error")
	ErrBusy     = errors.New("server busy") // can not grant exclusive access for requested command right now
)

Functions

func ConnectNamedPipe

func ConnectNamedPipe(ctx context.Context, stdLogOut io.Writer) (*Client, *CmdArgsHello, error)

func GetSharedLog

func GetSharedLog(baseLogger *zerolog.Logger, w1, w2 io.Writer, l1, l2 zerolog.Level) *zerolog.Logger

GetSharedLog gets a shared logger that sends log output over log sinks both using different levels

func StartNamedPipe

func StartNamedPipe(ctx context.Context, stdLogOut io.Writer, agentResource *SharedAgentResource, serviceBuildId *string) error

Types

type AgentServiceStatus

type AgentServiceStatus struct {
	Enrolled      bool       `json:"enrolled"`
	OpRunning     bool       `json:"op_running"`
	LastOperation string     `json:"last_op,omitempty"`
	LastResult    string     `json:"last_result,omitempty"`
	LastRun       *time.Time `json:"last_run,omitempty"`
}

AgentServiceStatus is atomically updated when an op begins or ends when an op begins the op name is set, last result is cleared and running is set to true when an op ends the result is set and op running is set to false

type Client

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

Client represents a once connected IPC client; all public methods are thread-safe

func (*Client) Attest

func (cl *Client) Attest(args CmdArgsAttest) (*CmdArgsAttestReply, error)

Attest tries to attest the remote attestation client with exclusive access returns ErrBusy when exclusive access fails when protocol is violated it will call Shutdown()

func (*Client) Enroll

func (cl *Client) Enroll(args CmdArgsEnroll) (*CmdArgsEnrollReply, error)

Enroll tries to enroll the remote attestation client with exclusive access returns ErrBusy when exclusive access fails when protocol is violated it will call Shutdown()

func (*Client) Shutdown

func (cl *Client) Shutdown()

Shutdown winds down the server and closes the underlying connection

type CmdArgsAttest

type CmdArgsAttest struct {
	DryRun bool `json:"dry_run"`
}

CmdArgsAttest wraps cli arguments for attest command

type CmdArgsAttestReply

type CmdArgsAttestReply struct {
	Status string `json:"status,omitempty"`
}

CmdArgsAttestReply wraps attestation return values in the future this can be extended with a report dump and the SaaS' response

type CmdArgsEnroll

type CmdArgsEnroll struct {
	Server   *url.URL `json:"server,omitempty"`
	Token    string   `json:"token"`
	DummyTPM bool     `json:"dummy_tpm"`
	TPMPath  string   `json:"tpm_path,omitempty"`
}

CmdArgsEnroll wraps cli arguments for enrollment command

type CmdArgsEnrollReply

type CmdArgsEnrollReply struct {
	Status string `json:"status,omitempty"`
}

CmdArgsEnrollReply wraps enrollment return values

type CmdArgsHello

type CmdArgsHello struct {
	ProtocolVersion int                `json:"version"`
	BuildId         string             `json:"build"`
	Status          AgentServiceStatus `json:"status"`
}

CmdArgsHello tells connecting clients the protocol version, server release id and status

type CmdArgsSetLog

type CmdArgsSetLog struct {
	LogLevel zerolog.Level `json:"log_level"`
}

CmdArgsSetLog configures the server-to-client logger

type Message

type Message struct {
	Command string          `json:"cmd"`
	Data    json.RawMessage `json:"data,omitempty"`
}

type SharedAgentResource

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

func NewSharedAgent

func NewSharedAgent(agent *core.AttestationClient) *SharedAgentResource

func (*SharedAgentResource) Status

func (*SharedAgentResource) TryAttest

func (a *SharedAgentResource) TryAttest(ctx context.Context, logger *zerolog.Logger, arguments *CmdArgsAttest) (bool, error)

TryAttest tries to get exclusive access to a shared agent to run the attest operation if logger argument is not nil it will be used for logging during the operation returns false if exclusive access was not possible

func (*SharedAgentResource) TryEnroll

func (a *SharedAgentResource) TryEnroll(ctx context.Context, logger *zerolog.Logger, arguments *CmdArgsEnroll) (bool, error)

TryEnroll tries to get exclusive access to a shared agent to run the enroll operation if logger argument is not nil it will be used for logging during the operation returns false if exclusive access was not possible

Jump to

Keyboard shortcuts

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