This directory contains examples demonstrating how to use the Citadel Protocol for various networking scenarios, including client-server (C2S) and peer-to-peer (P2P) communication patterns.
Before running any example, you must have a Citadel server running!
- First, set the server address:
export CITADEL_SERVER_ADDR="127.0.0.1:25000"
- Start a basic server:
cargo run --example server_basic
- Keep this server running while you try other examples in separate terminals.
Additional environment variables needed for specific examples:
# For P2P examples
export CITADEL_MY_USER="user1" # Your username
export CITADEL_OTHER_USER="user2" # Peer's username you want to connect to
-
Basic Client Examples
client_basic_transient_connection.rs
: Demonstrates temporary connections without persistent user accountsclient_basic_with_server_password.rs
: Shows how to connect to password-protected serversclient_echo.rs
: A simple echo client demonstrating basic message exchange using a credentialed, persistent account
-
Server Examples
server_basic.rs
: A basic Citadel server implementationserver_basic_with_password.rs
: Server with password protection enabledserver_echo.rs
: Echo server implementation responding to client messages
-
Chat Application
chat.rs
: Interactive P2P chat application using standard input/output
-
File Operations
file_transfer.rs
: Secure file transfer between peers
-
Remote Encrypted Virtual Filesystem (RE-VFS)
revfs_read_write.rs
: Basic read/write operations using RE-VFSrevfs_delete.rs
: File deletion operationsrevfs_take.rs
: Takes a file from the RE-VFS, deleting it from the RE-VFS in the process
-
Make sure you have a server running (see "Important First Step" above)
-
Then run a client:
# Basic client
cargo run --example client_basic_transient_connection
# Or with server password
cargo run --example client_basic_with_server_password
-
Make sure you have a server running (see "Important First Step" above)
-
For the chat example, run two instances:
# First peer
export CITADEL_MY_USER="user1"
export CITADEL_OTHER_USER="user2"
cargo run --example chat
# Second peer (in another terminal)
export CITADEL_MY_USER="user2"
export CITADEL_OTHER_USER="user1"
cargo run --example chat
- For file transfer:
# Sender
export CITADEL_MY_USER="sender"
export CITADEL_OTHER_USER="receiver"
cargo run --example file_transfer
# Receiver (in another terminal)
export CITADEL_MY_USER="receiver"
export CITADEL_OTHER_USER="sender"
cargo run --example file_transfer
Each example contains detailed documentation at the top of its source file explaining specific usage and features. For more detailed information about each example, see the examples/README.md file.