All log messages are prefixed with a category for easy filtering:
| Prefix | Meaning | Examples |
|---|---|---|
[CONN] |
Connection events | New connections, closures |
[TLS] |
TLS/SSL operations | Handshakes, failures |
[HTTP] |
HTTP protocol | Requests, responses, redirects |
[PEER] |
Peer negotiation | Reverse connections, trust establishment |
[CERT] |
Certificate verification | TOFU operations, fingerprint checks |
[CLIENT] |
Outbound connections | Connecting to peers |
[ERROR] |
Error conditions | Failures, exceptions |
Successful HTTPS:
[CONN] New connection from 192.168.1.100 (port: 54321)
[TLS] Starting TLS handshake with 192.168.1.100
[TLS] ✓ Handshake successful with 192.168.1.100
[HTTP] Request from 192.168.1.100: GET /test HTTP/1.1
[PEER] Initiating reverse connection to 192.168.1.100:39001
[CLIENT] Connecting to peer: 192.168.1.100:39001
[CLIENT] Establishing TCP connection...
[CLIENT] ✗ TLS handshake failed with 192.168.1.100:39001: Connection refused
[PEER] ⚠ Reverse connection failed: Connection refused (os error 111)
[PEER] Note: This is normal if 192.168.1.100 is not running a peer server
[HTTP] Sending 200 OK response for path: /test
[HTTP] ✓ Response sent successfully to 192.168.1.100
What this means:
- Browser connected successfully ✓
- TLS worked after accepting security warning ✓
- Server tried to connect back to browser (expected to fail) ✗
- Request processed and response sent ✓
Successful bidirectional trust:
[CONN] New connection from 192.168.1.200 (port: 39001)
[TLS] Starting TLS handshake with 192.168.1.200
[TLS] ✓ Handshake successful with 192.168.1.200
[HTTP] Request from 192.168.1.200: GET / HTTP/1.1
[PEER] Initiating reverse connection to 192.168.1.200:39001
[CLIENT] Connecting to peer: 192.168.1.200:39001
[CLIENT] Establishing TCP connection...
[CLIENT] ✓ TCP connected to 192.168.1.200:39001
[CLIENT] Starting TLS handshake...
[CERT] New peer detected: 192.168.1.200:39001
[CERT] Fingerprint: abc123def456...
[CERT] Auto-trusting (TOFU)
[CERT] ✓ Peer 192.168.1.200:39001 added to trusted list
[CLIENT] ✓ TLS handshake successful with 192.168.1.200:39001
[CLIENT] Sending HTTP request...
[CLIENT] ✓ Received response (45 bytes): HTTP/1.1 200 OK...
[PEER] ✓ Mutual trust established with 192.168.1.200:39001
[HTTP] Sending 200 OK response for path: /
[HTTP] ✓ Response sent successfully to 192.168.1.200
What this means:
- Peer connected ✓
- TLS handshake succeeded ✓
- Reverse connection succeeded ✓
- Certificate trusted via TOFU ✓
- Bidirectional trust established ✓
Logs:
[CONN] New connection from 192.168.1.100 (port: 54321)
[TLS] Starting TLS handshake with 192.168.1.100
[TLS] ✗ Handshake failed with 192.168.1.100: Custom { kind: InvalidData, error: AlertReceived(CertificateUnknown) }
[TLS] Common causes:
[TLS] - Browser rejecting self-signed certificate (accept security warning)
[TLS] - Client doesn't have TOFU verifier (use Rust peer client)
[TLS] - Certificate mismatch
Solution: In your browser, accept the security warning for the self-signed certificate.
Logs:
[CERT] ✗ WARNING: Certificate changed for peer 192.168.1.200:39001!
[CERT] Expected: abc123def456...
[CERT] Received: zzz999yyy888...
[CERT] This could indicate a security issue!
[CLIENT] ✗ TLS handshake failed with 192.168.1.200:39001: Certificate fingerprint mismatch
[PEER] ⚠ Reverse connection failed: Certificate fingerprint mismatch
Causes:
- Peer regenerated their certificate
- MITM attack
- Different node at same IP
Solution:
- Verify with peer operator
- Remove old entry from
certs/trusted_peers.json - Reconnect to re-establish trust
Logs:
[CONN] New connection from 192.168.1.100 (port: 54321)
[HTTP] Plain HTTP detected from 192.168.1.100, sending 301 redirect
[HTTP] ✓ Redirected to: https://192.168.1.100:39001/test
What this means:
- Client sent HTTP instead of HTTPS
- Server sent redirect to HTTPS URL
- Client should automatically follow redirect
cargo run --bin plan1 2>&1 | grep "\[ERROR\]"cargo run --bin plan1 2>&1 | grep "\[PEER\]"cargo run --bin plan1 2>&1 | grep "\[CERT\]"cargo run --bin plan1 2>&1 | grep -v "\[PEER\]"Meaning: Client doesn't trust the certificate
Common with: Browsers, curl without -k
Solution: Accept security warning or use TOFU client
Meaning: Encryption negotiation failed
Usually follows: Certificate rejection
Solution: Same as CertificateUnknown
Meaning: Plain HTTP sent to HTTPS port
Cause: Using http:// instead of https://
Solution: Server auto-redirects, or use HTTPS directly
Meaning: Certificate signature validation failed
Cause: Missing signature bypass in verifier
Solution: Already fixed in current version
Look for reverse connection failure:
[PEER] ⚠ Reverse connection failed: Connection refused
This is normal if connecting from browser/curl.
Look for these logs on BOTH peers:
[CERT] ✓ Peer <address> added to trusted list
Check certs/trusted_peers.json:
cat certs/trusted_peers.json | jqShould show peer fingerprints.
curl -v -k https://localhost:39001/testLook for SSL/TLS handshake details.
- Operations completed successfully
- Expected outcomes
- Non-fatal issues
- Expected failures (e.g., reverse connection to browser)
- Fatal errors for that operation
- Unexpected conditions
Logging is synchronous and may impact performance under high load. For production:
- Consider using a logging framework (e.g.,
tracing,log) - Add log levels (DEBUG, INFO, WARN, ERROR)
- Make logging configurable via environment variables
Peer A (192.168.1.100:39001) logs:
[CONN] New connection from 192.168.1.200 (port: 39001)
[TLS] Starting TLS handshake with 192.168.1.200
[TLS] ✓ Handshake successful with 192.168.1.200
[HTTP] Request from 192.168.1.200: GET / HTTP/1.1
[PEER] Initiating reverse connection to 192.168.1.200:39001
[CLIENT] Connecting to peer: 192.168.1.200:39001
[CERT] New peer detected: 192.168.1.200:39001
[CERT] Fingerprint: zzz999yyy888...
[CERT] Auto-trusting (TOFU)
[CERT] ✓ Peer 192.168.1.200:39001 added to trusted list
[PEER] ✓ Mutual trust established with 192.168.1.200:39001
Peer B (192.168.1.200:39001) logs:
[CLIENT] Connecting to peer: 192.168.1.100:39001
[CERT] New peer detected: 192.168.1.100:39001
[CERT] Fingerprint: abc123def456...
[CERT] Auto-trusting (TOFU)
[CERT] ✓ Peer 192.168.1.100:39001 added to trusted list
[CLIENT] ✓ TLS handshake successful with 192.168.1.100:39001
Both peers now trust each other!