watchtowerrpc

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2024 License: MIT Imports: 23 Imported by: 1

Documentation

Overview

Package watchtowerrpc is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

View Source
const Subsystem = "WRPC"

Subsystem defines the logging code for this subsystem.

Variables

View Source
var (

	// ErrTowerNotActive signals that RPC calls cannot be processed because
	// the watchtower is not active.
	ErrTowerNotActive = errors.New("watchtower not active")
)
View Source
var File_watchtowerrpc_watchtower_proto protoreflect.FileDescriptor

Functions

func DisableLog

func DisableLog()

DisableLog disables all library log output. Logging output is disabled by by default until UseLogger is called.

func RegisterWatchtowerHandler added in v0.3.0

func RegisterWatchtowerHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error

RegisterWatchtowerHandler registers the http handlers for service Watchtower to "mux". The handlers forward requests to the grpc endpoint over "conn".

func RegisterWatchtowerHandlerClient added in v0.3.0

func RegisterWatchtowerHandlerClient(ctx context.Context, mux *runtime.ServeMux, client WatchtowerClient) error

RegisterWatchtowerHandlerClient registers the http handlers for service Watchtower to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "WatchtowerClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "WatchtowerClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "WatchtowerClient" to call the correct interceptors.

func RegisterWatchtowerHandlerFromEndpoint added in v0.3.0

func RegisterWatchtowerHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)

RegisterWatchtowerHandlerFromEndpoint is same as RegisterWatchtowerHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.

func RegisterWatchtowerHandlerServer added in v0.3.0

func RegisterWatchtowerHandlerServer(ctx context.Context, mux *runtime.ServeMux, server WatchtowerServer) error

RegisterWatchtowerHandlerServer registers the http handlers for service Watchtower to "mux". UnaryRPC :call WatchtowerServer directly. StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterWatchtowerHandlerFromEndpoint instead.

func RegisterWatchtowerServer

func RegisterWatchtowerServer(s *grpc.Server, srv WatchtowerServer)

func UseLogger

