server/README.md

71 lines
2.2 KiB
Markdown

# Meet Server
The high-performance signaling and media relay server for the Meet application. Built with **Rust**, **Axum**, and **Tokio**.
## Features
- **Signaling**: WebSocket-based room management and peer discovery.
- **Media Relay**: Custom UDP protocol for low-latency video and screen sharing.
- **Architecture**: Asynchronous, localized state management using `DashMap`.
## Prerequisites
- **Rust**: Latest stable version. Install via [rustup.rs](https://rustup.rs).
- **Build Tools**: `build-essential` (Ubuntu) or `Development Tools` group (Fedora/RHEL).
## Installation
1. **Clone the Repository**:
```bash
git clone <your-server-repo-url>
cd server
```
2. **Verify Shared Crate**:
Ensure the `shared` directory exists in the root. This contains protocol definitions used by both client (logic port) and server.
```bash
ls -F shared/
```
3. **Build**:
```bash
cargo build --release
```
The binary will be located at `target/release/server`.
## Running the Server
### Ports
- **TCP/WebSocket**: 6000 (Bind: `0.0.0.0:6000`)
- **UDP (Media)**: 4000 (Bind: `0.0.0.0:4000`)
### Local Development
```bash
cargo run
```
Runs on `0.0.0.0:6000` (HTTP/WS) and `0.0.0.0:4000` (UDP).
### Production Deployment
1. **Run the Binary**:
```bash
./target/release/server
```
2. **Firewall**:
Ensure **TCP 6000** and **UDP 4000** are open.
```bash
# Fedora/CentOS
sudo firewall-cmd --add-port=6000/tcp --permanent
sudo firewall-cmd --add-port=4000/udp --permanent
sudo firewall-cmd --reload
# Ubuntu/Debian (UFW)
sudo ufw allow 6000/tcp
sudo ufw allow 4000/udp
```
3. **Systemd (Optional)**:
Create a service file `/etc/systemd/system/meet-server.service` to keep it running.
## Project Structure
- `src/main.rs`: Entry point. Sets up Axum router and spawns the UDP listener.
- `src/handlers.rs`: WebSocket handlers for joining rooms, signaling, and chat.
- `src/udp.rs`: The core UDP packet handling loop. Manages media relaying.
- `src/state.rs`: Shared application state (Rooms, Peers).
- `shared/`: Local crate containing shared data structures (`Packet` headers, `MediaType` enums).