Documentation
¶
Index ¶
- Constants
- Variables
- func APIFromCodecs(codecs []webrtc.RTPCodecParameters) (*webrtc.API, error)
- func APIFromNames(names []string) (*webrtc.API, error)
- func CodecPayloadType(codec webrtc.RTPCodecCapability) (webrtc.PayloadType, error)
- func ConstantTimeCompare(a, b string) bool
- func DelClient(c Client)
- func Delete(name string) bool
- func DeleteDescription(name, etag string) error
- func DeleteUser(group, username string, wildcard bool, etag string) error
- func GetDescriptionNames() ([]string, error)
- func GetDescriptionTag(name string) (string, error)
- func GetNames() []string
- func GetUserTag(group, username string, wildcard bool) (string, error)
- func GetUsers(group string) ([]string, string, error)
- func OperatorHubName() string
- func Range(f func(g *Group) bool)
- func SetKeys(group string, keys []map[string]any) error
- func SetUDPMux(port int) error
- func SetUserPassword(group, username string, wildcard bool, pw Password) error
- func Shutdown(message string)
- func Update()
- func UpdateDescription(name, etag string, desc *Description) error
- func UpdateUser(group, username string, wildcard bool, etag string, user *UserDescription) error
- type ChatHistoryEntry
- type Client
- type ClientCredentials
- type ClientPattern
- type Configuration
- type Description
- type FullError
- type Group
- func (g *Group) API() (*webrtc.API, error)
- func (g *Group) AddToChatHistory(id, source string, user *string, time time.Time, kind string, ...)
- func (g *Group) Admit(id string) error
- func (g *Group) ClearChatHistory(id string, userId string)
- func (g *Group) ClientCount() int
- func (g *Group) Data() map[string]interface{}
- func (g *Group) Deny(id string) error
- func (g *Group) Description() *Description
- func (g *Group) GetChatHistory() []ChatHistoryEntry
- func (g *Group) GetClient(id string) Client
- func (g *Group) GetClients(except Client) []Client
- func (g *Group) Locked() (bool, string)
- func (g *Group) Locked1on1() bool
- func (g *Group) Name() string
- func (g *Group) Range(f func(c Client) bool)
- func (g *Group) RemoveKnock(id string)
- func (g *Group) SetData(set func())
- func (g *Group) SetLocked(locked bool, message string)
- func (g *Group) SetLocked1on1(on bool)
- func (g *Group) SetPermissions(set func())
- func (g *Group) Status(authentified bool, base *url.URL) Status
- func (g *Group) UpdateData(d map[string]interface{})
- func (g *Group) UserExists(username string) bool
- func (g *Group) WallOps(message string)
- type KickError
- type NotAuthorisedError
- type Password
- type Permissions
- type ProtocolError
- type RawPassword
- type Status
- type SubGroup
- type SubGroupClient
- type SubGroupStatus
- type UserDescription
- type UserError
Constants ¶
const ( LowBitrate = 100 * 1024 MinBitrate = LowBitrate * 2 MaxBitrate = 1024 * 1024 * 1024 )
const DefaultMaxHistoryAge = 4 * time.Hour
const ReceiveMTU = 8192
ReceiveMTU is the largest datagram the WebRTC layer reads whole: the same as pion's ICE layer, which reads every datagram before it.
Variables ¶
var AudioRTCPFeedback = []webrtc.RTCPFeedback(nil)
AudioRTCPFeedback is like VideoRTCPFeedback but for audio tracks.
var Directory, DataDirectory string
var ErrBadPassword = &NotAuthorisedError{ err: errors.New("bad password"), }
var ErrDescriptionsNotWritable = &NotAuthorisedError{}
var ErrDuplicateUsername = &NotAuthorisedError{ err: errors.New("this username is taken"), }
var ErrGroupE2EEFull = &FullError{
Code: "group-e2ee-full",
Message: "this group requires end-to-end encryption " +
"and is limited to two participants",
}
var ErrGroupFull = &FullError{
Code: "group-full", Message: "too many users",
}
var ErrGroupOneOnOne = &FullError{
Code: "group-one-on-one", Message: "Room is busy, try again later",
}
var ErrKnocking = errors.New("knocking")
ErrKnocking is returned by AddClient when a non-op client has been placed in the waiting room (lobby) of a locked group instead of being refused. It is not an authorisation failure: the client is connected and waiting for an operator to admit or deny them.
var ErrNoSuchUsername = &NotAuthorisedError{ err: errors.New("user not found"), }
var ErrTagMismatch = errors.New("tag mismatch")
var ErrUnknownPermission = errors.New("unknown permission")
var ErrUsernameRequired = errors.New("username required")
var LogOversized bool
LogOversized enables the log of datagrams over 1500 bytes (set from -log-connections).
var UDPMin, UDPMax uint16
var UseMDNS bool
var VideoRTCPFeedback = []webrtc.RTCPFeedback{
{"goog-remb", ""},
{"nack", ""},
{"nack", "pli"},
{"ccm", "fir"},
}
VideoRTCPFeedback are the RTCP feedback types that we expect for video tracks.
Functions ¶
func APIFromCodecs ¶
func APIFromCodecs(codecs []webrtc.RTPCodecParameters) (*webrtc.API, error)
func CodecPayloadType ¶
func CodecPayloadType(codec webrtc.RTPCodecCapability) (webrtc.PayloadType, error)
func ConstantTimeCompare ¶
ConstantTimeCompare compares a and b in time proportional to the length of a.
func DeleteDescription ¶
DeleteDescription deletes a description (and therefore persistently deletes a group) but only if it matches a given ETag.
func GetDescriptionNames ¶
func GetDescriptionTag ¶
GetDescriptionTag returns an ETag for a description.
func OperatorHubName ¶
func OperatorHubName() string
OperatorHubName returns the name of the operator-room hub that is served at the site root, or "" if there is none. It is the first top-level group whose description has operator-room set (WalkDir visits entries in lexical order).
func SetUserPassword ¶
func Update ¶
func Update()
Update checks that all in-memory groups are up-to-date and updates the list of public groups. It also removes from memory any non-public groups that haven't been accessed in maxHistoryAge.
func UpdateDescription ¶
func UpdateDescription(name, etag string, desc *Description) error
UpdateDescription overwrites a description if it matches a given ETag. In order to create a new group, pass an empty ETag.
func UpdateUser ¶
func UpdateUser(group, username string, wildcard bool, etag string, user *UserDescription) error
Types ¶
type ChatHistoryEntry ¶
type Client ¶
type Client interface {
Group() *Group
Addr() net.Addr
Id() string
Username() string
Init(string, []string)
Permissions() []string
Data() map[string]interface{}
PushConn(g *Group, id string, conn conn.Up, tracks []conn.UpTrack, replace string) error
RequestConns(target Client, g *Group, id string) error
Joined(group, kind string) error
PushClient(group, kind, id, username string, perms []string, data map[string]interface{}) error
Kick(id string, user *string, message string) error
}
type ClientCredentials ¶
type ClientPattern ¶
type Configuration ¶
type Configuration struct {
CanonicalHost string `json:"canonicalHost,omitempty"`
AllowOrigin []string `json:"allowOrigin,omitempty"`
AllowAdminOrigin []string `json:"allowAdminOrigin,omitempty"`
ProxyURL string `json:"proxyURL,omitempty"`
WritableGroups bool `json:"writableGroups,omitempty"`
Users map[string]UserDescription `json:"users,omitempty"`
// obsolete fields
Admin []ClientPattern `json:"admin,omitempty"`
// contains filtered or unexported fields
}
Configuration represents the contents of the data/config.json file.
func GetConfiguration ¶
func GetConfiguration() (*Configuration, error)
func (Configuration) Zero ¶
func (conf Configuration) Zero() bool
type Description ¶
type Description struct {
// The file this was deserialised from. This is not necessarily
// the name of the group, for example in case of a subgroup.
FileName string `json:"-"`
// The user-friendly group name
DisplayName string `json:"displayName,omitempty"`
// A user-readable description of the group.
Description string `json:"description,omitempty"`
// A user-readable contact, typically an e-mail address.
Contact string `json:"contact,omitempty"`
// A user-readable comment. Ignored by the server.
Comment string `json:"comment,omitempty"`
// Whether to display the group on the landing page.
Public bool `json:"public,omitempty"`
// A URL to redirect the group to. If this is not empty, most
// other fields are ignored.
Redirect string `json:"redirect,omitempty"`
// The maximum number of simultaneous clients. Unlimited if 0.
MaxClients int `json:"max-clients,omitempty"`
// The time for which history entries are kept.
MaxHistoryAge int `json:"max-history-age,omitempty"`
// Time after which joining is no longer allowed
Expires *time.Time `json:"expires,omitempty"`
// Time before which joining is not allowed
NotBefore *time.Time `json:"not-before,omitempty"`
// Whether recording is allowed.
AllowRecording bool `json:"allow-recording,omitempty"`
// Whether creating tokens is allowed
UnrestrictedTokens bool `json:"unrestricted-tokens,omitempty"`
// Whether subgroups are created on the fly.
AutoSubgroups bool `json:"auto-subgroups,omitempty"`
// Whether to lock the group when the last op logs out.
Autolock bool `json:"autolock,omitempty"`
// Whether to kick all users when the last op logs out.
Autokick bool `json:"autokick,omitempty"`
// Whether non-op users are placed in a waiting room (lobby) and must
// be admitted by an operator before joining. A lobby group is always
// gated this way whenever an operator is present, independently of the
// group's locked state (so it survives a restart and needs no autolock).
Lobby bool `json:"lobby,omitempty"`
// Whether this group runs in end-to-end encrypted mode. When set, the
// web client encrypts media in the browser with a key the server never
// sees (ephemeral ECDH authenticated by an emoji SAS), so the SFU only
// ever forwards ciphertext. This is advertised to clients in the group
// status; the encryption itself is performed entirely in the browser.
E2EE bool `json:"e2ee,omitempty"`
// Whether an end-to-end encrypted group refuses connections that cannot
// be encrypted. When set, the group is limited to two participants (the
// most the pairwise E2EE covers): the server turns away anyone who would
// be the third, and clients that cannot encrypt do not publish media, so
// the call can never silently downgrade to cleartext. Only meaningful
// together with E2EE.
RequireE2EE bool `json:"require-e2ee,omitempty"`
// Whether this group is an operator hub. When set, an operator who
// logs in lands on a dashboard to manage per-client invite links, each
// scoped to a subgroup hub/<slug>. Only meaningful on a top-level
// group; it is cleared on the subgroups themselves (see readDescription).
OperatorRoom bool `json:"operator-room,omitempty"`
// Users allowed to login
Users map[string]UserDescription `json:"users,omitempty"`
// Credentials for user with arbitrary username
WildcardUser *UserDescription `json:"wildcard-user,omitempty"`
// The (public) keys used for token authentication.
AuthKeys []map[string]interface{} `json:"authKeys,omitempty"`
// The URL of the authentication server, if any.
AuthServer string `json:"authServer,omitempty"`
// The URL of the authentication portal, if any.
AuthPortal string `json:"authPortal,omitempty"`
// Codec preferences. If empty, a suitable default is chosen in
// the APIFromNames function.
Codecs []string `json:"codecs,omitempty"`
// Obsolete fields
Op []ClientPattern `json:"op,omitempty"`
Presenter []ClientPattern `json:"presenter,omitempty"`
Other []ClientPattern `json:"other,omitempty"`
AllowSubgroups bool `json:"allow-subgroups,omitempty"`
AllowAnonymous bool `json:"allow-anonymous,omitempty"`
// contains filtered or unexported fields
}
Description represents a group description together with some metadata about the JSON file it was deserialised from.
func GetDescription ¶
func GetDescription(name string) (*Description, error)
GetDescription gets a group description, either from cache or from disk
func GetSanitisedDescription ¶
func GetSanitisedDescription(name string) (*Description, string, error)
GetSanitisedDescription returns the subset of the description that is published on the web interface together with a suitable ETag.
func (*Description) GetPermission ¶
func (desc *Description) GetPermission(groupname string, creds ClientCredentials) (string, []string, error)
type FullError ¶ added in v0.3.1
FullError is what a join is refused with when the group has no seat left for the client. Code is sent to the client alongside the message, so it can explain the refusal in the user's language: the three reasons need different words, and "the room is full" is not even true of the third, where there are only two people inside. The messages are the ones these refusals always carried, so a client that does not know the codes reads what it did before. (Sozvon)
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
func (*Group) AddToChatHistory ¶
func (*Group) Admit ¶
Admit lets a knocking client into a locked group, in response to an operator accepting the knock. The client is granted a one-shot permission to bypass the lock and is asked to re-join.
func (*Group) ClearChatHistory ¶
func (*Group) ClientCount ¶
func (*Group) Description ¶
func (g *Group) Description() *Description
func (*Group) GetChatHistory ¶
func (g *Group) GetChatHistory() []ChatHistoryEntry
func (*Group) GetClients ¶
func (*Group) Locked1on1 ¶
Locked1on1 reports whether the operator has engaged the 1-on-1 lock: when set, non-op clients are turned away as soon as the room has two participants already (ops are exempt, mirroring max-clients).
func (*Group) Range ¶
Range calls f for every member of the group, with g.mu held for the whole walk. The lock is not reentrant, so f must not do anything that takes it again -- DelClient, for one, takes it on entry. (Sozvon)
func (*Group) RemoveKnock ¶
RemoveKnock drops any pending knock or admission for a client id, e.g. when the client disconnects while waiting.
func (*Group) SetData ¶ added in v0.3.1
func (g *Group) SetData(set func())
SetData runs set, which must be the assignment that replaces the data of one of g's members, while holding g.mu. The group clones its members' data under g.mu, as AddClient does, so the field must change under it too. set must store a new map rather than write into the old one: a write in place races with that clone whatever lock is held here. (Sozvon)
func (*Group) SetLocked1on1 ¶
SetLocked1on1 toggles the runtime 1-on-1 lock on this group. The state is purely in-memory and is cleared on server restart, the same as the regular lock — this matches the operator-only toggle in the web client's settings drawer.
func (*Group) SetPermissions ¶ added in v0.3.1
func (g *Group) SetPermissions(set func())
SetPermissions runs set, which must do nothing but replace the permissions of one of g's members, while holding g.mu. The group reads its members' permissions under g.mu, so they must change under it too, as they do when AddClient calls Init. set must store a new slice: slices already returned by Permissions() are read without the lock. (Sozvon)
func (*Group) Status ¶
Status returns a group's status. Base is the base URL for groups; if omitted, then both the Location and Endpoint members are omitted from the result.
func (*Group) UpdateData ¶
func (*Group) UserExists ¶
Return true if there is a user entry with the given username. Always return false for an empty username.
type NotAuthorisedError ¶
type NotAuthorisedError struct {
// contains filtered or unexported fields
}
func (*NotAuthorisedError) Error ¶
func (err *NotAuthorisedError) Error() string
func (*NotAuthorisedError) Unwrap ¶
func (err *NotAuthorisedError) Unwrap() error
type Password ¶
type Password RawPassword
func (Password) MarshalJSON ¶
func (*Password) UnmarshalJSON ¶
type Permissions ¶
type Permissions struct {
// contains filtered or unexported fields
}
func NewPermissions ¶
func NewPermissions(name string) (Permissions, error)
func (Permissions) MarshalJSON ¶
func (p Permissions) MarshalJSON() ([]byte, error)
func (Permissions) Permissions ¶
func (p Permissions) Permissions(desc *Description) []string
func (Permissions) String ¶
func (p Permissions) String() string
func (*Permissions) UnmarshalJSON ¶
func (p *Permissions) UnmarshalJSON(b []byte) error
type ProtocolError ¶
type ProtocolError string
func (ProtocolError) Error ¶
func (err ProtocolError) Error() string
type RawPassword ¶
type Status ¶
type Status struct {
Name string `json:"name"`
Redirect string `json:"redirect,omitempty"`
Location string `json:"location,omitempty"`
Endpoint string `json:"endpoint,omitempty"`
DisplayName string `json:"displayName,omitempty"`
Description string `json:"description,omitempty"`
AuthServer string `json:"authServer,omitempty"`
AuthPortal string `json:"authPortal,omitempty"`
Locked bool `json:"locked,omitempty"`
Locked1on1 bool `json:"locked1on1,omitempty"`
ClientCount *int `json:"clientCount,omitempty"`
CanChangePassword bool `json:"canChangePassword,omitempty"`
Lobby bool `json:"lobby,omitempty"`
E2EE bool `json:"e2ee,omitempty"`
RequireE2EE bool `json:"requireE2ee,omitempty"`
OperatorRoom bool `json:"operatorRoom,omitempty"`
// OperatorRoomChild marks a per-client room of an operator hub. The
// client needs to know: a token minted here would belong to the child
// room, where the hub dashboard lists it as if it were a client's
// invite link, so "remember me" is not offered in such a room. (Sozvon)
OperatorRoomChild bool `json:"operatorRoomChild,omitempty"`
}
type SubGroup ¶
func GetSubGroups ¶
type SubGroupClient ¶
type SubGroupStatus ¶
type SubGroupStatus struct {
Name string `json:"name"`
Clients []SubGroupClient `json:"clients"`
Knocking []string `json:"knocking"`
}
func GetSubGroupStatus ¶
func GetSubGroupStatus(parent string) []SubGroupStatus
GetSubGroupStatus returns, for every in-memory child room of parent (parent/...), who is connected (with their operator flag) and who is waiting in the lobby. Unlike GetSubGroups it also reports rooms that hold only knockers, which the operator-room dashboard needs to see.
type UserDescription ¶
type UserDescription struct {
Password Password `json:"password"`
Permissions Permissions `json:"permissions"`
}
func GetSanitisedUser ¶
func GetSanitisedUser(group, username string, wildcard bool) (UserDescription, string, error)
func (UserDescription) MarshalJSON ¶
func (u UserDescription) MarshalJSON() ([]byte, error)
Custom MarshalJSON in order to omit empty fields