Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ListenerConfig ¶
ListenerConfig is the configuration for the listener. Address: the address to bind the listener to. It could be an address behind a reverse proxy. TLSConfig: the TLS configuration for the listener.
type Peer ¶
type Peer struct {
// contains filtered or unexported fields
}
Peer represents a peer connection
func (*Peer) CloseGracefully ¶
CloseGracefully closes the connection with the peer gracefully. Send a close message to the client and close the connection.
type Relay ¶
type Relay struct {
// contains filtered or unexported fields
}
Relay represents the relay server
func NewRelay ¶
func NewRelay(meter metric.Meter, exposedAddress string, tlsSupport bool, validator auth.Validator) (*Relay, error)
NewRelay creates a new Relay instance
Parameters: meter: An instance of metric.Meter from the go.opentelemetry.io/otel/metric package. It is used to create and manage metrics for the relay server. exposedAddress: A string representing the address that the relay server is exposed on. The client will use this address as the relay server's instance URL. tlsSupport: A boolean indicating whether the relay server supports TLS (Transport Layer Security) or not. The instance URL depends on this value. validator: An instance of auth.Validator from the auth package. It is used to validate the authentication of the peers.
Returns: A pointer to a Relay instance and an error. If the Relay instance is successfully created, the error is nil. Otherwise, the error contains the details of what went wrong.
func (*Relay) InstanceURL ¶
InstanceURL returns the instance URL of the relay server
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the main entry point for the relay server. It is the gate between the WebSocket listener and the Relay server logic. In a new HTTP connection, the server will accept the connection and pass it to the Relay server via the Accept method.
func NewServer ¶
func NewServer(meter metric.Meter, exposedAddress string, tlsSupport bool, authValidator auth.Validator) (*Server, error)
NewServer creates a new relay server instance. meter: the OpenTelemetry meter exposedAddress: this address will be used as the instance URL. It should be a domain:port format. tlsSupport: if true, the server will support TLS authValidator: the auth validator to use for the server
func (*Server) InstanceURL ¶
InstanceURL returns the instance URL of the relay server.
func (*Server) Listen ¶
func (r *Server) Listen(cfg ListenerConfig) error
Listen starts the relay server.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is a thread-safe store of peers It is used to store the peers that are connected to the relay server
func (*Store) DeletePeer ¶
DeletePeer deletes a peer from the store