Add optional DTLS role config param

This commit is contained in:
Sergey Stepanov 2021-12-20 22:18:43 +03:00
parent 24ff0f2ea2
commit 589cda91f4
No known key found for this signature in database
GPG key ID: A56B4929BAA8556B
3 changed files with 14 additions and 0 deletions

View file

@ -252,6 +252,13 @@ webrtc:
# turn off default Pion interceptors (see: https://github.com/pion/interceptor)
# (performance)
disableDefaultInterceptors:
# indicates the role of the DTLS transport (see: https://github.com/pion/webrtc/blob/master/dtlsrole.go)
# (debug)
# - (default)
# - 1 (auto)
# - 2 (client)
# - 3 (server)
dtlsRole:
# a list of STUN/TURN servers to use
iceServers:
- url: stun:stun.l.google.com:19302

View file

@ -4,6 +4,7 @@ import "github.com/giongto35/cloud-game/v2/pkg/config/encoder"
type Webrtc struct {
DisableDefaultInterceptors bool
DtlsRole byte
IceServers []IceServer
IcePorts struct {
Min uint16

View file

@ -36,6 +36,12 @@ func DefaultPeerConnection(conf conf.Webrtc) (*PeerConnection, error) {
settingsOnce.Do(func() {
settingEngine := pion.SettingEngine{}
if conf.DtlsRole > 0 {
log.Printf("A custom DTLS role [%v]", conf.DtlsRole)
if err := settingEngine.SetAnsweringDTLSRole(pion.DTLSRole(conf.DtlsRole)); err != nil {
panic(err)
}
}
if conf.IcePorts.Min > 0 && conf.IcePorts.Max > 0 {
if err := settingEngine.SetEphemeralUDPPortRange(conf.IcePorts.Min, conf.IcePorts.Max); err != nil {
panic(err)