-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Session's contexts can now be updated #148
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #148 +/- ##
==========================================
+ Coverage 76.54% 76.71% +0.17%
==========================================
Files 17 17
Lines 1232 1254 +22
==========================================
+ Hits 943 962 +19
- Misses 198 200 +2
- Partials 91 92 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
98dcba4
to
e0fc42a
Compare
session.go
Outdated
@@ -106,17 +108,19 @@ func (s *session) close() error { | |||
} | |||
|
|||
func (s *session) start(localMasterKey, localMasterSalt, remoteMasterKey, remoteMasterSalt []byte, profile ProtectionProfile, child streamSession) error { | |||
var err error | |||
s.localContext, err = CreateContext(localMasterKey, localMasterSalt, profile, s.localOptions...) | |||
localContext, err := CreateContext(localMasterKey, localMasterSalt, profile, s.localOptions...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we call s.UpdateContext
? Just brings down the duplicated code (hopefully)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're absolutely right, plus it removes the need for the extra unit test
Do we also need to update the |
This is needed for DTLS restart, as mentioned in pion/webrtc#1636.
e0fc42a
to
c17cf2f
Compare
33e21d5
to
d55e443
Compare
I decided to take a deep look at RFC 3711, and I don' t think the
About the
There's a concept of re-keying (for instance if a key expire), during which both
I'll try to dig a bit in libwebrtc, see how they handle all of this |
e8f294f
to
a8cd890
Compare
This PR adds a
UpdateContext
to thesession
object, which allow to change the context of an already running SRTP / SRTCP session.This is needed for DTLS restart, as mentioned in pion/webrtc#1636.
Apart from the
UpdateContext
, this PR changes two things:remoteContext
is now aatomic.Value
: it previously had no locking mechanism, and none is required unless a context update is triggered.I did not benchmark anything but I assume an atomic Value will be far more efficient than a
sync.RwLock
in this specific case.session.start
no longer keeps itslocalContext
if the creation ofremoteContext
fails