Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sfu
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
sfu
Commits
df924cd4
Commit
df924cd4
authored
Apr 25, 2020
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make g.clients be a map.
parent
4ea4e7c0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
15 deletions
+18
-15
group.go
group.go
+18
-15
No files found.
group.go
View file @
df924cd4
...
...
@@ -64,7 +64,7 @@ type group struct {
description
*
groupDescription
mu
sync
.
Mutex
clients
[
]
*
client
clients
map
[
string
]
*
client
history
[]
chatHistoryEntry
}
...
...
@@ -138,6 +138,7 @@ func addGroup(name string, desc *groupDescription) (*group, error) {
g
=
&
group
{
name
:
name
,
description
:
desc
,
clients
:
make
(
map
[
string
]
*
client
),
}
groups
.
groups
[
name
]
=
g
}
else
if
desc
!=
nil
{
...
...
@@ -201,18 +202,23 @@ func addClient(name string, client *client, user, pass string) (*group, []userid
}
client
.
permissions
=
perms
var
users
[]
userid
g
.
mu
.
Lock
()
defer
g
.
mu
.
Unlock
()
if
!
perms
.
Op
&&
g
.
description
.
MaxClients
>
0
{
if
len
(
g
.
clients
)
>=
g
.
description
.
MaxClients
{
return
nil
,
nil
,
userError
(
"too many users"
)
}
}
if
g
.
clients
[
client
.
id
]
!=
nil
{
return
nil
,
nil
,
protocolError
(
"duplicate client id"
)
}
var
users
[]
userid
for
_
,
c
:=
range
g
.
clients
{
users
=
append
(
users
,
userid
{
c
.
id
,
c
.
username
})
}
g
.
clients
=
append
(
g
.
clients
,
client
)
g
.
clients
[
client
.
id
]
=
client
return
g
,
users
,
nil
}
...
...
@@ -220,19 +226,16 @@ func delClient(c *client) {
c
.
group
.
mu
.
Lock
()
defer
c
.
group
.
mu
.
Unlock
()
g
:=
c
.
group
for
i
,
cc
:=
range
g
.
clients
{
if
cc
==
c
{
g
.
clients
=
append
(
g
.
clients
[
:
i
],
g
.
clients
[
i
+
1
:
]
...
)
c
.
group
=
nil
if
len
(
g
.
clients
)
==
0
&&
!
g
.
description
.
Public
{
delGroupUnlocked
(
g
.
name
)
}
return
}
if
g
.
clients
[
c
.
id
]
!=
c
{
log
.
Printf
(
"Deleting unknown client"
)
return
}
delete
(
g
.
clients
,
c
.
id
)
if
len
(
g
.
clients
)
==
0
&&
!
g
.
description
.
Public
{
delGroupUnlocked
(
g
.
name
)
}
log
.
Printf
(
"Deleting unknown client"
)
c
.
group
=
nil
}
func
(
g
*
group
)
getClients
(
except
*
client
)
[]
*
client
{
...
...
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