autopilotserver

package
v0.12.4-alpha Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const Subsystem = "AUTO"

Variables

View Source
var ErrVersionIncompatible = fmt.Errorf("litd version is not compatible " +
	"with the minimum version required by the autopilot server")

ErrVersionIncompatible is returned when the minimum Lit version required by the autopilot server exceeds the version of this binary.

Functions

func UseLogger

func UseLogger(logger btclog.Logger)

UseLogger uses a specified Logger to output package logging info. This should be used in preference to SetLogWriter if the caller is also using btclog.

Types

type Autopilot

type Autopilot interface {
	// ListFeatures fetches the set of features offered by the autopilot
	// server along with all the rules and permissions required for those
	// features.
	ListFeatures(ctx context.Context) (map[string]*Feature, error)

	// ListFeaturePerms returns a map of feature names to a map of
	// permissions required for each feature. This call uses an in-memory
	// store that is updated periodically and so this should be used instead
	// of the ListFeatures call if only the permissions are required to
	// avoid doing multiple calls to the autopilot server. The ListFeatures
	// call can however be used to force the update of the in-memory list.
	ListFeaturePerms(ctx context.Context) (map[string]map[string]bool,
		error)

	// RegisterSession attempts to register a session with the autopilot
	// server. If the registration is successful, then the Client will also
	// track the session so that it can continuously ensure that the session
	// remains active.
	RegisterSession(ctx context.Context, pubKey *btcec.PublicKey,
		mailboxAddr string, devServer bool,
		featureConf map[string][]byte, linkedGroupKey *btcec.PublicKey,
		linkSig []byte) (*btcec.PublicKey, error)

	// ActivateSession attempts to inform the autopilot server that the
	// given session is still active. After this is called, the autopilot
	// client will periodically ensure that the session remains active.
	// The boolean returned is true if the error received was permanent
	// meaning that the session should be revoked and recreated.
	ActivateSession(ctx context.Context, pubKey *btcec.PublicKey) (bool,
		error)

	// SessionRevoked should be called when a session is no longer active
	// so that the client can forget the session.
	SessionRevoked(ctx context.Context, key *btcec.PublicKey)

	// Start kicks off the goroutines of the client.
	Start(opts ...func(cfg *Config)) error

	// Stop cleans up any resources held by the client.
	Stop()
}

Autopilot represents the functionality exposed by an autopilot server.

func NewClient

func NewClient(cfg *Config) (Autopilot, error)

NewClient returns a autopilot-server client.

type Client

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

Client is a client connection to the autopilot server.

func (*Client) ActivateSession

func (c *Client) ActivateSession(ctx context.Context, pubKey *btcec.PublicKey) (
	bool, error)

ActivateSession attempts to inform the autopilot server that the given session is still active. It also adds the session to the list tracked by the client so that the Client can ensure that the session remains active on the autopilot side.

Note: this is part of the Autopilot interface.

func (*Client) ListFeaturePerms

func (c *Client) ListFeaturePerms(_ context.Context) (
	map[string]map[string]bool, error)

ListFeaturePerms returns contents of the in-memory feature permissions list if it has been populated.

func (*Client) ListFeatures

func (c *Client) ListFeatures(ctx context.Context) (map[string]*Feature,
	error)

ListFeatures queries the autopilot server for all the features it has available.

Note: this is part of the Autopilot interface.

func (*Client) RegisterSession

func (c *Client) RegisterSession(ctx context.Context, pubKey *btcec.PublicKey,
	mailboxAddr string, devServer bool, featureConf map[string][]byte,
	groupKey *btcec.PublicKey, linkSig []byte) (*btcec.PublicKey, error)

RegisterSession attempts to register a session with the autopilot server. If the registration is successful, then the Client will also track the session so that it can continuously ensure that the session remains active.

Note: this is part of the Autopilot interface.

func (*Client) SessionRevoked

func (c *Client) SessionRevoked(ctx context.Context, pubKey *btcec.PublicKey)

SessionRevoked removes a session from the list of active sessions managed by the client.

Note: this is part of the Autopilot interface.

func (*Client) Start

func (c *Client) Start(opts ...func(cfg *Config)) error

Start kicks off all the goroutines required by the Client.

func (*Client) Stop

func (c *Client) Stop()

Stop cleans up any resources or goroutines managed by the Client.

type Config

type Config struct {
	// Disable will disable the autopilot client.
	Disable bool `long:"disable" description:"disable the autopilot client"`

	// Address is the domain:port of the autopilot server.
	Address string `long:"address" description:"autopilot server address host:port"`

	// Proxy is the SOCKS proxy that should be used to establish the
	// connection.
	Proxy string `` /* 136-byte string literal not displayed */

	// Insecure signals that no TLS should be used if set to true.
	Insecure bool `long:"insecure" description:"disable tls"`

	// TLSPath is the path to a local file that holds the autopilot
	// server's TLS certificate. This is only needed if the server is using
	// a self-signed cert.
	TLSPath string `long:"tlspath" description:"Path to autopilot server tls certificate"`

	// PingCadence determines how often the Autopilot client should
	// re-register an existing session with the Autopilot server to ensure
	// that the Autopilot server knows that the session is active.
	PingCadence time.Duration `long:"pingcadence" description:"How often the client should ensure that registered Autopilot sessions are active"`

	// DialOpts is a list of additional options that should be used when
	// dialing the gRPC connection.
	DialOpts []grpc.DialOption

	// LitVersion is the version of the Lit binary.
	LitVersion Version

	// LndVersion is the version of the connected LND binary.
	LndVersion Version
}

Config holds the configuration options for the autopilot server client.

type Feature

type Feature struct {
	// Name is the name of the feature.
	Name string

	// Description is a human-readable description of what the feature
	// offers
	Description string

	// Permissions is a list of RPC methods and access writes a feature
	// will need.
	Permissions map[string][]bakery.Op

	// Rules is a list of all the firewall that must be specified for this
	// feature.
	Rules map[string]*RuleValues

	// DefaultConfig is a JSON-serialized configuration of the feature. It
	// represents the default configuration we can use if the user doesn't
	// specify any.
	DefaultConfig []byte
}

Feature holds all the info necessary to subscribe to a feature offered by the autopilot server.

type RuleValues

type RuleValues struct {
	Default []byte
	MinVal  []byte
	MaxVal  []byte
}

RuleValues holds the default value along with the sane max and min values that the autopilot server indicates makes sense for feature that the rule is being applied to. The values can be unmarshalled in a higher layer if the name of the rule is known to LiT.

type Version

type Version struct {
	// Major is the major version of the software.
	Major uint32

	// Minor is the major version of the software.
	Minor uint32

	// Patch is the patch number that the software is running.
	Patch uint32
}

Version defines a software version.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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