Skip to content

Commit

Permalink
deploy: 97959ae
Browse files Browse the repository at this point in the history
  • Loading branch information
morganava committed Oct 6, 2024
1 parent df6a42e commit 33ccd40
Show file tree
Hide file tree
Showing 23 changed files with 120 additions and 44 deletions.
2 changes: 1 addition & 1 deletion coverage.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion crates/gosling/context/enum.Error.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions crates/search-index.js

Large diffs are not rendered by default.

78 changes: 71 additions & 7 deletions crates/src/tor_interface/arti_client_tor_client.rs.html
Original file line number Diff line number Diff line change
Expand Up @@ -541,10 +541,43 @@
<a href="#541" id="541">541</a>
<a href="#542" id="542">542</a>
<a href="#543" id="543">543</a>
<a href="#544" id="544">544</a>
<a href="#545" id="545">545</a>
<a href="#546" id="546">546</a>
<a href="#547" id="547">547</a>
<a href="#548" id="548">548</a>
<a href="#549" id="549">549</a>
<a href="#550" id="550">550</a>
<a href="#551" id="551">551</a>
<a href="#552" id="552">552</a>
<a href="#553" id="553">553</a>
<a href="#554" id="554">554</a>
<a href="#555" id="555">555</a>
<a href="#556" id="556">556</a>
<a href="#557" id="557">557</a>
<a href="#558" id="558">558</a>
<a href="#559" id="559">559</a>
<a href="#560" id="560">560</a>
<a href="#561" id="561">561</a>
<a href="#562" id="562">562</a>
<a href="#563" id="563">563</a>
<a href="#564" id="564">564</a>
<a href="#565" id="565">565</a>
<a href="#566" id="566">566</a>
<a href="#567" id="567">567</a>
<a href="#568" id="568">568</a>
<a href="#569" id="569">569</a>
<a href="#570" id="570">570</a>
<a href="#571" id="571">571</a>
<a href="#572" id="572">572</a>
<a href="#573" id="573">573</a>
<a href="#574" id="574">574</a>
<a href="#575" id="575">575</a>
</pre></div><pre class="rust"><code><span class="comment">// standard
</span><span class="kw">use </span>std::net::SocketAddr;
<span class="kw">use </span>std::ops::DerefMut;
<span class="kw">use </span>std::path::{Path, PathBuf};
<span class="kw">use </span>std::str::FromStr;
<span class="kw">use </span>std::sync::atomic::{AtomicBool, Ordering};
<span class="kw">use </span>std::sync::{Arc, Mutex};

Expand All @@ -559,6 +592,7 @@
<span class="kw">use </span>tor_cell::relaycell::msg::Connected;
<span class="kw">use </span>tor_hscrypto::pk::HsIdKeypair;
<span class="kw">use </span>tor_hsservice::config::OnionServiceConfigBuilder;
<span class="kw">use </span>tor_hsservice::config::restricted_discovery::HsClientNickname;
<span class="kw">use </span>tor_hsservice::{HsIdKeypairSpecifier, HsNickname, OnionServiceBuilder, RunningOnionService};
<span class="kw">use </span>tor_keymgr::{ArtiEphemeralKeystore, KeyMgrBuilder, KeystoreSelector};
<span class="kw">use </span>tor_llcrypto::pk::ed25519::ExpandedKeypair;
Expand Down Expand Up @@ -637,6 +671,7 @@
state_dir: PathBuf,
fs_mistrust: Mistrust,
pending_events: Arc&lt;Mutex&lt;Vec&lt;TorEvent&gt;&gt;&gt;,
bootstrapped: Arc&lt;AtomicBool&gt;,
}

