Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
galene
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alain Takoudjou
galene
Commits
a15915e8
Commit
a15915e8
authored
Jan 17, 2021
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tweak the autokick code.
parent
c769a4aa
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
23 deletions
+26
-23
README
README
+2
-1
group/group.go
group/group.go
+24
-22
No files found.
README
View file @
a15915e8
...
@@ -243,7 +243,8 @@ the group.
...
@@ -243,7 +243,8 @@ the group.
- `autolock`: if true, the group will start locked and become locked
- `autolock`: if true, the group will start locked and become locked
whenever there are no clients with operator privileges;
whenever there are no clients with operator privileges;
- `autokick`: if true, all clients will be kicked out whenever there are
- `autokick`: if true, all clients will be kicked out whenever there are
no clients with operator privileges.
no clients with operator privileges; this is not recommended, prefer
the `autolock` option instead;
- `redirect`: if set, then attempts to join the group will be redirected
- `redirect`: if set, then attempts to join the group will be redirected
to the given URL; most other fields are ignored in this case;
to the given URL; most other fields are ignored in this case;
- `codecs`: this is a list of codecs allowed in this group. The default
- `codecs`: this is a list of codecs allowed in this group. The default
...
...
group/group.go
View file @
a15915e8
...
@@ -438,6 +438,8 @@ func AddClient(group string, c Client) (*Group, error) {
...
@@ -438,6 +438,8 @@ func AddClient(group string, c Client) (*Group, error) {
g
.
mu
.
Lock
()
g
.
mu
.
Lock
()
defer
g
.
mu
.
Unlock
()
defer
g
.
mu
.
Unlock
()
clients
:=
g
.
getClientsUnlocked
(
nil
)
if
!
c
.
OverridePermissions
(
g
)
{
if
!
c
.
OverridePermissions
(
g
)
{
perms
,
err
:=
g
.
description
.
GetPermission
(
group
,
c
)
perms
,
err
:=
g
.
description
.
GetPermission
(
group
,
c
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -446,12 +448,29 @@ func AddClient(group string, c Client) (*Group, error) {
...
@@ -446,12 +448,29 @@ func AddClient(group string, c Client) (*Group, error) {
c
.
SetPermissions
(
perms
)
c
.
SetPermissions
(
perms
)
if
!
perms
.
Op
&&
g
.
locked
!=
nil
{
if
!
perms
.
Op
{
m
:=
*
g
.
locked
if
g
.
locked
!=
nil
{
if
m
==
""
{
m
:=
*
g
.
locked
m
=
"this group is locked"
if
m
==
""
{
m
=
"this group is locked"
}
return
nil
,
UserError
(
m
)
}
if
g
.
description
.
Autokick
{
ops
:=
false
for
_
,
c
:=
range
clients
{
if
c
.
Permissions
()
.
Op
{
ops
=
true
break
}
}
if
!
ops
{
return
nil
,
UserError
(
"there are no operators "
+
"in this group"
,
)
}
}
}
return
nil
,
UserError
(
m
)
}
}
if
!
perms
.
Op
&&
g
.
description
.
MaxClients
>
0
{
if
!
perms
.
Op
&&
g
.
description
.
MaxClients
>
0
{
...
@@ -461,27 +480,10 @@ func AddClient(group string, c Client) (*Group, error) {
...
@@ -461,27 +480,10 @@ func AddClient(group string, c Client) (*Group, error) {
}
}
}
}
clients
:=
g
.
getClientsUnlocked
(
nil
)
if
g
.
clients
[
c
.
Id
()]
!=
nil
{
if
g
.
clients
[
c
.
Id
()]
!=
nil
{
return
nil
,
ProtocolError
(
"duplicate client id"
)
return
nil
,
ProtocolError
(
"duplicate client id"
)
}
}
if
!
c
.
Permissions
()
.
Op
&&
g
.
description
.
Autokick
{
ops
:=
false
for
_
,
c
:=
range
clients
{
if
c
.
Permissions
()
.
Op
{
ops
=
true
break
}
}
if
!
ops
{
return
nil
,
UserError
(
"there are no operators in this group"
,
)
}
}
g
.
clients
[
c
.
Id
()]
=
c
g
.
clients
[
c
.
Id
()]
=
c
g
.
timestamp
=
time
.
Now
()
g
.
timestamp
=
time
.
Now
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment