Fix three doc-vs-implementation gaps found during audit
1. DB migration: add CHECK(mode IN ('l4', 'l7')) constraint on the
routes.mode column. ARCHITECTURE.md documented this constraint but
migration v2 omitted it. Enforces mode validity at the database
level in addition to application-level validation.
2. L7 reverse proxy: distinguish timeout errors from connection errors
in the ErrorHandler. Backend timeouts now return HTTP 504 Gateway
Timeout instead of 502. Uses errors.Is(context.DeadlineExceeded)
and net.Error.Timeout() detection. Added isTimeoutError unit tests.
3. Config validation: warn when L4 routes have tls_cert or tls_key set
(they are silently ignored). ARCHITECTURE.md documented this warning
but config.validate() did not emit it. Uses slog.Warn.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,7 @@ package config
|
||||
import (
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -198,6 +199,12 @@ func (c *Config) validate() error {
|
||||
i, l.Addr, j, r.Hostname, r.Mode)
|
||||
}
|
||||
|
||||
// Warn if L4 routes have cert/key set (they are ignored).
|
||||
if r.Mode == "l4" && (r.TLSCert != "" || r.TLSKey != "") {
|
||||
slog.Warn("L4 route has tls_cert/tls_key set (ignored)",
|
||||
"listener", l.Addr, "hostname", r.Hostname)
|
||||
}
|
||||
|
||||
// L7 routes require TLS cert and key.
|
||||
if r.Mode == "l7" {
|
||||
if r.TLSCert == "" || r.TLSKey == "" {
|
||||
|
||||
Reference in New Issue
Block a user