feat: прямой туннель без релея
This commit is contained in:
1 parent
fa9549e6e0
commit
2812ded2ed
18 files changed
+586
-26
No files matched your search
@@ -1,6 +1,7 @@
|
||||
package mobile
|
||||
|
||||
import (
|
||||
"sync/atomic"
|
||||
"syscall"
|
||||
|
||||
"github.com/samosvalishe/free-turn-proxy/internal/netctl"
|
||||
@@ -12,13 +13,23 @@ type Protector interface {
|
||||
Protect(fd int) bool
|
||||
}
|
||||
|
||||
var protector atomic.Pointer[Protector]
|
||||
|
||||
// SetProtect устанавливает обработчик защиты сокетов хоста (nil - no-op).
|
||||
func SetProtect(p Protector) {
|
||||
if p == nil {
|
||||
protector.Store(nil)
|
||||
netctl.SetControl(nil)
|
||||
return
|
||||
}
|
||||
protector.Store(&p)
|
||||
netctl.SetControl(func(_, _ string, c syscall.RawConn) error {
|
||||
return c.Control(func(fd uintptr) { p.Protect(int(fd)) })
|
||||
})
|
||||
}
|
||||
|
||||
func protectFD(fd int) {
|
||||
if p := protector.Load(); p != nil {
|
||||
(*p).Protect(fd)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user