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
b134bfcf
Commit
b134bfcf
authored
Dec 04, 2020
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve error handling on join failure.
Solves the issue of groups with a name ending in "/".
parent
e3098899
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
76 additions
and
48 deletions
+76
-48
group/group.go
group/group.go
+4
-0
rtpconn/webclient.go
rtpconn/webclient.go
+27
-20
static/sfu.js
static/sfu.js
+39
-28
webserver/webserver.go
webserver/webserver.go
+6
-0
No files found.
group/group.go
View file @
b134bfcf
...
@@ -159,6 +159,10 @@ func (g *Group) API() *webrtc.API {
...
@@ -159,6 +159,10 @@ func (g *Group) API() *webrtc.API {
}
}
func
Add
(
name
string
,
desc
*
description
)
(
*
Group
,
error
)
{
func
Add
(
name
string
,
desc
*
description
)
(
*
Group
,
error
)
{
if
name
==
""
||
strings
.
HasSuffix
(
name
,
"/"
)
{
return
nil
,
UserError
(
"illegal group name"
)
}
groups
.
mu
.
Lock
()
groups
.
mu
.
Lock
()
defer
groups
.
mu
.
Unlock
()
defer
groups
.
mu
.
Unlock
()
...
...
rtpconn/webclient.go
View file @
b134bfcf
...
@@ -3,11 +3,11 @@ package rtpconn
...
@@ -3,11 +3,11 @@ package rtpconn
import
(
import
(
"encoding/json"
"encoding/json"
"errors"
"errors"
"fmt"
"log"
"log"
"os"
"os"
"sync"
"sync"
"time"
"time"
"fmt"
"github.com/gorilla/websocket"
"github.com/gorilla/websocket"
"github.com/pion/webrtc/v3"
"github.com/pion/webrtc/v3"
...
@@ -1031,29 +1031,36 @@ func handleClientMessage(c *webClient, m clientMessage) error {
...
@@ -1031,29 +1031,36 @@ func handleClientMessage(c *webClient, m clientMessage) error {
c
.
password
=
m
.
Password
c
.
password
=
m
.
Password
g
,
err
:=
group
.
AddClient
(
m
.
Group
,
c
)
g
,
err
:=
group
.
AddClient
(
m
.
Group
,
c
)
if
err
!=
nil
{
if
err
!=
nil
{
var
s
string
if
os
.
IsNotExist
(
err
)
{
if
os
.
IsNotExist
(
err
)
{
return
c
.
error
(
s
=
"group does not exist"
group
.
UserError
(
"group does not exist"
),
)
}
else
if
err
==
group
.
ErrNotAuthorised
{
}
else
if
err
==
group
.
ErrNotAuthorised
{
s
=
"not authorised"
time
.
Sleep
(
200
*
time
.
Millisecond
)
time
.
Sleep
(
200
*
time
.
Millisecond
)
s
:=
"not authorised"
}
else
if
e
,
ok
:=
err
.
(
group
.
UserError
);
ok
{
return
c
.
write
(
clientMessage
{
s
=
string
(
e
)
Type
:
"joined"
,
}
else
{
Kind
:
"fail"
,
s
=
"internal server error"
Group
:
m
.
Group
,
log
.
Printf
(
"Join group: %v"
)
Permissions
:
&
group
.
ClientPermissions
{},
Value
:
&
s
,
})
}
}
return
err
return
c
.
write
(
clientMessage
{
Type
:
"joined"
,
Kind
:
"fail"
,
Group
:
m
.
Group
,
Permissions
:
&
group
.
ClientPermissions
{},
Value
:
&
s
,
})
}
}
if
redirect
:=
g
.
Redirect
();
redirect
!=
""
{
if
redirect
:=
g
.
Redirect
();
redirect
!=
""
{
// We normally redirect at the HTTP level, but the group
// We normally redirect at the HTTP level, but the group
// description could have been edited in the meantime.
// description could have been edited in the meantime.
return
c
.
error
(
return
c
.
write
(
clientMessage
{
group
.
UserError
(
"group is now at "
+
redirect
),
Type
:
"joined"
,
)
Kind
:
"redirect"
,
Group
:
m
.
Group
,
Permissions
:
&
group
.
ClientPermissions
{},
Value
:
&
redirect
,
})
}
}
c
.
group
=
g
c
.
group
=
g
perms
:=
c
.
permissions
perms
:=
c
.
permissions
...
@@ -1264,11 +1271,11 @@ func handleClientMessage(c *webClient, m clientMessage) error {
...
@@ -1264,11 +1271,11 @@ func handleClientMessage(c *webClient, m clientMessage) error {
sg
.
Name
,
sg
.
Clients
,
plural
)
sg
.
Name
,
sg
.
Clients
,
plural
)
}
}
c
.
write
(
clientMessage
{
c
.
write
(
clientMessage
{
Type
:
"chat"
,
Type
:
"chat"
,
Dest
:
c
.
id
,
Dest
:
c
.
id
,
Username
:
"Server"
,
Username
:
"Server"
,
Time
:
group
.
ToJSTime
(
time
.
Now
()),
Time
:
group
.
ToJSTime
(
time
.
Now
()),
Value
:
&
s
,
Value
:
&
s
,
})
})
default
:
default
:
return
group
.
ProtocolError
(
"unknown group action"
)
return
group
.
ProtocolError
(
"unknown group action"
)
...
...
static/sfu.js
View file @
b134bfcf
...
@@ -271,7 +271,7 @@ function setConnected(connected) {
...
@@ -271,7 +271,7 @@ function setConnected(connected) {
userpass
?
userpass
.
password
:
''
;
userpass
?
userpass
.
password
:
''
;
userbox
.
classList
.
add
(
'
invisible
'
);
userbox
.
classList
.
add
(
'
invisible
'
);
connectionbox
.
classList
.
remove
(
'
invisible
'
);
connectionbox
.
classList
.
remove
(
'
invisible
'
);
displayError
(
"
Disconnected!
"
,
"
error
"
);
displayError
(
'
Disconnected
'
,
'
error
'
);
hideVideo
();
hideVideo
();
closeVideoControls
();
closeVideoControls
();
}
}
...
@@ -1425,43 +1425,54 @@ let presentRequested = null;
...
@@ -1425,43 +1425,54 @@ let presentRequested = null;
* @param {Object<string,boolean>} perms
* @param {Object<string,boolean>} perms
*/
*/
async
function
gotJoined
(
kind
,
group
,
perms
,
message
)
{
async
function
gotJoined
(
kind
,
group
,
perms
,
message
)
{
if
(
kind
===
'
fail
'
)
{
let
present
=
presentRequested
;
presentRequested
=
null
;
switch
(
kind
)
{
case
'
fail
'
:
displayError
(
'
The server said:
'
+
message
);
displayError
(
'
The server said:
'
+
message
);
this
.
close
();
this
.
close
();
return
;
return
;
case
'
redirect
'
:
this
.
close
();
document
.
location
=
message
;
return
;
case
'
leave
'
:
this
.
close
();
return
;
case
'
join
'
:
break
;
default
:
displayError
(
'
Unknown join message
'
);
this
.
close
();
return
;
}
}
displayUsername
();
displayUsername
();
setButtonsVisibility
();
setButtonsVisibility
();
if
(
kind
!==
'
leave
'
)
this
.
request
(
getSettings
().
request
);
this
.
request
(
getSettings
().
request
);
if
(
serverConnection
.
permissions
.
present
&&
!
findUpMedia
(
'
local
'
))
{
try
{
if
(
present
)
{
if
(
kind
===
'
join
'
&&
if
(
present
===
'
mike
'
)
serverConnection
.
permissions
.
present
&&
!
findUpMedia
(
'
local
'
))
{
updateSettings
({
video
:
''
});
if
(
presentRequested
)
{
else
if
(
present
===
'
both
'
)
if
(
presentRequested
===
'
mike
'
)
delSetting
(
'
video
'
);
updateSettings
({
video
:
''
});
reflectSettings
();
else
if
(
presentRequested
===
'
both
'
)
delSetting
(
'
video
'
);
let
button
=
getButtonElement
(
'
presentbutton
'
);
reflectSettings
();
button
.
disabled
=
true
;
try
{
let
button
=
getButtonElement
(
'
presentbutton
'
);
await
addLocalMedia
();
button
.
disabled
=
true
;
}
finally
{
try
{
button
.
disabled
=
false
;
await
addLocalMedia
();
}
finally
{
button
.
disabled
=
false
;
}
}
else
{
displayMessage
(
"
Press Present to enable your camera or microphone
"
);
}
}
}
else
{
displayMessage
(
"
Press Ready to enable your camera or microphone
"
);
}
}
}
finally
{
presentRequested
=
null
;
}
}
}
}
...
...
webserver/webserver.go
View file @
b134bfcf
...
@@ -243,6 +243,12 @@ func groupHandler(w http.ResponseWriter, r *http.Request) {
...
@@ -243,6 +243,12 @@ func groupHandler(w http.ResponseWriter, r *http.Request) {
return
return
}
}
if
strings
.
HasSuffix
(
r
.
URL
.
Path
,
"/"
)
{
http
.
Redirect
(
w
,
r
,
r
.
URL
.
Path
[
:
len
(
r
.
URL
.
Path
)
-
1
],
http
.
StatusPermanentRedirect
)
return
}
g
,
err
:=
group
.
Add
(
name
,
nil
)
g
,
err
:=
group
.
Add
(
name
,
nil
)
if
err
!=
nil
{
if
err
!=
nil
{
if
os
.
IsNotExist
(
err
)
{
if
os
.
IsNotExist
(
err
)
{
...
...
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