refactor: common util package, ESL/AMI/security fixes, Prometheus metrics

Backend stability and security improvements:

* internal/util/ — common RandomHex helper, removed 3 duplicates
* ESL: deduplicated readMessage (locked/unlocked), net.JoinHostPort for IPv6
* AMI: synchronous reconnect() in readEventsLoop, net.JoinHostPort for IPv6
* Auth: /api/auth/refresh accepts Authorization header only (no ?token=)
* decodeJSON: http.MaxBytesReader(1<<20) body limit
* Trunks: gatewayParams() uses configured ESL.GatewayPrefix
* Config: jwt_secret_env env-var fallback
* FSCollector: time.After → time.NewTimer with defer Stop
* Monitoring: Prometheus counters (route_requests, nodes_total/healthy, uptime)
* go fmt pass across all internal/ packages
This commit is contained in:
Maksim Totmin
2026-06-25 19:30:36 +07:00
parent e66ac27dd9
commit cc9da3ad7d
25 changed files with 261 additions and 237 deletions
+4 -4
View File
@@ -15,10 +15,10 @@ import (
// Logger — потокобезопасный логгер метрик в ASCII-файл с дневной ротацией.
type Logger struct {
mu sync.Mutex
dir string
file *os.File
today string // YYYY-MM-DD последнего открытого файла
mu sync.Mutex
dir string
file *os.File
today string // YYYY-MM-DD последнего открытого файла
}
// NewLogger создаёт логгер, записывающий в dataDir/.