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
The Tor Project
Core
Arti
Commits
4ddbb3da
Commit
4ddbb3da
authored
3 years ago
by
Ian Jackson
Browse files
Options
Downloads
Patches
Plain Diff
connection preferences: Provide `set_connect_prefs` method
parent
dec0e1e7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!250
Provide TorClient::set_default_prefs and clone_with_prefs
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
crates/arti-client/src/client.rs
+22
-6
22 additions, 6 deletions
crates/arti-client/src/client.rs
with
22 additions
and
6 deletions
crates/arti-client/src/client.rs
+
22
−
6
View file @
4ddbb3da
...
...
@@ -45,7 +45,13 @@ pub struct TorClient<R: Runtime> {
/// Asynchronous runtime object.
runtime
:
R
,
/// Default isolation token for streams through this client.
///
/// This is eventually used for `owner_token` in `tor-circmgr/src/usage.rs`, and is orthogonal
/// to the `stream_token` which comes from `connect_prefs` (or a passed-in `ConnectPrefs`).
/// (ie, both must be the same to share a circuit).
client_isolation
:
IsolationToken
,
/// Connection preferences. Starts out as `Default`, Inherited by our clones.
connect_prefs
:
ConnectPrefs
,
/// Circuit manager for keeping our circuits up to date and building
/// them on-demand.
circmgr
:
Arc
<
tor_circmgr
::
CircMgr
<
R
>>
,
...
...
@@ -301,6 +307,7 @@ impl<R: Runtime> TorClient<R> {
Ok
(
TorClient
{
runtime
,
client_isolation
,
connect_prefs
:
Default
::
default
(),
circmgr
,
dirmgr
,
statemgr
,
...
...
@@ -404,8 +411,7 @@ impl<R: Runtime> TorClient<R> {
/// Note that because Tor prefers to do DNS resolution on the remote
/// side of the network, this function takes its address as a string.
pub
async
fn
connect
<
A
:
IntoTorAddr
>
(
&
self
,
target
:
A
)
->
Result
<
DataStream
>
{
self
.connect_with_prefs
(
target
,
&
ConnectPrefs
::
default
())
.await
self
.connect_with_prefs
(
target
,
&
self
.connect_prefs
)
.await
}
/// Launch an anonymized connection to the provided address and
...
...
@@ -436,10 +442,21 @@ impl<R: Runtime> TorClient<R> {
Ok
(
stream
)
}
/// Sets the default preferences for future connections made with this client.
///
/// The preferences set with this function will be inherited by clones of this client, but
/// updates to the preferences in those clones will not propagate back to the original. I.e.,
/// the preferences are copied by `clone`.
///
/// Connection preferences always override configuration, even configuration set later
/// (eg, by a config reload).
pub
fn
set_connect_prefs
(
&
mut
self
,
connect_prefs
:
ConnectPrefs
)
{
self
.connect_prefs
=
connect_prefs
;
}
/// On success, return a list of IP addresses.
pub
async
fn
resolve
(
&
self
,
hostname
:
&
str
)
->
Result
<
Vec
<
IpAddr
>>
{
self
.resolve_with_prefs
(
hostname
,
&
ConnectPrefs
::
default
())
.await
self
.resolve_with_prefs
(
hostname
,
&
self
.connect_prefs
)
.await
}
/// On success, return a list of IP addresses, but use prefs.
...
...
@@ -466,8 +483,7 @@ impl<R: Runtime> TorClient<R> {
///
/// On success, return a list of hostnames.
pub
async
fn
resolve_ptr
(
&
self
,
addr
:
IpAddr
)
->
Result
<
Vec
<
String
>>
{
self
.resolve_ptr_with_prefs
(
addr
,
&
ConnectPrefs
::
default
())
.await
self
.resolve_ptr_with_prefs
(
addr
,
&
self
.connect_prefs
)
.await
}
/// Perform a remote DNS reverse lookup with the provided IP address.
...
...
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