From cb2a4b936cb1870294f1b0c56a2be36b89935b58 Mon Sep 17 00:00:00 2001 From: Matee Ullah Malik Date: Sat, 16 Aug 2025 10:12:33 +0500 Subject: [PATCH] Update default gateway port from 8092 to 8002 --- README.md | 10 +++++----- supernode/node/supernode/gateway/server.go | 8 ++++---- supernode/services/verifier/verifier.go | 4 ++-- supernode/services/verifier/verifier_test.go | 16 ++++++++-------- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index c575ea55..07d95754 100644 --- a/README.md +++ b/README.md @@ -136,7 +136,7 @@ enum SupernodeEventType { ## HTTP Gateway -The supernode provides an HTTP gateway that exposes the gRPC services via REST API. The gateway runs on a separate port 8092 +The supernode provides an HTTP gateway that exposes the gRPC services via REST API. The gateway runs on a separate port 8002 ### Endpoints @@ -144,7 +144,7 @@ The supernode provides an HTTP gateway that exposes the gRPC services via REST A Returns the current supernode status including system resources (CPU, memory, storage) and service information. ```bash -curl http://localhost:8092/api/v1/status +curl http://localhost:8002/api/v1/status ``` Response: @@ -198,7 +198,7 @@ Response: Returns the list of available services on the supernode. ```bash -curl http://localhost:8092/api/v1/services +curl http://localhost:8002/api/v1/services ``` Response: @@ -214,8 +214,8 @@ The gateway automatically translates between HTTP/JSON and gRPC/protobuf formats The gateway provides interactive API documentation via Swagger UI: -- **Swagger UI**: http://localhost:8092/swagger-ui/ -- **OpenAPI Spec**: http://localhost:8092/swagger.json +- **Swagger UI**: http://localhost:8002/swagger-ui/ +- **OpenAPI Spec**: http://localhost:8002/swagger.json The Swagger UI provides an interactive interface to explore and test all available API endpoints. diff --git a/supernode/node/supernode/gateway/server.go b/supernode/node/supernode/gateway/server.go index 44bbe41f..70036244 100644 --- a/supernode/node/supernode/gateway/server.go +++ b/supernode/node/supernode/gateway/server.go @@ -15,7 +15,7 @@ import ( ) // DefaultGatewayPort is an uncommon port for internal gateway use -const DefaultGatewayPort = 8092 +const DefaultGatewayPort = 8002 // Server represents the HTTP gateway server type Server struct { @@ -49,8 +49,8 @@ func (s *Server) Run(ctx context.Context) error { // Create gRPC-Gateway mux with custom JSON marshaler options mux := runtime.NewServeMux( runtime.WithMarshalerOption(runtime.MIMEWildcard, &runtime.JSONPb{ - EmitDefaults: true, // This ensures zero values are included - OrigName: true, // Use original proto field names + EmitDefaults: true, // This ensures zero values are included + OrigName: true, // Use original proto field names }), ) @@ -123,4 +123,4 @@ func (s *Server) corsMiddleware(h http.Handler) http.Handler { h.ServeHTTP(w, r) }) -} \ No newline at end of file +} diff --git a/supernode/services/verifier/verifier.go b/supernode/services/verifier/verifier.go index b77f3123..b857cfc8 100644 --- a/supernode/services/verifier/verifier.go +++ b/supernode/services/verifier/verifier.go @@ -196,10 +196,10 @@ func (cv *ConfigVerifier) checkPortsAvailable(result *VerificationResult) { }) } - // Check gateway port (use configured port or default port 8092) + // Check gateway port (use configured port or default port 8002) gatewayPort := int(cv.config.SupernodeConfig.GatewayPort) if gatewayPort == 0 { - gatewayPort = 8092 // Default gateway port (same as gateway.DefaultGatewayPort) + gatewayPort = 8002 // Default gateway port (same as gateway.DefaultGatewayPort) } if !cv.isPortAvailable(cv.config.SupernodeConfig.Host, gatewayPort) { diff --git a/supernode/services/verifier/verifier_test.go b/supernode/services/verifier/verifier_test.go index 80fdc969..74972dc6 100644 --- a/supernode/services/verifier/verifier_test.go +++ b/supernode/services/verifier/verifier_test.go @@ -131,7 +131,7 @@ func TestVerificationResult_Summary(t *testing.T) { { name: "warning message", result: &VerificationResult{ - Valid: true, + Valid: true, Errors: []ConfigError{}, Warnings: []ConfigError{ { @@ -161,7 +161,7 @@ func TestConfigVerifier_isPortAvailable(t *testing.T) { Host: "127.0.0.1", }, } - + verifier := NewConfigVerifier(cfg, nil, nil).(*ConfigVerifier) // Test available port @@ -225,8 +225,8 @@ func TestConfigVerifier_checkPortsAvailable(t *testing.T) { } func TestConfigVerifier_checkPortsAvailable_DefaultGatewayPort(t *testing.T) { - // Create a listener to occupy the default gateway port 8092 - listener, err := net.Listen("tcp", "127.0.0.1:8092") + // Create a listener to occupy the default gateway port 8002 + listener, err := net.Listen("tcp", "127.0.0.1:8002") assert.NoError(t, err) defer listener.Close() @@ -236,7 +236,7 @@ func TestConfigVerifier_checkPortsAvailable_DefaultGatewayPort(t *testing.T) { KeyName: "test-key", Host: "127.0.0.1", Port: 4444, // Available port - GatewayPort: 0, // Not configured, should use default 8092 + GatewayPort: 0, // Not configured, should use default 8002 }, P2PConfig: config.P2PConfig{ Port: 4445, // Available port @@ -256,6 +256,6 @@ func TestConfigVerifier_checkPortsAvailable_DefaultGatewayPort(t *testing.T) { assert.False(t, result.IsValid()) assert.Len(t, result.Errors, 1) assert.Equal(t, "gateway_port", result.Errors[0].Field) - assert.Equal(t, "8092", result.Errors[0].Actual) - assert.Contains(t, result.Errors[0].Message, "Port 8092 is already in use") -} \ No newline at end of file + assert.Equal(t, "8002", result.Errors[0].Actual) + assert.Contains(t, result.Errors[0].Message, "Port 8002 is already in use") +}