From 86205708cdce75411d99cab24d541cf05108f128 Mon Sep 17 00:00:00 2001 From: Max Date: Sat, 5 Feb 2022 17:56:38 +0100 Subject: [PATCH] packages/hyprspace: 0.1.7 -> 0.2.2 Also introduce a patchset for private swarm support --- .../0001-Lain-ipfs-bootstrap-nodes.patch | 72 +++++++++++++++++++ ...-Remove-quic-transport-for-Lain-ipfs.patch | 48 +++++++++++++ .../0003-Remove-dep-from-go.mod.patch | 24 +++++++ packages/networking/hyprspace/default.nix | 12 +++- 4 files changed, 153 insertions(+), 3 deletions(-) create mode 100644 packages/networking/hyprspace/0001-Lain-ipfs-bootstrap-nodes.patch create mode 100644 packages/networking/hyprspace/0002-Remove-quic-transport-for-Lain-ipfs.patch create mode 100644 packages/networking/hyprspace/0003-Remove-dep-from-go.mod.patch diff --git a/packages/networking/hyprspace/0001-Lain-ipfs-bootstrap-nodes.patch b/packages/networking/hyprspace/0001-Lain-ipfs-bootstrap-nodes.patch new file mode 100644 index 0000000..e8d5700 --- /dev/null +++ b/packages/networking/hyprspace/0001-Lain-ipfs-bootstrap-nodes.patch @@ -0,0 +1,72 @@ +From 06370f8afc1a00da62757137f2f739c531ccfdfc Mon Sep 17 00:00:00 2001 +From: Tiago Carvalho +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/168.235.67.108/tcp/4001/p2p/QmRMA5pWXtfuW1y5w2t9gYxrDDD6bPRLKdWAYnHTeCxZMm", ++ "/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 + diff --git a/packages/networking/hyprspace/0002-Remove-quic-transport-for-Lain-ipfs.patch b/packages/networking/hyprspace/0002-Remove-quic-transport-for-Lain-ipfs.patch new file mode 100644 index 0000000..73af29e --- /dev/null +++ b/packages/networking/hyprspace/0002-Remove-quic-transport-for-Lain-ipfs.patch @@ -0,0 +1,48 @@ +From 743c2cc62daa48bbdcce038ad21805b906e8ddaf Mon Sep 17 00:00:00 2001 +From: Tiago Carvalho +Date: Sat, 5 Feb 2022 15:16:33 +0000 +Subject: [PATCH 2/3] Remove quic transport for Lain ipfs + +--- + p2p/node.go | 7 +------ + 1 file changed, 1 insertion(+), 6 deletions(-) + +diff --git a/p2p/node.go b/p2p/node.go +index 736101a..2f86317 100644 +--- a/p2p/node.go ++++ b/p2p/node.go +@@ -15,7 +15,6 @@ import ( + "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" + ma "github.com/multiformats/go-multiaddr" + ) +@@ -36,9 +35,6 @@ func CreateNode(ctx context.Context, inputKey string, port int, handler network. + 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) + +@@ -47,12 +43,11 @@ func CreateNode(ctx context.Context, inputKey string, port int, handler network. + // Create libp2p node + node, err = libp2p.New( + libp2p.PrivateNetwork(key), +- libp2p.ListenAddrStrings(ip6quic, ip4quic, ip6tcp, ip4tcp), ++ libp2p.ListenAddrStrings(ip6tcp, ip4tcp), + libp2p.Identity(privateKey), + libp2p.DefaultSecurity, + libp2p.NATPortMap(), + libp2p.DefaultMuxers, +- libp2p.Transport(libp2pquic.NewTransport), + libp2p.Transport(tcp.NewTCPTransport), + libp2p.FallbackDefaults, + ) +-- +2.34.1 + diff --git a/packages/networking/hyprspace/0003-Remove-dep-from-go.mod.patch b/packages/networking/hyprspace/0003-Remove-dep-from-go.mod.patch new file mode 100644 index 0000000..5c7b05d --- /dev/null +++ b/packages/networking/hyprspace/0003-Remove-dep-from-go.mod.patch @@ -0,0 +1,24 @@ +From 377b0a8f56b04e693a4d4c7a0b9bb674c63c5bba Mon Sep 17 00:00:00 2001 +From: Tiago Carvalho +Date: Sat, 5 Feb 2022 15:16:45 +0000 +Subject: [PATCH 3/3] Remove dep from go.mod + +--- + go.mod | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/go.mod b/go.mod +index 672c2fc..1092553 100644 +--- a/go.mod ++++ b/go.mod +@@ -11,7 +11,6 @@ require ( + github.com/libp2p/go-libp2p v0.17.0 + github.com/libp2p/go-libp2p-core v0.13.0 + github.com/libp2p/go-libp2p-kad-dht v0.15.0 +- github.com/libp2p/go-libp2p-quic-transport v0.15.2 + github.com/libp2p/go-tcp-transport v0.4.0 + github.com/multiformats/go-multiaddr v0.4.1 + github.com/nxadm/tail v1.4.8 +-- +2.34.1 + diff --git a/packages/networking/hyprspace/default.nix b/packages/networking/hyprspace/default.nix index 037fecc..fccc12b 100644 --- a/packages/networking/hyprspace/default.nix +++ b/packages/networking/hyprspace/default.nix @@ -2,18 +2,24 @@ buildGoModule rec { pname = "hyprspace"; - version = "0.1.7"; + version = "0.2.2"; propagatedBuildInputs = lib.optional stdenv.isDarwin iproute2mac; + patches = [ + ./0001-Lain-ipfs-bootstrap-nodes.patch + ./0002-Remove-quic-transport-for-Lain-ipfs.patch + ./0003-Remove-dep-from-go.mod.patch + ]; + src = fetchFromGitHub { owner = pname; repo = pname; rev = "v${version}"; - sha256 = "sha256-Ecdxs6see4uexY6DatZ/VSGgWR81zRjo3AeAsXSjJ4A="; + sha256 = "sha256-UlIQCy4moW58tQ1dqxrPsU5LN1Bs/Jy5X+2CEmXdYIk="; }; - vendorSha256 = "sha256-nFiBHhtvTu9Ya6n1KUF+pOXrksHMOph7ABVtGSWVWlo="; + vendorSha256 = "sha256-8j9M8LrcqiPShCCNOmmJoY6wclHRiX2xOJH/wvlwvwY="; meta = with lib; { description = "A Lightweight VPN Built on top of Libp2p for Truly Distributed Networks.";