upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/docs/tor.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/tor.md')
-rw-r--r--docs/tor.md159
1 files changed, 153 insertions, 6 deletions
diff --git a/docs/tor.md b/docs/tor.md
index 087c822..0016f8b 100644
--- a/docs/tor.md
+++ b/docs/tor.md
@@ -25,15 +25,106 @@ bitflash -tor=127.0.0.1:9150
25bitflash -tor=[::1]:9050 25bitflash -tor=[::1]:9050
26``` 26```
27 27
28For a SOCKS5 proxy that is not Tor, use `-socks` directly:
29
30```bash
31bitflash -socks=127.0.0.1:9050
32bitflash -socks=[::1]:9050
33```
34
35If both `-tor` and `-socks` are present, Tor mode wins and the node prints a
36warning. That keeps a command line with `-tor` from silently becoming a custom
37proxy route.
38
39## Managed Tor mode
40
41`-managedtor` starts a Tor process for this node, writes a local `torrc`, creates
42a v3 hidden service for the normal Bitflash P2P listener, routes outbound
43discovery through that Tor instance, and signs the generated `.onion:8433`
44endpoint into the node's `.btf` descriptor.
45
46```bash
47bitflash -managedtor
48```
49
50Without a value, Bitflash looks for Tor in this order:
51
521. `tor/tor.exe` or `tor/tor` beside the Bitflash binary;
532. `tor.exe` or `tor` beside the Bitflash binary;
543. `tor.exe` or `tor` on `PATH`.
55
56Windows releases can also be built as `Bitflash-*-windows-with-tor.zip`. That
57package includes the official Tor Expert Bundle under `tor/`, so the first path
58above exists immediately after extraction and `bitflash -managedtor` needs no
59separate Tor install.
60
61The bundled-Tor package is created by:
62
63```bash
64make windows-tor
65```
66
67The packaging script verifies a pinned SHA256 for the downloaded Tor Expert
68Bundle before copying it into the release directory. When `gpg` is available it
69also verifies the matching `.asc` signature against the pinned Tor Browser
70Developers signing-key fingerprint. Release builds should use
71`TOR_VERIFY_GPG=required make windows-tor` to make that second check mandatory.
72The Tor binary is bundled; the runtime data directory, hidden-service key, and
73control cookie are still created under the user's Bitflash data directory.
74
75To point at a specific Tor executable:
76
77```bash
78bitflash -managedtor=/opt/tor/bin/tor
79bitflash -managedtor=C:\Tor Browser\Browser\TorBrowser\Tor\tor.exe
80```
81
82Managed Tor writes its state under the Bitflash data directory:
83
84```text
85managed-tor/
86 torrc
87 data/
88 onion-service/
89```
90
91The private key for the onion address lives in `managed-tor/onion-service/`.
92Back up that directory if you want the same onion address after moving the node.
93Delete it only if you intentionally want a fresh onion endpoint.
94
95`-managedtor` takes precedence over `-tor` and `-socks`, because it must choose
96the local SOCKS port it starts. Diagnostics report the current managed Tor
97state, including the SOCKS port and onion endpoint once Tor has generated it.
98
28When Tor mode is enabled: 99When Tor mode is enabled:
29 100
30- outbound Nostr relay dials use Tor; 101- outbound Nostr relay dials use Tor;
31- outbound `.btf` rendezvous relay dials use Tor; 102- outbound `.btf` rendezvous relay dials use Tor;
103- outbound direct peer dials prefer signed `.onion` endpoints when a peer
104 advertises one;
32- destination names are sent to Tor as SOCKS5 domain-name CONNECT requests, so 105- destination names are sent to Tor as SOCKS5 domain-name CONNECT requests, so
33 the local DNS resolver does not see them; 106 the local DNS resolver does not see them;
34- direct `.onion` dials are refused unless a SOCKS5/Tor proxy is enabled; 107- direct `.onion` dials are refused unless a SOCKS5/Tor proxy is enabled;
35- plain HTTP external-IP probes are skipped. 108- plain HTTP external-IP probes are skipped.
36 109
110Tor mode affects outbound discovery and relay dials. It does not encrypt
111`wallet.dat`, hide mining rewards on-chain, or change the `.btf` identity. A
112relay still sees the TCP client that connected to it; with Tor mode that client
113is the Tor exit or onion circuit endpoint instead of the user's direct IP.
114
115## What to test
116
117Use the public status page only as a rough health check. To prove the local node
118is using Tor/SOCKS, test from the node machine:
119
120```bash
121bitflash -tor -debug
122```
123
124Then confirm in `debug.log` that Nostr and rendezvous dials report the proxy
125path. A DNS leak test should show no local resolver lookup for relay hostnames:
126the SOCKS5 request uses the domain-name form and asks the proxy to resolve it.
127
37## Onion rendezvous relay 128## Onion rendezvous relay
38 129
39An operator can expose a Bitflash rendezvous relay as a Tor hidden service. The 130An operator can expose a Bitflash rendezvous relay as a Tor hidden service. The
@@ -69,16 +160,72 @@ bitflash -operator -tor \
69 -announcerelay=exampleexampleexampleexampleexampleexampleexampleexample.onion:8434 160 -announcerelay=exampleexampleexampleexampleexampleexampleexampleexample.onion:8434
70``` 161```
71 162
72## Full-node hidden service 163## Manual direct full-node hidden service
73 164
74The legacy P2P listener still binds to port `8433`. You can expose it through 165Managed Tor is the preferred path for ordinary nodes. Operators can still expose
75Tor manually: 166the P2P listener through a separately managed Tor service:
76 167
77```text 168```text
78HiddenServiceDir /var/lib/tor/bitflash-node/ 169HiddenServiceDir /var/lib/tor/bitflash-node/
79HiddenServicePort 8433 127.0.0.1:8433 170HiddenServicePort 8433 127.0.0.1:8433
80``` 171```
81 172
82Current automatic peer discovery is `.btf`/rendezvous based, not onion-address 173After restarting Tor, read the generated onion name:
83gossip. Treat direct full-node onion access as an operator/admin tool unless a 174
84future release adds first-class onion peer advertisements. 175```bash
176sudo cat /var/lib/tor/bitflash-node/hostname
177```
178
179Then start Bitflash with Tor outbound enabled and advertise that hidden service:
180
181```bash
182bitflash -tor \
183 -onionservice=exampleexampleexampleexampleexampleexampleexampleexample.onion:8433
184```
185
186That onion endpoint is signed into this node's self-certifying `.btf`
187descriptor. New peers that resolve the descriptor and also run with `-tor` try
188the `.onion:8433` P2P connection first. If it fails, they fall back to the
189ordinary encrypted rendezvous path. Older nodes ignore the onion field and still
190use the rendezvous relay because the descriptor keeps the legacy signature too.
191
192If the node has `-onionservice` but has not registered at any rendezvous relay
193yet, it can still publish an onion-capable descriptor with
194`meeting_node = rendezvous-pending`. Tor-capable peers can dial the hidden
195service directly from that descriptor. Rendezvous becomes a fallback, not a
196precondition for being discoverable.
197
198This means rendezvous relays stop being the only way to reach a node that has
199published a hidden service. They remain useful bootstrap/fallback infrastructure,
200but an already-discovered onion-capable peer can be reached directly over Tor.
201
202Tor owns the private key under `HiddenServiceDir`; back it up if you want the
203onion name to stay stable.
204
205## Release smoke test
206
207After building a Windows binary with managed Tor support, run the two-node smoke
208test before cutting a release:
209
210```powershell
211powershell -ExecutionPolicy Bypass -File scripts\smoke-managed-tor-onion.ps1 `
212 -Bitflash .\src\bitflash.exe `
213 -Tor C:\path\to\tor.exe
214```
215
216The script creates two temporary datadirs, starts node A with `-managedtor`,
217waits for it to publish its `.btf` identity and generated `.onion` endpoint,
218then starts node B with its own `-managedtor`, `-oniononly`, and
219`-connectbtf=<node-a>`. It passes only when node B logs that it connected to
220node A `via direct onion`; rendezvous fallback cannot satisfy the test.
221
222By default the script waits 120 seconds after node A's descriptor self-resolves
223before it starts node B. Tor can create the local `hostname` before the hidden
224service descriptor is visible enough for client circuits, and early dials often
225fail with SOCKS5 reply `0x01`. Override this with `-OnionWarmupSec N` when
226testing a slow or already-warmed Tor environment.
227
228This test still uses Nostr for descriptor discovery, because that is how nodes
229learn each other's signed `.btf` descriptors. It does not require a Bitflash
230rendezvous relay to carry the P2P connection: once the descriptor includes the
231signed onion endpoint, the actual node connection goes directly through Tor.