refactor(layout): переименовать пакеты (split wire/transport/proxy)

internal/wrap → internal/wire/srtpmimicry; правки doc ("обфускация, не security").
internal/bond/{frame,client,server} → internal/wire/bondframe,
internal/proxy/bondclient, internal/proxy/bondserver.
internal/netadapt → internal/netconn.
internal/turnpipe → internal/transport/turndial; internal/dtlsdial →
internal/transport/dtlsdial.
tcputil → internal/transport/kcptun; selectedKCPProfile и selectedFEC теперь
кешируются через sync.Once (env читается один раз вместо per-connection).
internal/proxy/udp → internal/proxy/udprelay; internal/proxy/vless →
internal/proxy/tcpfwd. Флаг CLI -vless сохранён.
internal/ish → internal/client/ish; doc пакета расширен (iSH = Linux user-mode
эмулятор на iOS, только linux/386).

Чисто механическое переименование + обновление import-путей/идентификаторов.
Wire-формат, флаги CLI и поведение не изменены. go build + go test зелёные.
This commit is contained in:
samosvalishe committed 2026-05-19 20:42:46 +03:00
1 parent 7fd2d9594d
commit 1fb869b3e1
27 files changed
+178 -147

No files matched your search

+1 -1
View File
@@ -26,7 +26,7 @@ import (
"time"
"github.com/cacggghp/vk-turn-proxy/internal/client/browserprofile"
"github.com/cacggghp/vk-turn-proxy/internal/ish"
"github.com/cacggghp/vk-turn-proxy/internal/client/ish"
)
// Debug toggles verbose request/response logging for the proxied browser
+135
View File
@@ -0,0 +1,135 @@
//go:build linux && 386
package ish
import (
"io"
"net"
"os"
"syscall"
"time"
"unsafe"
)
type listener struct {
net.Listener
f *os.File
fd int
}
// WrapListener overrides the standard net.Listener with a legacy syscall listener
// designed specifically for the iSH simulator on iOS, which lacks modern `accept4`.
func WrapListener(ln net.Listener) (net.Listener, error) {
tl, ok := ln.(*net.TCPListener)
if !ok {
return ln, nil
}
f, err := tl.File()
if err != nil {
return nil, err
}
// Keep a reference to *os.File so the garbage collector doesn't close the FD.
return &listener{Listener: ln, f: f, fd: int(f.Fd())}, nil
}
func (l *listener) Accept() (net.Conn, error) {
// Set the listener socket to blocking mode. Go makes it non-blocking by default.
// This avoids using time.Sleep in a spin-loop, which triggers futex_time64 SIGSYS in modern Go on iSH.
if err := syscall.SetNonblock(l.fd, false); err != nil {
return nil, err
}
for {
addr := make([]byte, 128)
addrlen := uintptr(128)
// i386 network syscalls are multiplexed via socketcall (102).
// SYS_ACCEPT is subcall 5.
args := [3]uintptr{uintptr(l.fd), uintptr(unsafe.Pointer(&addr[0])), uintptr(unsafe.Pointer(&addrlen))}
// Use Syscall6 to ensure we have enough arguments registers for the platform.
r1, _, errno := syscall.Syscall6(102, 5, uintptr(unsafe.Pointer(&args)), 0, 0, 0, 0)
if errno != 0 {
if errno == syscall.EINTR {
continue
}
return nil, errno
}
nfd := int(r1)
_ = syscall.SetsockoptInt(nfd, syscall.IPPROTO_TCP, syscall.TCP_NODELAY, 1)
_ = syscall.SetsockoptInt(nfd, syscall.SOL_SOCKET, syscall.SO_RCVBUF, 256*1024)
_ = syscall.SetsockoptInt(nfd, syscall.SOL_SOCKET, syscall.SO_SNDBUF, 256*1024)
// We avoid Go's net.FileConn because it tries to register the fd with Go's epoll poller,
// which in iSH emulator consistency fails with EEXIST (file exists).
// Instead, we return a custom blocking net.Conn wrapper.
conn := &ishConn{fd: nfd}
return conn, nil
}
}
func (l *listener) Close() error {
// Close both the duplicated FD and the original listener.
err1 := l.f.Close()
err2 := l.Listener.Close()
if err1 != nil {
return err1
}
return err2
}
// ishConn bypasses Go's network poller to prevent EEXIST bugs in iSH
type ishConn struct {
fd int
}
func (c *ishConn) Read(b []byte) (n int, err error) {
for {
n, err = syscall.Read(c.fd, b)
if err == syscall.EINTR {
continue
}
if err != nil {
return n, err
}
if n == 0 {
return 0, os.ErrClosed
}
return n, nil
}
}
func (c *ishConn) Write(b []byte) (n int, err error) {
for n < len(b) {
written, writeErr := syscall.Write(c.fd, b[n:])
if writeErr == syscall.EINTR {
continue
}
if writeErr != nil {
return n, writeErr
}
if written == 0 {
return n, io.ErrShortWrite
}
n += written
}
return n, nil
}
func (c *ishConn) Close() error {
return syscall.Close(c.fd)
}
func (c *ishConn) LocalAddr() net.Addr {
return &net.TCPAddr{IP: net.ParseIP("127.0.0.1"), Port: 9000}
}
func (c *ishConn) RemoteAddr() net.Addr {
return &net.TCPAddr{IP: net.ParseIP("127.0.0.1"), Port: 0}
}
func (c *ishConn) SetDeadline(t time.Time) error { return nil }
func (c *ishConn) SetReadDeadline(t time.Time) error { return nil }
func (c *ishConn) SetWriteDeadline(t time.Time) error { return nil }
+15
View File
@@ -0,0 +1,15 @@
//go:build !(linux && 386)
// Package ish provides a TCP listener shim for iSH (https://ish.app), a
// Linux user-mode emulator that runs on iOS. iSH targets linux/386 and lacks
// modern accept4 / Go's epoll-based poller, so a sandbox-aware accept loop
// is needed there. On every other GOOS/GOARCH WrapListener is a no-op
// pass-through.
package ish
import "net"
// WrapListener returns ln unchanged on non-iSH platforms.
func WrapListener(ln net.Listener) (net.Listener, error) {
return ln, nil
}