-
Notifications
You must be signed in to change notification settings - Fork 0
feat(network): require fresh resolution authority before socket planning #50
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
Open
seonghobae
wants to merge
45
commits into
main
Choose a base branch
from
feat/network-consume-resolution-freshness
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
18270ff
test(network): require fresh resolution authority before planning
seonghobae 1fcc3b3
test(network): format fresh resolution planning contract
seonghobae a8da35a
test(network): isolate fresh-authority production RED
seonghobae 238770a
feat(destination): expose fresh snapshot for transport composition
seonghobae 18d3b19
feat(network): add fresh resolution connection plan
seonghobae f3981a4
fix(network): expose fresh resolution connection plan
seonghobae 8e8944e
test(network): exercise fresh connection authority
seonghobae 0d32685
test(network): satisfy strict lint contract without panic
seonghobae 435f736
docs(changelog): record fresh connection authority
seonghobae d23ff4d
test(network): preserve strict error handling in freshness integration
seonghobae 1b0915c
test(network): forbid stale public planning authority
seonghobae 7ade598
fix(network): hide untimed direct planner
seonghobae 5ac4041
test(tls): consume fresh socket authority in deadline integration
seonghobae c1378b8
test(tls): consume fresh socket authority in validity integration
seonghobae 69162ee
test(tls): consume fresh socket authority in handshake integration
seonghobae 1c9742f
style(tls): restore rustfmt newline
seonghobae a249405
style(tls): restore validity test newline
seonghobae f8b43bc
style(tls): restore handshake test newline
seonghobae 135851a
merge: align fresh socket planning with current prerequisite
seonghobae b1fc175
chore(network): realign freshness planning with current destination head
seonghobae 3f7fe10
docs(network): preserve current parent changelog during stack realign…
seonghobae 0393829
test(network): reproduce stale connection plan use
seonghobae 9038e64
fix(network): recheck resolution freshness at socket use
seonghobae 3c29eec
test(tls): supply socket-use freshness time
seonghobae 20178a2
test(tls): revalidate resolution at connect time
seonghobae 0c54ac3
test(tls): restore complete integration coverage
seonghobae 1a9de6b
test(tls): carry trusted time through socket use
seonghobae 70b5577
fix(network): preserve compatibility while rechecking socket freshness
seonghobae 01f9088
test(network): cover stale replay and time regression
seonghobae bf8281f
test(tls): use explicit socket freshness authority
seonghobae 8535d18
fix(network): require explicit socket-use freshness time
seonghobae dabae67
test(network): require explicit fresh time at socket use
seonghobae 4a7eb6b
test(tls): use explicit connect-time freshness
seonghobae 2434f85
chore(stack): merge current resolution freshness prerequisite
seonghobae ecd7884
docs(network): preserve freshness adapter changelog after stack conve…
seonghobae 20687be
chore(network): realign freshness stack on current prerequisite
seonghobae e6f74b5
Merge branch 'main' into feat/network-consume-resolution-freshness
opencode-agent[bot] 8695d40
chore(network): adopt current protected main without rewriting history
seonghobae 44c9fef
chore(network): adopt protected main #280 without rewriting history
seonghobae ae21163
chore(network): adopt current protected main
seonghobae 30d032b
Merge remote-tracking branch 'origin/main' into codex/adopt-main-pr50
seonghobae ddbefc9
fix(network): bind direct sockets to origin ports
seonghobae 2bd8518
docs(network): align public freshness contract
seonghobae e981ac4
test(network): cover default origin port binding
seonghobae ad87cfe
style(network): format default-port regression contract
seonghobae File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| use std::net::SocketAddr; | ||
| use std::time::Duration; | ||
|
|
||
| use originweave_destination::{DestinationError, FreshResolutionSnapshot}; | ||
|
|
||
| use crate::connection::{ConnectionPlan, DirectTcpConnection, NetworkError}; | ||
|
|
||
| /// A single-use direct connection plan authorized by a fresh resolution window. | ||
| /// | ||
| /// This adapter composes the destination crate's monotonic freshness authority | ||
| /// with the existing exact-socket connection planner. It performs no DNS lookup, | ||
| /// wall-clock read, proxy selection, TLS, HTTP, browser control, or persistence. | ||
| #[derive(Debug)] | ||
| pub struct FreshConnectionPlan { | ||
| connection_plan: ConnectionPlan, | ||
| resolution: FreshResolutionSnapshot, | ||
| socket_address: SocketAddr, | ||
| resolution_approved_at: Duration, | ||
| resolution_valid_until: Duration, | ||
| resolution_authorized_at: Duration, | ||
| } | ||
|
|
||
| impl FreshConnectionPlan { | ||
| /// Validate freshness and one exact direct-connection request without I/O. | ||
| pub fn new( | ||
| resolution: &FreshResolutionSnapshot, | ||
| current_time: Duration, | ||
| socket_address: SocketAddr, | ||
| connect_timeout: Duration, | ||
| maximum_attempts: u8, | ||
| ) -> Result<Self, NetworkError> { | ||
| let fresh_evidence = resolution | ||
| .authorize_connection(socket_address.ip(), current_time) | ||
| .map_err(|source| NetworkError::DestinationNotApproved { | ||
| socket_address, | ||
| source, | ||
| })?; | ||
| let connection_plan = ConnectionPlan::new( | ||
| resolution.resolution_snapshot(), | ||
| socket_address, | ||
| connect_timeout, | ||
| maximum_attempts, | ||
| )?; | ||
| Ok(Self { | ||
| connection_plan, | ||
| resolution: resolution.clone(), | ||
| socket_address, | ||
| resolution_approved_at: fresh_evidence.resolution_approved_at(), | ||
| resolution_valid_until: fresh_evidence.resolution_valid_until(), | ||
| resolution_authorized_at: fresh_evidence.authorized_at(), | ||
| }) | ||
| } | ||
|
|
||
| /// Return the trusted monotonic time at which resolution was approved. | ||
| #[must_use] | ||
| pub const fn resolution_approved_at(&self) -> Duration { | ||
| self.resolution_approved_at | ||
| } | ||
|
|
||
| /// Return the exclusive end of the resolution authority window. | ||
| #[must_use] | ||
| pub const fn resolution_valid_until(&self) -> Duration { | ||
| self.resolution_valid_until | ||
| } | ||
|
|
||
| /// Return the trusted monotonic time used to authorize this plan. | ||
| #[must_use] | ||
| pub const fn resolution_authorized_at(&self) -> Duration { | ||
| self.resolution_authorized_at | ||
| } | ||
|
|
||
| /// Open the exact approved socket only while resolution authority is still fresh. | ||
| /// | ||
| /// `current_time` must come from the same caller-owned trusted monotonic clock | ||
| /// domain used when this plan was created. Freshness is re-authorized immediately | ||
| /// before socket I/O so a plan cannot be created inside the validity window and | ||
| /// replayed after expiry. A supplied time earlier than the plan's own authorization | ||
| /// checkpoint fails closed instead of permitting clock regression. The plan remains | ||
| /// single-use because this method consumes `self`. | ||
| pub fn connect(self, current_time: Duration) -> Result<DirectTcpConnection, NetworkError> { | ||
| if current_time < self.resolution_authorized_at { | ||
| return Err(NetworkError::DestinationNotApproved { | ||
| socket_address: self.socket_address, | ||
| source: DestinationError::ResolutionUseBeforeApproval { | ||
| approved_at: self.resolution_authorized_at, | ||
| current_time, | ||
| }, | ||
| }); | ||
| } | ||
| self.resolution | ||
| .authorize_connection(self.socket_address.ip(), current_time) | ||
| .map_err(|source| NetworkError::DestinationNotApproved { | ||
| socket_address: self.socket_address, | ||
| source, | ||
| })?; | ||
| self.connection_plan.connect() | ||
|
seonghobae marked this conversation as resolved.
|
||
| } | ||
| } | ||
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.