libp2p-relay

command module
v1.0.0-b3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 21, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

README

libp2p-relay

Some projects of Threefold Tech or that Threefold Tech supports rely on libp2p peer routing.

This project provides an implementation for relay nodes that can be used to provide reliable peer communication.

Flow

sequenceDiagram
    participant Client
    participant Relay
    participant Daemon 
    Daemon -->> Relay: Connect(RelayAddress) 
    Client -->> Relay: Connect(RelayAddress)
    Client-->> Client:FindPeer(DaemonID)
    Client -->> +Daemon: Request
    Daemon -->> -Client:Response

Peer propagation

The relay also acts as a server for a DHT with peerconnections, propagating the peers and their connection informations to connected peers.

If a client can reach a daemon directly, the relay is not needed for relaying messages.

Private network

Since we only care about providing reliable peer routing for our own projects we create a private libp2p network with multiple relay nodes. This way the peer routing's dht is only populated with nodes within the private network.

PSK

A private network is defined by a 256-bit secret key, the pre-shared key (PSK) which has to be known and used by all members inside the network.

Any 32 (pseudo)random bytes are good, this is an example of how to create a PSK in hex on the commandline:

openssl rand -hex 32

Or in python:

import os,binascii
binascii.b2a_hex(os.urandom(32))
Security

Applications using the relay nodes and private network should NOT assume all traffic and connections are from trusted parties. Pre-shared private keys are known to leak and it is shared with multiple applications.

A leaked PSK is not a problem either as long as the relaying functionality stays reliable. This does not mean one should hardcode it and submit it to a public github repository off course.

Release build

The release.sh script builds a release version for linux/amd64 in a dist folder.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL