server

package
v0.0.0-...-180210d Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2025 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Connections that are not yet authenticated.
	GuestClients = &ClientConnectionsList[ClientAddr]{
		list: make(map[ClientAddr]*quic.Conn),
	}
	// Connections that have successfully authenticated, keyed by their public key.
	AuthenticatedClients = &ClientConnectionsList[PublicKey]{
		list: make(map[PublicKey]*quic.Conn),
	}
)

Global instances of our connection lists with specific types.

View Source
var Delimiter = []byte("\n\r\n\r")

Functions

func GenerateTLSConfig

func GenerateTLSConfig() (*tls.Config, error)

Creates a self-signed TLS configuration.

func HandleChatMessageRequest

func HandleChatMessageRequest(conn *quic.Conn, stream *quic.Stream, req *fb.ChatMessageRequest) error

func HandleConnection

func HandleConnection(conn *quic.Conn) error

func InitServer

func InitServer() error

Types

type ClientAddr

type ClientAddr string

Define specific types for identifiers to improve code clarity and safety.

type ClientConnectionsList

type ClientConnectionsList[T ClientAddr | PublicKey] struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

A thread-safe map for managing client connections.

func (*ClientConnectionsList[T]) Add

func (c *ClientConnectionsList[T]) Add(identifier T, conn *quic.Conn)

Add safely adds a new client connection to the list.

func (*ClientConnectionsList[T]) Remove

func (c *ClientConnectionsList[T]) Remove(identifier T)

Remove safely removes a client connection from the list.

func (*ClientConnectionsList[T]) RemoveByConnection

func (c *ClientConnectionsList[T]) RemoveByConnection(conn *quic.Conn)

RemoveByConnection safely removes a client by their connection object.

type PublicKey

type PublicKey string

Jump to

Keyboard shortcuts

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