style: перевести комментарии на русский, убрать очевидные

This commit is contained in:
samosvalishe committed 2026-05-21 12:31:50 +03:00
1 parent ada9b949a4
commit e417dac087
48 files changed
+659 -671

No files matched your search

+13 -15
View File
@@ -1,19 +1,17 @@
// DTLS-as-obfuscation note (V2-8):
// DTLS как обфускация (V2-8):
//
// DTLS in this project is used primarily as an *obfuscation* layer, not as a
// security boundary. The VK TURN content-filter drops payloads that do not
// look like a legitimate DTLS handshake followed by encrypted records, so the
// handshake is what gets us through. The encryption it provides is a free
// side-effect — we already trust the wrapped tunnel (WireGuard inside UDP
// mode, or smux+KCP inside tcpfwd mode) to handle confidentiality and
// integrity end-to-end.
// DTLS в этом проекте используется прежде всего как слой *обфускации*, а не
// как граница безопасности. VK TURN content-filter дропает payload, не
// похожий на легитимный DTLS handshake с зашифрованными записями, — именно
// handshake пропускает нас. Шифрование — бесплатный побочный эффект; мы уже
// доверяем внутреннему туннелю (WireGuard в UDP-режиме или smux+KCP в tcpfwd)
// для обеспечения конфиденциальности и целостности end-to-end.
//
// This is why the older `-no-dtls` / `Direct` flag was removed in V2-0: with
// DTLS off, VK drops packets and the proxy effectively does not work in
// production. There is no scenario in which disabling DTLS is the right
// call against the live VK filter.
// Именно поэтому старый флаг `-no-dtls` / `Direct` удалён в V2-0: без DTLS
// VK дропает пакеты и прокси фактически не работает в production. Нет
// сценария, в котором отключение DTLS против живого VK-фильтра — верное решение.
//
// Implication for future changes: do not treat the DTLS layer as if it were
// security-critical (e.g. it is fine to use self-signed certs, send-only CID,
// and no peer-cert validation — those are deliberate, not oversights).
// Для будущих изменений: не трактуй DTLS-слой как security-critical
// (самоподписанные сертификаты, send-only CID, отсутствие проверки peer-cert —
// это намеренно, не упущения).
package dtlsdial
+11 -15
View File
@@ -1,6 +1,6 @@
// Package dtlsdial wraps pion-dtls client setup (self-signed cert, EMS,
// AES-128-GCM, send-only CID) plus an optional concurrency gate around the
// handshake. Used by the client UDP and VLESS pipelines.
// Package dtlsdial оборачивает настройку pion-dtls клиента (self-signed cert, EMS,
// AES-128-GCM, send-only CID) плюс опциональный конкурентный gate на handshake.
// Используется UDP и VLESS pipeline'ами клиента.
package dtlsdial
import (
@@ -14,19 +14,16 @@ import (
"github.com/pion/dtls/v3/pkg/crypto/selfsign"
)
// GenerateSelfSignedCert returns a new self-signed TLS certificate for use
// as the DTLS identity. It is a thin wrapper around selfsign.GenerateSelfSigned
// and exists so both cmd/server and Dialer share one call-site.
func GenerateSelfSignedCert() (tls.Certificate, error) {
return selfsign.GenerateSelfSigned()
}
// Dialer configures the DTLS client handshake.
// Dialer конфигурирует DTLS-handshake клиента.
type Dialer struct {
// HandshakeTimeout caps the handshake context. Zero means no timeout.
// HandshakeTimeout ограничивает контекст handshake. Ноль — без таймаута.
HandshakeTimeout time.Duration
// HandshakeSem, if non-nil, gates concurrent handshakes (Dial blocks
// until a slot is available or ctx fires).
// HandshakeSem, если non-nil, ограничивает параллельные handshake
// (Dial блокируется до появления слота или отмены ctx).
HandshakeSem chan struct{}
certOnce sync.Once
@@ -34,11 +31,10 @@ type Dialer struct {
certErr error
}
// Dial acquires the optional handshake slot and performs a DTLS client
// handshake over pc to peer. On success returns the connected *dtls.Conn.
// Caller closes it. The self-signed cert is generated once per Dialer and
// reused across handshakes (DTLS is used here for obfuscation, not auth —
// see internal/transport/dtlsdial/doc.go).
// Dial захватывает опциональный handshake-слот и выполняет DTLS-handshake
// клиента поверх pc к peer. При успехе возвращает *dtls.Conn (закрывает вызывающий).
// Self-signed сертификат генерируется один раз на Dialer и переиспользуется
// (DTLS здесь — для обфускации, не аутентификации; см. doc.go).
func (d *Dialer) Dial(ctx context.Context, pc net.PacketConn, peer *net.UDPAddr) (*dtls.Conn, error) {
d.certOnce.Do(func() {
d.cert, d.certErr = GenerateSelfSignedCert()