Add replay protection setting to SettingEngine

Set windows size of each protocol by:
- SetDTLSReplayProtectionWindow
- SetSRTPReplayProtectionWindow
- SetSRTCPReplayProtectionWindow
This commit is contained in:
Atsushi Watanabe
2020-03-29 19:20:17 +09:00
committed by Sean DuBois
parent 58338965b2
commit 438ac1eb2f
3 changed files with 63 additions and 0 deletions

View File

@@ -89,3 +89,30 @@ func TestSetAnsweringDTLSRole(t *testing.T) {
assert.Error(t, s.SetAnsweringDTLSRole(DTLSRoleAuto), "SetAnsweringDTLSRole can only be called with DTLSRoleClient or DTLSRoleServer")
assert.Error(t, s.SetAnsweringDTLSRole(DTLSRole(0)), "SetAnsweringDTLSRole can only be called with DTLSRoleClient or DTLSRoleServer")
}
func TestSetReplayProtection(t *testing.T) {
s := SettingEngine{}
if s.replayProtection.DTLS != nil ||
s.replayProtection.SRTP != nil ||
s.replayProtection.SRTCP != nil {
t.Fatalf("SettingEngine defaults aren't as expected.")
}
s.SetDTLSReplayProtectionWindow(128)
s.SetSRTPReplayProtectionWindow(64)
s.SetSRTCPReplayProtectionWindow(32)
if s.replayProtection.DTLS == nil ||
*s.replayProtection.DTLS != 128 {
t.Errorf("Failed to set DTLS replay protection window")
}
if s.replayProtection.SRTP == nil ||
*s.replayProtection.SRTP != 64 {
t.Errorf("Failed to set SRTP replay protection window")
}
if s.replayProtection.SRTCP == nil ||
*s.replayProtection.SRTCP != 32 {
t.Errorf("Failed to set SRTCP replay protection window")
}
}