mirror of
https://github.com/jech/galene.git
synced 2024-11-25 01:55:57 +01:00
Implement client limit.
This commit is contained in:
parent
2890d21c98
commit
69fcdfbaba
1 changed files with 6 additions and 0 deletions
6
group.go
6
group.go
|
@ -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"`
|
||||||
|
|
Loading…
Reference in a new issue