mirror of
https://github.com/DeBrosOfficial/network.git
synced 2025-12-11 13:38:49 +00:00
commit
64ca6c2f99
21
CHANGELOG.md
21
CHANGELOG.md
@ -16,26 +16,16 @@ The format is based on [Keep a Changelog][keepachangelog] and adheres to [Semant
|
||||
|
||||
### Fixed
|
||||
|
||||
## [0.51.1] - 2025-10-22
|
||||
## [0.51.2] - 2025-09-26
|
||||
|
||||
### Added
|
||||
|
||||
### Changed
|
||||
|
||||
- Changed the configuration file for run-node3 to use node3.yaml.
|
||||
- Modified select_data_dir function to require a hasConfigFile parameter and added error handling for missing configuration.
|
||||
- Updated main function to pass the config path to select_data_dir.
|
||||
- Introduced a peer exchange protocol in the discovery package, allowing nodes to request and exchange peer information.
|
||||
- Refactored peer discovery logic in the node package to utilize the new discovery manager for active peer exchange.
|
||||
- Enhance gateway configuration by adding RQLiteDSN support and updating default connection settings. Updated config parsing to include RQLiteDSN from YAML and environment variables. Changed default RQLite connection URL from port 4001 to 5001.
|
||||
- Update CHANGELOG.md for version 0.51.2, enhance API key extraction to support query parameters, and implement internal auth context in status and storage handlers.
|
||||
|
||||
### Deprecated
|
||||
|
||||
### Removed
|
||||
- Cleaned up unused code related to previous peer discovery methods.
|
||||
|
||||
### Fixed
|
||||
|
||||
## [0.51.0] - 2025-09-26
|
||||
## [0.51.1] - 2025-09-26
|
||||
|
||||
### Added
|
||||
|
||||
@ -48,6 +38,7 @@ The format is based on [Keep a Changelog][keepachangelog] and adheres to [Semant
|
||||
- Updated node/node.go on loadOrCreateIdentity to use encryption.identity
|
||||
- Updated cli/main.go to remove fallbacks for identity
|
||||
- Updated install-debros-network.sh script to use new ./cmd/identity and fixed port order on print
|
||||
- Updated makefile and changelog
|
||||
|
||||
### Deprecated
|
||||
|
||||
@ -56,7 +47,7 @@ The format is based on [Keep a Changelog][keepachangelog] and adheres to [Semant
|
||||
### Fixed
|
||||
|
||||
|
||||
## [0.50.1] - 2025-09-23
|
||||
## [0.50.0] - 2025-09-23
|
||||
|
||||
### Added
|
||||
|
||||
|
||||
@ -45,6 +45,7 @@ func parseGatewayConfig(logger *logging.ColoredLogger) *gateway.Config {
|
||||
ListenAddr: ":6001",
|
||||
ClientNamespace: "default",
|
||||
BootstrapPeers: nil,
|
||||
RQLiteDSN: "",
|
||||
}
|
||||
|
||||
// 1) YAML (optional)
|
||||
@ -52,6 +53,7 @@ func parseGatewayConfig(logger *logging.ColoredLogger) *gateway.Config {
|
||||
type yamlCfg struct {
|
||||
ListenAddr string `yaml:"listen_addr"`
|
||||
ClientNamespace string `yaml:"client_namespace"`
|
||||
RQLiteDSN string `yaml:"rqlite_dsn"`
|
||||
BootstrapPeers []string `yaml:"bootstrap_peers"`
|
||||
}
|
||||
const path = "configs/gateway.yaml"
|
||||
@ -66,6 +68,9 @@ func parseGatewayConfig(logger *logging.ColoredLogger) *gateway.Config {
|
||||
if v := strings.TrimSpace(y.ClientNamespace); v != "" {
|
||||
cfg.ClientNamespace = v
|
||||
}
|
||||
if v := strings.TrimSpace(y.RQLiteDSN); v != "" {
|
||||
cfg.RQLiteDSN = v
|
||||
}
|
||||
if len(y.BootstrapPeers) > 0 {
|
||||
var bp []string
|
||||
for _, p := range y.BootstrapPeers {
|
||||
@ -89,6 +94,9 @@ func parseGatewayConfig(logger *logging.ColoredLogger) *gateway.Config {
|
||||
if v := strings.TrimSpace(os.Getenv("GATEWAY_NAMESPACE")); v != "" {
|
||||
cfg.ClientNamespace = v
|
||||
}
|
||||
if v := strings.TrimSpace(os.Getenv("GATEWAY_RQLITE_DSN")); v != "" {
|
||||
cfg.RQLiteDSN = v
|
||||
}
|
||||
if v := strings.TrimSpace(os.Getenv("GATEWAY_BOOTSTRAP_PEERS")); v != "" {
|
||||
parts := strings.Split(v, ",")
|
||||
var bp []string
|
||||
|
||||
@ -109,11 +109,11 @@ func DefaultConfig() *Config {
|
||||
},
|
||||
Discovery: DiscoveryConfig{
|
||||
BootstrapPeers: []string{
|
||||
"/ip4/217.76.54.168/tcp/4001/p2p/12D3KooWDp7xeShVY9uHfqNVPSsJeCKUatAviFZV8Y1joox5nUvx",
|
||||
"/ip4/217.76.54.178/tcp/4001/p2p/12D3KooWKZnirPwNT4URtNSWK45f6vLkEs4xyUZ792F8Uj1oYnm1",
|
||||
"/ip4/51.83.128.181/tcp/4001/p2p/12D3KooWBn2Zf1R8v9pEfmz7hDZ5b3oADxfejA3zJBYzKRCzgvhR",
|
||||
"/ip4/155.133.27.199/tcp/4001/p2p/12D3KooWC69SBzM5QUgrLrfLWUykE8au32X5LwT7zwv9bixrQPm1",
|
||||
"/ip4/217.76.56.2/tcp/4001/p2p/12D3KooWEiqJHvznxqJ5p2y8mUs6Ky6dfU1xTYFQbyKRCABfcZz4",
|
||||
"/ip4/127.0.0.1/tcp/4001/p2p/12D3KooWHbcFcrGPXKUrHcxvd8MXEeUzRYyvY8fQcpEBxncSUwhj",
|
||||
// "/ip4/217.76.54.178/tcp/4001/p2p/12D3KooWKZnirPwNT4URtNSWK45f6vLkEs4xyUZ792F8Uj1oYnm1",
|
||||
// "/ip4/51.83.128.181/tcp/4001/p2p/12D3KooWBn2Zf1R8v9pEfmz7hDZ5b3oADxfejA3zJBYzKRCzgvhR",
|
||||
// "/ip4/155.133.27.199/tcp/4001/p2p/12D3KooWC69SBzM5QUgrLrfLWUykE8au32X5LwT7zwv9bixrQPm1",
|
||||
// "/ip4/217.76.56.2/tcp/4001/p2p/12D3KooWEiqJHvznxqJ5p2y8mUs6Ky6dfU1xTYFQbyKRCABfcZz4",
|
||||
},
|
||||
BootstrapPort: 4001, // Default LibP2P port
|
||||
DiscoveryInterval: time.Second * 15, // Back to 15 seconds for testing
|
||||
|
||||
@ -90,7 +90,7 @@ func New(logger *logging.ColoredLogger, cfg *Config) (*Gateway, error) {
|
||||
logger.ComponentInfo(logging.ComponentGeneral, "Initializing RQLite ORM HTTP gateway...")
|
||||
dsn := cfg.RQLiteDSN
|
||||
if dsn == "" {
|
||||
dsn = "http://localhost:4001"
|
||||
dsn = "http://localhost:5001"
|
||||
}
|
||||
db, dbErr := sql.Open("rqlite", dsn)
|
||||
if dbErr != nil {
|
||||
|
||||
@ -130,7 +130,7 @@ func (g *Gateway) authMiddleware(next http.Handler) http.Handler {
|
||||
})
|
||||
}
|
||||
|
||||
// extractAPIKey extracts API key from Authorization or X-API-Key
|
||||
// extractAPIKey extracts API key from Authorization, X-API-Key header, or query parameters
|
||||
func extractAPIKey(r *http.Request) string {
|
||||
// Prefer Authorization header
|
||||
auth := r.Header.Get("Authorization")
|
||||
@ -148,10 +148,18 @@ func extractAPIKey(r *http.Request) string {
|
||||
return strings.TrimSpace(auth)
|
||||
}
|
||||
}
|
||||
// Fallback header
|
||||
// Fallback to X-API-Key header
|
||||
if v := strings.TrimSpace(r.Header.Get("X-API-Key")); v != "" {
|
||||
return v
|
||||
}
|
||||
// Fallback to query parameter (for WebSocket support)
|
||||
if v := strings.TrimSpace(r.URL.Query().Get("api_key")); v != "" {
|
||||
return v
|
||||
}
|
||||
// Also check token query parameter (alternative name)
|
||||
if v := strings.TrimSpace(r.URL.Query().Get("token")); v != "" {
|
||||
return v
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
|
||||
@ -60,7 +60,8 @@ func (g *Gateway) statusHandler(w http.ResponseWriter, r *http.Request) {
|
||||
writeError(w, http.StatusServiceUnavailable, "client not initialized")
|
||||
return
|
||||
}
|
||||
ctx := r.Context()
|
||||
// Use internal auth context to bypass client credential requirements
|
||||
ctx := client.WithInternalAuth(r.Context())
|
||||
status, err := g.client.Network().GetStatus(ctx)
|
||||
if err != nil {
|
||||
writeError(w, http.StatusInternalServerError, err.Error())
|
||||
|
||||
@ -3,6 +3,8 @@ package gateway
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"github.com/DeBrosOfficial/network/pkg/client"
|
||||
)
|
||||
|
||||
// Database HTTP handlers
|
||||
@ -12,7 +14,8 @@ func (g *Gateway) networkStatusHandler(w http.ResponseWriter, r *http.Request) {
|
||||
writeError(w, http.StatusServiceUnavailable, "client not initialized")
|
||||
return
|
||||
}
|
||||
ctx := r.Context()
|
||||
// Use internal auth context to bypass client credential requirements
|
||||
ctx := client.WithInternalAuth(r.Context())
|
||||
status, err := g.client.Network().GetStatus(ctx)
|
||||
if err != nil {
|
||||
writeError(w, http.StatusInternalServerError, err.Error())
|
||||
@ -26,7 +29,8 @@ func (g *Gateway) networkPeersHandler(w http.ResponseWriter, r *http.Request) {
|
||||
writeError(w, http.StatusServiceUnavailable, "client not initialized")
|
||||
return
|
||||
}
|
||||
ctx := r.Context()
|
||||
// Use internal auth context to bypass client credential requirements
|
||||
ctx := client.WithInternalAuth(r.Context())
|
||||
peers, err := g.client.Network().GetPeers(ctx)
|
||||
if err != nil {
|
||||
writeError(w, http.StatusInternalServerError, err.Error())
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user