subservers

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: 38 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LND      string = "lnd"
	LIT      string = "lit"
	LOOP     string = "loop"
	POOL     string = "pool"
	TAP      string = "taproot-assets"
	FARADAY  string = "faraday"
	ACCOUNTS string = "accounts"
)
View Source
const Subsystem = "SSVR"

Variables

This section is empty.

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 Manager

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

Manager manages a set of subServer objects.

func NewManager

func NewManager(permsMgr *perms.Manager,
	statusServer *status.Manager) *Manager

NewManager constructs a new Manager.

func (*Manager) AddServer

func (s *Manager) AddServer(ss SubServer, enable bool)

AddServer adds a new subServer to the manager's set.

func (*Manager) ConnectRemoteSubServers

func (s *Manager) ConnectRemoteSubServers()

ConnectRemoteSubServers creates connections to all the manager's sub-servers that are running remotely.

func (*Manager) GetRemoteConn

func (s *Manager) GetRemoteConn(uri string) (bool, *grpc.ClientConn, error)

GetRemoteConn checks if any of the manager's sub-servers owns the given uri and if so, the remote connection to that sub-server is returned. The bool return value indicates if the uri is managed by one of the sub-servers running in remote mode.

func (*Manager) Handles

func (s *Manager) Handles(uri string) (bool, string)

Handles returns true if one of its sub-servers owns the given URI along with the name of the service.

func (*Manager) MacaroonPath

func (s *Manager) MacaroonPath(uri string) (bool, string)

MacaroonPath checks if any of the manager's sub-servers owns the given uri and if so, the appropriate macaroon path is returned for that sub-server.

func (*Manager) ReadRemoteMacaroon

func (s *Manager) ReadRemoteMacaroon(uri string) (bool, []byte, error)

ReadRemoteMacaroon checks if any of the manager's sub-servers running in remote mode owns the given uri and if so, the appropriate macaroon path is returned for that sub-server.

func (*Manager) RegisterRPCServices

func (s *Manager) RegisterRPCServices(server grpc.ServiceRegistrar)

RegisterRPCServices registers all the manager's sub-servers with the given grpc registrar.

func (*Manager) RegisterRestServices

func (s *Manager) RegisterRestServices(ctx context.Context,
	mux *restProxy.ServeMux, endpoint string,
	dialOpts []grpc.DialOption) error

RegisterRestServices registers all the manager's sub-servers REST handlers with the given endpoint.

func (*Manager) StartIntegratedServers

func (s *Manager) StartIntegratedServers(lndClient lnrpc.LightningClient,
	lndGrpc *lndclient.GrpcLndServices, withMacaroonService bool)

StartIntegratedServers starts all the manager's sub-servers that should be started in integrated mode.

func (*Manager) Stop

func (s *Manager) Stop() error

Stop stops all the manager's sub-servers

func (*Manager) ValidateMacaroon

func (s *Manager) ValidateMacaroon(ctx context.Context,
	requiredPermissions []bakery.Op, uri string) (bool, error)

ValidateMacaroon checks if any of the manager's sub-servers owns the given uri and if so, if it is running in remote mode, then true is returned since the macaroon will be validated by the remote subserver itself when the request arrives. Otherwise, the integrated sub-server's validator validates the macaroon.

type RemoteConfig

type RemoteConfig struct {
	LitLogDir         string `long:"lit-logdir" description:"For lnd remote mode only: Directory to log output."`
	LitMaxLogFiles    int    `long:"lit-maxlogfiles" description:"For lnd remote mode only: Maximum logfiles to keep (0 for no rotation)"`
	LitMaxLogFileSize int    `long:"lit-maxlogfilesize" description:"For lnd remote mode only: Maximum logfile size in MB"`

	LitDebugLevel string `` /* 255-byte string literal not displayed */

	Lnd           *RemoteDaemonConfig `group:"Remote lnd (use when lnd-mode=remote)" namespace:"lnd"`
	Faraday       *RemoteDaemonConfig `group:"Remote faraday (use when faraday-mode=remote)" namespace:"faraday"`
	Loop          *RemoteDaemonConfig `group:"Remote loop (use when loop-mode=remote)" namespace:"loop"`
	Pool          *RemoteDaemonConfig `group:"Remote pool (use when pool-mode=remote)" namespace:"pool"`
	TaprootAssets *RemoteDaemonConfig `group:"Remote taproot-assets (use when taproot-assets-mode=remote)" namespace:"taproot-assets"`
}

