- C++ 67.2%
- Shell 23.5%
- CMake 5.5%
- Dockerfile 3.8%
| cmake | ||
| scripts | ||
| .clang-format | ||
| .dockerignore | ||
| .gitignore | ||
| CMakeLists.txt | ||
| docker-compose.yml | ||
| Dockerfile | ||
| main.cpp | ||
| model.cpp | ||
| model.hpp | ||
| README.md | ||
| run.sh | ||
| server.cpp | ||
| server.hpp | ||
| setup.sql | ||
Lab IHM Server
A C++ TCP chat server built with Qt, SQLite, and libsodium for secure messaging.
Overview
This project implements a backend server for a chat application as part of the IHM (Interface Homme-Machine) lab. It provides user authentication, message storage, and real-time messaging capabilities over TCP connections using JSON-based communication.
Features
- User authentication with Argon2id password hashing
- SQLite database for persistent storage
- TCP server handling JSON messages
- Session management for connected clients
- Message history and user management
- Admin user support
Dependencies
- Qt6 or Qt5 (Core, Sql, Network)
- libsodium (for cryptography)
- CMake (for building)
Building
- Ensure you have Qt and libsodium installed on your system.
- Create a build directory:
mkdir build cd build - Configure with CMake:
cmake .. - Build the project:
make
Running
Use the provided script:
./run.sh
Or run directly:
./lab-ihm-server
The server will start listening on port 8080.
Cross compilation
We use Docker to build the app into an ARM64 AppImage. The artifact will be built in the dist directory.
docker compose run --rm --build bundle
Database Setup
The server uses SQLite with a database file database.sqlite. The schema includes:
userstable: user information with hashed passwordsmessagestable: message storage with sender/receiver relationships
Default users are created on first run:
- admin (password: admin)
- jordan (password: admin)
- francois (password: admin)
API
The server communicates via JSON messages over TCP. Supported client message types:
- LOGIN: User authentication
- SEND: Send a message
- DELETE: Delete a message
- ERROR: Error handling
Testing
You can test the server using telnet:
telnet localhost 8080
Project Structure
main.cpp: Application entry point and server setupserver.cpp/hpp: Server logic and session managementmodel.cpp/hpp: Data structures and message handlingsetup.sql: Database schema and initial dataCMakeLists.txt: Build configurationrun.sh: Convenience script for building and running