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
fa299256
Commit
fa299256
authored
3 years ago
by
trinity-1686a
Browse files
Options
Downloads
Patches
Plain Diff
fix typos and minor issues
parent
604362bf
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/arti/src/dns.rs
+5
-2
5 additions, 2 deletions
crates/arti/src/dns.rs
crates/arti/src/lib.rs
+18
-13
18 additions, 13 deletions
crates/arti/src/lib.rs
crates/tor-rtcompat/src/traits.rs
+1
-1
1 addition, 1 deletion
crates/tor-rtcompat/src/traits.rs
with
24 additions
and
16 deletions
crates/arti/src/dns.rs
+
5
−
2
View file @
fa299256
...
...
@@ -19,6 +19,9 @@ use tor_rtcompat::{Runtime, UdpSocket};
use
anyhow
::{
anyhow
,
Result
};
/// Maximum lenght for receiving a single datagram
const
MAX_DATAGRAM_SIZE
:
usize
=
1536
;
/// Send an error DNS response with code NotImplemented
async
fn
not_implemented
<
U
:
UdpSocket
>
(
id
:
u16
,
addr
:
&
SocketAddr
,
socket
:
&
U
)
->
Result
<
()
>
{
let
response
=
Message
::
error_msg
(
id
,
OpCode
::
Query
,
ResponseCode
::
NotImp
);
...
...
@@ -133,7 +136,7 @@ pub(crate) async fn run_dns_resolver<R: Runtime>(
// We weren't able to bind any ports: There's nothing to do.
if
listeners
.is_empty
()
{
error!
(
"Couldn't open any DNS listeners."
);
return
Err
(
anyhow!
(
"Couldn't open
SOCK
S listeners"
));
return
Err
(
anyhow!
(
"Couldn't open
any DN
S listeners"
));
}
let
mut
incoming
=
futures
::
stream
::
select_all
(
...
...
@@ -141,7 +144,7 @@ pub(crate) async fn run_dns_resolver<R: Runtime>(
.into_iter
()
.map
(|
socket
|
{
futures
::
stream
::
unfold
(
Arc
::
new
(
socket
),
|
socket
|
async
{
let
mut
packet
=
[
0
;
1536
];
let
mut
packet
=
[
0
;
MAX_DATAGRAM_SIZE
];
let
packet
=
socket
.recv
(
&
mut
packet
)
.await
...
...
This diff is collapsed.
Click to expand it.
crates/arti/src/lib.rs
+
18
−
13
View file @
fa299256
...
...
@@ -131,6 +131,9 @@ use tracing::{info, warn};
use
std
::
convert
::
TryInto
;
/// Shorthand for a boxed and pinned Future.
type
PinnedFuture
<
T
>
=
std
::
pin
::
Pin
<
Box
<
dyn
futures
::
Future
<
Output
=
T
>>>
;
/// Run the main loop of the proxy.
///
/// # Panics
...
...
@@ -156,21 +159,23 @@ pub async fn run<R: Runtime>(
watch_cfg
::
watch_for_config_changes
(
config_sources
,
arti_config
,
client
.clone
())
?
;
}
let
mut
proxy
:
Vec
<
std
::
pin
::
Pin
<
Box
<
dyn
futures
::
Future
<
Output
=
Result
<
()
>
>>
>>
=
Vec
::
new
();
let
mut
proxy
:
Vec
<
PinnedFuture
<
(
Result
<
()
>
,
&
str
)
>>
=
Vec
::
new
();
if
socks_port
!=
0
{
proxy
.push
(
Box
::
pin
(
socks
::
run_socks_proxy
(
runtime
.clone
(),
client
.isolated_client
(),
socks_port
,
)));
let
runtime
=
runtime
.clone
();
let
client
=
client
.isolated_client
();
proxy
.push
(
Box
::
pin
(
async
move
{
let
res
=
socks
::
run_socks_proxy
(
runtime
,
client
,
socks_port
)
.await
;
(
res
,
"SOCKS"
)
}));
}
if
dns_port
!=
0
{
proxy
.push
(
Box
::
pin
(
dns
::
run_dns_resolver
(
runtime
.clone
(),
client
.isolated_client
(),
dns_port
,
)));
let
runtime
=
runtime
.clone
();
let
client
=
client
.isolated_client
();
proxy
.push
(
Box
::
pin
(
async
move
{
let
res
=
dns
::
run_dns_resolver
(
runtime
,
client
,
dns_port
)
.await
;
(
res
,
"DNS"
)
}));
}
if
proxy
.is_empty
()
{
...
...
@@ -179,12 +184,12 @@ pub async fn run<R: Runtime>(
return
Ok
(());
}
let
proxy
=
futures
::
future
::
select_all
(
proxy
);
let
proxy
=
futures
::
future
::
select_all
(
proxy
)
.map
(|(
finished
,
_index
,
_others
)|
finished
)
;
futures
::
select!
(
r
=
exit
::
wait_for_ctrl_c
()
.fuse
()
=>
r
.context
(
"waiting for termination signal"
),
r
=
proxy
.fuse
()
=>
r
.0
.context
(
"SOCKS
proxy failure"
),
=>
r
.0
.context
(
format!
(
"{}
proxy failure"
,
r
.1
)
),
r
=
async
{
client
.bootstrap
()
.await
?
;
info!
(
"Sufficiently bootstrapped; system SOCKS now functional."
);
...
...
This diff is collapsed.
Click to expand it.
crates/tor-rtcompat/src/traits.rs
+
1
−
1
View file @
fa299256
...
...
@@ -204,7 +204,7 @@ pub trait UdpSocket {
/// Connect to a remote address. After calling this [`UdpSocket::recv`] may only
/// return that same address, and the target provided to [`UdpSocket::send`] must
/// be this address.
// rational for taking &mut self: this changes the behavior of the whole socket,
// rational
e
for taking &mut self: this changes the behavior of the whole socket,
// so it should probably only be used when you have ownership of the socket and
// not when sharing it.
async
fn
connect
(
&
mut
self
,
addr
:
&
SocketAddr
)
->
IoResult
<
()
>
;
...
...
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