{"id":23385784,"url":"https://github.com/francoyudica/theychat","last_synced_at":"2025-04-11T03:52:57.539Z","repository":{"id":241679115,"uuid":"801137871","full_name":"FrancoYudica/TheyChat","owner":"FrancoYudica","description":"Client-server chat application that facilitates secure communication and file transferring. Built with CMake and designed for POSIX systems, it features a multithreaded server, a simple text-based client UI using ncurses, and SSL encryption for secure message transfer.","archived":false,"fork":false,"pushed_at":"2024-07-18T16:31:44.000Z","size":6746,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-11T03:52:52.021Z","etag":null,"topics":["chat-application","multithreading","ncurses","openssl","tcp-client","tcp-server","tls","tls-certificate"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FrancoYudica.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-15T17:03:47.000Z","updated_at":"2025-02-17T03:21:53.000Z","dependencies_parsed_at":"2024-05-29T16:51:18.059Z","dependency_job_id":"dc681c3f-db5c-480e-a922-3d4548e5f624","html_url":"https://github.com/FrancoYudica/TheyChat","commit_stats":null,"previous_names":["francoyudica/theychat"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FrancoYudica%2FTheyChat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FrancoYudica%2FTheyChat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FrancoYudica%2FTheyChat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FrancoYudica%2FTheyChat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FrancoYudica","download_url":"https://codeload.github.com/FrancoYudica/TheyChat/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248339261,"owners_count":21087214,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chat-application","multithreading","ncurses","openssl","tcp-client","tcp-server","tls","tls-certificate"],"created_at":"2024-12-22T00:29:20.606Z","updated_at":"2025-04-11T03:52:57.521Z","avatar_url":"https://github.com/FrancoYudica.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# They Chat\n\n## Overview\n\nTheyChat is a client-server chat application developed solely by me. The application allows multiple clients to connect to a server,exchange messages and files. The project is built using CMake and is designed to run on POSIX systems, utilizing pthreads for multithreading and ncurses for a simple client UI. Communication between the client and server is encrypted using OpenSSL.\n\n![ ](demo_screenshot_0.png)\n\n\n## Features\n\n- **Multithreaded Server**: Handles multiple clients concurrently using pthreads.\n- **Client UI**: Simple text-based interface built with ncurses.\n- **Encrypted Communication**: Ensures secure message transfer using SSL.\n- **File transferring**: Clients can upload and download files.\n- **Commands**: Clients can send messages and execute commands.\n- **Cross-platform**: Designed to run on POSIX-compliant systems.\n- **CMake Build System**: Easy to build and manage the project.\n- **MIT Licensed**: Open-source and freely available for modification and distribution.\n\n### Networking Implementation\n\nAll the networking functionality in this project has been implemented from scratch using raw sockets. This means that no additional libraries or frameworks were used to handle network communication. The code directly interacts with the underlying operating system's networking stack to manage connections, data transfer, and other network-related tasks. This approach ensures a deeper understanding and control over the networking processes, making the implementation more robust and customizable.\n\n#### Learning Objective\n\nThe primary goal of this project is to facilitate learning and to gain a comprehensive understanding of network programming at a low level. By building the networking stack from the ground up, this project provides invaluable insights into the intricacies of network communication, socket programming, and error handling.\n\n## Getting Started\n\n### Prerequisites\n\n- **POSIX-compliant system** (Linux, macOS, etc.)\n- **C 17** compatible compiler\n- **CMake**\n- **OpenSSL** (library `libssl-dev` installed)\n- **ncurses** (`ncurses` installed)\n\n### Building the Project\nThe following process builds server and client:\n1. Clone the repository:\n    ```sh\n    git clone --recursive https://github.com/FrancoYudica/TheyChat.git\n    cd TheyChat\n    ```\n\n2. Create a build directory and navigate into it:\n    ```sh\n    mkdir build\n    cd build\n    ```\n\n3. Run CMake to configure the project:\n    ```sh\n    cmake ..\n    ```\n\n    **Build Options:**\n    - `THEY_CHAT_SSL`: Enable or disable SSL encryption.\n      ```sh\n      cmake -DTHEY_CHAT_SSL=ON ..\n      ```         \n        If `THEY_CHAT_SSL` is enabled and you want to run the sever, a certificate and key file should be provided. By default, the application expects the certificate and key to be located in `~/.ssl/TheyChat/` directory with filenames `certificate.pem` and `private.key` respectively.\n\n        To generate the certificate and key, you can use the `generate_ssl.sh` script. This script creates the necessary files in the `~/.ssl/TheyChat/` directory. The generated certificate is a self-signed certificate, created for testing purposes.\n\n        ```sh\n        chmod +x generate_ssl.sh\n        ./generate_ssl.sh\n        ```\n    - `THEY_CHAT_COMPILE_TESTS`: Enable or disable tests.\n      ```sh\n      cmake -DTHEY_CHAT_COMPILE_TESTS=ON ..\n      ```\n\n    - `THEY_CHAT_STATIC_LINK`: Compile libraries as static.\n      ```sh\n      cmake -THEY_CHAT_STATIC_LINK=ON ..\n      ```\n\n4. Build the project:\n    ```sh\n    make\n    ```\n   \n\n### Precompiled binaries\nThis project provides precompiled binaries for various platforms to facilitate easy installation and usage.\nAll the dependencies, except for `libc` are statically linked.\n\n#### Linux x86_64\nThere are two versions:\n- [Linux x86_64](https://github.com/FrancoYudica/TheyChat/blob/main/releases/TheyChat_linux_x86_64.zip) communication not encrypted.\n- [Linux x86_64 SSL](https://github.com/FrancoYudica/TheyChat/blob/main/releases/TheyChat_linux_x86_64_ssl.zip) communication encrypted with OpenSSL.\n\n\u003e [!WARNING]\n\u003e These binaries are tested in Ubuntu, but should work in Debian, Fedora, CentOS, Arch and more.\n\n### Running programs\nFor **server** navigate to the build/server directory and run executable: ```./server```\n\nFor **client** navigate to the build/client directory and run executable: ```./client```\n\n\u003e [!TIP]  \n\u003e Note that both programs accept arguments, such as status port, task port and more.\n\n## Usage\n\n### Server\nOnce the program is executed, it listens for incoming client connections, handling different states such as *login*, *chat*, *disconnect* and more.\nThe only accepted inputs are signals that terminate the program, such as ctrl+c or closing the terminal. Note that if the server is exited with one of the accepted signals, it closes all the connections and cleanly frees all memory.\n\n### Client\nClient is a command based program, meaning that all the interactions are executed with defined commands. \n\u003e [!TIP]  \n\u003e If you want to check the available commands, execute `/h`. Keep in mind that the available commands change in different states of the program. \n\nIt starts in the **offline state**, and the connection with the server should be established with the `/connect` command, where the server IP is expected as argument. Once connected to the server, the program enters **login state**, asks for a unique username, and then enters the **chat state**. Once you are done using client program you can use `/quit` or `/disconnect` in case you want to got to the **offline state**.\n\n#### Commands\n- ```/help```: Lists all the available commands in the current program state.\n- ```/connect```: Establishes connection with server.\n- ```/disconnect```: Disconnects from server, and transitions to offline state\n- ```/quit```: Quits the application\n- ```/users```: Lists all connected users, and allows arguments such as *ip* to see the ip of users.\n- ```/files```: Lists downloadable files with it's name, id and owner.\n- ```/upload```: Uploads a file to the server\n- ```/download```: Downloads a file from the server\n- ```/remove```: Removes uploaded file/s. You can specify individual files id or use argument *all* to remove all\n\n## File transferring\nSince TheyChat uses a client-server architecture, clients should first upload files to the server. When any client uploads a file, all the other clients can download the file, by it's name (if it's unique) or it's id.\nAlso, uploaded files can be removed from the server, and a notification will be sent to all clients.\nDownloaded files are located inside ```resources/downloads``` folder.\n\u003e [!IMPORTANT]\n\u003e You should keep in mind that when client disconnects, all it's uploaded files are removed from the server.\n\n## Windows support\n\u003e [!CAUTION]\n\u003e The server and client can be compiled and executed on Windows. However, it is not recommended, especially for the client side, where ncurses is not as powerful as on systems such as Ubuntu. Additionally, the CMakeLists.txt is not intended for Windows, meaning that modifications (such as setting ncurses location) should be made for it to work properly.\n\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n\n## Acknowledgements\n\n- [ncurses](https://invisible-island.net/ncurses/)\n- [OpenSSL](https://www.openssl.org/)\n\n## Contact\n\nIf you have any questions, suggestions or want to contribute, feel free to contact me.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrancoyudica%2Ftheychat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffrancoyudica%2Ftheychat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrancoyudica%2Ftheychat/lists"}