Commit 841f813a authored by Nick Mathewson's avatar Nick Mathewson 🦞
Browse files

Merge branch 'dns' into 'main'

Add DNS resolver support to arti

See merge request !390
parents f23fca5e 3a6eac13
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -137,9 +137,9 @@ integration:
  image: debian:stable-slim
  script:
    - apt update
    - apt install -y tor git python3 curl
    - apt install -y tor git python3 curl dnsutils
    - ./tests/chutney/setup proxy
    - curl http://example.com -vs --socks5-hostname 127.0.0.1:9150 -o /dev/null
    - ./tests/chutney/test
    - ./tests/chutney/stop-arti
    - RUST_LOG=debug target/x86_64-unknown-linux-gnu/release/arti-bench -c ./chutney/net/nodes/arti.toml --socks5 127.0.0.1:9008 -o benchmark_results.json
    - ./tests/chutney/teardown
+56 −0
Original line number Diff line number Diff line
@@ -96,6 +96,7 @@ dependencies = [
 "tracing-appender",
 "tracing-journald",
 "tracing-subscriber",
 "trust-dns-proto",
 "winapi 0.3.9",
]

@@ -849,6 +850,12 @@ dependencies = [
 "syn",
]

[[package]]
name = "data-encoding"
version = "2.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ee2393c4a91429dffb4bedf19f4d6abf27d8a732c8ce4980305d782e5426d57"

[[package]]
name = "der"
version = "0.4.5"
@@ -1020,6 +1027,18 @@ version = "1.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457"

[[package]]
name = "enum-as-inner"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "21cdad81446a7f7dc43f6a77409efeb9733d2fa65553efef6018ef257c959b73"
dependencies = [
 "heck",
 "proc-macro2",
 "quote",
 "syn",
]

[[package]]
name = "enum-ordinalize"
version = "3.1.10"
@@ -1395,6 +1414,12 @@ dependencies = [
 "hashbrown",
]

[[package]]
name = "heck"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9"

[[package]]
name = "hermit-abi"
version = "0.1.19"
@@ -1571,6 +1596,12 @@ dependencies = [
 "libc",
]

[[package]]
name = "ipnet"
version = "2.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68f2d64f2edebec4ce84ad108148e67e1064789bee435edc5b60ad398714a3a9"

[[package]]
name = "itertools"
version = "0.10.3"
@@ -3684,6 +3715,31 @@ dependencies = [
 "syn",
]

[[package]]
name = "trust-dns-proto"
version = "0.21.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2861b3ed517888174d13909e675c4e94b3291867512068be59d76533e4d1270c"
dependencies = [
 "async-trait",
 "cfg-if 1.0.0",
 "data-encoding",
 "enum-as-inner",
 "futures-channel",
 "futures-io",
 "futures-util",
 "idna",
 "ipnet",
 "lazy_static",
 "log",
 "rand 0.8.5",
 "smallvec",
 "thiserror",
 "tinyvec",
 "tokio",
 "url",
]

[[package]]
name = "try-lock"
version = "0.2.3"
+1 −1
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ async fn main() -> Result<()> {
    // Instantiate our custom TCP provider (see implementation below).
    let tcp_rt = CustomTcpProvider { inner: rt.clone() };
    // Create a `CompoundRuntime`, swapping out the TCP part of the preferred runtime for our custom one.
    let rt = CompoundRuntime::new(rt.clone(), rt.clone(), tcp_rt, rt);
    let rt = CompoundRuntime::new(rt.clone(), rt.clone(), tcp_rt, rt.clone(), rt);

    eprintln!("connecting to Tor...");
    // Pass in our custom runtime using `with_runtime`.
+1 −1
Original line number Diff line number Diff line
@@ -724,7 +724,7 @@ impl<R: Runtime> TorClient<R> {
        hostname: &str,
        prefs: &StreamPrefs,
    ) -> crate::Result<Vec<IpAddr>> {
        let addr = (hostname, 0).into_tor_addr().map_err(wrap_err)?;
        let addr = (hostname, 1).into_tor_addr().map_err(wrap_err)?;
        addr.enforce_config(&self.addrcfg.get()).map_err(wrap_err)?;

        let circ = self.get_or_launch_exit_circ(&[], prefs).await?;
+10 −0
Original line number Diff line number Diff line
@@ -171,6 +171,10 @@ pub struct ProxyConfig {
    #[serde(default = "default_socks_port")]
    #[builder(default = "default_socks_port()")]
    socks_port: Option<u16>,
    /// Port to lisen on (at localhost) for incoming DNS connections.
    #[serde(default)]
    #[builder(default)]
    dns_port: Option<u16>,
}

/// Return the default value for `socks_port`
@@ -196,6 +200,12 @@ impl ProxyConfig {
    pub fn socks_port(&self) -> Option<u16> {
        self.socks_port
    }

    /// Return the configured DNS port for this proxy configuration,
    /// if one is enabled.
    pub fn dns_port(&self) -> Option<u16> {
        self.dns_port
    }
}

/// Structure to hold Arti's configuration options, whether from a
Loading