onionwire/docs/arti-socks-feasibility.md
agent f95c1e7ca7
docs: rewrite README and living docs to match the tree
Audit the operator docs against the source: pin downloads to v0.14.0,
document the real CLI/flags/env/F-keys (including F9, no F7), keep 18081
as the app-owned daemon port, describe the local chat outbox vs a
server-side one, and stop implying SECURITY_AUDIT.md is a third-party
audit. Spike reports stay; they get a status header only.
2026-09-20 00:31:07 -04:00

8.5 KiB

Arti SOCKS Feasibility Report

Status: shipped as Option A (bundled arti binary as SOCKS child for .onion daemons). Living doc: WALLET.md. Verdict below is the historical finding; do not rewrite it.

Date: 2026-09-13 Scope: Can OnionWire's in-process arti-client 0.46.0 expose a SOCKS5 listener for an external process (monero-wallet-rpc child) to route its daemon traffic through Tor? Verdict: Not directly. The arti-client library does not expose a configurable SOCKS proxy listener. See options below.


What the docs say

arti-client is an outbound client library, not a SOCKS server

From docs.rs/arti-client/0.46.0:

  • The crate's public API surface is TorClient::connect(), resolve(), bootstrap(), etc. — all outbound connection primitives.
  • There is no public socks_port(), set_socks_listener(), or equivalent configuration method on TorClient or TorClientConfigBuilder.
  • TorClientConfigBuilder exposes: storage, tor_network, channel, bridges, preemptive_circuits, circuit_timing, address_filter, stream_timeouts, vanguards, system, path_rules, download_schedule, directory_tolerance. No SOCKS listener configuration.
  • The crate's own overview explicitly says: "If you are trying to glue Arti to some other programming language, right now your best bet is probably to spawn the arti CLI SOCKS proxy, as a subprocess."

This is a deliberate architectural statement: the library does not expose a SOCKS listener for external consumers.

The SOCKS functionality lives in the arti binary, not the library

  • The arti CLI (separate crate from arti-client) has a proxy subcommand: arti proxy -l debug -p 9150. This opens a SOCKS5 listener on the given port.
  • tor-socksproto (a lower-level arti crate) implements the SOCKS protocol encode/decode, and the docs say it's "only used to provide a SOCKS proxy over the Tor network" — but it's a protocol implementation, not a ready-made listener you can slot into arti-client.
  • tor-hsrproxy is for the reverse direction (onion service → local ports), not relevant here.

The one hint that SOCKS exists internally

The TorClient docs say: "This ObjectID for this object can be used as the target of a SOCKS stream." This confirms SOCKS routing exists inside the arti RPC system, but it's an internal detail, not a public listener API. There's no method to expose "here's a port, connect external processes to it."

isolated_client is relevant but not a SOCKS solution

TorClient::isolated_client() creates a new handle that shares state/config but doesn't share circuits. This is useful if you want separate isolation domains, but it doesn't give you a SOCKS listener.


Why this matters for OnionWire

The payment plan's Backend 2 (local wallet child + remote onion daemon) needs the wallet child (monero-wallet-rpc) to reach a .onion daemon through a SOCKS5 proxy. The wallet child speaks plain SOCKS5 to 127.0.0.1:<port> via --proxy. It does not use Arti's connect() — it's an external binary that only knows SOCKS5.

OnionWire already runs arti-client in-process for the messenger. The question was: can we configure that same Arti instance to also listen on a SOCKS port, so the wallet child just points --proxy 127.0.0.1:<that port> and everything routes through the same Tor client?

Answer: no, not through arti-client 0.46.0's public API.


Options

Option A: Bundle the arti binary as a SOCKS subprocess

Run the arti CLI (not arti-client) as a child process with arti proxy -p <port>. The wallet child points --proxy 127.0.0.1:<port> at it. The messenger continues using in-process arti-client.

