Peer-to-Peer file sharing application built with JavaFX that enables secure file transfers, real-time chat, and network monitoring across a distributed network.
- Real P2P Network: Socket-based peer-to-peer communication with automatic node discovery
- File Encryption: AES encryption for secure file transfers using secret key authentication
- Multi-threaded Downloads: Concurrent file transfers with progress tracking
- Upload Progress Tracking: Real-time upload progress monitoring
- Network Statistics: Comprehensive monitoring of upload/download speeds, data transferred, and connected nodes
- File Search: Search for files across all connected nodes in the network
- Chat/Messaging: Real-time messaging between connected nodes
- Modern UI: Clean and intuitive JavaFX interface with split-pane layout
- Java 17 or higher
- Maven 3.6 or higher
- JavaFX 21 (included via Maven dependencies)
-
Clone or download this repository:
git clone https://github.com/ErselSeyit/P2PFileSharing.git cd P2PFileSharing -
Build the project using Maven:
mvn clean compile
mvn javafx:run# Compile first
mvn clean compile
# Run (adjust JavaFX module path if needed)
java --module-path <path-to-javafx-sdk>/lib --add-modules javafx.controls,javafx.fxml -cp target/classes com.p2pfilesharing.Main- Select Shared Folder: Click "Browse" to select a folder containing files you want to share
- Enter Secret Key: Provide a secret key for network authentication (all nodes must use the same key)
- Set Port: Specify the port number to listen on (default: 8888)
- Connect to Nodes (Optional): Enter IP address and port of another node to connect
- Start Network: Click "Start Network" to initialize the P2P network
- Search Bar: Search for files across all connected nodes
- Available Files: Lists files from selected node (double-click to download)
- Connected Nodes: Shows all connected nodes (double-click to refresh file list)
- Downloads: Active download progress with real-time updates
- Uploads: Active upload progress tracking
- Chat: Real-time messaging with connected nodes
- Select a node and type a message to send
- Network Statistics:
- Total bytes uploaded/downloaded
- Number of files transferred
- Current upload/download speeds
- Number of connected nodes
-
Downloading Files:
- Select a node from "Connected Nodes"
- Double-click the node to refresh its file list
- Double-click a file to start download
- Progress is shown in real-time
-
Searching Files:
- Enter search query in the search bar
- Results from all connected nodes are displayed
- Files show which node they're from
-
Chatting:
- Select a node from "Connected Nodes"
- Type message in chat input field
- Press "Send" or Enter to send message
-
Connecting to Nodes:
- Enter IP address and port in setup screen
- Click "Connect" to establish connection
- Node will appear in "Connected Nodes" list
P2PFileSharing/
├── src/
│ └── main/
│ ├── java/
│ │ └── com/
│ │ └── p2pfilesharing/
│ │ ├── Main.java # Application entry point
│ │ ├── P2PFileSharingApp.java # Main JavaFX application
│ │ ├── Download.java # Download model
│ │ ├── model/
│ │ │ ├── NetworkStatistics.java # Network statistics tracking
│ │ │ └── Upload.java # Upload model
│ │ ├── network/
│ │ │ ├── NetworkNode.java # P2P network node implementation
│ │ │ ├── Message.java # Network message protocol
│ │ │ ├── MessageType.java # Message types enum
│ │ │ ├── NodeInfo.java # Node information
│ │ │ └── *Callback.java # Callback interfaces
│ │ └── security/
│ │ └── FileEncryption.java # File encryption utilities
│ └── resources/ # Application resources
├── pom.xml # Maven configuration
├── .gitignore # Git ignore file
└── README.md # This file
- Java 17: Core programming language
- JavaFX 21: GUI framework
- Maven: Build and dependency management
- BouncyCastle: Cryptographic library for encryption
- Gson: JSON processing (for future enhancements)
The application uses a custom P2P protocol with the following message types:
HANDSHAKE: Initial connection establishmentFILE_REQUEST: Request a file from a nodeFILE_START/END: File transfer markersFILE_LIST_REQUEST/RESPONSE: File listingCHAT_MESSAGE: Chat messagesSEARCH_REQUEST/RESPONSE: File search
- Files are encrypted using AES encryption
- Secret key authentication required for network access
- All file transfers are encrypted
- Key derivation from user-provided secret key
- Multi-threaded file transfers
- Concurrent downloads/uploads
- Efficient socket-based communication
- Progress tracking with minimal overhead
- Real-time statistics updates
This project is open source and available for educational purposes.
Contributions are welcome! Please feel free to submit a Pull Request.
- Ensure firewall allows connections on the specified port
- All nodes must use the same secret key to communicate
- Files are downloaded to a
downloadssubfolder in the shared folder - Network statistics update in real-time during transfers