Skip to content

CLI Reference

The runtime image and release archive contain one binary: p2pstream.

Release archives also include LICENSE, NOTICE, SOURCE.txt, and third-party legal notices. p2pstream is licensed under AGPL-3.0-or-later; see License.

Exact Commands And Flags

Start the server:

bash
p2pstream server

Reset a management user's password:

bash
p2pstream users reset-password USERNAME [flags]
FlagDescription
--database-urlOverride DATABASE_URL for this operation.
--password-envRead the new password from the named environment variable.
--password-fileRead the new password from a file.

Start an agent:

bash
p2pstream agent [flags]
FlagEnv varDescription
--management-urlMANAGEMENT_URLHTTPS URL of management server.
--agent-tokenAGENT_TOKENBearer token from Agent Setup.
--agent-idAGENT_IDGenerated agent public ID.
--agent-nameAGENT_NAMEOptional display name.
--management-ca-fileMANAGEMENT_CA_FILEPEM CA bundle for management HTTPS.
--management-ca-pem-base64MANAGEMENT_CA_PEM_BASE64Base64 PEM CA bundle for management HTTPS.
--management-trust-fileMANAGEMENT_TRUST_FILEWritable durable CA bundle used for acknowledged management certificate rotation.
--tls-cert-fileAGENT_TLS_CERT_FILEClient certificate for management mTLS.
--tls-key-fileAGENT_TLS_KEY_FILEClient private key for management mTLS.
--allow-insecure-managementAGENT_ALLOW_INSECURE_MANAGEMENTPermit HTTP management URL.
--tunnel-max-stream-window-bytesTUNNEL_MAX_STREAM_WINDOW_BYTESMaximum Yamux receive window per tunnel stream.
--tunnel-max-concurrent-requestsTUNNEL_MAX_CONCURRENT_REQUESTSMaximum concurrent requests handled by the agent tunnel.
--allow-targetAGENT_ALLOW_TARGETSOpt-in destination allowlist entry. Repeat the flag, or separate env entries with commas/whitespace.
--allow-any-targetAGENT_ALLOW_ANY_TARGETExplicitly permit any destination reachable by the agent.

Validation Rules

  • users reset-password requires a valid username and a password with at least 12 characters.
  • Use only one password source: prompt, --password-env, or --password-file.
  • agent requires AGENT_ID and AGENT_TOKEN.
  • Agent HTTP management URLs are rejected unless --allow-insecure-management or AGENT_ALLOW_INSECURE_MANAGEMENT is set.
  • --tunnel-max-stream-window-bytes must be at least 262144 and at most 67108864.
  • --tunnel-max-concurrent-requests must be between 1 and 2048.
  • The stream window multiplied by --tunnel-max-concurrent-requests cannot exceed 536870912 bytes.
  • When neither an allowlist nor --allow-any-target/AGENT_ALLOW_ANY_TARGET=true is set, the agent permits only IPv4 and IPv6 loopback destinations.
  • --allow-any-target cannot be combined with --allow-target entries.
  • Allow target entries are exact hostnames, IP literals, or CIDR prefixes with optional ports or port ranges, such as myapp.internal:443, 10.0.5.0/24:8080, or metrics.internal:9000-9010. IPv6 entries with ports must use brackets, for example [2001:db8::/64]:8443.

Runtime Effects

p2pstream server reads .env and environment variables, starts management on MANAGEMENT_PORT, starts public listeners from SQLite configuration, and starts ACME scheduling when available.

users reset-password updates the configured SQLite database directly and revokes active sessions for that user. Run it where the same CONFIG_DIR or DATABASE_URL is available.

If no management URL is provided to the agent, it guesses https://<local-route-ip>:8081; production agents should use the explicit URL from the Agent Setup modal opened from Agents.

Examples

Server:

bash
CONFIG_DIR=/var/lib/p2pstream \
MANAGEMENT_PUBLIC_URL=https://proxy.example.com:8081 \
p2pstream server

Interactive password reset:

bash
CONFIG_DIR=/var/lib/p2pstream \
p2pstream users reset-password admin

Noninteractive reset:

bash
RESET_PASSWORD='new long password value' \
p2pstream users reset-password admin --password-env RESET_PASSWORD

Agent:

bash
p2pstream agent \
  --management-url https://proxy.example.com:8081 \
  --management-ca-file /etc/p2pstream/management-ca.pem \
  --management-trust-file ./p2pstream-agent-state/management-ca.pem \
  --agent-id agent-abc123 \
  --agent-token "$AGENT_TOKEN" \
  --allow-target myapp.internal:443 \
  --allow-target 10.0.5.0/24:8080

Operations documentation for self-hosted p2pstream deployments.