Fixed that maybe
continuous-integration/drone/push Build is passing Details

This commit is contained in:
DutchEllie 2022-05-29 22:12:20 +02:00
parent ce67b14ca6
commit f892a69556
Signed by: DutchEllie
SSH Key Fingerprint: SHA256:UU8yhd1Bh8exU88ev0ej/Dm+CeyfR/ZIDRrpRfYdfbg
1 changed files with 14 additions and 0 deletions

View File

@ -5,8 +5,11 @@ import (
"context"
"fmt"
"log"
mrand "math/rand"
"time"
"github.com/libp2p/go-libp2p"
"github.com/libp2p/go-libp2p-core/crypto"
"github.com/libp2p/go-libp2p-core/host"
"github.com/libp2p/go-libp2p-core/network"
relayv1 "github.com/libp2p/go-libp2p/p2p/protocol/circuitv1/relay"
@ -27,11 +30,22 @@ func run() {
// Create a libp2p host, able to be a relay
// Should connect other clients together
r := mrand.New(mrand.NewSource(time.Now().UnixMicro()))
// Generate a key pair for this host. We will use it at least
// to obtain a valid host ID.
priv, _, err := crypto.GenerateKeyPairWithReader(crypto.RSA, 2048, r)
if err != nil {
log.Printf("Error creating key pair: %v\n", err)
return
}
// Create a host h1 that is a relay
h1, err := libp2p.New(libp2p.DisableRelay(),
// Set transports
libp2p.Transport(tcp.NewTCPTransport),
libp2p.Transport(libp2pquic.NewTransport),
libp2p.Identity(priv),
// Set listenaddrs
libp2p.ListenAddrStrings(
"/ip4/0.0.0.0/tcp/6666",