This project is a simple peer-to-peer (P2P) file-sharing application. It includes a tracker and multiple nodes (peers) that can share files with each other using TCP/IP and multi-threaded data transfer.
- Peer-to-peer file sharing using Java sockets.
- Multi-directional data transfer (MDDT) – download file pieces from multiple peers simultaneously.
- Tracker server to manage peer-to-peer communication.
- Command-line interface (CLI) using Spring Shell for easy interaction.
- H2 database for tracking file metadata.
- Lightweight, efficient file-sharing system.
- Backend: Java (Socket programming, multithreading)
- CLI: Spring Shell
- Database: H2
- Build Tool: Maven
- Java: JDK 21 or later
- Maven: Latest version (for building and managing dependencies)
- Spring Boot: 3.3.4
- H2 Database: Embedded mode for simplicity.
git clone https://github.com/DankoFox/STA.git
cd STA
To build the project and download dependencies:
mvn clean install
The tracker is the central server that keeps track of peers. Run it by executing:
mvn spring-boot:run -Dspring-boot.run.arguments="tracker"
Each peer (or node) can be run as a separate instance. To run a peer, execute the following command:
mvn spring-boot:run -Dspring-boot.run.arguments="node"
After running the node, you can interact with it using the following commands:
start-download <file-name>
: Start downloading a file from available peers.stop-download <file-name>
: Stop the download process.show-stats
: Display upload/download statistics.upload <file-path>
: Share a file with the network.
Database: The application uses H2 in embedded mode by default. Configuration for H2 is available in the application.properties
file in the src/main/resources
directory:
spring.datasource.url=jdbc:h2:file:./data
spring.datasource.driver-class-name=org.h2.Driver
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
spring.h2.console.enabled=true
You can access the H2 console at http://localhost:8080/h2-console to view or manage the data.
This project is licensed under the MIT License.