Skip to content

Commit 80fd6d8

Browse files
committed
Expose SRTP protection profiles in setting engine
Allows to override default SRTP protection profiles in settingengine.go
1 parent 9d59da5 commit 80fd6d8

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ Check out the **[contributing wiki](https://github.com/pion/webrtc/wiki/Contribu
274274
* [Tomek](https://github.com/trojek)
275275
* [Jin Gong](https://github.com/cgojin)
276276
* [yusuke](https://github.com/yusukem99)
277+
* [Patryk Rogalski](https://github.com/digitalix)
277278

278279
### License
279280
MIT License - see [LICENSE](LICENSE) for full text

dtlstransport.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -301,10 +301,16 @@ func (t *DTLSTransport) Start(remoteParameters DTLSParameters) error {
301301
PrivateKey: cert.privateKey,
302302
},
303303
},
304-
SRTPProtectionProfiles: []dtls.SRTPProtectionProfile{dtls.SRTP_AEAD_AES_128_GCM, dtls.SRTP_AES128_CM_HMAC_SHA1_80},
305-
ClientAuth: dtls.RequireAnyClientCert,
306-
LoggerFactory: t.api.settingEngine.LoggerFactory,
307-
InsecureSkipVerify: true,
304+
SRTPProtectionProfiles: func() []dtls.SRTPProtectionProfile {
305+
if len(t.api.settingEngine.srtpProtectionProfiles) > 0 {
306+
return t.api.settingEngine.srtpProtectionProfiles
307+
}
308+
309+
return []dtls.SRTPProtectionProfile{dtls.SRTP_AEAD_AES_128_GCM, dtls.SRTP_AES128_CM_HMAC_SHA1_80}
310+
}(),
311+
ClientAuth: dtls.RequireAnyClientCert,
312+
LoggerFactory: t.api.settingEngine.LoggerFactory,
313+
InsecureSkipVerify: true,
308314
}, nil
309315
}
310316

settingengine.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"io"
77
"time"
88

9+
"github.com/pion/dtls/v2"
910
"github.com/pion/ice/v2"
1011
"github.com/pion/logging"
1112
"github.com/pion/transport/packetio"
@@ -61,6 +62,7 @@ type SettingEngine struct {
6162
iceUDPMux ice.UDPMux
6263
iceProxyDialer proxy.Dialer
6364
disableMediaEngineCopy bool
65+
srtpProtectionProfiles []dtls.SRTPProtectionProfile
6466
}
6567

6668
// DetachDataChannels enables detaching data channels. When enabled
@@ -70,6 +72,11 @@ func (e *SettingEngine) DetachDataChannels() {
7072
e.detach.DataChannels = true
7173
}
7274

75+
// SetSRTPProtectionProfiles overrides default srtp protection profiles
76+
func (e *SettingEngine) SetSRTPProtectionProfiles(profiles ...dtls.SRTPProtectionProfile) {
77+
e.srtpProtectionProfiles = profiles
78+
}
79+
7380
// SetICETimeouts sets the behavior around ICE Timeouts
7481
// * disconnectedTimeout is the duration without network activity before a Agent is considered disconnected. Default is 5 Seconds
7582
// * failedTimeout is the duration without network activity before a Agent is considered failed after disconnected. Default is 25 Seconds

0 commit comments

Comments
 (0)