func UseLogger(logger slog.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 slog.

Types

type Config

type Config struct {
	// Active indicates if the watchtower is enabled.
	Active bool

	// Tower is the active watchtower which serves as the primary source for
	// information presented via RPC.
	Tower WatchtowerBackend
}

Config is the primary configuration struct for the watchtower RPC server. It contains all items required for the RPC server to carry out its duties. The fields with struct tags are meant to parsed as normal configuration options, while if able to be populated, the latter fields MUST also be specified.

type GetInfoRequest

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

func (*GetInfoRequest) Descriptor deprecated

func (*GetInfoRequest) Descriptor() ([]byte, []int)

Deprecated: Use GetInfoRequest.ProtoReflect.Descriptor instead.

func (*GetInfoRequest) ProtoMessage

func (*GetInfoRequest) ProtoMessage()

func (*GetInfoRequest) ProtoReflect added in v0.3.0

func (x *GetInfoRequest) ProtoReflect() protoreflect.Message

func (*GetInfoRequest) Reset

func (x *GetInfoRequest) Reset()

func (*GetInfoRequest) String

func (x *GetInfoRequest) String() string

type GetInfoResponse

type GetInfoResponse struct {

	// The public key of the watchtower.
	Pubkey []byte `protobuf:"bytes,1,opt,name=pubkey,proto3" json:"pubkey,omitempty"`
	// The listening addresses of the watchtower.
	Listeners []string `protobuf:"bytes,2,rep,name=listeners,proto3" json:"listeners,omitempty"`
	// The URIs of the watchtower.
	Uris []string `protobuf:"bytes,3,rep,name=uris,proto3" json:"uris,omitempty"`
	// contains filtered or unexported fields
}

func (*GetInfoResponse) Descriptor deprecated

func (*GetInfoResponse) Descriptor() ([]byte, []int)

Deprecated: Use GetInfoResponse.ProtoReflect.Descriptor instead.

func (*GetInfoResponse) GetListeners

func (x *GetInfoResponse) GetListeners() []string

func (*GetInfoResponse) GetPubkey

func (x *GetInfoResponse) GetPubkey() []byte

func (*GetInfoResponse) GetUris

func (x *GetInfoResponse) GetUris() []string

func (*GetInfoResponse) ProtoMessage

func (*GetInfoResponse) ProtoMessage()

func (*GetInfoResponse) ProtoReflect added in v0.3.0

func (x *GetInfoResponse) ProtoReflect() protoreflect.Message

func (*GetInfoResponse) Reset

func (x *GetInfoResponse) Reset()

func (*GetInfoResponse) String

func (x *GetInfoResponse) String() string

type Handler added in v0.3.0

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

Handler is the RPC server we'll use to interact with the backing active watchtower.

func New added in v0.3.0

func New(cfg *Config) (*Handler, lnrpc.MacaroonPerms, error)

New returns a new instance of the Watchtower sub-server. We also return the set of permissions for the macaroons that we may create within this method. If the macaroons we need aren't found in the filepath, then we'll create them on start up. If we're unable to locate, or create the macaroons we need, then we'll return with an error.

func (*Handler) GetInfo added in v0.3.0

func (c *Handler) GetInfo(ctx context.Context,
	req *GetInfoRequest) (*GetInfoResponse, error)

AddTower adds a new watchtower reachable at the given address and considers it for new sessions. If the watchtower already exists, then any new addresses included will be considered when dialing it for session negotiations and backups.

func (*Handler) Name added in v0.3.0

func (c *Handler) Name() string

Name returns a unique string representation of the sub-server. This can be used to identify the sub-server and also de-duplicate them.

NOTE: This is part of the lnrpc.SubServer interface.

func (*Handler) Start added in v0.3.0

func (c *Handler) Start() error

Start launches any helper goroutines required for the Handler to function.

NOTE: This is part of the lnrpc.SubServer interface.

func (*Handler) Stop added in v0.3.0

func (c *Handler) Stop() error

Stop signals any active goroutines for a graceful closure.

NOTE: This is part of the lnrpc.SubServer interface.

type ServerShell added in v0.5.0

type ServerShell struct {
	WatchtowerServer
}

ServerShell is a shell struct holding a reference to the actual sub-server. It is used to register the gRPC sub-server with the root server before we have the necessary dependencies to populate the actual sub-server.

func (*ServerShell) CreateSubServer added in v0.5.0

func (r *ServerShell) CreateSubServer(configRegistry lnrpc.SubServerConfigDispatcher) (
	lnrpc.SubServer, lnrpc.MacaroonPerms, error)

CreateSubServer populates the subserver's dependencies using the passed SubServerConfigDispatcher. This method should fully initialize the sub-server instance, making it ready for action. It returns the macaroon permissions that the sub-server wishes to pass on to the root server for all methods routed towards it.

NOTE: This is part of the lnrpc.GrpcHandler interface.

func (*ServerShell) RegisterWithRestServer added in v0.5.0

func (r *ServerShell) RegisterWithRestServer(ctx context.Context,
	mux *runtime.ServeMux, dest string, opts []grpc.DialOption) error

RegisterWithRestServer will be called by the root REST mux to direct a sub RPC server to register itself with the main REST mux server. Until this is called, each sub-server won't be able to have requests routed towards it.

NOTE: This is part of the lnrpc.GrpcHandler interface.

func (*ServerShell) RegisterWithRootServer added in v0.5.0

func (r *ServerShell) RegisterWithRootServer(grpcServer *grpc.Server) error

RegisterWithRootServer will be called by the root gRPC server to direct a sub RPC server to register itself with the main gRPC root server. Until this is called, each sub-server won't be able to have requests routed towards it.

NOTE: This is part of the lnrpc.GrpcHandler interface.

type UnimplementedWatchtowerServer added in v0.3.0

type UnimplementedWatchtowerServer struct {
}

UnimplementedWatchtowerServer can be embedded to have forward compatible implementations.

func (*UnimplementedWatchtowerServer) GetInfo added in v0.3.0

type WatchtowerBackend

type WatchtowerBackend interface {
	// PubKey returns the public key for the watchtower used to
	// authentication and encrypt traffic with clients.
	PubKey() *secp256k1.PublicKey

	// ListeningAddrs returns the listening addresses where the watchtower
	// server can accept client connections.
	ListeningAddrs() []net.Addr

	// ExternalIPs returns the addresses where the watchtower can be reached
	// by clients externally.
	ExternalIPs() []net.Addr
}

WatchtowerBackend abstracts access to the watchtower information that is served via RPC connections.

type WatchtowerClient

type WatchtowerClient interface {
	// lncli: tower info
	// GetInfo returns general information concerning the companion watchtower
	// including its public key and URIs where the server is currently
	// listening for clients.
	GetInfo(ctx context.Context, in *GetInfoRequest, opts ...grpc.CallOption) (*GetInfoResponse, error)
}

WatchtowerClient is the client API for Watchtower service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.

func NewWatchtowerClient

func NewWatchtowerClient(cc grpc.ClientConnInterface) WatchtowerClient

type WatchtowerServer

type WatchtowerServer interface {
	// lncli: tower info
	// GetInfo returns general information concerning the companion watchtower
	// including its public key and URIs where the server is currently
	// listening for clients.
	GetInfo(context.Context, *GetInfoRequest) (*GetInfoResponse, error)
}

WatchtowerServer is the server API for Watchtower service.

Jump to

Keyboard shortcuts

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