A robust peer-to-peer (P2P) file transfer system implemented in Go. This system enables efficient file sharing and chunk-based data transfer between peers, utilizing a central server for peer discovery and file metadata management.
p2p-working.mp4
- Peer Discovery: Utilizes a central server for dynamic peer discovery and registration.
- Chunk-Based File Transfer: Files are divided into chunks for efficient transfer and storage.
- Concurrent Transfers: Supports concurrent chunk downloads to optimize transfer speed.
- File Integrity Verification: Ensures file integrity through hash verification.
- Error Handling: Robust error handling and logging for reliable operation.
- Configurable Transport: Supports TCP transport for peer communication.
-
Ensure you have Go 1.16+ installed on your system.
-
Clone the repository:
git clone https://github.com/yourusername/p2p-file-transfer.git cd p2p-file-transfer
-
Build the project:
go build -o p2p-transfer
The central server manages peer registration and file metadata. Start it with:
./p2p-transfer central-server --addr <address:port>
A peer server handles file requests and transfers. Start it with:
./p2p-transfer peer-server --central-server-addr <central-server-address:port> --addr <peer-address:port>
To make a file available for sharing:
./p2p-transfer register-file --path <file-path> --peer-addr <peer-address:port>
To download a file from the network:
./p2p-transfer request-file --file-id <file-id> --peer-addr <peer-address:port>
The application uses a CLI for system interaction. Available commands:
central-server
: Launches the central server.peer-server
: Starts a peer server.register-file
: Registers a file with the network.request-file
: Initiates a file download from the network.
Each command has its own set of flags and options for configuration.
Starting the central server:
./p2p-transfer central-server --addr 127.0.0.1:8000
Starting a peer server:
./p2p-transfer peer-server --central-server-addr 127.0.0.1:8000 --addr 127.0.0.1:8001
Registering a file:
./p2p-transfer register-file --path /path/to/file.txt --peer-addr 127.0.0.1:8001
Requesting a file:
./p2p-transfer request-file --file-id <file-id> --peer-addr 127.0.0.1:8001
pkg/
: Core package for message types and peer management.peer/
: Peer server logic and file handling functions.centralserver/
: Central server logic for peer registration and metadata management.cmd/
: CLI commands for system interaction.
-
Enhanced CLI:
- Implement interactive mode for easier system navigation.
- Add command autocompletion for improved user experience.
- Incorporate progress bars for file transfers.
-
Improved Fault Tolerance:
- Implement automatic peer reconnection on network failures.
- Add data redundancy to mitigate peer unavailability.
- Develop a mechanism for resuming interrupted downloads.
-
Security Enhancements:
- Implement end-to-end encryption for file transfers.
- Add user authentication and authorization.
-
Performance Optimizations:
- Implement adaptive chunk sizing based on network conditions.
- Optimize peer selection algorithm for faster downloads.
-
Extended Functionality:
- Add support for directory transfers.
- Implement a web interface for easier file management.
- Develop mobile applications for on-the-go file sharing.
-
Testing and Documentation:
- Increase unit test coverage.
- Create comprehensive API documentation.
- Develop integration and stress tests.
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a new branch:
git checkout -b feature-branch-name
. - Make your changes and commit them:
git commit -m 'Add some feature'
. - Push to the branch:
git push origin feature-branch-name
. - Submit a pull request.