Trojan Rust

Relay Node

Configuring intermediate relay nodes

A relay node (B) verifies the relay password from upstream, connects to the next hop, and forwards traffic transparently.

Running

trojan relay -c relay.toml

Configuration

[relay]
listen = "0.0.0.0:443"
transport = "tls"              # Inbound: "tls" (default) or "plain"

[relay.auth]
password = "relay-password"

[relay.outbound]
sni = "crates.io"              # Default outbound SNI

[relay.timeouts]
handshake_timeout_secs = 5
connect_timeout_secs = 10
idle_timeout_secs = 300

Options

OptionTypeDefaultDescription
listenstringrequiredListen address
transportstring"tls"Inbound transport ("tls" or "plain")

Auth

OptionTypeDescription
passwordstringRelay authentication password (hashed with SHA-224)

Outbound

OptionTypeDescription
snistringDefault TLS SNI for outbound connections

Timeouts

OptionTypeDefaultDescription
handshake_timeout_secsint5Relay handshake timeout
connect_timeout_secsint10Outbound connection timeout
idle_timeout_secsint300Idle connection timeout

TLS Certificates

Relay nodes automatically generate self-signed certificates at startup using ECDSA P-256. No certificate files are needed.

To use specific certificates:

[relay.tls]
cert = "/path/to/cert.pem"
key = "/path/to/key.pem"

Certificate verification is skipped between relay nodes. Authentication relies on the relay password.

How It Works

  1. Upstream connects (entry node or previous relay)
  2. Relay reads the handshake: password hash + target address + metadata
  3. Password is verified against configured relay password
  4. Relay connects to the target address using the transport specified in metadata
  5. If the target is another relay, a new handshake is sent
  6. Bidirectional data relay begins

The relay node never sees the original Trojan protocol data — it only processes relay handshakes and forwards opaque bytes.

On this page