diff --git a/app/app_test.go b/app/app_test.go index dad5c9e..0c400ff 100644 --- a/app/app_test.go +++ b/app/app_test.go @@ -6,6 +6,8 @@ import ( "dito/logging" "log/slog" "testing" + + "github.com/redis/go-redis/v9" ) // TestLoggerUpdate tests if the logger updates correctly when the log level changes. @@ -21,7 +23,11 @@ func TestLoggerUpdate(t *testing.T) { config.UpdateConfig(initialConfig) // Create a new Dito instance with the initial logger - dito := NewDito(nil, logging.InitializeLogger(initialConfig.Logging.Level)) + // Create a mock Redis client and HTTP transport config for testing + mockRedisClient := &redis.Client{} + mockHTTPTransportConfig := &config.HTTPTransportConfig{} + + dito := NewDito(mockRedisClient, mockHTTPTransportConfig, logging.InitializeLogger(initialConfig.Logging.Level)) // Check if the initial logger level is set to "info" if dito.Logger.Handler().Enabled(context.Background(), slog.LevelDebug) { diff --git a/bin/config.yaml b/bin/config.yaml index 2e0aa35..8e293a6 100644 --- a/bin/config.yaml +++ b/bin/config.yaml @@ -42,10 +42,10 @@ transport: # List of location configurations for proxying requests. locations: - - path: "^/test-ws$" # Il path per cui vuoi abilitare il WebSocket + - path: "^/test-ws$" target_url: "wss://echo.websocket.org" - enable_websocket: true # Abilita il supporto WebSocket per questa location - replace_path: true # Sostituisce il path con il target URL + enable_websocket: true n + replace_path: true - path: "^/dito$" # Regex pattern to match the request path. target_url: https://httpbin.org/get diff --git a/bin/dito b/bin/dito index 5db8195..2f7940e 100755 Binary files a/bin/dito and b/bin/dito differ diff --git a/cmd/main.go b/cmd/main.go index 655f288..6eddfe9 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -12,7 +12,6 @@ import ( "errors" "flag" "fmt" - "github.com/redis/go-redis/v9" "log" "log/slog" "net/http" @@ -22,6 +21,8 @@ import ( "runtime" "syscall" "time" + + "github.com/redis/go-redis/v9" ) // main is the entry point of the application. @@ -122,7 +123,7 @@ func StartServer(dito *app.Dito) { // Attempt to gracefully shut down the server. if err := server.Shutdown(ctx); err != nil { - dito.Logger.Error("Server forced to shutdown: ", err) + dito.Logger.Error("Server forced to shutdown", "error", err) } else { dito.Logger.Info("Server shut down gracefully.") } @@ -135,7 +136,7 @@ func StartServer(dito *app.Dito) { // Start the HTTP server. if err := server.ListenAndServe(); !errors.Is(err, http.ErrServerClosed) { - dito.Logger.Error("Server failed to start: ", err) + dito.Logger.Error("Server failed to start", "error", err) log.Fatal(err) } @@ -150,7 +151,7 @@ func startProfiling(logger *slog.Logger) { go func() { logger.Info("Starting pprof on :6060") if err := http.ListenAndServe("localhost:6060", nil); err != nil { - logger.Error("pprof failed:", err) + logger.Error("pprof failed", "error", err) } }() diff --git a/handlers/handlers.go b/handlers/handlers.go index 59d6a47..75138a6 100644 --- a/handlers/handlers.go +++ b/handlers/handlers.go @@ -80,7 +80,7 @@ func ServeProxy(dito *app.Dito, locationIndex int, lrw http.ResponseWriter, r *h targetURL, err := url.Parse(location.TargetURL) if err != nil { - dito.Logger.Error("Error parsing the target URL: ", err) + dito.Logger.Error("Error parsing the target URL: ", "error", err) http.Error(lrw, InternalServerErrorMessage, http.StatusInternalServerError) return } diff --git a/handlers/handlers_test.go b/handlers/handlers_test.go index 893d6e2..4e3d96c 100644 --- a/handlers/handlers_test.go +++ b/handlers/handlers_test.go @@ -6,13 +6,15 @@ import ( "dito/config" "dito/handlers" "dito/logging" - "github.com/redis/go-redis/v9" - "github.com/stretchr/testify/assert" "io" "net/http" "net/http/httptest" "regexp" "testing" + "time" + + "github.com/redis/go-redis/v9" + "github.com/stretchr/testify/assert" ) // setupTestConfig initializes a sample configuration for testing. @@ -56,7 +58,29 @@ func setupDito() *app.Dito { logger := logging.InitializeLogger("info") // Create a new Dito instance. - return app.NewDito(redisClient, logger) + // Create a sample HTTPTransportConfig. + httpTransportConfig := &config.HTTPTransportConfig{ + IdleConnTimeout: 90 * time.Second, + MaxIdleConns: 100, + MaxIdleConnsPerHost: 10, + MaxConnsPerHost: 100, + TLSHandshakeTimeout: 10 * time.Second, + ResponseHeaderTimeout: 10 * time.Second, + ExpectContinueTimeout: 1 * time.Second, + DisableCompression: false, + ForceHTTP2: true, + DialTimeout: 30 * time.Second, + KeepAlive: 30 * time.Second, + CertFile: "testdata/test_cert.pem", + KeyFile: "testdata/test_key.pem", + CaFile: "testdata/test_ca.pem", + } + + dito := app.NewDito(redisClient, httpTransportConfig, logger) + if dito == nil { + panic("Failed to initialize Dito instance") + } + return dito } func TestDynamicProxyHandler(t *testing.T) { @@ -71,7 +95,9 @@ func TestDynamicProxyHandler(t *testing.T) { // Create a ResponseRecorder to capture the response. rr := httptest.NewRecorder() - // Create a dummy request body. + if dito == nil { + t.Fatal("Dito instance is nil") + } req.Body = io.NopCloser(bytes.NewBufferString("Test body")) // Call the handler. diff --git a/handlers/testdata/client_cert.pem b/handlers/testdata/client_cert.pem new file mode 100644 index 0000000..ea376c4 --- /dev/null +++ b/handlers/testdata/client_cert.pem @@ -0,0 +1,22 @@ +-----BEGIN CERTIFICATE----- +MIIDujCCAqKgAwIBAgIUcmdRANmvrDIZy4t8MBj36sODNbkwDQYJKoZIhvcNAQEL +BQAwbDELMAkGA1UEBhMCSVQxDjAMBgNVBAgMBUl0YWx5MQ0wCwYDVQQHDARSb21l +MRQwEgYDVQQKDAtZb3VyQ29tcGFueTEWMBQGA1UECwwNSVQgRGVwYXJ0bWVudDEQ +MA4GA1UEAwwHVGVzdCBDQTAeFw0yNDEwMTgyMTMzMjRaFw0yNjAzMDIyMTMzMjRa +MGsxCzAJBgNVBAYTAklUMQ4wDAYDVQQIDAVJdGFseTENMAsGA1UEBwwEUm9tZTEU +MBIGA1UECgwLWW91ckNvbXBhbnkxFjAUBgNVBAsMDUlUIERlcGFydG1lbnQxDzAN +BgNVBAMMBmNsaWVudDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKCS +tZp/9DSoaPuujP4Z9i2NYO+knXL51hm9sY/iV3aWWVmy2OljfdxaqkIk0UXOvPC3 +rQg4lxmrkbEP3GazgAvE4Hz3fNCrClo6MtuuPwoIiwsCIxGa/k7z+Qbm5AhlVb2W +4uUrl+en7ju3DdAXy0xylSmrOP+PBaHLu0m8sFutckU0vITtKUOeMWfEEWq5AQx+ +p2VPCRY6bmfEccgBUXnwJ9e0z9LWkbrpQ5RqYdckK1TmxbAnfCf5Z3U7fD0X+xnF +hdpHeT3DnhWsrlzxuwKIQOfSPqDP1awnbXy51SLEzA1w9mJ1d7b1FSK3t72uzJFK +tlBXkKbanfqKRR+tGQsCAwEAAaNVMFMwEQYDVR0RBAowCIIGY2xpZW50MB0GA1Ud +DgQWBBRew2y3HkAO01QCKsWa4n9ODAFnMjAfBgNVHSMEGDAWgBTLP/FlZN+sOc93 +zW1ml7RATyTnKDANBgkqhkiG9w0BAQsFAAOCAQEAUjYBxUuJ3eC72WnHIxsjmRB2 +uBinnH3hvQHI5vBsF4RPKJxcl55FUhgVmyDZX2p7hlajXmcDli23L9AjdJjhugBY +ww0f4WNdALwSxCsTyKqincIzmBHnXg7jo18cMoA+G97GuhuTPyrZd+Rg5TxrIojp +tQtvhBE4XN+UOby7XQohH6XLtVlkRxoSIFLJJQtP67sJXE8/Xc6ULNYvEx3dpfdE +o7eKdBgU8vKiUlYNmkFUIVWIUfajcVp1WgaoSg9GD8hPqjzrd+33MloGrrzCXz5W +psqtKTOx95+EN+1uRzzXdZ/vhn4a+6olRbR3gr/OhXL0QRGuMsRCcBdPaiGRkQ== +-----END CERTIFICATE----- diff --git a/handlers/testdata/client_key.pem b/handlers/testdata/client_key.pem new file mode 100644 index 0000000..1fcc19d --- /dev/null +++ b/handlers/testdata/client_key.pem @@ -0,0 +1,28 @@ +-----BEGIN PRIVATE KEY----- +MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCgkrWaf/Q0qGj7 +roz+GfYtjWDvpJ1y+dYZvbGP4ld2lllZstjpY33cWqpCJNFFzrzwt60IOJcZq5Gx +D9xms4ALxOB893zQqwpaOjLbrj8KCIsLAiMRmv5O8/kG5uQIZVW9luLlK5fnp+47 +tw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UOtg7xx3dVboTIb3UHB3sznXAoGAH2iv +JoWZysfPoH+LQu0qOph6gR6jtSYzaq+uFFOzt1nv9HvX9ngoTpLnG3QMb5vEEo16 +LmbnMp1bQFyxiwfgiwAcwQGXiAH9xrGOTFOqOUH5EindZnIa6jpxYn1ddNMgYa0e +2t0tKIM5FaBycmXM8JQ+qLrio/YvEEtycQ2lKWECgYBcKEI3JrMJhahbcMqA6ACO +y8yTB2qtmL+GQNVPN7ctZ0DYfYwdnKtg3W7ipy8wAqQZDjykLIfFLrCnyIqg/3R1 +cUdoL+YBsB2AcmdEExkU7S7KrOf2G6bJlFmZnScObFRj+RKZ+sO1p022Eh4IEY1T +Ndkud1A182ZnhbOJkgolIQ== +-----END PRIVATE KEY----- diff --git a/handlers/testdata/test_ca.pem b/handlers/testdata/test_ca.pem new file mode 100644 index 0000000..bdb1537 --- /dev/null +++ b/handlers/testdata/test_ca.pem @@ -0,0 +1,22 @@ +-----BEGIN CERTIFICATE----- +MIIDuTCCAqGgAwIBAgIUVmNkawz/bH4gN0HxvYPhTZHdYRYwDQYJKoZIhvcNAQEL +BQAwbDELMAkGA1UEBhMCSVQxDjAMBgNVBAgMBUl0YWx5MQ0wCwYDVQQHDARSb21l +MRQwEgYDVQQKDAtZb3VyQ29tcGFueTEWMBQGA1UECwwNSVQgRGVwYXJ0bWVudDEQ +MA4GA1UEAwwHVGVzdCBDQTAeFw0yNDEwMTgyMTMyMTVaFw0yNzA4MDgyMTMyMTVa +MGwxCzAJBgNVBAYTAklUMQ4wDAYDVQQIDAVJdGFseTENMAsGA1UEBwwEUm9tZTEU +MBIGA1UECgwLWW91ckNvbXBhbnkxFjAUBgNVBAsMDUlUIERlcGFydG1lbnQxEDAO +BgNVBAMMB1Rlc3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC9 +fgucEf299EyQVH21JvTqkWodhXk85kchUR7n7UHmanU0/NL9q0nnGCZpTzm4FYK2 +rlhCGLUbIQzZG+MhmBXAVo2W6ji23LBVT/TRX7/MwGeltREdrXb8P9EkxzFajyAR ++50drR9wU2BljKbwTExzjUWsFN0yjNWC94eD1sDRTXv/K86MNfqGda3IL+HDAOMG +7YJJLR5Zzq+4LqLXauGfcpNsl6/beZiNlxhb3uZbjr6elGzhEFGywVIXleWPFXhZ +ssIq2qig4yqX2PYyTbaCC3ZhFVB23+gKdv+k4raG6TsaDOKHEA3k0dyFWG2NUoqz +6bVoeJEr4H/n8SuF1OX5AgMBAAGjUzBRMB0GA1UdDgQWBBTLP/FlZN+sOc93zW1m +l7RATyTnKDAfBgNVHSMEGDAWgBTLP/FlZN+sOc93zW1ml7RATyTnKDAPBgNVHRMB +Af8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQCDh1A+PE2fZ6VdxInwZzhlzQQm +43EZgKNBj67baFR2LLlqnJwmLJ+Q8VblHSjmdpkFYbF0wGniTI2eL3t/wAEroUxi +nwpBdzklZDkU5fjP/rKvDJffZelFuSNLexD7znKyp60+E/UtIHCy3qJepVdlUDKj +0hJe086H9m+2JDfVSpaadqVwiCZMLDe5LheFyiw1nNBY0t42ENHbK7Fu1bbjUh7a +EpkeGXDMMAHND0MDqFteYsa5AcULcFUAkTE3+jRpDyWXeQyq4xXYjF0xNDMw20ed +mGsOV4b1M74TrTY/aS4qU7UzbgU8kchVfrVVu+eqbcOLPTED1r5h3oPuHaH1 +-----END CERTIFICATE----- diff --git a/handlers/testdata/test_cert.pem b/handlers/testdata/test_cert.pem new file mode 100644 index 0000000..3de28f1 --- /dev/null +++ b/handlers/testdata/test_cert.pem @@ -0,0 +1,17 @@ +-----BEGIN CERTIFICATE----- +MIICrzCCAZcCFHEjMjahJ2kOSszF6i6nRWFJBCy/MA0GCSqGSIb3DQEBCwUAMBIx +EDAOBgNVBAMMB1Rlc3QgQ0EwHhcNMjQxMDA3MTQ0NDQzWhcNMjUxMDA3MTQ0NDQz +WjAWMRQwEgYDVQQDDAtUZXN0IENsaWVudDCCASIwDQYJKoZIhvcNAQEBBQADggEP +ADCCAQoCggEBAIpTcC3WbWrHoY8MNuOJ7FnQjGlMtpYxmUByfAOStYrvGU3QYJaM +tzZ2wKvpRcPthkBZiG/atYiouN54TrnA72wK/uV2ZzWKxWLxfGnIxUokSyaaUTnR +g6Oaog3dQaCkf+u3hMA7f4jElEj49x1Q92rJTgkyJfKmry/G2j/p1LI3W9lfFa8g +Yhf3hdZj0QIQnrDdYSpWJ2aCinMFpft4X7Mj9KjfVdbISIKZhWDOU2TBh/Z2fZG1 +q1lYcBvdgb9niPIh0ZOdYv/ZEL8bgheGNbtWp5NofXiaC90oPL8pkNY1IzMhjzUi +fcCgADEbvHPILZMLyWWetZrxVMDh97X8dCMCAwEAATANBgkqhkiG9w0BAQsFAAOC +AQEAGLKZymIlINJWZDxYUVyfLzsGSqbQHf2jWo8QMPk1p9bHK/a9mj2klNmeIuF1 +eFg7jh5DPaIgKuqHKieuQ5qOnx3XVeQTQI5wM9ygwBuhqbiwKLAsCLp6teheRbTY +JMZI/91L/DsXZtFq9GsTCw1dkMi3rw8aj4PKLUdCJEcEbpiN78LSLh5VJYXgH/WI +a14SVseZOt0NFlGk8o1UzahduJ24PtLcC0NXPvUUkJP8wrFOgkVF8mYr4kb3k28n +BCFb6kcSbn7o9svtTxhJHLF+dsHN1L7tUG6WhnNv5uM/n2qvEyxjLxRIIdh/Bv0M +paCRZDQXjI8oep7JDJXmfWz2PQ== +-----END CERTIFICATE----- diff --git a/handlers/testdata/test_key.pem b/handlers/testdata/test_key.pem new file mode 100644 index 0000000..b3804fb --- /dev/null +++ b/handlers/testdata/test_key.pem @@ -0,0 +1,28 @@ +-----BEGIN PRIVATE KEY----- +MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCKU3At1m1qx6GP +DDbjiexZ0IxpTLaWMZlAcnwDkrWK7xlN0GCWjLc2dsCr6UXD7YZAWYhv2rWIqLje +eE65wO9sCv7ldmc1isVi8XxpyMVKJEsmmlE50Y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XIug7eiC6MHW9ZOK5Cu4JwjnTR7sQ8bwb9AeWwc/2GRxxb7Y6Xk3rhRAoGAEMMB +6FcNidDAAqHqJVdiM/OlBl7xuHjBNmKluhyWJHHhRY4QHyGpEYmZLRo2ZauMur9Z +cWTw2Ahy8OZuQ6+EckHmdDz+4PogFl4ZruLjZ5A7dF7NuUb0LIL54jBwZ4Q9QRQt +Kf+3DRFHKC2Z3csLvxbrLzfGL5JqaUUflF3DT+0CgYAmmtFUh479ekFEykFQ8ykn +AoO/8l1lJ3ulwzfvJVDmzteIuLwqCq5a6BOMqBZR01rPFnqCkgVJ3bQQ3wq6dyxq +0znKjn4QUZxq+bqLQXtgJJcwq52Mg5iK34w+213WhX6Dd5z+DzsocMY47MVJuWFQ +x+NEmDXAZ3rx2PPy+QWqTw== +-----END PRIVATE KEY----- diff --git a/logging/logging.go b/logging/logging.go index fd327f2..939a3d4 100644 --- a/logging/logging.go +++ b/logging/logging.go @@ -3,14 +3,15 @@ package logging import ( "dito/writer" "fmt" - "github.com/fatih/color" - "github.com/gorilla/websocket" - "github.com/lmittmann/tint" "log/slog" "net/http" "os" "strings" "time" + + "github.com/fatih/color" + "github.com/gorilla/websocket" + "github.com/lmittmann/tint" ) var logger *slog.Logger @@ -134,9 +135,9 @@ func LogWebSocketMessageOLD(messageType int, message []byte, err error, duration } if err != nil { - logger.Error(fmt.Sprintf("WebSocket %s Message Error: %v", "error", messageTypeStr, err)) + logger.Error(fmt.Sprintf("WebSocket %s Message Error: %v", messageTypeStr, err)) } else { - logger.Info(fmt.Sprintf("WebSocket %s Message: %s (%.6f seconds)", "error", messageTypeStr, string(message), duration.Seconds())) + logger.Info(fmt.Sprintf("WebSocket %s Message: %s (%.6f seconds)", messageTypeStr, string(message), duration.Seconds())) } } diff --git a/logging/logging_test.go b/logging/logging_test.go index 821d874..115e6a0 100644 --- a/logging/logging_test.go +++ b/logging/logging_test.go @@ -2,10 +2,11 @@ package logging import ( "bytes" - "github.com/lmittmann/tint" "log/slog" "os" + "github.com/lmittmann/tint" + "net/http" "testing" "time" @@ -22,7 +23,7 @@ func TestLogRequestVerbose(t *testing.T) { duration := 2 * time.Second body := []byte("request body") - LogRequestVerbose(req, &body, &headers, statusCode, duration) + LogRequestVerbose(req, body, headers, statusCode, duration) } // TestLogRequestCompact tests the LogRequestCompact function. @@ -36,7 +37,7 @@ func TestLogRequestCompact(t *testing.T) { duration := 2 * time.Second body := []byte("request body") - LogRequestCompact(req, &body, &headers, statusCode, duration) + LogRequestCompact(req, body, headers, statusCode, duration) } // InitializeLogger initializes a new logger with the specified log level.