feat(uri): ссылка на звонок и пейсинг обфускации в freeturn://
vk применяется, только если своих ссылок не задано; timing - только вместе с обфускацией.
This commit is contained in:
1 parent
e102acbc4b
commit
64f8b63548
4 files changed
+47
No files matched your search
@@ -85,6 +85,14 @@ func (r *raw) applyURI(u *uri.Config) {
|
|||||||
if u.ObfKey != "" {
|
if u.ObfKey != "" {
|
||||||
r.ObfKey = 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 != "" {
|
if u.Peer != "" {
|
||||||
r.Peer = u.Peer
|
r.Peer = u.Peer
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/samosvalishe/free-turn-proxy/internal/uri"
|
"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) {
|
func TestApplyURIIgnoresZeroValues(t *testing.T) {
|
||||||
r := defaultRaw()
|
r := defaultRaw()
|
||||||
r.N = 5
|
r.N = 5
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ type Config struct {
|
|||||||
Mode string
|
Mode string
|
||||||
ObfProfile string
|
ObfProfile string
|
||||||
ObfKey string
|
ObfKey string
|
||||||
|
ObfTimingMs int
|
||||||
N int
|
N int
|
||||||
StreamsPerCred int
|
StreamsPerCred int
|
||||||
ClientID string
|
ClientID string
|
||||||
@@ -29,6 +30,7 @@ type Config struct {
|
|||||||
ManualCaptcha bool
|
ManualCaptcha bool
|
||||||
KCP *KCP
|
KCP *KCP
|
||||||
Comment string
|
Comment string
|
||||||
|
VKLink string
|
||||||
WGConf string
|
WGConf string
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,6 +43,7 @@ type wire struct {
|
|||||||
Mode string `json:"mode,omitempty"`
|
Mode string `json:"mode,omitempty"`
|
||||||
Obf string `json:"obf,omitempty"`
|
Obf string `json:"obf,omitempty"`
|
||||||
Key string `json:"key,omitempty"`
|
Key string `json:"key,omitempty"`
|
||||||
|
TimingMs int `json:"timing,omitempty"`
|
||||||
N int `json:"n,omitempty"`
|
N int `json:"n,omitempty"`
|
||||||
StreamsPerCred int `json:"spc,omitempty"`
|
StreamsPerCred int `json:"spc,omitempty"`
|
||||||
ClientID string `json:"cid,omitempty"`
|
ClientID string `json:"cid,omitempty"`
|
||||||
@@ -50,6 +53,7 @@ type wire struct {
|
|||||||
ManualCaptcha bool `json:"mcap,omitempty"`
|
ManualCaptcha bool `json:"mcap,omitempty"`
|
||||||
KCP *KCP `json:"kcp,omitempty"`
|
KCP *KCP `json:"kcp,omitempty"`
|
||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name,omitempty"`
|
||||||
|
VK string `json:"vk,omitempty"`
|
||||||
WGConf string `json:"wg,omitempty"`
|
WGConf string `json:"wg,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,6 +94,7 @@ func Parse(s string) (*Config, error) {
|
|||||||
Mode: w.Mode,
|
Mode: w.Mode,
|
||||||
ObfProfile: w.Obf,
|
ObfProfile: w.Obf,
|
||||||
ObfKey: w.Key,
|
ObfKey: w.Key,
|
||||||
|
ObfTimingMs: w.TimingMs,
|
||||||
N: w.N,
|
N: w.N,
|
||||||
StreamsPerCred: w.StreamsPerCred,
|
StreamsPerCred: w.StreamsPerCred,
|
||||||
ClientID: w.ClientID,
|
ClientID: w.ClientID,
|
||||||
@@ -99,6 +104,7 @@ func Parse(s string) (*Config, error) {
|
|||||||
ManualCaptcha: w.ManualCaptcha,
|
ManualCaptcha: w.ManualCaptcha,
|
||||||
KCP: w.KCP,
|
KCP: w.KCP,
|
||||||
Comment: w.Name,
|
Comment: w.Name,
|
||||||
|
VKLink: w.VK,
|
||||||
WGConf: w.WGConf,
|
WGConf: w.WGConf,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
@@ -120,11 +126,13 @@ func (c *Config) String() string {
|
|||||||
ManualCaptcha: c.ManualCaptcha,
|
ManualCaptcha: c.ManualCaptcha,
|
||||||
KCP: c.KCP,
|
KCP: c.KCP,
|
||||||
Name: c.Comment,
|
Name: c.Comment,
|
||||||
|
VK: c.VKLink,
|
||||||
WGConf: c.WGConf,
|
WGConf: c.WGConf,
|
||||||
}
|
}
|
||||||
if c.ObfProfile != "" && c.ObfProfile != "none" {
|
if c.ObfProfile != "" && c.ObfProfile != "none" {
|
||||||
w.Obf = c.ObfProfile
|
w.Obf = c.ObfProfile
|
||||||
w.Key = c.ObfKey
|
w.Key = c.ObfKey
|
||||||
|
w.TimingMs = c.ObfTimingMs
|
||||||
}
|
}
|
||||||
|
|
||||||
raw, err := json.Marshal(w)
|
raw, err := json.Marshal(w)
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ func TestRoundTrip(t *testing.T) {
|
|||||||
Mode: "tcp",
|
Mode: "tcp",
|
||||||
ObfProfile: "rtpopus",
|
ObfProfile: "rtpopus",
|
||||||
ObfKey: "d823fa",
|
ObfKey: "d823fa",
|
||||||
|
ObfTimingMs: 20,
|
||||||
N: 16,
|
N: 16,
|
||||||
StreamsPerCred: 8,
|
StreamsPerCred: 8,
|
||||||
ClientID: "abc123",
|
ClientID: "abc123",
|
||||||
@@ -29,6 +30,7 @@ func TestRoundTrip(t *testing.T) {
|
|||||||
DNSServers: "1.1.1.1,8.8.8.8",
|
DNSServers: "1.1.1.1,8.8.8.8",
|
||||||
ManualCaptcha: true,
|
ManualCaptcha: true,
|
||||||
Comment: "MyServer",
|
Comment: "MyServer",
|
||||||
|
VKLink: "https://vk.ru/call/join/abc",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user