freddie

package
v0.0.0-...-d9d1ba7 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: GPL-3.0 Imports: 30 Imported by: 2 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Freddie

type Freddie struct {
	TLSConfig *tls.Config

	// ConsumerCountry, if non-nil, returns the ISO 3166-1 alpha-2 country of the consumer making
	// r, a GET /v1/signal, or "" when it is unknown. Freddie indexes the consumer under the
	// (normalized) result so producers who target that country can prefer it. It must derive the
	// country server-side and must not trust client-controlled input: a consumer who could claim
	// a country would absorb every genesis message targeted at it. nil, or a "" result, leaves the
	// consumer untargeted: it still receives untargeted and fallback broadcasts, but is never
	// selected by country. Set it after New and before ListenAndServe or ListenAndServeTLS; it
	// is read without synchronization by concurrent request handlers.
	//
	// Freddie also calls it on each offer POST, so freddie.producer.outcomes can say
	// which country the consumer behind each attempt was in.
	ConsumerCountry func(r *http.Request) string

	// RoomTicket, if non-nil, verifies a helper pairing ticket presented for role and returns the
	// room it admits to, the pairing's opaque ID, or ok=false. A consumer's inviter tickets, in
	// common.RoomTicketsHeader, put it in their rooms; a producer's volunteer tickets, in
	// common.RoomTicketField, send its genesis messages to those rooms' consumers first. It must
	// check the signature, the key, the expiry and the role, and must not log, trace or count the
	// ticket or the room. helperticket.RoomFunc is one. nil disables rooms: tickets are ignored, so
	// a producer that serves only its rooms is offered to nobody. Set it after New and before
	// serving; it is read without synchronization by concurrent request handlers.
	//
	// Freddie caches each ticket it accepts until the ticket's own expiry, so RoomTicket runs once
	// per distinct valid ticket rather than at every subscribe and genesis. See KnownKeyID.
	RoomTicket func(ticket string, role helperticket.Role) (room string, ok bool)

	// KnownKeyID reports whether kid names a key RoomTicket currently trusts. Freddie asks it on
	// every cache hit, and a ticket whose key is no longer trusted is dropped and refused, so a
	// key that leaves RoomTicket's set stops admitting anyone at once. nil disables the cache:
	// every ticket is verified by RoomTicket every time. helperticket.KnownKeyFunc is one. Set it
	// with RoomTicket, after New and before serving.
	KnownKeyID func(kid string) bool

	// RoomICEServers, if non-nil, returns ICE servers (TURN relays) for room pairings. Freddie
	// calls it once per genesis that carries a verified room ticket and stamps the result on the
	// genesis each room's consumers receive and, when a room consumer took the genesis, on the
	// offer it returns to the producer. It must not block: signaling waits on it. Nil, or an empty
	// result, leaves every message unchanged.
	RoomICEServers func(ctx context.Context) []webrtc.ICEServer
	// contains filtered or unexported fields
}

func New

func New(ctx context.Context, listenAddr string) (*Freddie, error)

func (*Freddie) FlushRoomTicketCache

func (f *Freddie) FlushRoomTicketCache()

FlushRoomTicketCache forgets every verified room ticket, so each is verified afresh the next time it is presented. Call it when the set of trusted ticket keys changes.

func (*Freddie) ListenAndServe

func (f *Freddie) ListenAndServe() error

func (*Freddie) ListenAndServeTLS

func (f *Freddie) ListenAndServeTLS(certFile, keyFile string) error

func (*Freddie) SetGenesisFanout

func (f *Freddie) SetGenesisFanout(n int)

SetGenesisFanout caps how many waiting consumers each pool genesis goes to, both among its target countries and in the fallback to everyone. Zero, the default, sends it to all of them. A room genesis isn't capped: it goes only to its room's consumers. Safe to call while serving.

func (*Freddie) Shutdown

func (f *Freddie) Shutdown() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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