From 64f8b63548edff2ab521be013502680fc5f04df7 Mon Sep 17 00:00:00 2001 From: samosvalishe Date: Sat, 19 Sep 2026 23:54:42 +0300 Subject: [PATCH] =?UTF-8?q?feat(uri):=20=D1=81=D1=81=D1=8B=D0=BB=D0=BA?= =?UTF-8?q?=D0=B0=20=D0=BD=D0=B0=20=D0=B7=D0=B2=D0=BE=D0=BD=D0=BE=D0=BA=20?= =?UTF-8?q?=D0=B8=20=D0=BF=D0=B5=D0=B9=D1=81=D0=B8=D0=BD=D0=B3=20=D0=BE?= =?UTF-8?q?=D0=B1=D1=84=D1=83=D1=81=D0=BA=D0=B0=D1=86=D0=B8=D0=B8=20=D0=B2?= =?UTF-8?q?=20freeturn://?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit vk применяется, только если своих ссылок не задано; timing - только вместе с обфускацией. --- internal/config/raw.go | 8 ++++++++ internal/config/raw_test.go | 29 +++++++++++++++++++++++++++++ internal/uri/uri.go | 8 ++++++++ internal/uri/uri_test.go | 2 ++ 4 files changed, 47 insertions(+) diff --git a/internal/config/raw.go b/internal/config/raw.go index 0129032..dfaae4c 100644 --- a/internal/config/raw.go +++ b/internal/config/raw.go @@ -85,6 +85,14 @@ func (r *raw) applyURI(u *uri.Config) { if u.ObfKey != "" { r.ObfKey = u.ObfKey } + + if u.ObfTimingMs > 0 && u.ObfProfile != "" && u.ObfProfile != string(ObfProfileNone) { + r.ObfTiming = time.Duration(u.ObfTimingMs) * time.Millisecond + } + + if u.VKLink != "" && r.Links == "" && r.Link == "" { + r.Links = u.VKLink + } if u.Peer != "" { r.Peer = u.Peer } diff --git a/internal/config/raw_test.go b/internal/config/raw_test.go index 895e9f1..4f8ef79 100644 --- a/internal/config/raw_test.go +++ b/internal/config/raw_test.go @@ -4,6 +4,7 @@ import ( "reflect" "strings" "testing" + "time" "github.com/samosvalishe/free-turn-proxy/internal/uri" ) @@ -92,6 +93,34 @@ func TestApplyURIOverridesOnlyPresentFields(t *testing.T) { } } +func TestApplyURIVKLinkIsFallback(t *testing.T) { + r := defaultRaw() + r.applyURI(&uri.Config{VKLink: "https://vk.ru/call/join/OWNER"}) + if r.Links != "https://vk.ru/call/join/OWNER" { + t.Errorf("Links = %q, want owner link", r.Links) + } + + r = defaultRaw() + r.Links = "https://vk.ru/call/join/MINE" + r.applyURI(&uri.Config{VKLink: "https://vk.ru/call/join/OWNER"}) + if r.Links != "https://vk.ru/call/join/MINE" { + t.Errorf("Links = %q, own link must win", r.Links) + } +} + +func TestApplyURITimingNeedsObf(t *testing.T) { + r := defaultRaw() + r.applyURI(&uri.Config{ObfTimingMs: 20}) + if r.ObfTiming != 0 { + t.Errorf("ObfTiming = %s without obf profile, want 0", r.ObfTiming) + } + + r.applyURI(&uri.Config{ObfProfile: "rtpopus", ObfKey: "00", ObfTimingMs: 20}) + if r.ObfTiming != 20*time.Millisecond { + t.Errorf("ObfTiming = %s, want 20ms", r.ObfTiming) + } +} + func TestApplyURIIgnoresZeroValues(t *testing.T) { r := defaultRaw() r.N = 5 diff --git a/internal/uri/uri.go b/internal/uri/uri.go index 3d6d0b7..9ae384e 100644 --- a/internal/uri/uri.go +++ b/internal/uri/uri.go @@ -20,6 +20,7 @@ type Config struct { Mode string ObfProfile string ObfKey string + ObfTimingMs int N int StreamsPerCred int ClientID string @@ -29,6 +30,7 @@ type Config struct { ManualCaptcha bool KCP *KCP Comment string + VKLink string WGConf string } @@ -41,6 +43,7 @@ type wire struct { Mode string `json:"mode,omitempty"` Obf string `json:"obf,omitempty"` Key string `json:"key,omitempty"` + TimingMs int `json:"timing,omitempty"` N int `json:"n,omitempty"` StreamsPerCred int `json:"spc,omitempty"` ClientID string `json:"cid,omitempty"` @@ -50,6 +53,7 @@ type wire struct { ManualCaptcha bool `json:"mcap,omitempty"` KCP *KCP `json:"kcp,omitempty"` Name string `json:"name,omitempty"` + VK string `json:"vk,omitempty"` WGConf string `json:"wg,omitempty"` } @@ -90,6 +94,7 @@ func Parse(s string) (*Config, error) { Mode: w.Mode, ObfProfile: w.Obf, ObfKey: w.Key, + ObfTimingMs: w.TimingMs, N: w.N, StreamsPerCred: w.StreamsPerCred, ClientID: w.ClientID, @@ -99,6 +104,7 @@ func Parse(s string) (*Config, error) { ManualCaptcha: w.ManualCaptcha, KCP: w.KCP, Comment: w.Name, + VKLink: w.VK, WGConf: w.WGConf, }, nil } @@ -120,11 +126,13 @@ func (c *Config) String() string { ManualCaptcha: c.ManualCaptcha, KCP: c.KCP, Name: c.Comment, + VK: c.VKLink, WGConf: c.WGConf, } if c.ObfProfile != "" && c.ObfProfile != "none" { w.Obf = c.ObfProfile w.Key = c.ObfKey + w.TimingMs = c.ObfTimingMs } raw, err := json.Marshal(w) diff --git a/internal/uri/uri_test.go b/internal/uri/uri_test.go index 0f52b07..9f3f3e6 100644 --- a/internal/uri/uri_test.go +++ b/internal/uri/uri_test.go @@ -21,6 +21,7 @@ func TestRoundTrip(t *testing.T) { Mode: "tcp", ObfProfile: "rtpopus", ObfKey: "d823fa", + ObfTimingMs: 20, N: 16, StreamsPerCred: 8, ClientID: "abc123", @@ -29,6 +30,7 @@ func TestRoundTrip(t *testing.T) { DNSServers: "1.1.1.1,8.8.8.8", ManualCaptcha: true, Comment: "MyServer", + VKLink: "https://vk.ru/call/join/abc", }, }, {