RemoteConfig holds the configuration parameters that are needed when running LiT in the "remote" lnd mode.

type RemoteDaemonConfig

type RemoteDaemonConfig struct {
	// RPCServer is host:port that the remote daemon's RPC server is
	// listening on.
	RPCServer string `long:"rpcserver" description:"The host:port that the remote daemon is listening for RPC connections on."`

	// MacaroonPath is the path to the single macaroon that should be used
	// instead of needing to specify the macaroon directory that contains
	// all of the daemon's macaroons. The specified macaroon MUST have all
	// permissions that all the subservers use, otherwise permission errors
	// will occur.
	MacaroonPath string `` /* 272-byte string literal not displayed */

	// TLSCertPath is the path to the tls cert of the remote daemon that
	// should be used to verify the TLS identity of the remote RPC server.
	TLSCertPath string `long:"tlscertpath" description:"The full path to the remote daemon's TLS cert to use for RPC connection verification."`
}

RemoteDaemonConfig holds the configuration parameters that are needed to connect to a remote daemon like lnd for example.

type SubServer

type SubServer interface {
	macaroons.MacaroonValidator

	// Name returns the name of the sub-server.
	Name() string

	// Remote returns true if the sub-server is running remotely and so
	// should be connected to instead of spinning up an integrated server.
	Remote() bool

	// RemoteConfig returns the config required to connect to the sub-server
	// if it is running in remote mode.
	RemoteConfig() *RemoteDaemonConfig

	// Start starts the sub-server in integrated mode.
	Start(lnrpc.LightningClient, *lndclient.GrpcLndServices, bool) error

	// Stop stops the sub-server in integrated mode.
	Stop() error

	// RegisterGrpcService must register the sub-server's GRPC server with
	// the given registrar.
	RegisterGrpcService(grpc.ServiceRegistrar)

	// RegisterRestService registers the sub-server's REST handlers with the
	// given endpoint.
	RegisterRestService(context.Context, *restProxy.ServeMux, string,
		[]grpc.DialOption) error

	// ServerErrChan returns an error channel that should be listened on
	// after starting the sub-server to listen for any runtime errors. It
	// is optional and may be set to nil. This only applies in integrated
	// mode.
	ServerErrChan() chan error

	// MacPath returns the path to the sub-server's macaroon if it is not
	// running in remote mode.
	MacPath() string

	// Permissions returns a map of all RPC methods and their required
	// macaroon permissions to access the sub-server.
	Permissions() map[string][]bakery.Op

	// WhiteListedURLs returns a map of all the sub-server's URLs that can
	// be accessed without a macaroon.
	WhiteListedURLs() map[string]struct{}
}

SubServer defines an interface that should be implemented by any sub-server that the subServer manager should manage. A sub-server can be run in either integrated or remote mode. A sub-server is considered non-fatal to LiT meaning that if a sub-server fails to start, LiT can safely continue with its operations and other sub-servers can too.

func NewFaradaySubServer

func NewFaradaySubServer(cfg *faraday.Config, rpcCfg *frdrpcserver.Config,
	remoteCfg *RemoteDaemonConfig, remote bool) SubServer

NewFaradaySubServer returns a new faraday implementation of the SubServer interface.

func NewLoopSubServer

func NewLoopSubServer(cfg *loopd.Config, remoteCfg *RemoteDaemonConfig,
	remote bool) SubServer

NewLoopSubServer returns a new loop implementation of the SubServer interface.

func NewPoolSubServer

func NewPoolSubServer(cfg *pool.Config, remoteCfg *RemoteDaemonConfig,
	remote bool) SubServer

NewPoolSubServer returns a new pool implementation of the SubServer interface.

func NewTaprootAssetsSubServer

func NewTaprootAssetsSubServer(cfg *tapcfg.Config,
	remoteCfg *RemoteDaemonConfig, remote bool) SubServer

NewTaprootAssetsSubServer returns a new tap implementation of the SubServer interface.

Jump to

Keyboard shortcuts

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