Fixed that maybe
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
ce67b14ca6
commit
f892a69556
14
src/main.go
14
src/main.go
|
@ -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",
|
||||
|
|
Loading…
Reference in New Issue