* save url when connected and allow toggling connection on app start (#2)

* mask ip in logs, reduce keep-alive logs frequency

* update comment about debug link, migrate prefs to ktx

* auto-connect for telemost

* fix ice ipv6 resolving

* auto-connect for vk

* refactor hooks names

* regenerate android resources

* remove stale telemost dc

* kick disconnected user from vk, refactor relay on mobile client, prevent double hook injection

* refactor constants

* set low importance for notification to avoid signals

* stop vpn/relay at app destroy, reset state at vpn disconnect

* prevent vk session close at video tunnel

* kick disconnected user from vk, refactor relay on mobile client, prevent double hook injection

* multiple tabs/calls, write android logs in file

* update ux, fix fd lifecycle in tun2socks

* increment release version

---------

Co-authored-by: HukuToc2288 <hukutoc2288@yandex.ru>
Co-authored-by: kulikov <user@Mac.lan>
This commit is contained in:
authored and kulikov committed 2026-03-26 09:54:48 +01:00
1 parent e8da07179a
commit 84da73c324
52 files changed
+1510 -479

No files matched your search

+55 -1
View File
@@ -2,7 +2,9 @@ package pion
import (
"encoding/json"
"net"
"net/http"
"strings"
"sync"
"github.com/gorilla/websocket"
@@ -37,6 +39,47 @@ var WsUpgrader = websocket.Upgrader{
CheckOrigin: func(r *http.Request) bool { return true },
}
// Wraps bare IPv6 addresses in brackets for TURN/STUN URLs.
// Tries host:port split first (more common), then full address.
func fixICEURL(url string) string {
idx := strings.Index(url, ":")
if idx < 0 {
return url
}
scheme := url[:idx]
if scheme != "turn" && scheme != "stun" && scheme != "turns" && scheme != "stuns" {
return url
}
rest := url[idx+1:]
if strings.HasPrefix(rest, "[") {
return url
}
if strings.Count(rest, ":") <= 1 {
return url
}
params := ""
if qm := strings.Index(rest, "?"); qm >= 0 {
params = rest[qm:]
rest = rest[:qm]
}
// Try splitting last segment as port first (host:port is more common)
lastColon := strings.LastIndex(rest, ":")
if lastColon > 0 {
host := rest[:lastColon]
port := rest[lastColon+1:]
if net.ParseIP(host) != nil {
return scheme + ":[" + host + "]:" + port + params
}
}
// Fallback: whole thing is an IPv6 address with no port
if net.ParseIP(rest) != nil {
return scheme + ":[" + rest + "]" + params
}
return url
}
var iceLogFn func(string, ...any)
func ParseICEServers(data json.RawMessage) ([]webrtc.ICEServer, error) {
var servers []ICEServerConfig
if err := json.Unmarshal(data, &servers); err != nil {
@@ -44,8 +87,19 @@ func ParseICEServers(data json.RawMessage) ([]webrtc.ICEServer, error) {
}
iceServers := make([]webrtc.ICEServer, len(servers))
for i, s := range servers {
urls := make([]string, len(s.URLs))
for j, u := range s.URLs {
fixed := fixICEURL(u)
if iceLogFn != nil && fixed != u {
iceLogFn("ice: fix URL %q -> %q", u, fixed)
}
urls[j] = fixed
}
if iceLogFn != nil {
iceLogFn("ice: server %d: urls=%v", i, urls)
}
iceServers[i] = webrtc.ICEServer{
URLs: s.URLs, Username: s.Username, Credential: s.Credential,
URLs: urls, Username: s.Username, Credential: s.Credential,
}
}
return iceServers, nil