Documentation
¶
Index ¶
Constants ¶
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) RelayAddr ¶
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.