libp2p-relay
is a project designed to facilitate peer-to-peer communication using the libp2p protocol. It includes a Dockerized setup for easy deployment, a pubsub protocol for message broadcasting, an HTTP server for web interactions, and a pinning service to ensure data persistence. For more details on the pinning service, see the Pinning Service Documentation.
- Docker Compose Setup: Simplifies deployment and management of the application.
- Pubsub Protocol: Enables efficient message broadcasting between peers.
- HTTP Server: Provides a web interface for interaction and management.
- Pinning Service: Ensures data is persistently stored and accessible.
- Circuit Relay: Facilitates connections between peers that are behind NATs or firewalls.
- Auto-NAT: Automatically detects network address translation to optimize peer connections.
- DCUTR (Direct Connection Upgrade Through Relay): Enables hole punching to establish direct connections between peers.
- Secure WebSocket: Ensures secure communication over WebSocket connections.
- Docker and Docker Compose installed on your system.
- Node.js and npm for local development and testing.
-
Clone the Repository:
git clone https://github.com/silkroadnomad/libp2p-relay.git cd libp2p-relay/relay
-
Environment Configuration:
- Copy
.env.example
to.env
and configure the environment variables as needed.
- Copy
-
Modify Docker Compose:
- Ensure the
docker-compose.yml
file is correctly set up for your environment.
- Ensure the
-
Initialize Let's Encrypt:
- Modify
init-letsencrypt.sh
to set up your domain. - Run the script to generate SSL certificates:
./init-letsencrypt.sh
- Modify
-
Start the Services:
- Use Docker Compose to start the services:
docker-compose up -d
- Use Docker Compose to start the services:
-
Check Logs:
- View logs to find the libp2p address:
docker-compose logs
- View logs to find the libp2p address:
-
Install Dependencies:
npm install
-
Start the Relay:
node relay/src/relay.js
-
Debug Mode:
- Run with debug mode enabled:
DEBUG=libp2p:* node relay/src/relay.js
- Run with debug mode enabled:
The pubsub protocol is used for broadcasting messages between peers. Ensure your topics and subscriptions are correctly configured in the .env
file.
The HTTP server provides a web interface for managing the relay and viewing status information. Access it via the configured domain or IP address.
The IPFS pinning service ensures that data is persistently stored. It interacts with the blockchain to verify and pin content based on transactions.
To ensure the reliability and correctness of the libp2p-relay
project, tests are provided in the relay/tests
directory. Follow these steps to run the tests:
-
Start Test Services:
- Use Docker Compose to start the test services:
docker compose -f docker-compose-test.yml up -d
- Use Docker Compose to start the test services:
-
Run Tests:
- Execute the tests using npm:
npm test
- Execute the tests using npm:
Ensure that your environment is correctly configured before running the tests. The test services should be running to provide the necessary infrastructure for the tests.
Contributions are welcome! Please fork the repository and submit a pull request for any improvements or bug fixes.
This project is licensed under the MIT License. See the LICENSE file for details.
For questions or support, please open an issue on the GitHub repository.