Pros: Uses the real arti SOCKS proxy. No custom protocol code. Cons: Now you have two Tor clients — in-process arti-client for the messenger, and a subprocess arti for SOCKS. They don't share state, circuits, or configuration unless you point them at the same state dir (which may or may not be safe/supported). More moving parts. On Android, this is a third binary to bundle (messenger uses in-process arti-client, SOCKS uses arti binary, wallet uses monero-wallet-rpc).

Option B: Implement a SOCKS5 listener that forwards to in-process arti-client::connect()

Use tor-socksproto (or another SOCKS5 server crate) to accept SOCKS5 connections on a localhost port, parse the target address, and then use the in-process arti-client's connect() to open the actual Tor stream, bridging the two byte streams.

Pros: One Tor client (in-process arti-client). No second binary. The wallet child talks SOCKS5 to localhost, your code translates that to arti-client::connect() calls. Cons: You're writing a SOCKS5 server. tor-socksproto gives you the protocol encode/decode, but you still need the accept-loop, the byte bridging, the stream lifecycle management, error handling, DNS-leak precautions (SOCKS4a vs SOCKS5 remote DNS), etc. This is real code. The docs note tor-socksproto "does no networking code: it only implements the server (proxy) side of the SOCKS handshake by handling a series of bytes" — so the networking glue is on you. Also, routing all the wallet child's daemon traffic through your own SOCKS bridge means you're responsible for circuit isolation, timeout handling, and not leaking the target address via local DNS resolution.

Option C: Run a separate Tor daemon (C tor or arti binary) for SOCKS

Run a dedicated Tor SOCKS proxy (system tor, or bundled arti binary) listening on localhost. Wallet child points at it. Messenger uses in-process arti-client. Two Tor clients, but the SOCKS one is a known quantity.

Pros: Well-understood. The wallet child just works. Cons: Another binary on Android. Two Tor clients again.

Option D: Skip the SOCKS indirection — make the wallet child use Arti directly

This isn't viable. monero-wallet-rpc is a C++ binary. It speaks plain TCP or SOCKS5. It does not link arti-client. You cannot make it use in-process Arti without a SOCKS shim.


What I'd recommend

For the feasibility proof: try Option B first (a small SOCKS5 listener using tor-socksproto + arti-client::connect()), because if it works, it's the cleanest path — one Tor client, no second binary, and it directly answers the question "can the in-process Arti serve the wallet child's SOCKS needs?"

If Option B turns out to be more code than it's worth, fall back to Option A (bundle the arti binary as a SOCKS subprocess) — it's the known quantity, and the arti project itself points to this as the interop path.

Either way, the answer to "does arti-client 0.46.0 expose a SOCKS port we can use" is no — you have to build or bundle the SOCKS layer yourself.


Things to verify during the proof

  1. tor-socksproto 0.46.0 API surface — can you actually build a working SOCKS5 server with it in reasonable code, or is it too low-level? The crate docs say it handles the handshake bytes but no networking — confirm what's actually involved.
  2. DNS leak handling — SOCKS5 has a remote-DNS flag. The wallet child's daemon connection targets a .onion address, which is already a Tor address (not a DNS name), but verify the SOCKS handshake and the arti-client::connect() call handle it correctly and don't do local DNS on the target.
  3. Two-Tor-client question for Option A — if you go with bundled arti binary for SOCKS, confirm whether sharing the state dir with the in-process arti-client is safe or whether they need separate state.
  4. Android thread/runtime constraints — a SOCKS accept-loop bridging to arti-client::connect() runs in the app's Tokio runtime. Confirm it doesn't block or interfere with the messenger's Arti usage.
  5. monero-wallet-rpc --proxy behavior — confirm the wallet child actually honors --proxy for its daemon connection and speaks SOCKS5 (not just HTTP proxy or something else).

Bottom line

arti-client 0.46.0 is an outbound Tor client library. It does not expose a SOCKS5 listener. The SOCKS proxy is a feature of the arti binary, not the library. For the wallet child to route its daemon traffic through the app's Tor, you either build a SOCKS shim on top of in-process arti-client (Option B), or you run a separate SOCKS-capable Tor process (Option A/C). The cleanest architectural fit is Option B if tor-socksproto is usable for it; the safest fallback is Option A.