Skip to content

Peer-to-Peer file sharing application with real-time chat, file encryption, and network monitoring. Built with JavaFX and Java 17.

Notifications You must be signed in to change notification settings

ErselSeyit/P2PFileSharing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 

Repository files navigation

P2P File Sharing Application

Peer-to-Peer file sharing application built with JavaFX that enables secure file transfers, real-time chat, and network monitoring across a distributed network.

Features

Core Functionality

  • 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

Requirements

  • Java 17 or higher
  • Maven 3.6 or higher
  • JavaFX 21 (included via Maven dependencies)

Installation

  1. Clone or download this repository:

    git clone https://github.com/ErselSeyit/P2PFileSharing.git
    cd P2PFileSharing
  2. Build the project using Maven:

    mvn clean compile

Running the Application

Using Maven (Recommended)

mvn javafx:run

Using Java directly

# 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

Usage

Setup Phase

  1. Select Shared Folder: Click "Browse" to select a folder containing files you want to share
  2. Enter Secret Key: Provide a secret key for network authentication (all nodes must use the same key)
  3. Set Port: Specify the port number to listen on (default: 8888)
  4. Connect to Nodes (Optional): Enter IP address and port of another node to connect
  5. Start Network: Click "Start Network" to initialize the P2P network

Main Interface

Left Panel - Files and Nodes

  • 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)

Center Panel - Transfers

  • Downloads: Active download progress with real-time updates
  • Uploads: Active upload progress tracking

Right Panel - Chat and Statistics

  • 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

Key Operations

  1. 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
  2. Searching Files:

    • Enter search query in the search bar
    • Results from all connected nodes are displayed
    • Files show which node they're from
  3. Chatting:

    • Select a node from "Connected Nodes"
    • Type message in chat input field
    • Press "Send" or Enter to send message
  4. Connecting to Nodes:

    • Enter IP address and port in setup screen
    • Click "Connect" to establish connection
    • Node will appear in "Connected Nodes" list

Project Structure

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

Technologies Used

  • 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)

Network Protocol

The application uses a custom P2P protocol with the following message types:

  • HANDSHAKE: Initial connection establishment
  • FILE_REQUEST: Request a file from a node
  • FILE_START/END: File transfer markers
  • FILE_LIST_REQUEST/RESPONSE: File listing
  • CHAT_MESSAGE: Chat messages
  • SEARCH_REQUEST/RESPONSE: File search

Security

  • 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

Performance Features

  • Multi-threaded file transfers
  • Concurrent downloads/uploads
  • Efficient socket-based communication
  • Progress tracking with minimal overhead
  • Real-time statistics updates

License

This project is open source and available for educational purposes.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Notes

  • Ensure firewall allows connections on the specified port
  • All nodes must use the same secret key to communicate
  • Files are downloaded to a downloads subfolder in the shared folder
  • Network statistics update in real-time during transfers

About

Peer-to-Peer file sharing application with real-time chat, file encryption, and network monitoring. Built with JavaFX and Java 17.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages