noderelay

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2024 License: BlueOak-1.0.0 Imports: 19 Imported by: 0

README

NodeRelay

NodeRelay is a system for connecting to nodes on remote private machines. This is done through a WebSockets-based reverse tunnel.

  1. Run a full node on a home or otherwise private server. Coordinate credentials for RPC requests (rcpuser, rpcpassword) with the server operator.

  2. The server operator will expose the NodeRelay through an external IP address.

  3. The server operator generates a relay ID, which can be any string without whitespace. Each asset backend that will connect through NodeRelay will need its own relay ID.

  4. The server operator modifies the asset configuration to specify a relay ID for each asset for which a noderelay is needed.

  5. The server operator specifies a noderelayaddr in as part of the dcrdex configuration. This is the external address at which source nodes will contact the server.

  6. Upon starting, the server will generate and store a relayfile to a directory located by default at ~/.dcrdex/data/mainnet/noderelay/relay-files/, with a file name of e.g. btc_0405f1069d352a0f.relayfile. Send this file to the private server. The relayfile is good until the relay ID is changed or a new TLS key-cert pair is generated.

  7. On the private server, run sourcenode, pointing at the relay file with --relayfile and setting the node RPC port with --port. Specify a TLS certificate for full node RPC with --localcert, if required.

    ./sourcenode --relayfile btc_0405f1069d352a0f.relayfile --port 8332
    

Documentation

Index

Constants

View Source
const (
	// PongWait is the time allowed to read the next pong message from the peer.
	PongWait = 60 * time.Second
	// PingPeriod sets the frequency on which websocket clients should ping.
	PingPeriod = 30 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Nexus

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

Nexus is run on the server and manages a series of node relays. A source node will connect to the Nexus, making their services available for a local consumer.

func NewNexus

func NewNexus(cfg *NexusConfig) (*Nexus, error)

NewNexus is the constructor for a Nexus.

func (*Nexus) Connect

func (n *Nexus) Connect(ctx context.Context) (*sync.WaitGroup, error)

Connect starts the Nexus, creating a relay node for every relay ID.

func (*Nexus) RelayAddr

func (n *Nexus) RelayAddr(relayID string) (string, error)

RelayAddr returns the local address for relay, or an error if there is no server running for the given relay ID.

func (*Nexus) WaitForSourceNodes

func (n *Nexus) WaitForSourceNodes() <-chan struct{}

WaitForSourceNodes returns a channel that will be closed when a source node has connected for all relays.

type NexusConfig

type NexusConfig struct {
	// ExternalAddr is the external IP:port address or host(:port) of the
	// Nexus relay manager. The operator must configure this independently
	// so that the External address is routed to the specified Port listening
	// on all loopback interfaces.
	ExternalAddr string
	// Port is the port that Nexus will listen on.
	Port string
	// Dir is a directory to output relayfiles and generated TLS key-cert pairs.
	Dir string
	// Key is the path to a TLS key. If Key == "", a new key and certificate
	// will be created in the Dir. The ExternalAddr will be added to the
	// certificate as a host. If the ExternalAddr changes, a new certificate
	// can be generated by deleting the old key-cert pair and restarting.
	// Changing the ExternalAddr renders any previously generated relayfiles
	// void.
	Key string
	// Cert is the path to a TLS certificate. See docs for Key.
	Cert   string
	Logger dex.Logger
	// RelayIDs are the relay IDs for which to start node relays. These can be
	// any string the caller chooses. These relay IDs are given to source node
	// operators (generally as part of a relayfile) and are used to configure
	// their source nodes. The channel returned from WaitForSourceNodes will
	// not close until there is at least one source node connected for every
	// ID in RelayIDs.
	RelayIDs []string
}

type RelayFile

type RelayFile struct {
	RelayID string    `json:"relayID"`
	Cert    dex.Bytes `json:"cert"`
	Addr    string    `json:"addr"`
}

RelayFile is used for encoding JSON relayfiles. A relayfile is a file that contains all the relevant connection information for a source node configuration. Nexus will generate a relayfile for each relay ID on startup.

type RelayedMessage

type RelayedMessage struct {
	MessageID uint64              `json:"messageID"`
	Method    string              `json:"method,omitempty"`
	Body      dex.Bytes           `json:"body"`
	Headers   map[string][]string `json:"headers,omitempty"`
}

RelayedMessage is the format with which HTTP requests are routed over the source nodes' WebSocket connections.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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