72 lines
2.6 KiB
Diff
72 lines
2.6 KiB
Diff
From 06370f8afc1a00da62757137f2f739c531ccfdfc Mon Sep 17 00:00:00 2001
|
|
From: Tiago Carvalho <sugoiuguu@tfwno.gf>
|
|
Date: Sat, 5 Feb 2022 15:15:24 +0000
|
|
Subject: [PATCH 1/3] Lain ipfs bootstrap nodes
|
|
|
|
---
|
|
p2p/node.go | 20 ++++++++++++++------
|
|
1 file changed, 14 insertions(+), 6 deletions(-)
|
|
|
|
diff --git a/p2p/node.go b/p2p/node.go
|
|
index 65d13c8..736101a 100644
|
|
--- a/p2p/node.go
|
|
+++ b/p2p/node.go
|
|
@@ -4,6 +4,7 @@ import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
+ "os"
|
|
"sync"
|
|
|
|
"github.com/ipfs/go-datastore"
|
|
@@ -12,6 +13,7 @@ import (
|
|
"github.com/libp2p/go-libp2p-core/host"
|
|
"github.com/libp2p/go-libp2p-core/network"
|
|
"github.com/libp2p/go-libp2p-core/peer"
|
|
+ "github.com/libp2p/go-libp2p-core/pnet"
|
|
dht "github.com/libp2p/go-libp2p-kad-dht"
|
|
libp2pquic "github.com/libp2p/go-libp2p-quic-transport"
|
|
"github.com/libp2p/go-tcp-transport"
|
|
@@ -29,14 +31,22 @@ func CreateNode(ctx context.Context, inputKey string, port int, handler network.
|
|
return
|
|
}
|
|
|
|
+ swarmKey, err := os.Open(os.Getenv("HYPRSPACE_SWARM_KEY"))
|
|
+ if err != nil {
|
|
+ return
|
|
+ }
|
|
+
|
|
ip6quic := fmt.Sprintf("/ip6/::/udp/%d/quic", port)
|
|
ip4quic := fmt.Sprintf("/ip4/0.0.0.0/udp/%d/quic", port)
|
|
|
|
ip6tcp := fmt.Sprintf("/ip6/::/tcp/%d", port)
|
|
ip4tcp := fmt.Sprintf("/ip4/0.0.0.0/tcp/%d", port)
|
|
|
|
+ key, _ := pnet.DecodeV1PSK(swarmKey)
|
|
+
|
|
// Create libp2p node
|
|
node, err = libp2p.New(
|
|
+ libp2p.PrivateNetwork(key),
|
|
libp2p.ListenAddrStrings(ip6quic, ip4quic, ip6tcp, ip4tcp),
|
|
libp2p.Identity(privateKey),
|
|
libp2p.DefaultSecurity,
|
|
@@ -58,12 +68,10 @@ func CreateNode(ctx context.Context, inputKey string, port int, handler network.
|
|
|
|
// Define Bootstrap Nodes.
|
|
peers := []string{
|
|
- "/dnsaddr/bootstrap.libp2p.io/p2p/QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt",
|
|
- "/ip4/104.131.131.82/tcp/4001/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
|
|
- "/ip4/104.131.131.82/udp/4001/quic/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
|
|
- "/dnsaddr/bootstrap.libp2p.io/p2p/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN",
|
|
- "/dnsaddr/bootstrap.libp2p.io/p2p/QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa",
|
|
- "/dnsaddr/bootstrap.libp2p.io/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb",
|
|
+ "/ip4/95.216.8.12/tcp/995/p2p/QmYs4xNBby2fTs8RnzfXEk161KD4mftBfCiR8yXtgGPj4J",
|
|
+ "/ip4/95.216.8.12/tcp/4001/p2p/Qmd7QHZU8UjfYdwmjmq1SBh9pvER9AwHpfwQvnvNo3HBBo",
|
|
+ "/ip6/2001:41d0:800:1402::3f16:3fb5/tcp/4001/p2p/12D3KooWDUgNsoLVauCDpRAo54mc4whoBudgeXQnZZK2iVYhBLCN",
|
|
+ "/ip6/2001:818:da65:e400:a553:fbc1:f0b1:5743/tcp/4001/p2p/12D3KooWC1RZxLvAeEFNTZWk1FWc1sZZ3yemF4FNNRYa3X854KJ8",
|
|
}
|
|
|
|
// Convert Bootstap Nodes into usable addresses.
|
|
--
|
|
2.34.1
|
|
|