Add TURN server support
This commit is contained in:
parent
92f1e7ba04
commit
4be18ea3a2
|
@ -12,7 +12,7 @@ import (
|
|||
|
||||
// Version of the config format - when new fields are added, it will attempt
|
||||
// to write the settings.toml to disk so new defaults populate.
|
||||
var currentVersion = 2
|
||||
var currentVersion = 3
|
||||
|
||||
// Config for your BareRTC app.
|
||||
type Config struct {
|
||||
|
@ -37,9 +37,17 @@ type Config struct {
|
|||
MaxImageWidth int
|
||||
PreviewImageWidth int
|
||||
|
||||
TURN TurnConfig
|
||||
|
||||
PublicChannels []Channel
|
||||
}
|
||||
|
||||
type TurnConfig struct {
|
||||
URLs []string
|
||||
Username string
|
||||
Credential string
|
||||
}
|
||||
|
||||
// GetChannels returns a JavaScript safe array of the default PublicChannels.
|
||||
func (c Config) GetChannels() template.JS {
|
||||
data, _ := json.Marshal(c.PublicChannels)
|
||||
|
@ -90,6 +98,11 @@ func DefaultConfig() Config {
|
|||
},
|
||||
},
|
||||
},
|
||||
TURN: TurnConfig{
|
||||
URLs: []string{
|
||||
"stun:stun.l.google.com:19302",
|
||||
},
|
||||
},
|
||||
}
|
||||
c.JWT.Strict = true
|
||||
return c
|
||||
|
|
|
@ -2,9 +2,18 @@
|
|||
|
||||
// WebRTC configuration.
|
||||
const configuration = {
|
||||
iceServers: [{
|
||||
urls: 'stun:stun.l.google.com:19302'
|
||||
}]
|
||||
iceServers: TURN.URLs.map(val => {
|
||||
let row = {
|
||||
urls: val,
|
||||
};
|
||||
|
||||
if (val.indexOf('turn:') === 0) {
|
||||
row.username = TURN.Username;
|
||||
row.credential = TURN.Credential;
|
||||
}
|
||||
|
||||
return row;
|
||||
})
|
||||
};
|
||||
|
||||
const FileUploadMaxSize = 1024 * 1024 * 8; // 8 MB
|
||||
|
|
|
@ -1041,6 +1041,7 @@
|
|||
const PublicChannels = {{.Config.GetChannels}};
|
||||
const WebsiteURL = "{{.Config.WebsiteURL}}";
|
||||
const PermitNSFW = {{AsJS .Config.PermitNSFW}};
|
||||
const TURN = {{.Config.TURN}};
|
||||
const UserJWTToken = {{.JWTTokenString}};
|
||||
const UserJWTValid = {{if .JWTAuthOK}}true{{else}}false{{end}};
|
||||
const UserJWTClaims = {{.JWTClaims.ToJSON}};
|
||||
|
|
Loading…
Reference in New Issue
Block a user