Skip to content

Commit 9d4d2cf

Browse files
committed
docs: more cli example in readme
1 parent 0695cf4 commit 9d4d2cf

File tree

1 file changed

+187
-5
lines changed

1 file changed

+187
-5
lines changed

README.md

Lines changed: 187 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -218,13 +218,13 @@ cargo run -p client
218218
Check the variable configuration and export the environment
219219

220220
```console
221-
set +a && source .env && set -a
221+
set -a && source .env && set +a
222222
```
223223

224224
Test server
225225

226226
```console
227-
cargo run -p server
227+
cargo run -p patela-server -- run -vv
228228
```
229229

230230
For development this can be useful for logging and reload
@@ -283,9 +283,191 @@ swtpm socket --tpm2 \
283283
export TPM2TOOLS_TCTI="swtpm:host=localhost,port=2321"
284284
```
285285

286-
## Notes
286+
### Basic CLI operations
287+
288+
#### Server Configuration
289+
290+
**Setup default Tor configuration:**
291+
292+
```bash
293+
# Import a default torrc file
294+
cargo run -p patela-server -- torrc import misc/default.torrc default
295+
296+
# View current global Tor configuration
297+
cargo run -p patela-server -- torrc get default
298+
299+
# View as JSON
300+
cargo run -p patela-server -- torrc get default --json
301+
```
302+
303+
**Setup default node (network) configuration:**
304+
305+
```bash
306+
# Set global network configuration (required fields)
307+
cargo run -p patela-server -- node set ipv4_gateway 10.10.10.1 default
308+
cargo run -p patela-server -- node set ipv6_gateway fd00:1234:5678::1 default
309+
310+
# Set optional fields
311+
cargo run -p patela-server -- node set dns_server 10.10.10.2 default
312+
cargo run -p patela-server -- node set interface_name eth0 default
313+
314+
# View current global node configuration
315+
cargo run -p patela-server -- node get default
316+
# Output:
317+
# Network Configuration:
318+
# IPv4 Gateway: 10.10.10.1
319+
# IPv6 Gateway: fd00:1234:5678::1
320+
# DNS Server: 10.10.10.2
321+
# Interface Name: eth0
322+
323+
# View as JSON
324+
cargo run -p patela-server -- node get default --json
325+
326+
# Remove optional fields (sets to null)
327+
cargo run -p patela-server -- node remove dns_server default
328+
cargo run -p patela-server -- node remove interface_name default
329+
```
330+
331+
**Complete example - Setting up a fresh server:**
332+
333+
```bash
334+
# 1. Set up default Tor configuration
335+
cargo run -p patela-server -- torrc import misc/default.torrc default
336+
# ✓ Global default configuration imported successfully
337+
338+
# 2. Set up default network configuration
339+
cargo run -p patela-server -- node set ipv4_gateway 10.10.10.1 default
340+
# ✓ Global default ipv4_gateway set to 10.10.10.1
341+
342+
cargo run -p patela-server -- node set ipv6_gateway fd00:1234:5678::1 default
343+
# ✓ Global default ipv6_gateway set to fd00:1234:5678::1
344+
345+
# 3. Verify configuration
346+
cargo run -p patela-server -- node get default
347+
# Network Configuration:
348+
# IPv4 Gateway: 10.10.10.1
349+
# IPv6 Gateway: fd00:1234:5678::1
350+
351+
cargo run -p patela-server -- torrc get default
352+
# AvoidDiskWrites 1
353+
# RelayBandwidthRate 40 MB
354+
# RelayBandwidthBurst 80 MB
355+
# ...
356+
357+
# 4. Start the server
358+
set -a && source pippo.env && set +a
359+
cargo run -p patela-server -- run -vvv
360+
361+
# 5. When a client connects, check for pending nodes
362+
cargo run -p patela-server -- list node
363+
# ID | First Seen | Last Login | Enabled | EK Public (first 16 chars)
364+
# 1 | 2025-11-17 10:30:00 | 2025-11-17 10:30:00 | false | 0123456789abcdef...
365+
366+
# 6. Enable the new node
367+
cargo run -p patela-server -- node enable 1
368+
# ✓ Node 1 enabled successfully
369+
370+
# 7. View all relays
371+
cargo run -p patela-server -- list relay
372+
# ID | Node | Name | IPv4 | IPv6 | OR Port | Dir Port
373+
# 1 | 1 | murazzano | 10.10.10.10 | fd00:1234:5678::100 | 9001 | 9030
374+
# 2 | 1 | montebore | 10.10.10.11 | fd00:1234:5678::101 | 9001 | 9030
375+
```
376+
377+
**Setup node-specific configuration:**
378+
379+
```bash
380+
# Override Tor configuration for a specific node
381+
cargo run -p patela-server -- torrc import custom-node.torrc node --id 1
382+
383+
# Override network configuration for a specific node
384+
cargo run -p patela-server -- node set ipv4_gateway 10.20.20.1 node --id 1
385+
cargo run -p patela-server -- node set dns_server 10.20.20.2 node --id 1
386+
387+
# View node-specific configuration
388+
cargo run -p patela-server -- node get node --id 1
389+
```
390+
391+
**Setup relay-specific configuration:**
392+
393+
```bash
394+
# Override Tor configuration for a specific relay
395+
cargo run -p patela-server -- torrc import custom-relay.torrc relay --id murazzano
396+
```
397+
398+
#### Node Management
287399

288-
Here are free words, both for documentation and for future blog post
400+
**List nodes and relays:**
401+
402+
```bash
403+
# List all nodes and relays
404+
cargo run -p patela-server -- list all
405+
406+
# List only nodes
407+
cargo run -p patela-server -- list node
408+
409+
# List only relays
410+
cargo run -p patela-server -- list relay
411+
412+
# Filter by name
413+
cargo run -p patela-server -- list all murazzano
414+
```
415+
416+
**Enable/disable nodes:**
417+
418+
```bash
419+
# Enable a node (allow authentication and relay creation)
420+
cargo run -p patela-server -- node enable 1
421+
422+
# Disable a node (block authentication)
423+
cargo run -p patela-server -- node disable 1
424+
```
425+
426+
#### Running the Server
427+
428+
```bash
429+
# Run with environment variables from pippo.env
430+
set -a && source pippo.env && set +a
431+
cargo run -p patela-server -- run
432+
433+
# Run with verbose logging
434+
cargo run -p patela-server -- run -vvv
435+
436+
# Run with custom options
437+
cargo run -p patela-server -- run \
438+
--host 0.0.0.0 \
439+
--port 8020 \
440+
--ssl-cert-file certs/server.cert \
441+
--ssl-key-file certs/server.key \
442+
--biscuit-key <hex-key>
443+
```
444+
445+
#### Client Operations
446+
447+
```bash
448+
# Run client (connects to server, configures relays)
449+
cargo run -p patela-client -- run --server https://server.example.com:8020
450+
451+
# Skip network setup (useful for testing)
452+
cargo run -p patela-client -- run --server https://server.example.com:8020 --skip-net
453+
454+
# Skip key restoration (fresh start)
455+
cargo run -p patela-client -- run --server https://server.example.com:8020 --skip-restore
456+
457+
# TPM operations
458+
cargo run -p patela-client -- tpm attestate
459+
cargo run -p patela-client -- tpm print-keys
460+
cargo run -p patela-client -- tpm nv-read
461+
cargo run -p patela-client -- tpm nv-write
462+
463+
# Network operations
464+
cargo run -p patela-client -- net list
465+
```
466+
467+
468+
Test tpm for attestation
469+
470+
## Notes
289471

290472
### Authentication (V2)
291473

@@ -384,7 +566,7 @@ Clear tpm from persistent setup
384566
Run patela with the server on the host
385567

386568
```console
387-
/mnt/target/x86_64-unknown-linux-gnu/debug/patela-client --server https://192.168.122.1:8020 --tpm2 /dev/tpmrm0
569+
/mnt/target/x86_64-unknown-linux-gnu/debug/patela-client --server https://10.10.10.1:8020 --tpm2 /dev/tpmrm0
388570
```
389571

390572
If you need to remove all ip address from interface for dev

0 commit comments

Comments
 (0)