Mark all existing options as non-updateable - #377
Open
sirzooro wants to merge 1 commit into
Open
Conversation
Initial changes to allow changing selected options at runtime. This is needed for Cryptex implementation.
sirzooro
force-pushed
the
options_not_updateable
branch
from
July 15, 2026 06:12
067b4ba to
39b05fe
Compare
There was a problem hiding this comment.
Pull request overview
This PR introduces a constructed flag on Context and uses it to make all existing ContextOptions reject mutation after context construction, establishing a baseline for future “selectively updatable options” work (notably for Cryptex).
Changes:
- Add
Context.constructedand set it duringCreateContextto gate option updates. - Make all existing options in
option.goreturnErrContextOptionNotUpdatableafter construction. - Add/adjust tests to validate the new non-updatability behavior and update a test helper to mark contexts as constructed.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
context.go |
Adds the constructed flag to Context and sets it during CreateContext. |
errors.go |
Introduces ErrContextOptionNotUpdatable for post-construction option mutation attempts. |
option.go |
Adds constructed-state checks to all existing ContextOptions. |
option_test.go |
New test coverage for option “set during construction only” behavior. |
srtp_cipher_utils_test.go |
Marks test-created contexts as constructed to align with new option gating. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
14
to
+18
| func SRTPReplayProtection(windowSize uint) ContextOption { // nolint:revive | ||
| return func(c *Context) error { | ||
| if c.constructed { | ||
| return ErrContextOptionNotUpdatable | ||
| } |
Comment on lines
+58
to
+62
| return func(c *Context) error { | ||
| c.newSRTPReplayDetector = func() replaydetector.ReplayDetector { return &testReplayDetector{} } | ||
|
|
||
| return SRTPNoReplayProtection()(c) | ||
| } |
Comment on lines
+74
to
+78
| return func(c *Context) error { | ||
| c.newSRTCPReplayDetector = func() replaydetector.ReplayDetector { return &testReplayDetector{} } | ||
|
|
||
| return SRTCPNoReplayProtection()(c) | ||
| } |
Comment on lines
+122
to
+126
| return func(c *Context) error { | ||
| c.encryptSRTP = false | ||
|
|
||
| return SRTPEncryption()(c) | ||
| } |
Comment on lines
+136
to
+140
| return func(c *Context) error { | ||
| c.encryptSRTP = true | ||
|
|
||
| return SRTPNoEncryption()(c) | ||
| } |
Comment on lines
+150
to
+154
| return func(c *Context) error { | ||
| c.encryptSRTCP = false | ||
|
|
||
| return SRTCPEncryption()(c) | ||
| } |
Comment on lines
+164
to
+168
| return func(c *Context) error { | ||
| c.encryptSRTCP = true | ||
|
|
||
| return SRTCPNoEncryption()(c) | ||
| } |
Comment on lines
+83
to
+85
| // constructed is set to true after the Context is fully initialized. | ||
| // Options can check this flag to reject updates that are only valid during construction. | ||
| constructed bool |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Initial changes to allow changing selected options at runtime. This is needed for Cryptex implementation.