* 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

+26 -17
View File
@@ -2,44 +2,53 @@
package mobile
/*
#include <stdint.h>
void disable_fdsan() {
#ifdef __ANDROID__
extern void android_fdsan_set_error_level(uint32_t) __attribute__((weak));
if (android_fdsan_set_error_level) {
android_fdsan_set_error_level(0);
}
#endif
}
*/
import "C"
import (
"fmt"
"os"
"sync"
"syscall"
"github.com/xjasonlyu/tun2socks/v2/engine"
)
var (
tunReady sync.WaitGroup
tunOrigFd int = -1
)
func StartTun2Socks(fd, mtu, socksPort int) error {
// dup the fd: tun2socks will close the dup on Stop(),
// we keep the original open to prevent the kernel from
// recycling the fd number while gvisor goroutines drain
dupFd, err := syscall.Dup(fd)
if err != nil {
return fmt.Errorf("dup tun fd: %w", err)
}
tunOrigFd = fd
proxy := fmt.Sprintf("socks5://127.0.0.1:%d", socksPort)
logMsg("tun2socks: starting fd=%d mtu=%d proxy=%s", fd, mtu, proxy)
logMsg("tun2socks: starting fd=%d (dup=%d) mtu=%d proxy=%s", fd, dupFd, mtu, proxy)
os.Setenv("TUN2SOCKS_LOG_LEVEL", "info")
key := &engine.Key{
Proxy: proxy,
Device: fmt.Sprintf("fd://%d", fd),
Device: fmt.Sprintf("fd://%d", dupFd),
MTU: mtu,
}
tunReady.Add(1)
engine.Insert(key)
engine.Start()
tunReady.Done()
logMsg("tun2socks: running")
return nil
}
func StopTun2Socks() {
C.disable_fdsan()
tunReady.Wait()
engine.Stop()
// now safe to close the original - gvisor goroutines are done
if tunOrigFd >= 0 {
syscall.Close(tunOrigFd)
tunOrigFd = -1
}
logMsg("tun2socks: stopped")
}