In this project we have set up private p2p network taking advantage of InterPlanetary File System IPFS.
Client nodes in the network are able to find themselves over the internet using the bootstrap server. After clients have found other clients, bootstrap server it is not necessary anymore and clients can communicate directly with each other.
Project represents a system where there are nodes that want to occasionally share some files with each other, but keep network restricted only the nodes that have the key for the network.
We experimented with multiple network setups with Docker networking. However, we did not get the bootstrapping to work in a network where the client nodes were isolated. In this project the client nodes are running on the same local network, in which the bootstrap nodes are not needed to discover peers. We decided to include the bootstrap nodes in this setup anyway to demonstrate the structure of the network in an actual use-case.
- Run
run.sh
. This script will initialize and start the system. You are ready to transfer files between the nodes and create directories to your private network. When you want to stop, shutdown the system and clean up afterwards withdown.sh
- You can execute file transfer between nodes by running
simulate.sh
. This script generates random files and transfers them between the nodes in the network.
The above scripts are located in the simulation
directory.
If you want to access other nodes with web UI go to Settings page and change the port matching the port of the node.
cleanup.sh
is script which clears and creates the folders for local data of IPFS nodes.
10import-webui.sh
, 20clean-bootstrap.sh
and 30log-bootstrap.sh
are a configuration scripts for the IPFS nodes.
swarm.key
is the private key that the nodes authenticate itself to private network.
To be able to run the project you must have Docker and Docker Compose installed. Follow the installation guide in Docker documentation: https://docs.docker.com/engine/
Reboot your system after install.
Option is to run the Docker in virtual machine. You can automate the creation of virtual machine with Vagrant. You need to install VirtualBox for virtual machines and Vagrant for automation.
Setup tested with:
- Vagrant 2.3.4
- VirtualBox 6.1.40
Install virtualbox guest additions plugin to enable automatic installation of virtualbox guest additions:
vagrant plugin install vagrant-vbguest
Clone repository to some folder or copy the Vagrantfile and bootstrap.sh into folder. Open terminal in same folder and run vagrant up
. Vagrant will set up the environment for you.
You can ssh to virtual machine with vagrant ssh
or export the ssh profile with vagrant ssh-config
and save it to your ~./ssh/config
and use your preferred tools to connect to VM.
If using VSCode you can use integrated port forwarding. Otherwise you need to forward the ports from the VM.