watchtower

package
v0.10.1-beta.rc1 Latest Latest
Warning

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

Go to latest
Published: May 19, 2020 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultPeerPort is the default server port to which clients can
	// connect.
	DefaultPeerPort = 9911

	// DefaultReadTimeout is the default timeout after which the tower will
	// hang up on a client if nothing is received.
	DefaultReadTimeout = 15 * time.Second

	// DefaultWriteTimeout is the default timeout after which the tower will
	// hang up on a client if it is unable to send a message.
	DefaultWriteTimeout = 15 * time.Second
)

Variables

View Source
var (
	// ErrNoListeners signals that no listening ports were provided,
	// rendering the tower unable to receive client requests.
	ErrNoListeners = errors.New("no listening ports were specified")

	// ErrNoNetwork signals that no tor.Net is provided in the Config, which
	// prevents resolution of listening addresses.
	ErrNoNetwork = errors.New("no network specified, must be tor or clearnet")
)
View Source
var (
	// DefaultListenAddr is the default watchtower address listening on all
	// interfaces.
	DefaultListenAddr = fmt.Sprintf(":%d", DefaultPeerPort)
)

Functions

func DisableLog

func DisableLog()

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

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 AddressNormalizer

type AddressNormalizer func(addrs []string, defaultPort string,
	resolver func(string, string) (*net.TCPAddr, error)) ([]net.Addr, error)

AddressNormalizer is a function signature that allows the tower to resolve TCP addresses on clear or onion networks.

type Conf

type Conf struct {
	// RawListeners configures the watchtower's listening ports/interfaces.
	RawListeners []string `long:"listen" description:"Add interfaces/ports to listen for peer connections"`

	// RawExternalIPs configures the watchtower's external ports/interfaces.
	RawExternalIPs []string `long:"externalip" description:"Add interfaces/ports where the watchtower can accept peer connections"`

	// ReadTimeout specifies the duration the tower will wait when trying to
	// read a message from a client before hanging up.
	ReadTimeout time.Duration `` /* 130-byte string literal not displayed */

	// WriteTimeout specifies the duration the tower will wait when trying
	// to write a message from a client before hanging up.
	WriteTimeout time.Duration `` /* 141-byte string literal not displayed */
}

Conf specifies the watchtower options that can be configured from the command line or configuration file.

func (*Conf) Apply

func (c *Conf) Apply(cfg *Config,
	normalizer AddressNormalizer) (*Config, error)

Apply completes the passed Config struct by applying any parsed Conf options. If the corresponding values parsed by Conf are already set in the Config, those fields will be not be modified.

type Config

type Config struct {
	// ChainHash identifies the chain that the watchtower will be monitoring
	// for breaches and that will be advertised in the server's Init message
	// to inbound clients.
	ChainHash chainhash.Hash

	// BlockFetcher supports the ability to fetch blocks from the network by
	// hash.
	BlockFetcher lookout.BlockFetcher

	// DB provides access to persistent storage of sessions and state
	// updates uploaded by watchtower clients, and the ability to query for
	// breach hints when receiving new blocks.
	DB DB

	// EpochRegistrar supports the ability to register for events
	// corresponding to newly created blocks.
	EpochRegistrar lookout.EpochRegistrar

	// Net specifies the network type that the watchtower will use to listen
	// for client connections. Either a clear net or Tor are supported.
	Net tor.Net

	// NewAddress is used to generate reward addresses, where a cut of
	// successfully sent funds can be received.
	NewAddress func() (btcutil.Address, error)

	// NodePrivKey is private key to be used in accepting new brontide
	// connections.
	NodePrivKey *btcec.PrivateKey

	// PublishTx provides the ability to send a signed transaction to the
	// network.
	//
	// TODO(conner): replace with lnwallet.WalletController interface to
	// have stronger guarantees wrt. returned error types.
	PublishTx func(*wire.MsgTx) error

	// ListenAddrs specifies the listening addresses of the tower.
	ListenAddrs []net.Addr

	// ExternalIPs specifies the addresses to which clients may connect to
	// the tower.
	ExternalIPs []net.Addr

	// ReadTimeout specifies how long a client may go without sending a
	// message.
	ReadTimeout time.Duration

	// WriteTimeout specifies how long a client may go without reading a
	// message from the other end, if the connection has stopped buffering
	// the server's replies.
	WriteTimeout time.Duration

	// TorController allows the watchtower to optionally setup an onion hidden
	// service.
	TorController *tor.Controller

	// WatchtowerKeyPath allows the watchtower to specify where the private key
	// for a watchtower hidden service should be stored.
	WatchtowerKeyPath string

	// Type specifies the hidden service type (V2 or V3) that the watchtower
	// will create.
	Type tor.OnionType
}

Config defines the resources and parameters used to configure a Watchtower. All nil-able elements besides tor-related ones must be set in order for the Watchtower to function properly.

type DB

type DB interface {
	lookout.DB
	wtserver.DB
}

DB abstracts the persistent functionality required to run the watchtower daemon. It composes the database interfaces required by the lookout and wtserver subsystems.

type Standalone

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

Standalone encapsulates the server-side functionality required by watchtower clients. A Standalone couples the two primary subsystems such that, as a unit, this instance can negotiate sessions with clients, accept state updates for active sessions, monitor the chain for breaches matching known breach hints, publish reconstructed justice transactions on behalf of tower clients.

func New

func New(cfg *Config) (*Standalone, error)

New validates the passed Config and returns a fresh Standalone instance if the tower's subsystems could be properly initialized.

func (*Standalone) ExternalIPs

func (w *Standalone) ExternalIPs() []net.Addr

ExternalIPs returns the addresses where the watchtower can be reached by clients externally.

NOTE: Part of the watchtowerrpc.WatchtowerBackend interface.

func (*Standalone) ListeningAddrs

func (w *Standalone) ListeningAddrs() []net.Addr

ListeningAddrs returns the listening addresses where the watchtower server can accept client connections.

NOTE: Part of the watchtowerrpc.WatchtowerBackend interface.

func (*Standalone) PubKey

func (w *Standalone) PubKey() *btcec.PublicKey

PubKey returns the public key for the watchtower used to authentication and encrypt traffic with clients.

NOTE: Part of the watchtowerrpc.WatchtowerBackend interface.

func (*Standalone) Start

func (w *Standalone) Start() error

Start idempotently starts the Standalone, an error is returned if the subsystems could not be initialized.

func (*Standalone) Stop

func (w *Standalone) Stop() error

Stop idempotently stops the Standalone and blocks until the subsystems have completed their shutdown.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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