diff --git a/CHANGELOG.md b/CHANGELOG.md index 6fe5b33..3c68f26 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,21 @@ The format is based on [Keep a Changelog][keepachangelog] and adheres to [Semant ### Deprecated ### Fixed +## [0.58.0] - 2025-11-07 + +### Added +- Added default configuration for IPFS Cluster and IPFS API settings in node and gateway configurations. +- Added `ipfs` configuration section to node configuration, including settings for cluster API URL, replication factor, and encryption. + +### Changed +- Improved error logging for cache operations in the Gateway. + +### Deprecated + +### Removed + +### Fixed +\n ## [0.57.0] - 2025-11-07 ### Added diff --git a/Makefile b/Makefile index ca4347b..4262b76 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,7 @@ test-e2e: .PHONY: build clean test run-node run-node2 run-node3 run-example deps tidy fmt vet lint clear-ports install-hooks kill -VERSION := 0.57.0 +VERSION := 0.58.0 COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown) DATE ?= $(shell date -u +%Y-%m-%dT%H:%M:%SZ) LDFLAGS := -X 'main.version=$(VERSION)' -X 'main.commit=$(COMMIT)' -X 'main.date=$(DATE)' diff --git a/pkg/cli/config_commands.go b/pkg/cli/config_commands.go index a7043af..ebd6326 100644 --- a/pkg/cli/config_commands.go +++ b/pkg/cli/config_commands.go @@ -405,6 +405,10 @@ func GenerateNodeConfig(name, id string, listenPort, rqliteHTTPPort, rqliteRaftP joinAddr = "localhost:5001" } + // Calculate IPFS cluster API port (9094 for bootstrap, 9104+ for nodes) + // Pattern: Bootstrap (5001) -> 9094, Node2 (5002) -> 9104, Node3 (5003) -> 9114 + clusterAPIPort := 9094 + (rqliteHTTPPort-5001)*10 + return fmt.Sprintf(`node: id: "%s" type: "node" @@ -425,6 +429,17 @@ database: cluster_sync_interval: "30s" peer_inactivity_limit: "24h" min_cluster_size: 1 + ipfs: + # IPFS Cluster API endpoint for pin management (leave empty to disable) + cluster_api_url: "http://localhost:%d" + # IPFS HTTP API endpoint for content retrieval + api_url: "http://localhost:%d" + # Timeout for IPFS operations + timeout: "60s" + # Replication factor for pinned content + replication_factor: 3 + # Enable client-side encryption before upload + enable_encryption: true discovery: %s @@ -440,7 +455,7 @@ security: logging: level: "info" format: "console" -`, nodeID, listenPort, dataDir, dataDir, rqliteHTTPPort, rqliteRaftPort, joinAddr, peersYAML.String(), 4001, rqliteHTTPPort, rqliteRaftPort) +`, nodeID, listenPort, dataDir, dataDir, rqliteHTTPPort, rqliteRaftPort, joinAddr, clusterAPIPort, rqliteHTTPPort, peersYAML.String(), 4001, rqliteHTTPPort, rqliteRaftPort) } // GenerateBootstrapConfig generates a bootstrap configuration @@ -472,6 +487,17 @@ database: cluster_sync_interval: "30s" peer_inactivity_limit: "24h" min_cluster_size: 1 + ipfs: + # IPFS Cluster API endpoint for pin management (leave empty to disable) + cluster_api_url: "http://localhost:9094" + # IPFS HTTP API endpoint for content retrieval + api_url: "http://localhost:%d" + # Timeout for IPFS operations + timeout: "60s" + # Replication factor for pinned content + replication_factor: 3 + # Enable client-side encryption before upload + enable_encryption: true discovery: bootstrap_peers: [] @@ -487,7 +513,7 @@ security: logging: level: "info" format: "console" -`, nodeID, listenPort, dataDir, dataDir, rqliteHTTPPort, rqliteRaftPort, 4001, rqliteHTTPPort, rqliteRaftPort) +`, nodeID, listenPort, dataDir, dataDir, rqliteHTTPPort, rqliteRaftPort, rqliteHTTPPort, 4001, rqliteHTTPPort, rqliteRaftPort) } // GenerateGatewayConfig generates a gateway configuration @@ -515,5 +541,12 @@ func GenerateGatewayConfig(bootstrapPeers string) string { client_namespace: "default" rqlite_dsn: "" %s +olric_servers: + - "127.0.0.1:3320" +olric_timeout: "10s" +ipfs_cluster_api_url: "http://localhost:9094" +ipfs_api_url: "http://localhost:9105" +ipfs_timeout: "60s" +ipfs_replication_factor: 3 `, peersYAML.String()) } diff --git a/pkg/cli/setup.go b/pkg/cli/setup.go index a103b27..782877a 100644 --- a/pkg/cli/setup.go +++ b/pkg/cli/setup.go @@ -1794,13 +1794,11 @@ func generateGatewayConfigDirect(bootstrapPeers string, enableHTTPS bool, domain olricYAML.WriteString(" - \"localhost:3320\"\n") } - // IPFS Cluster configuration (defaults - can be customized later) - ipfsYAML := `# IPFS Cluster configuration (optional) -# Uncomment and configure if you have IPFS Cluster running: -# ipfs_cluster_api_url: "http://localhost:9094" -# ipfs_api_url: "http://localhost:5001" -# ipfs_timeout: "60s" -# ipfs_replication_factor: 3 + // IPFS Cluster configuration + ipfsYAML := `ipfs_cluster_api_url: "http://localhost:9094" +ipfs_api_url: "http://localhost:9105" +ipfs_timeout: "60s" +ipfs_replication_factor: 3 ` return fmt.Sprintf(`listen_addr: ":6001" diff --git a/pkg/gateway/cache_handlers.go b/pkg/gateway/cache_handlers.go index 58c2beb..56ea931 100644 --- a/pkg/gateway/cache_handlers.go +++ b/pkg/gateway/cache_handlers.go @@ -8,7 +8,9 @@ import ( "strings" "time" + "github.com/DeBrosOfficial/network/pkg/logging" olriclib "github.com/olric-data/olric" + "go.uber.org/zap" ) // Cache HTTP handlers for Olric distributed cache @@ -76,12 +78,20 @@ func (g *Gateway) cacheGetHandler(w http.ResponseWriter, r *http.Request) { writeError(w, http.StatusNotFound, "key not found") return } + g.logger.ComponentError(logging.ComponentGeneral, "failed to get key from cache", + zap.String("dmap", req.DMap), + zap.String("key", req.Key), + zap.Error(err)) writeError(w, http.StatusInternalServerError, fmt.Sprintf("failed to get key: %v", err)) return } value, err := decodeValueFromOlric(gr) if err != nil { + g.logger.ComponentError(logging.ComponentGeneral, "failed to decode value from cache", + zap.String("dmap", req.DMap), + zap.String("key", req.Key), + zap.Error(err)) writeError(w, http.StatusInternalServerError, fmt.Sprintf("failed to decode value: %v", err)) return }