Skip to content

0xRef0rm/Hyperswarm-P2P-File-Transfer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hyperswarm P2P File Transfer

A simple peer-to-peer (P2P) file transfer system using HyperDHT and Hyperswarm for decentralized networking. This project demonstrates how to send files between peers over a distributed network, suitable for local or remote (VPS) usage.

Features

  • P2P file transfer using HyperDHT and Hyperswarm
  • Persistent server keypair for stable public key
  • Simple protocol: send file name and file data
  • Works on local network or over the internet
  • Modular folder structure for client and server

Folder Structure

.
├── hyperdht-client/           # Client code (send files)
│   ├── hyperdht-client.js
│   └── ...
├── hyperdht-server/           # Server code (receive files)
│   ├── hyperdht-server-persistent.js
│   └── ...
├── hyperswarmer_p2p/          # Additional P2P examples
├── store-reader/              # Storage (reader)
├── store-writer/              # Storage (writer)
├── sample.txt                 # Example file to send
└── ...

Requirements

  • Node.js (recommended: v16.x or v18.x LTS)
  • npm (Node Package Manager)

Installation

  1. Clone this repository:
    git clone <repo-url>
    cd hyperswarm_fixed
  2. Install dependencies:
    npm install
    cd hyperdht-client && npm install && cd ..
    cd hyperdht-server && npm install && cd ..

Usage

1. Start the Server

  • Run on your VPS or local machine:
    cd hyperdht-server
    node hyperdht-server-persistent.js
  • The server will generate a persistent keypair and display its public key.

2. Configure the Client

  • Edit hyperdht-client/hyperdht-client.js:
    • Set SERVER_PUBLIC_KEY to the public key shown by the server.
    • Set FILE_PATH to the file you want to send (default: ./sample.txt).

3. Run the Client

cd hyperdht-client
node hyperdht-client.js
  • The client will connect to the server and send the file.

Troubleshooting

  • HOLEPUNCH_ABORTED: Ensure both server and client use the same Node.js version and compatible hyperdht/sodium-native versions. Try running both on the same machine for testing.
  • Cannot read properties of undefined (reading 'buffer'): This is usually a Node.js version or native module issue. Use Node.js v16 or v18, reinstall dependencies, and rebuild native modules.
  • No connection: Double-check the public key, ensure the server is running and listening, and that both sides are using the same port.

Credits

About

My Hyperswarm, HyperDHT playground

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors