feat(uri): ссылка на звонок и пейсинг обфускации в freeturn://

vk применяется, только если своих ссылок не задано; timing - только вместе с обфускацией.
This commit is contained in:
samosvalishe committed 2026-09-19 23:54:42 +03:00
1 parent e102acbc4b
commit 64f8b63548
4 files changed
+47

No files matched your search

+8
View File
@@ -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
}
+29
View File
@@ -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
+8
View File
@@ -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)
+2
View File
@@ -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",
},
},
{