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
845dccc2
Commit
845dccc2
authored
Jan 01, 2021
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement coturn's use-auth-secret.
parent
dbec9df2
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
7 deletions
+34
-7
README
README
+7
-7
group/ice.go
group/ice.go
+27
-0
No files found.
README
View file @
845dccc2
...
@@ -26,9 +26,9 @@ case of Academic and Enterprise networks), then you will need a TURN
...
@@ -26,9 +26,9 @@ case of Academic and Enterprise networks), then you will need a TURN
server running on an innocent-looking TCP port. This is the recommended
server running on an innocent-looking TCP port. This is the recommended
setup.
setup.
You should probably be running your own TURN server
— I use *coturn*. T
he
You should probably be running your own TURN server
. The address of t
he
address of the TURN server is configured in the file `data/ice-servers.json`.
TURN server is configured in the file `data/ice-servers.json`. It should
It should
look like this:
look like this:
[
[
{
{
...
@@ -36,13 +36,13 @@ It should look like this:
...
@@ -36,13 +36,13 @@ It should look like this:
"turn:turn.example.com:443",
"turn:turn.example.com:443",
"turn:turn.example.com:443?transport=tcp"
"turn:turn.example.com:443?transport=tcp"
],
],
"username": "
usernam
e",
"username": "
galen
e",
"credential": "
password
"
"credential": "
secret
"
}
}
]
]
The port number, username and password should be the same as the ones in
If you use coturn's `use-auth-secret` option, set `credentialType` to
your TURN server's configuration
.
`hmac-sha1`
.
## Set up a group
## Set up a group
...
...
group/ice.go
View file @
845dccc2
package
group
package
group
import
(
import
(
"bytes"
"crypto/hmac"
"crypto/sha1"
"encoding/base64"
"encoding/json"
"encoding/json"
"errors"
"errors"
"fmt"
"log"
"log"
"os"
"os"
"sync/atomic"
"sync/atomic"
...
@@ -29,6 +34,28 @@ func getICEServer(server ICEServer) (webrtc.ICEServer, error) {
...
@@ -29,6 +34,28 @@ func getICEServer(server ICEServer) (webrtc.ICEServer, error) {
s
.
CredentialType
=
webrtc
.
ICECredentialTypePassword
s
.
CredentialType
=
webrtc
.
ICECredentialTypePassword
case
"oauth"
:
case
"oauth"
:
s
.
CredentialType
=
webrtc
.
ICECredentialTypeOauth
s
.
CredentialType
=
webrtc
.
ICECredentialTypeOauth
case
"hmac-sha1"
:
cred
,
ok
:=
server
.
Credential
.
(
string
)
if
!
ok
{
return
webrtc
.
ICEServer
{},
errors
.
New
(
"credential is not a string"
)
}
ts
:=
time
.
Now
()
.
Unix
()
+
86400
var
username
string
if
server
.
Username
==
""
{
username
=
fmt
.
Sprintf
(
"%d"
,
ts
)
}
else
{
username
=
fmt
.
Sprintf
(
"%d:%s"
,
ts
,
server
.
Username
)
}
mac
:=
hmac
.
New
(
sha1
.
New
,
[]
byte
(
cred
))
mac
.
Write
([]
byte
(
username
))
buf
:=
bytes
.
Buffer
{}
e
:=
base64
.
NewEncoder
(
base64
.
StdEncoding
,
&
buf
)
e
.
Write
(
mac
.
Sum
(
nil
))
e
.
Close
()
s
.
Username
=
username
s
.
Credential
=
string
(
buf
.
Bytes
())
s
.
CredentialType
=
webrtc
.
ICECredentialTypePassword
default
:
default
:
return
webrtc
.
ICEServer
{},
errors
.
New
(
"unsupported credential type"
)
return
webrtc
.
ICEServer
{},
errors
.
New
(
"unsupported credential type"
)
}
}
...
...
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