mirror of
https://github.com/DeBrosOfficial/network.git
synced 2025-12-15 00:58:49 +00:00
feat: enhance IPFS and Cluster integration in setup
- Added automatic setup for IPFS and IPFS Cluster during the network setup process. - Implemented initialization of IPFS repositories and Cluster configurations for each node. - Enhanced Makefile to support starting IPFS and Cluster daemons with improved logging. - Introduced a new documentation guide for IPFS Cluster setup, detailing configuration and verification steps. - Updated changelog to reflect the new features and improvements.
This commit is contained in:
parent
d00290d278
commit
fbdfa23c77
@ -286,7 +286,7 @@ func initFullStack(force bool) {
|
|||||||
fmt.Printf("✅ Generated bootstrap identity: %s (Peer ID: %s)\n", bootstrapIdentityPath, bootstrapInfo.PeerID.String())
|
fmt.Printf("✅ Generated bootstrap identity: %s (Peer ID: %s)\n", bootstrapIdentityPath, bootstrapInfo.PeerID.String())
|
||||||
|
|
||||||
// Construct bootstrap multiaddr
|
// Construct bootstrap multiaddr
|
||||||
bootstrapMultiaddr := fmt.Sprintf("/ip4/localhost/tcp/4001/p2p/%s", bootstrapInfo.PeerID.String())
|
bootstrapMultiaddr := fmt.Sprintf("/ip4/127.0.0.1/tcp/4001/p2p/%s", bootstrapInfo.PeerID.String())
|
||||||
fmt.Printf(" Bootstrap multiaddr: %s\n", bootstrapMultiaddr)
|
fmt.Printf(" Bootstrap multiaddr: %s\n", bootstrapMultiaddr)
|
||||||
|
|
||||||
// Generate configs for all nodes...
|
// Generate configs for all nodes...
|
||||||
|
|||||||
@ -11,7 +11,7 @@ func TestDefaultBootstrapPeersNonEmpty(t *testing.T) {
|
|||||||
old := os.Getenv("DEBROS_BOOTSTRAP_PEERS")
|
old := os.Getenv("DEBROS_BOOTSTRAP_PEERS")
|
||||||
t.Cleanup(func() { os.Setenv("DEBROS_BOOTSTRAP_PEERS", old) })
|
t.Cleanup(func() { os.Setenv("DEBROS_BOOTSTRAP_PEERS", old) })
|
||||||
// Set a valid bootstrap peer
|
// Set a valid bootstrap peer
|
||||||
validPeer := "/ip4/localhost/tcp/4001/p2p/12D3KooWHbcFcrGPXKUrHcxvd8MXEeUzRYyvY8fQcpEBxncSUwhj"
|
validPeer := "/ip4/127.0.0.1/tcp/4001/p2p/12D3KooWHbcFcrGPXKUrHcxvd8MXEeUzRYyvY8fQcpEBxncSUwhj"
|
||||||
_ = os.Setenv("DEBROS_BOOTSTRAP_PEERS", validPeer)
|
_ = os.Setenv("DEBROS_BOOTSTRAP_PEERS", validPeer)
|
||||||
peers := DefaultBootstrapPeers()
|
peers := DefaultBootstrapPeers()
|
||||||
if len(peers) == 0 {
|
if len(peers) == 0 {
|
||||||
@ -50,8 +50,11 @@ func TestNormalizeEndpoints(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestEndpointFromMultiaddr(t *testing.T) {
|
func TestEndpointFromMultiaddr(t *testing.T) {
|
||||||
ma, _ := multiaddr.NewMultiaddr("/ip4/localhost/tcp/4001")
|
ma, err := multiaddr.NewMultiaddr("/ip4/127.0.0.1/tcp/4001")
|
||||||
if ep := endpointFromMultiaddr(ma, 5001); ep != "http://localhost:5001" {
|
if err != nil {
|
||||||
|
t.Fatalf("failed to create multiaddr: %v", err)
|
||||||
|
}
|
||||||
|
if ep := endpointFromMultiaddr(ma, 5001); ep != "http://127.0.0.1:5001" {
|
||||||
t.Fatalf("unexpected endpoint: %s", ep)
|
t.Fatalf("unexpected endpoint: %s", ep)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,7 +7,7 @@ import (
|
|||||||
|
|
||||||
// validConfigForType returns a valid config for the given node type
|
// validConfigForType returns a valid config for the given node type
|
||||||
func validConfigForType(nodeType string) *Config {
|
func validConfigForType(nodeType string) *Config {
|
||||||
validPeer := "/ip4/localhost/tcp/4001/p2p/12D3KooWHbcFcrGPXKUrHcxvd8MXEeUzRYyvY8fQcpEBxncSUwhj"
|
validPeer := "/ip4/127.0.0.1/tcp/4001/p2p/12D3KooWHbcFcrGPXKUrHcxvd8MXEeUzRYyvY8fQcpEBxncSUwhj"
|
||||||
cfg := &Config{
|
cfg := &Config{
|
||||||
Node: NodeConfig{
|
Node: NodeConfig{
|
||||||
Type: nodeType,
|
Type: nodeType,
|
||||||
@ -205,7 +205,7 @@ func TestValidateRQLiteJoinAddress(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestValidateBootstrapPeers(t *testing.T) {
|
func TestValidateBootstrapPeers(t *testing.T) {
|
||||||
validPeer := "/ip4/localhost/tcp/4001/p2p/12D3KooWHbcFcrGPXKUrHcxvd8MXEeUzRYyvY8fQcpEBxncSUwhj"
|
validPeer := "/ip4/127.0.0.1/tcp/4001/p2p/12D3KooWHbcFcrGPXKUrHcxvd8MXEeUzRYyvY8fQcpEBxncSUwhj"
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
nodeType string
|
nodeType string
|
||||||
@ -217,9 +217,9 @@ func TestValidateBootstrapPeers(t *testing.T) {
|
|||||||
{"bootstrap with peer", "bootstrap", []string{validPeer}, false},
|
{"bootstrap with peer", "bootstrap", []string{validPeer}, false},
|
||||||
{"bootstrap without peer", "bootstrap", []string{}, false},
|
{"bootstrap without peer", "bootstrap", []string{}, false},
|
||||||
{"invalid multiaddr", "node", []string{"invalid"}, true},
|
{"invalid multiaddr", "node", []string{"invalid"}, true},
|
||||||
{"missing p2p", "node", []string{"/ip4/localhost/tcp/4001"}, true},
|
{"missing p2p", "node", []string{"/ip4/127.0.0.1/tcp/4001"}, true},
|
||||||
{"duplicate peer", "node", []string{validPeer, validPeer}, true},
|
{"duplicate peer", "node", []string{validPeer, validPeer}, true},
|
||||||
{"invalid port", "node", []string{"/ip4/localhost/tcp/99999/p2p/12D3KooWHbcFcrGPXKUrHcxvd8MXEeUzRYyvY8fQcpEBxncSUwhj"}, true},
|
{"invalid port", "node", []string{"/ip4/127.0.0.1/tcp/99999/p2p/12D3KooWHbcFcrGPXKUrHcxvd8MXEeUzRYyvY8fQcpEBxncSUwhj"}, true},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
@ -397,7 +397,7 @@ func TestValidateCompleteConfig(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Discovery: DiscoveryConfig{
|
Discovery: DiscoveryConfig{
|
||||||
BootstrapPeers: []string{
|
BootstrapPeers: []string{
|
||||||
"/ip4/localhost/tcp/4001/p2p/12D3KooWHbcFcrGPXKUrHcxvd8MXEeUzRYyvY8fQcpEBxncSUwhj",
|
"/ip4/127.0.0.1/tcp/4001/p2p/12D3KooWHbcFcrGPXKUrHcxvd8MXEeUzRYyvY8fQcpEBxncSUwhj",
|
||||||
},
|
},
|
||||||
DiscoveryInterval: 15 * time.Second,
|
DiscoveryInterval: 15 * time.Second,
|
||||||
BootstrapPort: 4001,
|
BootstrapPort: 4001,
|
||||||
|
|||||||
@ -234,7 +234,7 @@ func isPrivateOrLocalHost(host string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check for localhost variants
|
// Check for localhost variants
|
||||||
if host == "localhost" || host == "localhost" || host == "::1" {
|
if host == "localhost" || host == "::1" {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -371,7 +371,7 @@ func discoverOlricServers(networkClient client.NetworkClient, logger *zap.Logger
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Skip localhost loopback addresses (we'll use localhost:3320 as fallback)
|
// Skip localhost loopback addresses (we'll use localhost:3320 as fallback)
|
||||||
if ip == "localhost" || ip == "::1" || ip == "localhost" {
|
if ip == "localhost" || ip == "::1" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -402,7 +402,7 @@ func discoverOlricServers(networkClient client.NetworkClient, logger *zap.Logger
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Skip localhost
|
// Skip localhost
|
||||||
if ip == "localhost" || ip == "::1" || ip == "localhost" {
|
if ip == "localhost" || ip == "::1" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -177,13 +177,13 @@ func TestHashBootstrapConnections(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create two hosts (A and B) listening on localhost TCP
|
// Create two hosts (A and B) listening on localhost TCP
|
||||||
hA, err := libp2p.New(libp2p.ListenAddrStrings("/ip4/localhost/tcp/0"))
|
hA, err := libp2p.New(libp2p.ListenAddrStrings("/ip4/127.0.0.1/tcp/0"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("libp2p.New (A): %v", err)
|
t.Fatalf("libp2p.New (A): %v", err)
|
||||||
}
|
}
|
||||||
defer hA.Close()
|
defer hA.Close()
|
||||||
|
|
||||||
hB, err := libp2p.New(libp2p.ListenAddrStrings("/ip4/localhost/tcp/0"))
|
hB, err := libp2p.New(libp2p.ListenAddrStrings("/ip4/127.0.0.1/tcp/0"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("libp2p.New (B): %v", err)
|
t.Fatalf("libp2p.New (B): %v", err)
|
||||||
}
|
}
|
||||||
@ -244,19 +244,19 @@ func TestHashBootstrapConnections(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create three hosts (A, B, C) listening on localhost TCP
|
// Create three hosts (A, B, C) listening on localhost TCP
|
||||||
hA, err := libp2p.New(libp2p.ListenAddrStrings("/ip4/localhost/tcp/0"))
|
hA, err := libp2p.New(libp2p.ListenAddrStrings("/ip4/127.0.0.1/tcp/0"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("libp2p.New (A): %v", err)
|
t.Fatalf("libp2p.New (A): %v", err)
|
||||||
}
|
}
|
||||||
defer hA.Close()
|
defer hA.Close()
|
||||||
|
|
||||||
hB, err := libp2p.New(libp2p.ListenAddrStrings("/ip4/localhost/tcp/0"))
|
hB, err := libp2p.New(libp2p.ListenAddrStrings("/ip4/127.0.0.1/tcp/0"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("libp2p.New (B): %v", err)
|
t.Fatalf("libp2p.New (B): %v", err)
|
||||||
}
|
}
|
||||||
defer hB.Close()
|
defer hB.Close()
|
||||||
|
|
||||||
hC, err := libp2p.New(libp2p.ListenAddrStrings("/ip4/localhost/tcp/0"))
|
hC, err := libp2p.New(libp2p.ListenAddrStrings("/ip4/127.0.0.1/tcp/0"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("libp2p.New (C): %v", err)
|
t.Fatalf("libp2p.New (C): %v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user