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
nexedi
galene
Commits
8bfdc2b0
Commit
8bfdc2b0
authored
Apr 25, 2020
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Display username, rename admin to op.
parent
a45914fe
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
11 deletions
+33
-11
client.go
client.go
+2
-2
group.go
group.go
+7
-7
static/sfu.html
static/sfu.html
+1
-0
static/sfu.js
static/sfu.js
+23
-2
No files found.
client.go
View file @
8bfdc2b0
...
@@ -794,7 +794,7 @@ func handleClientMessage(c *client, m clientMessage) error {
...
@@ -794,7 +794,7 @@ func handleClientMessage(c *client, m clientMessage) error {
cc
.
write
(
m
)
cc
.
write
(
m
)
}
}
case
"op"
,
"unop"
,
"present"
,
"unpresent"
:
case
"op"
,
"unop"
,
"present"
,
"unpresent"
:
if
!
c
.
permissions
.
Admin
{
if
!
c
.
permissions
.
Op
{
c
.
error
(
userError
(
"not authorised"
))
c
.
error
(
userError
(
"not authorised"
))
return
nil
return
nil
}
}
...
@@ -803,7 +803,7 @@ func handleClientMessage(c *client, m clientMessage) error {
...
@@ -803,7 +803,7 @@ func handleClientMessage(c *client, m clientMessage) error {
return
c
.
error
(
err
)
return
c
.
error
(
err
)
}
}
case
"kick"
:
case
"kick"
:
if
!
c
.
permissions
.
Admin
{
if
!
c
.
permissions
.
Op
{
c
.
error
(
userError
(
"not authorised"
))
c
.
error
(
userError
(
"not authorised"
))
return
nil
return
nil
}
}
...
...
group.go
View file @
8bfdc2b0
...
@@ -196,7 +196,7 @@ func addClient(name string, client *client, user, pass string) (*group, []userid
...
@@ -196,7 +196,7 @@ 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
!
perms
.
Op
&&
g
.
description
.
MaxClients
>
0
{
if
len
(
g
.
clients
)
>=
g
.
description
.
MaxClients
{
if
len
(
g
.
clients
)
>=
g
.
description
.
MaxClients
{
return
nil
,
nil
,
userError
(
"too many users"
)
return
nil
,
nil
,
userError
(
"too many users"
)
}
}
...
@@ -322,7 +322,7 @@ type groupDescription struct {
...
@@ -322,7 +322,7 @@ type groupDescription struct {
Public
bool
`json:"public,omitempty"`
Public
bool
`json:"public,omitempty"`
MaxClients
int
`json:"max-clients,omitempty"`
MaxClients
int
`json:"max-clients,omitempty"`
AllowAnonymous
bool
`json:"allow-anonymous,omitempty"`
AllowAnonymous
bool
`json:"allow-anonymous,omitempty"`
Admin
[]
groupUser
`json:"admin
,omitempty"`
Op
[]
groupUser
`json:"op
,omitempty"`
Presenter
[]
groupUser
`json:"presenter,omitempty"`
Presenter
[]
groupUser
`json:"presenter,omitempty"`
Other
[]
groupUser
`json:"other,omitempty"`
Other
[]
groupUser
`json:"other,omitempty"`
}
}
...
@@ -370,7 +370,7 @@ func getDescription(name string) (*groupDescription, error) {
...
@@ -370,7 +370,7 @@ func getDescription(name string) (*groupDescription, error) {
}
}
type
userPermission
struct
{
type
userPermission
struct
{
Admin
bool
`json:"admin
,omitempty"`
Op
bool
`json:"op
,omitempty"`
Present
bool
`json:"present,omitempty"`
Present
bool
`json:"present,omitempty"`
}
}
...
@@ -379,9 +379,9 @@ func getPermission(desc *groupDescription, user, pass string) (userPermission, e
...
@@ -379,9 +379,9 @@ func getPermission(desc *groupDescription, user, pass string) (userPermission, e
if
!
desc
.
AllowAnonymous
&&
user
==
""
{
if
!
desc
.
AllowAnonymous
&&
user
==
""
{
return
p
,
userError
(
"anonymous users not allowed in this group, please choose a username"
)
return
p
,
userError
(
"anonymous users not allowed in this group, please choose a username"
)
}
}
if
found
,
good
:=
matchUser
(
user
,
pass
,
desc
.
Admin
);
found
{
if
found
,
good
:=
matchUser
(
user
,
pass
,
desc
.
Op
);
found
{
if
good
{
if
good
{
p
.
Admin
=
true
p
.
Op
=
true
p
.
Present
=
true
p
.
Present
=
true
return
p
,
nil
return
p
,
nil
}
}
...
@@ -414,9 +414,9 @@ func setPermission(g *group, id string, perm string) error {
...
@@ -414,9 +414,9 @@ func setPermission(g *group, id string, perm string) error {
switch
perm
{
switch
perm
{
case
"op"
:
case
"op"
:
c
.
permissions
.
Admin
=
true
c
.
permissions
.
Op
=
true
case
"unop"
:
case
"unop"
:
c
.
permissions
.
Admin
=
false
c
.
permissions
.
Op
=
false
case
"present"
:
case
"present"
:
c
.
permissions
.
Present
=
true
c
.
permissions
.
Present
=
true
case
"unpresent"
:
case
"unpresent"
:
...
...
static/sfu.html
View file @
8bfdc2b0
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
<div
id=
"header"
>
<div
id=
"header"
>
<div
id=
"statdiv"
>
<div
id=
"statdiv"
>
<span
id=
"statspan"
></span>
<span
id=
"statspan"
></span>
<span
id=
"userspan"
></span>
<form
id=
"userform"
class=
"userform"
>
<form
id=
"userform"
class=
"userform"
>
<label
for=
"username"
>
Username:
</label>
<label
for=
"username"
>
Username:
</label>
<input
id=
"username"
type=
"text"
name=
"username"
<input
id=
"username"
type=
"text"
name=
"username"
...
...
static/sfu.js
View file @
8bfdc2b0
...
@@ -83,6 +83,7 @@ function setConnected(connected) {
...
@@ -83,6 +83,7 @@ function setConnected(connected) {
userform
.
classList
.
add
(
'
userform-invisible
'
);
userform
.
classList
.
add
(
'
userform-invisible
'
);
userform
.
classList
.
remove
(
'
userform
'
);
userform
.
classList
.
remove
(
'
userform
'
);
disconnectbutton
.
classList
.
remove
(
'
disconnect-invisible
'
);
disconnectbutton
.
classList
.
remove
(
'
disconnect-invisible
'
);
displayUsername
();
}
else
{
}
else
{
let
userpass
=
getUserPass
();
let
userpass
=
getUserPass
();
document
.
getElementById
(
'
username
'
).
value
=
document
.
getElementById
(
'
username
'
).
value
=
...
@@ -96,6 +97,7 @@ function setConnected(connected) {
...
@@ -96,6 +97,7 @@ function setConnected(connected) {
userform
.
classList
.
remove
(
'
userform-invisible
'
);
userform
.
classList
.
remove
(
'
userform-invisible
'
);
disconnectbutton
.
classList
.
add
(
'
disconnect-invisible
'
);
disconnectbutton
.
classList
.
add
(
'
disconnect-invisible
'
);
permissions
=
{};
permissions
=
{};
clearUsername
(
false
);
}
}
}
}
...
@@ -518,10 +520,29 @@ function gotUser(id, name, del) {
...
@@ -518,10 +520,29 @@ function gotUser(id, name, del) {
addUser
(
id
,
name
);
addUser
(
id
,
name
);
}
}
function
displayUsername
()
{
let
userpass
=
getUserPass
();
let
text
=
''
;
if
(
userpass
&&
userpass
.
username
)
text
=
'
as
'
+
userpass
.
username
;
if
(
permissions
.
op
&&
permissions
.
present
)
text
=
text
+
'
(op, presenter)
'
;
else
if
(
permissions
.
op
)
text
=
text
+
'
(op)
'
;
else
if
(
permissions
.
present
)
text
=
text
+
'
(presenter)
'
;
document
.
getElementById
(
'
userspan
'
).
textContent
=
text
;
}
function
clearUsername
()
{
document
.
getElementById
(
'
userspan
'
).
textContent
=
''
;
}
function
gotPermissions
(
perm
)
{
function
gotPermissions
(
perm
)
{
permissions
=
perm
;
permissions
=
perm
;
document
.
getElementById
(
'
presenterbox
'
).
disabled
=
!
perm
.
present
;
document
.
getElementById
(
'
presenterbox
'
).
disabled
=
!
perm
.
present
;
document
.
getElementById
(
'
sharebox
'
).
disabled
=
!
perm
.
present
;
document
.
getElementById
(
'
sharebox
'
).
disabled
=
!
perm
.
present
;
displayUsername
();
}
}
const
urlRegexp
=
/https
?
:
\/\/[
-a-zA-Z0-9@:%
/
._
\+
~#=?
]
+
[
-a-zA-Z0-9@:%
/
_
\+
~#=
]
/g
;
const
urlRegexp
=
/https
?
:
\/\/[
-a-zA-Z0-9@:%
/
._
\+
~#=?
]
+
[
-a-zA-Z0-9@:%
/
_
\+
~#=
]
/g
;
...
@@ -647,8 +668,8 @@ function handleInput() {
...
@@ -647,8 +668,8 @@ function handleInput() {
case
'
/kick
'
:
case
'
/kick
'
:
case
'
/present
'
:
case
'
/present
'
:
case
'
/unpresent
'
:
case
'
/unpresent
'
:
if
(
!
permissions
.
admin
)
{
if
(
!
permissions
.
op
)
{
displayError
(
"
You're not an
administ
rator
"
);
displayError
(
"
You're not an
ope
rator
"
);
return
;
return
;
}
}
let
id
;
let
id
;
...
...
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