1
Fork 0
mirror of https://github.com/jech/galene.git synced 2024-11-25 10:05:58 +01:00

Implement client limit.

This commit is contained in:
Juliusz Chroboczek 2020-04-25 02:37:41 +02:00
parent 2890d21c98
commit 69fcdfbaba

View file

@ -154,6 +154,11 @@ func addClient(name string, client *client, user, pass string) (*group, []userid
var users []userid var users []userid
g.mu.Lock() g.mu.Lock()
defer g.mu.Unlock() defer g.mu.Unlock()
if !perms.Admin && g.description.MaxClients > 0 {
if len(g.clients) >= g.description.MaxClients {
return nil, nil, userError("too many users")
}
}
for _, c := range g.clients { for _, c := range g.clients {
users = append(users, userid{c.id, c.username}) users = append(users, userid{c.id, c.username})
} }
@ -249,6 +254,7 @@ func matchUser(user, pass string, users []groupUser) (bool, bool) {
type groupDescription struct { type groupDescription struct {
Public bool `json:"public,omitempty"` Public bool `json:"public,omitempty"`
MaxClients int `json:"max-clients,omitempty"`
AllowAnonymous bool `json:"allow-anonymous,omitempty"` AllowAnonymous bool `json:"allow-anonymous,omitempty"`
Admin []groupUser `json:"admin,omitempty"` Admin []groupUser `json:"admin,omitempty"`
Presenter []groupUser `json:"presenter,omitempty"` Presenter []groupUser `json:"presenter,omitempty"`