From 5b68683d415043af8d8c56dbdc3c58cb01bf31c4 Mon Sep 17 00:00:00 2001 From: samosvalishe Date: Tue, 19 May 2026 17:19:44 +0300 Subject: [PATCH] =?UTF-8?q?refactor(config):=20=D1=83=D0=B1=D1=80=D0=B0?= =?UTF-8?q?=D1=82=D1=8C=20=D1=84=D0=BB=D0=B0=D0=B3=D0=B8=20-no-dtls=20?= =?UTF-8?q?=D0=B8=20=D1=81=D0=B5=D1=80=D0=B2=D0=B5=D1=80=D0=BD=D1=8B=D0=B9?= =?UTF-8?q?=20-vless-bond?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Чистка CLI (breaking): - Клиент: убран -no-dtls (был помечен DO NOT USE; VK content-filter дропает payload без DTLS-handshake, так что прямой путь в проде не работал). Поле config.Client.Direct, guard диспатчера в main и TestParseClient_WrapDirectConflict удалены. - Сервер: убран -vless-bond. Сервер уже автоопределяет bond по magic-префиксу на первом smux-стриме (bond-autodetect=true), флаг был избыточен. Поле config.Server.VLESSBond, параметр useBond у handleVLESSConnection и ветка-предупреждение "non-bond stream while bond enabled" удалены. - Клиентский -vless-bond остаётся — он по-прежнему управляет страйпингом на стороне клиента. Wire-форматы не тронуты. Оба удаления флагов — breaking CLI-изменения. --- internal/config/config.go | 14 +++----------- internal/config/config_test.go | 8 -------- 2 files changed, 3 insertions(+), 19 deletions(-) diff --git a/internal/config/config.go b/internal/config/config.go index 45967da..cc8571a 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -15,8 +15,9 @@ import ( "github.com/cacggghp/vk-turn-proxy/internal/wrap" ) -// Mirrors of constants defined in client/internal packages, duplicated here -// because internal/config cannot import client/internal/*. +// Mirrors of constants defined in internal/client/* packages, duplicated here +// because internal/config cannot import internal/client/* (those packages +// import internal/config indirectly through dependents — avoid the cycle). const ( dnsModeUDP = "udp" dnsModeDoH = "doh" @@ -33,7 +34,6 @@ type Client struct { Peer string N int UDP bool - Direct bool VLESSMode bool VLESSBond bool WrapMode bool @@ -51,7 +51,6 @@ type Server struct { Listen string Connect string VLESSMode bool - VLESSBond bool WrapMode bool WrapKey []byte GenWrapKey bool @@ -73,7 +72,6 @@ func ParseClient(args []string, errOut io.Writer) (*Client, error) { peerAddr := fs.String("peer", "", "peer server address (host:port)") n := fs.Int("n", 10, "connections to TURN") udp := fs.Bool("udp", false, "connect to TURN with UDP") - direct := fs.Bool("no-dtls", false, "connect without obfuscation. DO NOT USE") vlessMode := fs.Bool("vless", false, "VLESS mode: forward TCP connections (for VLESS) instead of UDP packets") vlessBond := fs.Bool("vless-bond", false, "bond one VLESS TCP connection across all active smux sessions") wrapMode := fs.Bool("wrap", false, "WRAP mode: ChaCha20-XOR obfuscate DTLS packets before they reach TURN ChannelData") @@ -96,7 +94,6 @@ func ParseClient(args []string, errOut io.Writer) (*Client, error) { Peer: *peerAddr, N: *n, UDP: *udp, - Direct: *direct, VLESSMode: *vlessMode, VLESSBond: *vlessBond, WrapMode: *wrapMode, @@ -128,9 +125,6 @@ func ParseClient(args []string, errOut io.Writer) (*Client, error) { if *vklink == "" { return nil, errors.New("need vk-link") } - if c.WrapMode && c.Direct { - return nil, fmt.Errorf("-wrap requires DTLS; remove -no-dtls") - } key, err := wrap.DecodeKey(c.WrapMode, *wrapKeyHex) if err != nil { return nil, err @@ -163,7 +157,6 @@ func ParseServer(args []string, errOut io.Writer) (*Server, error) { listen := fs.String("listen", "0.0.0.0:56000", "listen on ip:port") connect := fs.String("connect", "", "connect to ip:port") vlessMode := fs.Bool("vless", false, "VLESS mode: forward TCP connections (for VLESS) instead of UDP packets") - vlessBond := fs.Bool("vless-bond", false, "bond one VLESS TCP connection across all active smux sessions") wrapMode := fs.Bool("wrap", false, "WRAP mode: ChaCha20-XOR obfuscate DTLS packets before they reach TURN ChannelData") wrapKeyHex := fs.String("wrap-key", "", "32-byte hex-encoded shared key for -wrap (64 hex chars)") genWrapKey := fs.Bool("gen-wrap-key", false, "print a fresh 64-character hex key for -wrap-key and exit") @@ -177,7 +170,6 @@ func ParseServer(args []string, errOut io.Writer) (*Server, error) { Listen: *listen, Connect: *connect, VLESSMode: *vlessMode, - VLESSBond: *vlessBond, WrapMode: *wrapMode, GenWrapKey: *genWrapKey, Debug: *debugFlag, diff --git a/internal/config/config_test.go b/internal/config/config_test.go index b290e1c..76aa192 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -77,14 +77,6 @@ func TestParseClient_InvalidDNS(t *testing.T) { } } -func TestParseClient_WrapDirectConflict(t *testing.T) { - args := append(validClientArgs(), "-wrap", "-no-dtls", "-wrap-key", strings.Repeat("aa", 32)) - _, err := ParseClient(args, io.Discard) - if err == nil || !strings.Contains(err.Error(), "-wrap requires DTLS") { - t.Errorf("expected wrap/direct conflict, got %v", err) - } -} - func TestParseClient_WrapMissingKey(t *testing.T) { args := append(validClientArgs(), "-wrap") _, err := ParseClient(args, io.Discard)