P2P File Share
A simple peer-to-peer file sharing system.
|
A simple peer-to-peer file sharing system using TCP sockets. View Source.
This was made for an assignment in a graduate course on Operating Systems.
For educational purposes.
The system consists of two components:
The tracker is a server that listens for incoming connections from clients and other trackers.
Every request to the tracker is saved as a Transaction.
Atleast one tracker must be online at any point in time.
Whenever a new tracker joins the network, it receives a list of all the successful transactions from the others.
The new tracker then executes these transactions to get up to date with the network.
The client connects to the tracker to get a list of files available on the network. It can download files from other clients on the network.
There are 2 daemon-type components that run in the background.
The DownloadManager is responsible for downloading files from other clients on the network.
The user of the class can enqueue a download request, and the DownloadManager will download the file in the background.
The user can either poll the status of the downloads or register a callback to be notified when the download is complete.
This is a part of our custom networking library.
The TCP Server is a high-level abstraction over TCP socket, which in turn is a high-level abstraction over the POSIX socket API.
The TCPServer class is loosely based on the QTcpServer class from the Qt framework. TCPSocket is similarly modelled after QTcpSocket.
block_size
constant in fileinfo.hpp.select
system call to handle multiple connections. poll
and epoll
system calls. select()
should be deprecated by now. See:
This project has a .editorconfig file to enforce project level coding standards.
CLion has built-in support, VSCode requires a plugin.
This project requires CMake to build. Your IDE (VSCode or CLion) should automatically detect the CMakeLists.txt file and build the project. Install extensions for CMake support if prompted.
If you are using the command line, you can run the following commands:
quit
quit
create_user <user_id> <passwd>
login <user_id> <passwd>
logout
create_group <group_id>
join_group <group_id>
leave_group <group_id>
list_requests <group_id>
accept_request <group_id> <user_id>
list_groups
list_files <group_id>
upload_file <file_path> <group_id>
download_file <group_id> <file_name> <destination_path>
show_downloads
This project uses Doxygen to generate documentation.
If Doxygen is available on your system,
You can generate the documentation by running the doc
CMake target.
This repository also has an automated workflow to generate documentatation via Github Actions.
The generated documentation can be viewed at /docs.
A good starting point to explore the codebase is the file listing page. (files.html if you are viewing this in a browser)