feat: Client ID шлётся всегда, симметричный wire авторизации

Клиент всегда отправляет Client ID первой DTLS app-record, сервер
всегда читает. Флаг -auth и URI-параметр auth удалены — рассинхрон
client/server невозможен. -clients-file на сервере включает только
проверку ID по allowlist clients.json.

Также:
- clients.json и client_config.json пишутся с правами 0o600
- исправлены все находки golangci-lint (errcheck, gosec, govet shadow)

Примечание: удалён флаг -auth и URI-параметр auth; Client ID теперь
всегда в первой записи туннеля — старые клиенты/серверы несовместимы.
This commit is contained in:
samosvalishe committed 2026-05-25 00:33:26 +03:00
1 parent 198d314031
commit f1b047e9e5
14 files changed
+49 -63

No files matched your search

+5 -6
View File
@@ -32,7 +32,6 @@ type Params struct {
KCPProfile kcptun.Profile
KCPFEC kcptun.FEC
ClientID string
Auth bool
}
// BondHandler распределяет одно принятое TCP-соединение по всем активным сессиям пула.
@@ -258,11 +257,11 @@ func createSmuxSession(ctx context.Context, deps *Deps, params *Params, peer *ne
cleanupFns = append(cleanupFns, func() { _ = dtlsConn.Close() })
deps.log().Debugf("DTLS connection established")
if params.Auth {
if err := clientsdb.WriteClientID(dtlsConn, params.ClientID); err != nil {
cleanup()
return nil, nil, fmt.Errorf("send client ID: %w", err)
}
// Client ID шлётся всегда первой DTLS app-record; сервер всегда читает.
// -clients-file на сервере решает только, проверять ли ID по allowlist.
if werr := clientsdb.WriteClientID(dtlsConn, params.ClientID); werr != nil {
cleanup()
return nil, nil, fmt.Errorf("send client ID: %w", werr)
}
statsCtx, statsCancel := context.WithCancel(ctx) //nolint:gosec // cancel is held in cleanupFns and invoked via cleanup() LIFO