<span class="comment">// used to forward traffic to/from arti to local tcp streams
Expand Down Expand Up @@ -750,6 +785,7 @@
state_dir,
fs_mistrust,
pending_events,
bootstrapped: Arc::new(AtomicBool::new(<span class="bool-val">false</span>)),
})
}
}
Expand All @@ -769,8 +805,12 @@
<span class="comment">// save progress events
</span><span class="kw">let </span><span class="kw-2">mut </span>bootstrap_events = <span class="self">self</span>.arti_client.bootstrap_events();
<span class="kw">let </span>pending_events = <span class="self">self</span>.pending_events.clone();
<span class="kw">let </span>bootstrapped = <span class="self">self</span>.bootstrapped.clone();
<span class="self">self</span>.tokio_runtime.spawn(<span class="kw">async move </span>{
<span class="kw">while let </span><span class="prelude-val">Some</span>(evt) = bootstrap_events.next().<span class="kw">await </span>{
<span class="kw">if </span>bootstrapped.load(Ordering::Relaxed) {
<span class="kw">break</span>;
}
<span class="kw">match </span>pending_events.lock() {
<span class="prelude-val">Ok</span>(<span class="kw-2">mut </span>pending_events) =&gt; {
pending_events.push(TorEvent::BootstrapStatus {
Expand All @@ -790,11 +830,18 @@
<span class="comment">// initiate bootstrap
</span><span class="kw">let </span>arti_client = <span class="self">self</span>.arti_client.clone();
<span class="kw">let </span>pending_events = <span class="self">self</span>.pending_events.clone();
<span class="kw">let </span>bootstrapped = <span class="self">self</span>.bootstrapped.clone();
<span class="self">self</span>.tokio_runtime.spawn(<span class="kw">async move </span>{
<span class="kw">match </span>arti_client.bootstrap().<span class="kw">await </span>{
<span class="prelude-val">Ok</span>(()) =&gt; <span class="kw">match </span>pending_events.lock() {
<span class="prelude-val">Ok</span>(<span class="kw-2">mut </span>pending_events) =&gt; {
pending_events.push(TorEvent::BootstrapStatus {
progress: <span class="number">100</span>,
tag: <span class="string">"no-tag"</span>.to_string(),
summary: <span class="string">"no summary"</span>.to_string(),
});
pending_events.push(TorEvent::BootstrapComplete);
bootstrapped.store(<span class="bool-val">true</span>, Ordering::Relaxed);
<span class="kw">return</span>;
}
<span class="prelude-val">Err</span>(<span class="kw">_</span>) =&gt; <span class="macro">unreachable!</span>(
Expand Down Expand Up @@ -910,10 +957,6 @@
virt_port: u16,
authorized_clients: <span class="prelude-ty">Option</span>&lt;<span class="kw-2">&amp;</span>[X25519PublicKey]&gt;,
) -&gt; <span class="prelude-ty">Result</span>&lt;OnionListener, tor_provider::Error&gt; {
<span class="comment">// client auth is not implemented yet
</span><span class="kw">if </span>authorized_clients.is_some() {
<span class="kw">return </span><span class="prelude-val">Err</span>(Error::NotImplemented().into());
}

<span class="comment">// try to bind to a local address, let OS pick our port
</span><span class="kw">let </span>socket_addr = SocketAddr::from(([<span class="number">127</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">1</span>], <span class="number">0u16</span>));
Expand Down Expand Up @@ -962,9 +1005,30 @@
}

<span class="comment">// create an OnionServiceConfig with the ephemeral nickname
</span><span class="kw">let </span>onion_service_config = <span class="kw">match </span>OnionServiceConfigBuilder::default()
.nickname(hs_nickname)
.build()
</span><span class="kw">let </span><span class="kw-2">mut </span>onion_service_config_builder = OnionServiceConfigBuilder::default();
onion_service_config_builder.nickname(hs_nickname);

<span class="comment">// add authorised client keys if they exist
</span><span class="kw">if let </span><span class="prelude-val">Some</span>(authorized_clients) = authorized_clients {
<span class="kw">if </span>!authorized_clients.is_empty() {
<span class="kw">let </span>restricted_discovery_config = onion_service_config_builder
.restricted_discovery();
restricted_discovery_config.enabled(<span class="bool-val">true</span>);

<span class="kw">for </span>(i, key) <span class="kw">in </span>authorized_clients.iter().enumerate() {
<span class="kw">let </span>nickname = <span class="macro">format!</span>(<span class="string">"client_{i}"</span>);
restricted_discovery_config
.static_keys()
.access()
.push((
HsClientNickname::from_str(nickname.as_str()).unwrap(),
key.inner().clone().into(),
));
}
}
}

<span class="kw">let </span>onion_service_config = <span class="kw">match </span>onion_service_config_builder.build()
{
<span class="prelude-val">Ok</span>(onion_service_config) =&gt; onion_service_config,
<span class="prelude-val">Err</span>(err) =&gt; <span class="prelude-val">Err</span>(err).map_err(Error::OnionServiceConfigBuilderError)<span class="question-mark">?</span>,
Expand Down
12 changes: 12 additions & 0 deletions crates/src/tor_interface/tor_crypto.rs.html
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,12 @@
<a href="#812" id="812">812</a>
<a href="#813" id="813">813</a>
<a href="#814" id="814">814</a>
<a href="#815" id="815">815</a>
<a href="#816" id="816">816</a>
<a href="#817" id="817">817</a>
<a href="#818" id="818">818</a>
<a href="#819" id="819">819</a>
<a href="#820" id="820">820</a>
</pre></div><pre class="rust"><code><span class="comment">// standard
</span><span class="kw">use </span>std::convert::TryInto;
<span class="kw">use </span>std::str;
Expand Down Expand Up @@ -1504,6 +1510,12 @@
</span><span class="kw">pub fn </span>as_bytes(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="kw-2">&amp;</span>[u8; X25519_PUBLIC_KEY_SIZE] {
<span class="self">self</span>.public_key.as_bytes()
}

<span class="attr">#[cfg(feature = <span class="string">"arti-client-tor-provider"</span>)]
</span><span class="kw">pub</span>(<span class="kw">crate</span>) <span class="kw">fn </span>inner(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="kw-2">&amp;</span>pk::curve25519::PublicKey {
<span class="kw-2">&amp;</span><span class="self">self</span>.public_key
}

}

<span class="kw">impl </span>std::fmt::Debug <span class="kw">for </span>X25519PublicKey {
Expand Down
Loading

0 comments on commit 33ccd40

Please sign in to comment.