Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Arti
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jill
Arti
Commits
d39557b8
Commit
d39557b8
authored
3 years ago
by
Nick Mathewson
Browse files
Options
Downloads
Patches
Plain Diff
Define accessors for circuit hops.
Closes #415
parent
764930b9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
crates/tor-proto/src/circuit.rs
+25
-0
25 additions, 0 deletions
crates/tor-proto/src/circuit.rs
crates/tor-proto/src/circuit/path.rs
+14
-0
14 additions, 0 deletions
crates/tor-proto/src/circuit/path.rs
doc/semver_status.md
+3
-0
3 additions, 0 deletions
doc/semver_status.md
with
42 additions
and
0 deletions
crates/tor-proto/src/circuit.rs
+
25
−
0
View file @
d39557b8
...
...
@@ -193,6 +193,24 @@ pub(crate) struct StreamTarget {
}
impl
ClientCirc
{
/// Return a description of the first hop of this circuit.
///
/// # Panics
///
/// Panics if there is no first hop. (This should be impossible outside of
/// the tor-proto crate, but within the crate it's possible to have a
/// circuit with no hops.)
pub
fn
first_hop
(
&
self
)
->
OwnedChanTarget
{
self
.path
.first_hop
()
.expect
(
"called first_hop on an un-constructed circuit"
)
}
/// Return a description of all the hops in this circuit.
pub
fn
path
(
&
self
)
->
Vec
<
OwnedChanTarget
>
{
self
.path
.all_hops
()
}
/// Extend the circuit via the ntor handshake to a new target last
/// hop.
pub
async
fn
extend_ntor
<
Tg
>
(
&
self
,
target
:
&
Tg
,
params
:
&
CircParameters
)
->
Result
<
()
>
...
...
@@ -1029,6 +1047,13 @@ mod test {
// Did we really add another hop?
assert_eq!
(
circ
.n_hops
(),
4
);
// Do the path accessors report a reasonable outcome?
let
path
=
circ
.path
();
assert_eq!
(
path
.len
(),
4
);
use
tor_linkspec
::
ChanTarget
;
assert_eq!
(
path
[
3
]
.ed_identity
(),
example_target
()
.ed_identity
());
assert_ne!
(
path
[
0
]
.ed_identity
(),
example_target
()
.ed_identity
());
});
}
...
...
This diff is collapsed.
Click to expand it.
crates/tor-proto/src/circuit/path.rs
+
14
−
0
View file @
d39557b8
...
...
@@ -23,4 +23,18 @@ impl Path {
pub
(
super
)
fn
push_hop
(
&
self
,
target
:
OwnedChanTarget
)
{
self
.hops
.lock
()
.expect
(
"poisoned lock"
)
.push
(
target
);
}
/// Return an OwnedChanTarget representing the first hop of this path.
pub
(
super
)
fn
first_hop
(
&
self
)
->
Option
<
OwnedChanTarget
>
{
self
.hops
.lock
()
.expect
(
"poisoned lock"
)
.get
(
0
)
.map
(
Clone
::
clone
)
}
/// Return a copy of all the hops in this path.
pub
(
super
)
fn
all_hops
(
&
self
)
->
Vec
<
OwnedChanTarget
>
{
self
.hops
.lock
()
.expect
(
"poisoned lock"
)
.clone
()
}
}
This diff is collapsed.
Click to expand it.
doc/semver_status.md
+
3
−
0
View file @
d39557b8
...
...
@@ -65,6 +65,9 @@ tor-netdoc:
api-break: changed the return type of GenericRouterStatus::version()
tor-proto:
new-api: ClientCirc path accessors.
tor-protover:
new-api: Protocols now implements Eq, PartialEq, and Hash.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment