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:
1 parent
7fd2d9594d
commit
1fb869b3e1
27 files changed
+178
-147
No files matched your search
+21
-21
@@ -15,17 +15,17 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
bondclient "github.com/cacggghp/vk-turn-proxy/internal/bond/client"
|
|
||||||
"github.com/cacggghp/vk-turn-proxy/internal/client/captcha"
|
"github.com/cacggghp/vk-turn-proxy/internal/client/captcha"
|
||||||
manualcaptcha "github.com/cacggghp/vk-turn-proxy/internal/client/captcha/manual"
|
manualcaptcha "github.com/cacggghp/vk-turn-proxy/internal/client/captcha/manual"
|
||||||
"github.com/cacggghp/vk-turn-proxy/internal/client/dnsdial"
|
"github.com/cacggghp/vk-turn-proxy/internal/client/dnsdial"
|
||||||
"github.com/cacggghp/vk-turn-proxy/internal/client/vkauth"
|
"github.com/cacggghp/vk-turn-proxy/internal/client/vkauth"
|
||||||
"github.com/cacggghp/vk-turn-proxy/internal/config"
|
"github.com/cacggghp/vk-turn-proxy/internal/config"
|
||||||
"github.com/cacggghp/vk-turn-proxy/internal/dtlsdial"
|
|
||||||
"github.com/cacggghp/vk-turn-proxy/internal/logx"
|
"github.com/cacggghp/vk-turn-proxy/internal/logx"
|
||||||
udpproxy "github.com/cacggghp/vk-turn-proxy/internal/proxy/udp"
|
bondclient "github.com/cacggghp/vk-turn-proxy/internal/proxy/bondclient"
|
||||||
"github.com/cacggghp/vk-turn-proxy/internal/proxy/vless"
|
"github.com/cacggghp/vk-turn-proxy/internal/proxy/tcpfwd"
|
||||||
"github.com/cacggghp/vk-turn-proxy/internal/wrap"
|
"github.com/cacggghp/vk-turn-proxy/internal/proxy/udprelay"
|
||||||
|
"github.com/cacggghp/vk-turn-proxy/internal/transport/dtlsdial"
|
||||||
|
"github.com/cacggghp/vk-turn-proxy/internal/wire/srtpmimicry"
|
||||||
)
|
)
|
||||||
|
|
||||||
type getCredsFunc func(ctx context.Context, link string, streamID int) (string, string, string, error)
|
type getCredsFunc func(ctx context.Context, link string, streamID int) (string, string, string, error)
|
||||||
@@ -97,7 +97,7 @@ func main() {
|
|||||||
appDialer = dnsdial.AppDialer(cfg.DNSMode)
|
appDialer = dnsdial.AppDialer(cfg.DNSMode)
|
||||||
dnsdial.InstallGlobalResolver(cfg.DNSMode)
|
dnsdial.InstallGlobalResolver(cfg.DNSMode)
|
||||||
if cfg.GenWrapKey {
|
if cfg.GenWrapKey {
|
||||||
key, gerr := wrap.GenKeyHex()
|
key, gerr := srtpmimicry.GenKeyHex()
|
||||||
if gerr != nil {
|
if gerr != nil {
|
||||||
log.Panicf("%v", gerr)
|
log.Panicf("%v", gerr)
|
||||||
}
|
}
|
||||||
@@ -137,20 +137,20 @@ func main() {
|
|||||||
|
|
||||||
if cfg.VLESSMode {
|
if cfg.VLESSMode {
|
||||||
bondH := &bondclient.Handler{Deps: bondclient.Deps{Log: logger}}
|
bondH := &bondclient.Handler{Deps: bondclient.Deps{Log: logger}}
|
||||||
vlessDeps := &vless.Deps{
|
vlessDeps := &tcpfwd.Deps{
|
||||||
DTLSDialer: vlessDtlsDialer,
|
DTLSDialer: vlessDtlsDialer,
|
||||||
Log: logger,
|
Log: logger,
|
||||||
BondHandler: bondH.Handle,
|
BondHandler: bondH.Handle,
|
||||||
}
|
}
|
||||||
vlessParams := &vless.Params{
|
vlessParams := &tcpfwd.Params{
|
||||||
Host: params.host,
|
Host: params.host,
|
||||||
Port: params.port,
|
Port: params.port,
|
||||||
Link: params.link,
|
Link: params.link,
|
||||||
UDP: params.udp,
|
UDP: params.udp,
|
||||||
WrapKey: params.wrapKey,
|
WrapKey: params.wrapKey,
|
||||||
GetCreds: vless.GetCredsFunc(params.getCreds),
|
GetCreds: tcpfwd.GetCredsFunc(params.getCreds),
|
||||||
}
|
}
|
||||||
vless.Run(ctx, vlessDeps, vlessParams, peer, cfg.Listen, cfg.N, cfg.VLESSBond)
|
tcpfwd.Run(ctx, vlessDeps, vlessParams, peer, cfg.Listen, cfg.N, cfg.VLESSBond)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,7 +170,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Shared Worker Pool Queue for Aggregation
|
// Shared Worker Pool Queue for Aggregation
|
||||||
inboundChan := make(chan *udpproxy.Packet, 2000)
|
inboundChan := make(chan *udprelay.Packet, 2000)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
// Pointer-cache for the last seen local peer addr. Avoids the
|
// Pointer-cache for the last seen local peer addr. Avoids the
|
||||||
@@ -182,8 +182,8 @@ func main() {
|
|||||||
var lastAddr net.Addr
|
var lastAddr net.Addr
|
||||||
var lastAddrStr string
|
var lastAddrStr string
|
||||||
for {
|
for {
|
||||||
pktIface := udpproxy.Pool.Get()
|
pktIface := udprelay.Pool.Get()
|
||||||
pkt, ok := pktIface.(*udpproxy.Packet)
|
pkt, ok := pktIface.(*udprelay.Packet)
|
||||||
if !ok {
|
if !ok {
|
||||||
log.Printf("packetPool returned unexpected type: %T", pktIface)
|
log.Printf("packetPool returned unexpected type: %T", pktIface)
|
||||||
continue
|
continue
|
||||||
@@ -208,7 +208,7 @@ func main() {
|
|||||||
case inboundChan <- pkt:
|
case inboundChan <- pkt:
|
||||||
default:
|
default:
|
||||||
// Drop the packet only if the global queue is completely full
|
// Drop the packet only if the global queue is completely full
|
||||||
udpproxy.Pool.Put(pkt)
|
udprelay.Pool.Put(pkt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
@@ -216,7 +216,7 @@ func main() {
|
|||||||
wg1 := sync.WaitGroup{}
|
wg1 := sync.WaitGroup{}
|
||||||
t := time.Tick(200 * time.Millisecond)
|
t := time.Tick(200 * time.Millisecond)
|
||||||
|
|
||||||
udpDeps := &udpproxy.Deps{
|
udpDeps := &udprelay.Deps{
|
||||||
DTLSDialer: udpDtlsDialer,
|
DTLSDialer: udpDtlsDialer,
|
||||||
Auth: vkAuth,
|
Auth: vkAuth,
|
||||||
Log: logger,
|
Log: logger,
|
||||||
@@ -224,22 +224,22 @@ func main() {
|
|||||||
ConnectedStreams: &connectedStreams,
|
ConnectedStreams: &connectedStreams,
|
||||||
AppCancel: cancel,
|
AppCancel: cancel,
|
||||||
}
|
}
|
||||||
udpParams := &udpproxy.Params{
|
udpParams := &udprelay.Params{
|
||||||
Host: params.host,
|
Host: params.host,
|
||||||
Port: params.port,
|
Port: params.port,
|
||||||
Link: params.link,
|
Link: params.link,
|
||||||
UDP: params.udp,
|
UDP: params.udp,
|
||||||
WrapKey: params.wrapKey,
|
WrapKey: params.wrapKey,
|
||||||
GetCreds: udpproxy.GetCredsFunc(params.getCreds),
|
GetCreds: udprelay.GetCredsFunc(params.getCreds),
|
||||||
}
|
}
|
||||||
|
|
||||||
okchan := make(chan struct{})
|
okchan := make(chan struct{})
|
||||||
connchan := make(chan net.PacketConn)
|
connchan := make(chan net.PacketConn)
|
||||||
wg1.Go(func() {
|
wg1.Go(func() {
|
||||||
udpproxy.DTLSLoop(ctx, udpDeps, peer, listenConn, inboundChan, connchan, okchan, 1)
|
udprelay.DTLSLoop(ctx, udpDeps, peer, listenConn, inboundChan, connchan, okchan, 1)
|
||||||
})
|
})
|
||||||
wg1.Go(func() {
|
wg1.Go(func() {
|
||||||
udpproxy.TURNLoop(ctx, udpDeps, udpParams, peer, connchan, t, 1)
|
udprelay.TURNLoop(ctx, udpDeps, udpParams, peer, connchan, t, 1)
|
||||||
})
|
})
|
||||||
|
|
||||||
select {
|
select {
|
||||||
@@ -251,10 +251,10 @@ func main() {
|
|||||||
cchan := make(chan net.PacketConn)
|
cchan := make(chan net.PacketConn)
|
||||||
streamID := i
|
streamID := i
|
||||||
wg1.Go(func() {
|
wg1.Go(func() {
|
||||||
udpproxy.DTLSLoop(ctx, udpDeps, peer, listenConn, inboundChan, cchan, nil, streamID)
|
udprelay.DTLSLoop(ctx, udpDeps, peer, listenConn, inboundChan, cchan, nil, streamID)
|
||||||
})
|
})
|
||||||
wg1.Go(func() {
|
wg1.Go(func() {
|
||||||
udpproxy.TURNLoop(ctx, udpDeps, udpParams, peer, cchan, t, streamID)
|
udprelay.TURNLoop(ctx, udpDeps, udpParams, peer, cchan, t, streamID)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,13 +12,13 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/cacggghp/vk-turn-proxy/internal/bond"
|
|
||||||
bondserver "github.com/cacggghp/vk-turn-proxy/internal/bond/server"
|
|
||||||
"github.com/cacggghp/vk-turn-proxy/internal/config"
|
"github.com/cacggghp/vk-turn-proxy/internal/config"
|
||||||
"github.com/cacggghp/vk-turn-proxy/internal/logx"
|
"github.com/cacggghp/vk-turn-proxy/internal/logx"
|
||||||
|
bondserver "github.com/cacggghp/vk-turn-proxy/internal/proxy/bondserver"
|
||||||
"github.com/cacggghp/vk-turn-proxy/internal/stats"
|
"github.com/cacggghp/vk-turn-proxy/internal/stats"
|
||||||
"github.com/cacggghp/vk-turn-proxy/internal/wrap"
|
"github.com/cacggghp/vk-turn-proxy/internal/transport/kcptun"
|
||||||
"github.com/cacggghp/vk-turn-proxy/tcputil"
|
"github.com/cacggghp/vk-turn-proxy/internal/wire/bondframe"
|
||||||
|
"github.com/cacggghp/vk-turn-proxy/internal/wire/srtpmimicry"
|
||||||
"github.com/pion/dtls/v3"
|
"github.com/pion/dtls/v3"
|
||||||
"github.com/pion/dtls/v3/pkg/crypto/selfsign"
|
"github.com/pion/dtls/v3/pkg/crypto/selfsign"
|
||||||
"github.com/xtaci/smux"
|
"github.com/xtaci/smux"
|
||||||
@@ -38,7 +38,7 @@ func main() {
|
|||||||
globalBondRegistry = bondserver.NewRegistry(bondserver.Deps{Log: logger})
|
globalBondRegistry = bondserver.NewRegistry(bondserver.Deps{Log: logger})
|
||||||
|
|
||||||
if cfg.GenWrapKey {
|
if cfg.GenWrapKey {
|
||||||
key, gerr := wrap.GenKeyHex()
|
key, gerr := srtpmimicry.GenKeyHex()
|
||||||
if gerr != nil {
|
if gerr != nil {
|
||||||
log.Panicf("gen-wrap-key: %v", gerr)
|
log.Panicf("gen-wrap-key: %v", gerr)
|
||||||
}
|
}
|
||||||
@@ -83,7 +83,7 @@ func main() {
|
|||||||
var listener net.Listener
|
var listener net.Listener
|
||||||
if cfg.WrapMode {
|
if cfg.WrapMode {
|
||||||
log.Printf("WRAP mode enabled: listener only accepts clients with matching -wrap-key")
|
log.Printf("WRAP mode enabled: listener only accepts clients with matching -wrap-key")
|
||||||
wrapListener, werr := wrap.Listen(addr, wrapKey)
|
wrapListener, werr := srtpmimicry.Listen(addr, wrapKey)
|
||||||
if werr != nil {
|
if werr != nil {
|
||||||
panic(werr)
|
panic(werr)
|
||||||
}
|
}
|
||||||
@@ -277,7 +277,7 @@ func handleVLESSConnection(ctx context.Context, dtlsConn net.Conn, connectAddr s
|
|||||||
"from-client",
|
"from-client",
|
||||||
)
|
)
|
||||||
|
|
||||||
kcpSess, err := tcputil.NewKCPOverDTLS(&stats.CountingConn{Conn: dtlsConn, Stats: st}, true)
|
kcpSess, err := kcptun.NewKCPOverDTLS(&stats.CountingConn{Conn: dtlsConn, Stats: st}, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("KCP session error: %s", err)
|
log.Printf("KCP session error: %s", err)
|
||||||
return
|
return
|
||||||
@@ -290,7 +290,7 @@ func handleVLESSConnection(ctx context.Context, dtlsConn net.Conn, connectAddr s
|
|||||||
logger.Debugf("KCP session established (server)")
|
logger.Debugf("KCP session established (server)")
|
||||||
|
|
||||||
// 2. Create smux server session over KCP
|
// 2. Create smux server session over KCP
|
||||||
smuxSess, err := smux.Server(kcpSess, tcputil.DefaultSmuxConfig())
|
smuxSess, err := smux.Server(kcpSess, kcptun.DefaultSmuxConfig())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("smux server error: %s", err)
|
log.Printf("smux server error: %s", err)
|
||||||
return
|
return
|
||||||
@@ -325,7 +325,7 @@ func handleVLESSConnection(ctx context.Context, dtlsConn net.Conn, connectAddr s
|
|||||||
_ = s.Close()
|
_ = s.Close()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if string(prefix[:]) == bond.Magic {
|
if string(prefix[:]) == bondframe.Magic {
|
||||||
logger.Debugf("auto-detected bond smux stream")
|
logger.Debugf("auto-detected bond smux stream")
|
||||||
globalBondRegistry.HandleStreamAfterMagic(ctx, s, connectAddr, prefix)
|
globalBondRegistry.HandleStreamAfterMagic(ctx, s, connectAddr, prefix)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/cacggghp/vk-turn-proxy/internal/client/browserprofile"
|
"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
|
// Debug toggles verbose request/response logging for the proxied browser
|
||||||
|
|||||||
File renamed without changes.
@@ -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
|
||||||
|
}
|
||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/cacggghp/vk-turn-proxy/internal/wrap"
|
"github.com/cacggghp/vk-turn-proxy/internal/wire/srtpmimicry"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Mirrors of constants defined in internal/client/* packages, duplicated here
|
// Mirrors of constants defined in internal/client/* packages, duplicated here
|
||||||
@@ -125,7 +125,7 @@ func ParseClient(args []string, errOut io.Writer) (*Client, error) {
|
|||||||
if *vklink == "" {
|
if *vklink == "" {
|
||||||
return nil, errors.New("need vk-link")
|
return nil, errors.New("need vk-link")
|
||||||
}
|
}
|
||||||
key, err := wrap.DecodeKey(c.WrapMode, *wrapKeyHex)
|
key, err := srtpmimicry.DecodeKey(c.WrapMode, *wrapKeyHex)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -182,7 +182,7 @@ func ParseServer(args []string, errOut io.Writer) (*Server, error) {
|
|||||||
if s.Connect == "" {
|
if s.Connect == "" {
|
||||||
return nil, fmt.Errorf("server address is required")
|
return nil, fmt.Errorf("server address is required")
|
||||||
}
|
}
|
||||||
key, err := wrap.DecodeKey(s.WrapMode, *wrapKeyHex)
|
key, err := srtpmimicry.DecodeKey(s.WrapMode, *wrapKeyHex)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
//go:build !(linux && 386)
|
|
||||||
|
|
||||||
// Package ish provides a TCP listener shim for the iSH iOS simulator on
|
|
||||||
// linux/386, which lacks modern accept4 and Go's epoll-based poller. 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
|
|
||||||
}
|
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
// Package netadapt holds small net.Conn / transport.Net adapters used by both
|
// Package netconn holds small net.Conn / transport.Net adapters used by both
|
||||||
// client and server: a passthrough transport.Net (for pion turn),
|
// client and server: a passthrough transport.Net (for pion turn),
|
||||||
// ConnectedUDPConn (Write-only WriteTo on a dialed UDPConn), and
|
// ConnectedUDPConn (Write-only WriteTo on a dialed UDPConn), and
|
||||||
// SplitFirstWriteConn (DPI evasion via first-segment split).
|
// SplitFirstWriteConn (DPI evasion via first-segment split).
|
||||||
package netadapt
|
package netconn
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package netadapt
|
package netconn
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
// Package bondclient implements the client side of the bonded VLESS lane:
|
// Package bondclient implements the client side of the bonded VLESS lane:
|
||||||
// a single accepted TCP connection striped (round-robin) across all currently
|
// a single accepted TCP connection striped (round-robin) across all currently
|
||||||
// live smux sessions in a vless.SessionPool. Frame wire-format lives in
|
// live smux sessions in a tcpfwd.SessionPool. Frame wire-format lives in
|
||||||
// internal/bond; this package wires the local TCP <-> lanes copy loops.
|
// internal/bond; this package wires the local TCP <-> lanes copy loops.
|
||||||
package bondclient
|
package bondclient
|
||||||
|
|
||||||
@@ -16,10 +16,10 @@ import (
|
|||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/cacggghp/vk-turn-proxy/internal/bond"
|
|
||||||
"github.com/cacggghp/vk-turn-proxy/internal/logx"
|
"github.com/cacggghp/vk-turn-proxy/internal/logx"
|
||||||
"github.com/cacggghp/vk-turn-proxy/internal/proxy/vless"
|
"github.com/cacggghp/vk-turn-proxy/internal/proxy/tcpfwd"
|
||||||
"github.com/cacggghp/vk-turn-proxy/internal/stats"
|
"github.com/cacggghp/vk-turn-proxy/internal/stats"
|
||||||
|
"github.com/cacggghp/vk-turn-proxy/internal/wire/bondframe"
|
||||||
"github.com/xtaci/smux"
|
"github.com/xtaci/smux"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -35,22 +35,22 @@ func (d *Deps) log() logx.Logger {
|
|||||||
return d.Log
|
return d.Log
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handler binds Deps and exposes Handle, matching the vless.BondHandler signature.
|
// Handler binds Deps and exposes Handle, matching the tcpfwd.BondHandler signature.
|
||||||
type Handler struct {
|
type Handler struct {
|
||||||
Deps Deps
|
Deps Deps
|
||||||
}
|
}
|
||||||
|
|
||||||
// lane is one striped smux stream within a bonded TCP connection.
|
// lane is one striped smux stream within a bonded TCP connection.
|
||||||
type lane struct {
|
type lane struct {
|
||||||
ps *vless.PooledSession
|
ps *tcpfwd.PooledSession
|
||||||
stream *smux.Stream
|
stream *smux.Stream
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
dead atomic.Bool
|
dead atomic.Bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle stripes the local TCP connection across all live candidate sessions.
|
// Handle stripes the local TCP connection across all live candidate sessions.
|
||||||
// Signature matches vless.BondHandler.
|
// Signature matches tcpfwd.BondHandler.
|
||||||
func (h *Handler) Handle(ctx context.Context, tcpConn net.Conn, connID uint64, candidates []*vless.PooledSession) {
|
func (h *Handler) Handle(ctx context.Context, tcpConn net.Conn, connID uint64, candidates []*tcpfwd.PooledSession) {
|
||||||
defer func() { _ = tcpConn.Close() }()
|
defer func() { _ = tcpConn.Close() }()
|
||||||
|
|
||||||
ctx, cancel := context.WithCancel(ctx)
|
ctx, cancel := context.WithCancel(ctx)
|
||||||
@@ -67,7 +67,7 @@ func (h *Handler) Handle(ctx context.Context, tcpConn net.Conn, connID uint64, c
|
|||||||
log.Printf("[bond %d] session %d open stream error: %s", connID, ps.ID, err)
|
log.Printf("[bond %d] session %d open stream error: %s", connID, ps.ID, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if err := bond.WriteHello(stream, connID, uint16(i), uint16(len(candidates))); err != nil {
|
if err := bondframe.WriteHello(stream, connID, uint16(i), uint16(len(candidates))); err != nil {
|
||||||
log.Printf("[bond %d] session %d hello error: %s", connID, ps.ID, err)
|
log.Printf("[bond %d] session %d hello error: %s", connID, ps.ID, err)
|
||||||
_ = stream.Close()
|
_ = stream.Close()
|
||||||
continue
|
continue
|
||||||
@@ -106,12 +106,12 @@ func (h *Handler) Handle(ctx context.Context, tcpConn net.Conn, connID uint64, c
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
recvCh := make(chan bond.Frame, 1024)
|
recvCh := make(chan bondframe.Frame, 1024)
|
||||||
var readWG sync.WaitGroup
|
var readWG sync.WaitGroup
|
||||||
for _, l := range lanes {
|
for _, l := range lanes {
|
||||||
readWG.Go(func() {
|
readWG.Go(func() {
|
||||||
for {
|
for {
|
||||||
f, err := bond.ReadFrame(l.stream)
|
f, err := bondframe.ReadFrame(l.stream)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.dead.Store(true)
|
l.dead.Store(true)
|
||||||
select {
|
select {
|
||||||
@@ -123,7 +123,7 @@ func (h *Handler) Handle(ctx context.Context, tcpConn net.Conn, connID uint64, c
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if f.Type == bond.FrameData {
|
if f.Type == bondframe.FrameData {
|
||||||
l.ps.FromSession.Add(uint64(len(f.Data)))
|
l.ps.FromSession.Add(uint64(len(f.Data)))
|
||||||
}
|
}
|
||||||
select {
|
select {
|
||||||
@@ -151,13 +151,13 @@ func (h *Handler) Handle(ctx context.Context, tcpConn net.Conn, connID uint64, c
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *Handler) copyTCPToBond(ctx context.Context, connID uint64, tcpConn net.Conn, lanes []*lane) {
|
func (h *Handler) copyTCPToBond(ctx context.Context, connID uint64, tcpConn net.Conn, lanes []*lane) {
|
||||||
buf := make([]byte, bond.MaxChunk)
|
buf := make([]byte, bondframe.MaxChunk)
|
||||||
var seq uint64
|
var seq uint64
|
||||||
var laneIdx uint64
|
var laneIdx uint64
|
||||||
for {
|
for {
|
||||||
n, err := tcpConn.Read(buf)
|
n, err := tcpConn.Read(buf)
|
||||||
if n > 0 {
|
if n > 0 {
|
||||||
l, writeErr := writeBondFrameToNextLane(ctx, lanes, bond.FrameData, seq, buf[:n], &laneIdx)
|
l, writeErr := writeBondFrameToNextLane(ctx, lanes, bondframe.FrameData, seq, buf[:n], &laneIdx)
|
||||||
if writeErr != nil {
|
if writeErr != nil {
|
||||||
log.Printf("[bond %d] write data error: %v", connID, writeErr)
|
log.Printf("[bond %d] write data error: %v", connID, writeErr)
|
||||||
return
|
return
|
||||||
@@ -174,7 +174,7 @@ func (h *Handler) copyTCPToBond(ctx context.Context, connID uint64, tcpConn net.
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
l.mu.Lock()
|
l.mu.Lock()
|
||||||
writeErr := bond.WriteFrame(l.stream, bond.FrameFIN, seq, nil)
|
writeErr := bondframe.WriteFrame(l.stream, bondframe.FrameFIN, seq, nil)
|
||||||
l.mu.Unlock()
|
l.mu.Unlock()
|
||||||
if writeErr != nil && ctx.Err() == nil {
|
if writeErr != nil && ctx.Err() == nil {
|
||||||
log.Printf("[bond %d] session %d write FIN error: %v", connID, l.ps.ID, writeErr)
|
log.Printf("[bond %d] session %d write FIN error: %v", connID, l.ps.ID, writeErr)
|
||||||
@@ -200,7 +200,7 @@ func writeBondFrameToNextLane(ctx context.Context, lanes []*lane, typ byte, seq
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
l.mu.Lock()
|
l.mu.Lock()
|
||||||
err := bond.WriteFrame(l.stream, typ, seq, data)
|
err := bondframe.WriteFrame(l.stream, typ, seq, data)
|
||||||
l.mu.Unlock()
|
l.mu.Unlock()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return l, nil
|
return l, nil
|
||||||
@@ -216,14 +216,14 @@ func writeBondFrameToNextLane(ctx context.Context, lanes []*lane, typ byte, seq
|
|||||||
return nil, fmt.Errorf("no live bond lanes")
|
return nil, fmt.Errorf("no live bond lanes")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Handler) copyBondToTCP(ctx context.Context, connID uint64, tcpConn net.Conn, recvCh <-chan bond.Frame) {
|
func (h *Handler) copyBondToTCP(ctx context.Context, connID uint64, tcpConn net.Conn, recvCh <-chan bondframe.Frame) {
|
||||||
pending := make(map[uint64][]byte)
|
pending := make(map[uint64][]byte)
|
||||||
var expect uint64
|
var expect uint64
|
||||||
var finSeq *uint64
|
var finSeq *uint64
|
||||||
|
|
||||||
for {
|
for {
|
||||||
if finSeq != nil && expect == *finSeq {
|
if finSeq != nil && expect == *finSeq {
|
||||||
bond.CloseWrite(tcpConn, h.Deps.log().Debugf)
|
bondframe.CloseWrite(tcpConn, h.Deps.log().Debugf)
|
||||||
h.Deps.log().Debugf("[bond %d] download finished chunks=%d", connID, expect)
|
h.Deps.log().Debugf("[bond %d] download finished chunks=%d", connID, expect)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -236,13 +236,13 @@ func (h *Handler) copyBondToTCP(ctx context.Context, connID uint64, tcpConn net.
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
switch f.Type {
|
switch f.Type {
|
||||||
case bond.FrameData:
|
case bondframe.FrameData:
|
||||||
if len(pending) >= 1024 {
|
if len(pending) >= 1024 {
|
||||||
log.Printf("[bond %d] pending map overflow (>1024), closing", connID)
|
log.Printf("[bond %d] pending map overflow (>1024), closing", connID)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
pending[f.Seq] = f.Data
|
pending[f.Seq] = f.Data
|
||||||
case bond.FrameFIN:
|
case bondframe.FrameFIN:
|
||||||
v := f.Seq
|
v := f.Seq
|
||||||
if finSeq == nil || v < *finSeq {
|
if finSeq == nil || v < *finSeq {
|
||||||
finSeq = &v
|
finSeq = &v
|
||||||
@@ -12,8 +12,8 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/cacggghp/vk-turn-proxy/internal/bond"
|
|
||||||
"github.com/cacggghp/vk-turn-proxy/internal/logx"
|
"github.com/cacggghp/vk-turn-proxy/internal/logx"
|
||||||
|
"github.com/cacggghp/vk-turn-proxy/internal/wire/bondframe"
|
||||||
"github.com/xtaci/smux"
|
"github.com/xtaci/smux"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -56,12 +56,12 @@ func NewRegistry(deps Deps) *Registry {
|
|||||||
// already been consumed (server-side multiplex pre-peek), reads the Hello,
|
// already been consumed (server-side multiplex pre-peek), reads the Hello,
|
||||||
// attaches as a lane, and blocks until the underlying bond connection is done.
|
// attaches as a lane, and blocks until the underlying bond connection is done.
|
||||||
func (r *Registry) HandleStreamAfterMagic(ctx context.Context, stream *smux.Stream, connectAddr string, magic [4]byte) {
|
func (r *Registry) HandleStreamAfterMagic(ctx context.Context, stream *smux.Stream, connectAddr string, magic [4]byte) {
|
||||||
r.handleStream(ctx, stream, connectAddr, func(rd io.Reader) (bond.Hello, error) {
|
r.handleStream(ctx, stream, connectAddr, func(rd io.Reader) (bondframe.Hello, error) {
|
||||||
return bond.ReadHelloAfterMagic(rd, magic)
|
return bondframe.ReadHelloAfterMagic(rd, magic)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Registry) handleStream(ctx context.Context, stream *smux.Stream, connectAddr string, readHello func(io.Reader) (bond.Hello, error)) {
|
func (r *Registry) handleStream(ctx context.Context, stream *smux.Stream, connectAddr string, readHello func(io.Reader) (bondframe.Hello, error)) {
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := stream.Close(); err != nil && err != smux.ErrGoAway {
|
if err := stream.Close(); err != nil && err != smux.ErrGoAway {
|
||||||
log.Printf("failed to close bond smux stream: %v", err)
|
log.Printf("failed to close bond smux stream: %v", err)
|
||||||
@@ -101,7 +101,7 @@ func (r *Registry) get(ctx context.Context, id uint64, connectAddr string) *serv
|
|||||||
cancel: cancel,
|
cancel: cancel,
|
||||||
done: make(chan struct{}),
|
done: make(chan struct{}),
|
||||||
ready: make(chan struct{}, 1),
|
ready: make(chan struct{}, 1),
|
||||||
recvCh: make(chan bond.Frame, 1024),
|
recvCh: make(chan bondframe.Frame, 1024),
|
||||||
}
|
}
|
||||||
r.conns[id] = c
|
r.conns[id] = c
|
||||||
go func() {
|
go func() {
|
||||||
@@ -134,7 +134,7 @@ type serverConn struct {
|
|||||||
want uint16
|
want uint16
|
||||||
ready chan struct{}
|
ready chan struct{}
|
||||||
|
|
||||||
recvCh chan bond.Frame
|
recvCh chan bondframe.Frame
|
||||||
once sync.Once
|
once sync.Once
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,7 +179,7 @@ func (c *serverConn) removeLane(l *serverLane) int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *serverConn) waitForInitialLanes() {
|
func (c *serverConn) waitForInitialLanes() {
|
||||||
timer := time.NewTimer(bond.LaneAttachTimeout)
|
timer := time.NewTimer(bondframe.LaneAttachTimeout)
|
||||||
defer timer.Stop()
|
defer timer.Stop()
|
||||||
for {
|
for {
|
||||||
c.lanesMu.RLock()
|
c.lanesMu.RLock()
|
||||||
@@ -202,7 +202,7 @@ func (c *serverConn) waitForInitialLanes() {
|
|||||||
|
|
||||||
func (c *serverConn) readLane(l *serverLane) {
|
func (c *serverConn) readLane(l *serverLane) {
|
||||||
for {
|
for {
|
||||||
f, err := bond.ReadFrame(l.stream)
|
f, err := bondframe.ReadFrame(l.stream)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
left := c.removeLane(l)
|
left := c.removeLane(l)
|
||||||
select {
|
select {
|
||||||
@@ -272,7 +272,7 @@ func (c *serverConn) copyBondToBackend(backendConn net.Conn) {
|
|||||||
|
|
||||||
for {
|
for {
|
||||||
if finSeq != nil && expect == *finSeq {
|
if finSeq != nil && expect == *finSeq {
|
||||||
bond.CloseWrite(backendConn, c.deps.log().Debugf)
|
bondframe.CloseWrite(backendConn, c.deps.log().Debugf)
|
||||||
c.deps.log().Debugf("[bond %d] upload to backend finished chunks=%d", c.id, expect)
|
c.deps.log().Debugf("[bond %d] upload to backend finished chunks=%d", c.id, expect)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -282,9 +282,9 @@ func (c *serverConn) copyBondToBackend(backendConn net.Conn) {
|
|||||||
return
|
return
|
||||||
case f := <-c.recvCh:
|
case f := <-c.recvCh:
|
||||||
switch f.Type {
|
switch f.Type {
|
||||||
case bond.FrameData:
|
case bondframe.FrameData:
|
||||||
pending[f.Seq] = f.Data
|
pending[f.Seq] = f.Data
|
||||||
case bond.FrameFIN:
|
case bondframe.FrameFIN:
|
||||||
v := f.Seq
|
v := f.Seq
|
||||||
if finSeq == nil || v < *finSeq {
|
if finSeq == nil || v < *finSeq {
|
||||||
finSeq = &v
|
finSeq = &v
|
||||||
@@ -313,7 +313,7 @@ func (c *serverConn) copyBondToBackend(backendConn net.Conn) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *serverConn) copyBackendToBond(backendConn net.Conn) {
|
func (c *serverConn) copyBackendToBond(backendConn net.Conn) {
|
||||||
buf := make([]byte, bond.MaxChunk)
|
buf := make([]byte, bondframe.MaxChunk)
|
||||||
var seq uint64
|
var seq uint64
|
||||||
var laneIdx uint64
|
var laneIdx uint64
|
||||||
for {
|
for {
|
||||||
@@ -321,7 +321,7 @@ func (c *serverConn) copyBackendToBond(backendConn net.Conn) {
|
|||||||
if n > 0 {
|
if n > 0 {
|
||||||
data := make([]byte, n)
|
data := make([]byte, n)
|
||||||
copy(data, buf[:n])
|
copy(data, buf[:n])
|
||||||
if writeErr := c.writeToNextLane(bond.FrameData, seq, data, &laneIdx); writeErr != nil {
|
if writeErr := c.writeToNextLane(bondframe.FrameData, seq, data, &laneIdx); writeErr != nil {
|
||||||
log.Printf("[bond %d] lane write data error: %v", c.id, writeErr)
|
log.Printf("[bond %d] lane write data error: %v", c.id, writeErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -331,7 +331,7 @@ func (c *serverConn) copyBackendToBond(backendConn net.Conn) {
|
|||||||
lanes := c.snapshotLanes()
|
lanes := c.snapshotLanes()
|
||||||
for _, lane := range lanes {
|
for _, lane := range lanes {
|
||||||
lane.mu.Lock()
|
lane.mu.Lock()
|
||||||
writeErr := bond.WriteFrame(lane.stream, bond.FrameFIN, seq, nil)
|
writeErr := bondframe.WriteFrame(lane.stream, bondframe.FrameFIN, seq, nil)
|
||||||
lane.mu.Unlock()
|
lane.mu.Unlock()
|
||||||
if writeErr != nil && c.ctx.Err() == nil {
|
if writeErr != nil && c.ctx.Err() == nil {
|
||||||
log.Printf("[bond %d] lane %d write FIN error: %v", c.id, lane.index, writeErr)
|
log.Printf("[bond %d] lane %d write FIN error: %v", c.id, lane.index, writeErr)
|
||||||
@@ -355,7 +355,7 @@ func (c *serverConn) writeToNextLane(typ byte, seq uint64, data []byte, laneIdx
|
|||||||
lane := lanes[*laneIdx%uint64(len(lanes))]
|
lane := lanes[*laneIdx%uint64(len(lanes))]
|
||||||
*laneIdx++
|
*laneIdx++
|
||||||
lane.mu.Lock()
|
lane.mu.Lock()
|
||||||
err := bond.WriteFrame(lane.stream, typ, seq, data)
|
err := bondframe.WriteFrame(lane.stream, typ, seq, data)
|
||||||
lane.mu.Unlock()
|
lane.mu.Unlock()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return nil
|
return nil
|
||||||
+15
-15
@@ -10,7 +10,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/cacggghp/vk-turn-proxy/internal/bond"
|
"github.com/cacggghp/vk-turn-proxy/internal/wire/bondframe"
|
||||||
)
|
)
|
||||||
|
|
||||||
// fakeStream implements laneStream over an in-memory ring; reads block when
|
// fakeStream implements laneStream over an in-memory ring; reads block when
|
||||||
@@ -36,14 +36,14 @@ func (f *fakeStream) Write(p []byte) (int, error) {
|
|||||||
|
|
||||||
func (f *fakeStream) SetDeadline(time.Time) error { return nil }
|
func (f *fakeStream) SetDeadline(time.Time) error { return nil }
|
||||||
|
|
||||||
func (f *fakeStream) writtenFrames(t *testing.T) []bond.Frame {
|
func (f *fakeStream) writtenFrames(t *testing.T) []bondframe.Frame {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
f.mu.Lock()
|
f.mu.Lock()
|
||||||
buf := bytes.NewReader(f.sink.Bytes())
|
buf := bytes.NewReader(f.sink.Bytes())
|
||||||
f.mu.Unlock()
|
f.mu.Unlock()
|
||||||
var out []bond.Frame
|
var out []bondframe.Frame
|
||||||
for {
|
for {
|
||||||
fr, err := bond.ReadFrame(buf)
|
fr, err := bondframe.ReadFrame(buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == io.EOF {
|
if err == io.EOF {
|
||||||
return out
|
return out
|
||||||
@@ -66,7 +66,7 @@ func newTestConn(t *testing.T) *serverConn {
|
|||||||
cancel: cancel,
|
cancel: cancel,
|
||||||
done: make(chan struct{}),
|
done: make(chan struct{}),
|
||||||
ready: make(chan struct{}, 1),
|
ready: make(chan struct{}, 1),
|
||||||
recvCh: make(chan bond.Frame, 1024),
|
recvCh: make(chan bondframe.Frame, 1024),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,10 +94,10 @@ func TestCopyBondToBackendReorder(t *testing.T) {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
// out-of-order: seq 2, 0, FIN(3), 1
|
// out-of-order: seq 2, 0, FIN(3), 1
|
||||||
c.recvCh <- bond.Frame{Type: bond.FrameData, Seq: 2, Data: []byte("C")}
|
c.recvCh <- bondframe.Frame{Type: bondframe.FrameData, Seq: 2, Data: []byte("C")}
|
||||||
c.recvCh <- bond.Frame{Type: bond.FrameData, Seq: 0, Data: []byte("A")}
|
c.recvCh <- bondframe.Frame{Type: bondframe.FrameData, Seq: 0, Data: []byte("A")}
|
||||||
c.recvCh <- bond.Frame{Type: bond.FrameFIN, Seq: 3}
|
c.recvCh <- bondframe.Frame{Type: bondframe.FrameFIN, Seq: 3}
|
||||||
c.recvCh <- bond.Frame{Type: bond.FrameData, Seq: 1, Data: []byte("B")}
|
c.recvCh <- bondframe.Frame{Type: bondframe.FrameData, Seq: 1, Data: []byte("B")}
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-done:
|
case <-done:
|
||||||
@@ -140,10 +140,10 @@ func TestCopyBondToBackendPendingDrains(t *testing.T) {
|
|||||||
if i == 0 {
|
if i == 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
c.recvCh <- bond.Frame{Type: bond.FrameData, Seq: uint64(i), Data: []byte{byte(i)}}
|
c.recvCh <- bondframe.Frame{Type: bondframe.FrameData, Seq: uint64(i), Data: []byte{byte(i)}}
|
||||||
}
|
}
|
||||||
c.recvCh <- bond.Frame{Type: bond.FrameData, Seq: 0, Data: []byte{0}}
|
c.recvCh <- bondframe.Frame{Type: bondframe.FrameData, Seq: 0, Data: []byte{0}}
|
||||||
c.recvCh <- bond.Frame{Type: bond.FrameFIN, Seq: uint64(N)}
|
c.recvCh <- bondframe.Frame{Type: bondframe.FrameFIN, Seq: uint64(N)}
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-done:
|
case <-done:
|
||||||
@@ -172,7 +172,7 @@ func TestWriteToNextLaneRoundRobin(t *testing.T) {
|
|||||||
|
|
||||||
var idx uint64
|
var idx uint64
|
||||||
for seq := range 6 {
|
for seq := range 6 {
|
||||||
if err := c.writeToNextLane(bond.FrameData, uint64(seq), []byte{byte(seq)}, &idx); err != nil {
|
if err := c.writeToNextLane(bondframe.FrameData, uint64(seq), []byte{byte(seq)}, &idx); err != nil {
|
||||||
t.Fatalf("write seq %d: %v", seq, err)
|
t.Fatalf("write seq %d: %v", seq, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -205,7 +205,7 @@ func TestWriteToNextLaneChurn(t *testing.T) {
|
|||||||
|
|
||||||
var idx uint64
|
var idx uint64
|
||||||
for seq := range 4 {
|
for seq := range 4 {
|
||||||
if err := c.writeToNextLane(bond.FrameData, uint64(seq), []byte{byte(seq)}, &idx); err != nil {
|
if err := c.writeToNextLane(bondframe.FrameData, uint64(seq), []byte{byte(seq)}, &idx); err != nil {
|
||||||
t.Fatalf("seq %d: %v", seq, err)
|
t.Fatalf("seq %d: %v", seq, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -236,7 +236,7 @@ func TestWriteToNextLaneAllFail(t *testing.T) {
|
|||||||
c.lanes = []*serverLane{mk(0), mk(1)}
|
c.lanes = []*serverLane{mk(0), mk(1)}
|
||||||
|
|
||||||
var idx uint64
|
var idx uint64
|
||||||
err := c.writeToNextLane(bond.FrameData, 0, []byte("x"), &idx)
|
err := c.writeToNextLane(bondframe.FrameData, 0, []byte("x"), &idx)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatal("expected error when all lanes fail")
|
t.Fatal("expected error when all lanes fail")
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
// Package vless implements VLESS mode: TCP forwarding over a pool of TURN-tunneled
|
// Package tcpfwd implements VLESS mode: TCP forwarding over a pool of TURN-tunneled
|
||||||
// smux sessions. Each accepted local TCP connection is opened as a smux stream
|
// smux sessions. Each accepted local TCP connection is opened as a smux stream
|
||||||
// (round-robin across sessions) or, with bond, striped across all live sessions.
|
// (round-robin across sessions) or, with bond, striped across all live sessions.
|
||||||
//
|
//
|
||||||
// The package exposes SessionPool/PooledSession so that the bond client half
|
// The package exposes SessionPool/PooledSession so that the bond client half
|
||||||
// (still living in main during refactor stage 4.2) can operate on them.
|
// (still living in main during refactor stage 4.2) can operate on them.
|
||||||
package vless
|
package tcpfwd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"sync"
|
"sync"
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package vless
|
package tcpfwd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@@ -9,13 +9,13 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/cacggghp/vk-turn-proxy/internal/dtlsdial"
|
"github.com/cacggghp/vk-turn-proxy/internal/client/ish"
|
||||||
"github.com/cacggghp/vk-turn-proxy/internal/ish"
|
|
||||||
"github.com/cacggghp/vk-turn-proxy/internal/logx"
|
"github.com/cacggghp/vk-turn-proxy/internal/logx"
|
||||||
"github.com/cacggghp/vk-turn-proxy/internal/stats"
|
"github.com/cacggghp/vk-turn-proxy/internal/stats"
|
||||||
"github.com/cacggghp/vk-turn-proxy/internal/turnpipe"
|
"github.com/cacggghp/vk-turn-proxy/internal/transport/dtlsdial"
|
||||||
"github.com/cacggghp/vk-turn-proxy/internal/wrap"
|
"github.com/cacggghp/vk-turn-proxy/internal/transport/kcptun"
|
||||||
"github.com/cacggghp/vk-turn-proxy/tcputil"
|
"github.com/cacggghp/vk-turn-proxy/internal/transport/turndial"
|
||||||
|
"github.com/cacggghp/vk-turn-proxy/internal/wire/srtpmimicry"
|
||||||
"github.com/xtaci/smux"
|
"github.com/xtaci/smux"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -237,7 +237,7 @@ func createSmuxSession(ctx context.Context, deps *Deps, params *Params, peer *ne
|
|||||||
return nil, nil, fmt.Errorf("get TURN creds: %w", err)
|
return nil, nil, fmt.Errorf("get TURN creds: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
stream, err := turnpipe.Open(ctx, turnpipe.Config{
|
stream, err := turndial.Open(ctx, turndial.Config{
|
||||||
HostOverride: params.Host,
|
HostOverride: params.Host,
|
||||||
PortOverride: params.Port,
|
PortOverride: params.Port,
|
||||||
UDP: params.UDP,
|
UDP: params.UDP,
|
||||||
@@ -250,15 +250,15 @@ func createSmuxSession(ctx context.Context, deps *Deps, params *Params, peer *ne
|
|||||||
deps.log().Debugf("[session %d] TURN server IP: %s", id, stream.ServerUDPAddr.IP)
|
deps.log().Debugf("[session %d] TURN server IP: %s", id, stream.ServerUDPAddr.IP)
|
||||||
deps.log().Debugf("relayed-address=%s", relayConn.LocalAddr().String())
|
deps.log().Debugf("relayed-address=%s", relayConn.LocalAddr().String())
|
||||||
|
|
||||||
var relayWC *wrap.Conn
|
var relayWC *srtpmimicry.Conn
|
||||||
if len(params.WrapKey) == wrap.KeyLen {
|
if len(params.WrapKey) == srtpmimicry.KeyLen {
|
||||||
relayWC, err = wrap.NewConn(params.WrapKey, false)
|
relayWC, err = srtpmimicry.NewConn(params.WrapKey, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cleanup()
|
cleanup()
|
||||||
return nil, nil, fmt.Errorf("wrap init: %w", err)
|
return nil, nil, fmt.Errorf("wrap init: %w", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dtlsPC := &wrap.RelayPacketConn{Relay: relayConn, Peer: peer, Conn: relayWC}
|
dtlsPC := &srtpmimicry.RelayPacketConn{Relay: relayConn, Peer: peer, Conn: relayWC}
|
||||||
dtlsConn, err := deps.DTLSDialer.Dial(ctx, dtlsPC, peer)
|
dtlsConn, err := deps.DTLSDialer.Dial(ctx, dtlsPC, peer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cleanup()
|
cleanup()
|
||||||
@@ -272,7 +272,7 @@ func createSmuxSession(ctx context.Context, deps *Deps, params *Params, peer *ne
|
|||||||
st := stats.New(deps.log().DebugEnabled())
|
st := stats.New(deps.log().DebugEnabled())
|
||||||
go st.LogEvery(statsCtx, deps.log().Debugf, fmt.Sprintf("[session %d] VLESS", id), "to-turn", "from-turn")
|
go st.LogEvery(statsCtx, deps.log().Debugf, fmt.Sprintf("[session %d] VLESS", id), "to-turn", "from-turn")
|
||||||
|
|
||||||
kcpSess, err := tcputil.NewKCPOverDTLS(&stats.CountingConn{Conn: dtlsConn, Stats: st}, false)
|
kcpSess, err := kcptun.NewKCPOverDTLS(&stats.CountingConn{Conn: dtlsConn, Stats: st}, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cleanup()
|
cleanup()
|
||||||
return nil, nil, fmt.Errorf("KCP session: %w", err)
|
return nil, nil, fmt.Errorf("KCP session: %w", err)
|
||||||
@@ -280,7 +280,7 @@ func createSmuxSession(ctx context.Context, deps *Deps, params *Params, peer *ne
|
|||||||
cleanupFns = append(cleanupFns, func() { _ = kcpSess.Close() })
|
cleanupFns = append(cleanupFns, func() { _ = kcpSess.Close() })
|
||||||
deps.log().Debugf("KCP session established")
|
deps.log().Debugf("KCP session established")
|
||||||
|
|
||||||
smuxSess, err := smux.Client(kcpSess, tcputil.DefaultSmuxConfig())
|
smuxSess, err := smux.Client(kcpSess, kcptun.DefaultSmuxConfig())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cleanup()
|
cleanup()
|
||||||
return nil, nil, fmt.Errorf("smux client: %w", err)
|
return nil, nil, fmt.Errorf("smux client: %w", err)
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
// Package udp implements the UDP-mode proxy loop: it terminates DTLS from a
|
// Package udprelay implements the UDP-mode proxy loop: it terminates DTLS from a
|
||||||
// local peer (WireGuard) and relays its packets through a per-stream TURN
|
// local peer (WireGuard) and relays its packets through a per-stream TURN
|
||||||
// allocation back to a remote peer. It owns oneDtlsConnection /
|
// allocation back to a remote peer. It owns oneDtlsConnection /
|
||||||
// oneTurnConnection and their retry loops; wiring (flag parsing, listener,
|
// oneTurnConnection and their retry loops; wiring (flag parsing, listener,
|
||||||
// inbound dispatch) stays in main.
|
// inbound dispatch) stays in main.
|
||||||
package udp
|
package udprelay
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@@ -16,11 +16,11 @@ import (
|
|||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/cacggghp/vk-turn-proxy/internal/dtlsdial"
|
|
||||||
"github.com/cacggghp/vk-turn-proxy/internal/logx"
|
"github.com/cacggghp/vk-turn-proxy/internal/logx"
|
||||||
"github.com/cacggghp/vk-turn-proxy/internal/stats"
|
"github.com/cacggghp/vk-turn-proxy/internal/stats"
|
||||||
"github.com/cacggghp/vk-turn-proxy/internal/turnpipe"
|
"github.com/cacggghp/vk-turn-proxy/internal/transport/dtlsdial"
|
||||||
"github.com/cacggghp/vk-turn-proxy/internal/wrap"
|
"github.com/cacggghp/vk-turn-proxy/internal/transport/turndial"
|
||||||
|
"github.com/cacggghp/vk-turn-proxy/internal/wire/srtpmimicry"
|
||||||
"github.com/cbeuw/connutil"
|
"github.com/cbeuw/connutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -253,7 +253,7 @@ func oneTURN(ctx context.Context, deps *Deps, params *Params, peer *net.UDPAddr,
|
|||||||
err = fmt.Errorf("failed to get TURN credentials: %s", err1)
|
err = fmt.Errorf("failed to get TURN credentials: %s", err1)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
stream, err1 := turnpipe.Open(ctx, turnpipe.Config{
|
stream, err1 := turndial.Open(ctx, turndial.Config{
|
||||||
HostOverride: params.Host,
|
HostOverride: params.Host,
|
||||||
PortOverride: params.Port,
|
PortOverride: params.Port,
|
||||||
UDP: params.UDP,
|
UDP: params.UDP,
|
||||||
@@ -293,10 +293,10 @@ func oneTURN(ctx context.Context, deps *Deps, params *Params, peer *net.UDPAddr,
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
var internalPipeAddr atomic.Value
|
var internalPipeAddr atomic.Value
|
||||||
var wc *wrap.Conn
|
var wc *srtpmimicry.Conn
|
||||||
if len(params.WrapKey) == wrap.KeyLen {
|
if len(params.WrapKey) == srtpmimicry.KeyLen {
|
||||||
var wcErr error
|
var wcErr error
|
||||||
wc, wcErr = wrap.NewConn(params.WrapKey, false)
|
wc, wcErr = srtpmimicry.NewConn(params.WrapKey, false)
|
||||||
if wcErr != nil {
|
if wcErr != nil {
|
||||||
log.Printf("[STREAM %d] WRAP init failed: %v", streamID, wcErr)
|
log.Printf("[STREAM %d] WRAP init failed: %v", streamID, wcErr)
|
||||||
turncancel()
|
turncancel()
|
||||||
@@ -309,7 +309,7 @@ func oneTURN(ctx context.Context, deps *Deps, params *Params, peer *net.UDPAddr,
|
|||||||
buf := make([]byte, 1600)
|
buf := make([]byte, 1600)
|
||||||
var wireBuf []byte
|
var wireBuf []byte
|
||||||
if wc != nil {
|
if wc != nil {
|
||||||
wireBuf = make([]byte, wrap.MaxWire(len(buf)))
|
wireBuf = make([]byte, srtpmimicry.MaxWire(len(buf)))
|
||||||
}
|
}
|
||||||
for {
|
for {
|
||||||
if turnctx.Err() != nil {
|
if turnctx.Err() != nil {
|
||||||
@@ -347,7 +347,7 @@ func oneTURN(ctx context.Context, deps *Deps, params *Params, peer *net.UDPAddr,
|
|||||||
defer turncancel()
|
defer turncancel()
|
||||||
readBufLen := 1600
|
readBufLen := 1600
|
||||||
if wc != nil {
|
if wc != nil {
|
||||||
readBufLen = wrap.MaxWire(1600)
|
readBufLen = srtpmimicry.MaxWire(1600)
|
||||||
}
|
}
|
||||||
buf := make([]byte, readBufLen)
|
buf := make([]byte, readBufLen)
|
||||||
plain := make([]byte, 1600)
|
plain := make([]byte, 1600)
|
||||||
File renamed without changes.
File renamed without changes.
@@ -1,16 +1,26 @@
|
|||||||
package tcputil
|
package kcptun
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/xtaci/kcp-go/v5"
|
"github.com/xtaci/kcp-go/v5"
|
||||||
"github.com/xtaci/smux"
|
"github.com/xtaci/smux"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
kcpProfileOnce sync.Once
|
||||||
|
cachedKCPProfile kcpProfile
|
||||||
|
|
||||||
|
fecOnce sync.Once
|
||||||
|
cachedFECData int
|
||||||
|
cachedFECParity int
|
||||||
|
)
|
||||||
|
|
||||||
type kcpProfile struct {
|
type kcpProfile struct {
|
||||||
nodelay int
|
nodelay int
|
||||||
interval int
|
interval int
|
||||||
@@ -23,6 +33,13 @@ type kcpProfile struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func selectedKCPProfile() kcpProfile {
|
func selectedKCPProfile() kcpProfile {
|
||||||
|
kcpProfileOnce.Do(func() {
|
||||||
|
cachedKCPProfile = loadKCPProfile()
|
||||||
|
})
|
||||||
|
return cachedKCPProfile
|
||||||
|
}
|
||||||
|
|
||||||
|
func loadKCPProfile() kcpProfile {
|
||||||
profile := strings.ToLower(strings.TrimSpace(os.Getenv("VK_TURN_KCP_PROFILE")))
|
profile := strings.ToLower(strings.TrimSpace(os.Getenv("VK_TURN_KCP_PROFILE")))
|
||||||
var cfg kcpProfile
|
var cfg kcpProfile
|
||||||
switch profile {
|
switch profile {
|
||||||
@@ -98,6 +115,13 @@ func envInt(name string, fallback int) int {
|
|||||||
// selectedFEC parses VK_TURN_KCP_FEC as "data:parity" (e.g. "10:3").
|
// selectedFEC parses VK_TURN_KCP_FEC as "data:parity" (e.g. "10:3").
|
||||||
// Returns 0,0 if unset/invalid (FEC disabled). Both sides must match.
|
// Returns 0,0 if unset/invalid (FEC disabled). Both sides must match.
|
||||||
func selectedFEC() (dataShards, parityShards int) {
|
func selectedFEC() (dataShards, parityShards int) {
|
||||||
|
fecOnce.Do(func() {
|
||||||
|
cachedFECData, cachedFECParity = loadFEC()
|
||||||
|
})
|
||||||
|
return cachedFECData, cachedFECParity
|
||||||
|
}
|
||||||
|
|
||||||
|
func loadFEC() (dataShards, parityShards int) {
|
||||||
raw := strings.TrimSpace(os.Getenv("VK_TURN_KCP_FEC"))
|
raw := strings.TrimSpace(os.Getenv("VK_TURN_KCP_FEC"))
|
||||||
if raw == "" {
|
if raw == "" {
|
||||||
return 0, 0
|
return 0, 0
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
// Package turnpipe centralizes the TURN dial+allocate pipeline shared by
|
// Package turndial centralizes the TURN dial+allocate pipeline shared by
|
||||||
// the client UDP (oneTurnConnection) and VLESS (createSmuxSession) modes.
|
// the client UDP (oneTurnConnection) and VLESS (createSmuxSession) modes.
|
||||||
//
|
//
|
||||||
// One call to Open performs: parse target, apply host/port overrides,
|
// One call to Open performs: parse target, apply host/port overrides,
|
||||||
// resolve UDP addr, dial UDP-or-TCP (with SplitFirstWriteConn over TCP),
|
// resolve UDP addr, dial UDP-or-TCP (with SplitFirstWriteConn over TCP),
|
||||||
// turn.NewClient, Listen, Allocate. Returns the relay PacketConn plus a
|
// turn.NewClient, Listen, Allocate. Returns the relay PacketConn plus a
|
||||||
// Close that tears down the allocation, TURN client, and underlying conn.
|
// Close that tears down the allocation, TURN client, and underlying conn.
|
||||||
package turnpipe
|
package turndial
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@@ -13,7 +13,7 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/cacggghp/vk-turn-proxy/internal/netadapt"
|
"github.com/cacggghp/vk-turn-proxy/internal/netconn"
|
||||||
"github.com/pion/logging"
|
"github.com/pion/logging"
|
||||||
"github.com/pion/turn/v5"
|
"github.com/pion/turn/v5"
|
||||||
)
|
)
|
||||||
@@ -86,7 +86,7 @@ func Open(ctx context.Context, cfg Config, peer *net.UDPAddr, user, pass, rawAdd
|
|||||||
if derr != nil {
|
if derr != nil {
|
||||||
return nil, fmt.Errorf("dial TURN (udp): %w", derr)
|
return nil, fmt.Errorf("dial TURN (udp): %w", derr)
|
||||||
}
|
}
|
||||||
turnConn = &netadapt.ConnectedUDPConn{UDPConn: c}
|
turnConn = &netconn.ConnectedUDPConn{UDPConn: c}
|
||||||
closeConn = c.Close
|
closeConn = c.Close
|
||||||
} else {
|
} else {
|
||||||
dctx, cancel := context.WithTimeout(ctx, dialTimeout)
|
dctx, cancel := context.WithTimeout(ctx, dialTimeout)
|
||||||
@@ -96,7 +96,7 @@ func Open(ctx context.Context, cfg Config, peer *net.UDPAddr, user, pass, rawAdd
|
|||||||
if derr != nil {
|
if derr != nil {
|
||||||
return nil, fmt.Errorf("dial TURN (tcp): %w", derr)
|
return nil, fmt.Errorf("dial TURN (tcp): %w", derr)
|
||||||
}
|
}
|
||||||
wrapped := &netadapt.SplitFirstWriteConn{Conn: c, SplitAt: 6, Delay: 20 * time.Millisecond}
|
wrapped := &netconn.SplitFirstWriteConn{Conn: c, SplitAt: 6, Delay: 20 * time.Millisecond}
|
||||||
turnConn = turn.NewSTUNConn(wrapped)
|
turnConn = turn.NewSTUNConn(wrapped)
|
||||||
closeConn = c.Close
|
closeConn = c.Close
|
||||||
}
|
}
|
||||||
@@ -111,7 +111,7 @@ func Open(ctx context.Context, cfg Config, peer *net.UDPAddr, user, pass, rawAdd
|
|||||||
STUNServerAddr: turnServerAddr,
|
STUNServerAddr: turnServerAddr,
|
||||||
TURNServerAddr: turnServerAddr,
|
TURNServerAddr: turnServerAddr,
|
||||||
Conn: turnConn,
|
Conn: turnConn,
|
||||||
Net: netadapt.New(),
|
Net: netconn.New(),
|
||||||
Username: user,
|
Username: user,
|
||||||
Password: pass,
|
Password: pass,
|
||||||
RequestedAddressFamily: addrFamily,
|
RequestedAddressFamily: addrFamily,
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package turnpipe
|
package turndial
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
// Package bond contains the wire format used by the VLESS bond multi-lane
|
// Package bond contains the wire format used by the VLESS bond multi-lane
|
||||||
// transport (hello + framed data/FIN). Both the client (initiator) and the
|
// transport (hello + framed data/FIN). Both the client (initiator) and the
|
||||||
// server (acceptor) speak the same encoding.
|
// server (acceptor) speak the same encoding.
|
||||||
package bond
|
package bondframe
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package bond
|
package bondframe
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package wrap
|
package srtpmimicry
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package wrap
|
package srtpmimicry
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net"
|
"net"
|
||||||
@@ -1,8 +1,13 @@
|
|||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
// Package wrap implements an SRTP-mimicry AEAD framing used to bypass
|
// Package srtpmimicry implements an SRTP-mimicry AEAD framing used to bypass
|
||||||
// the VK TURN content filter.
|
// the VK TURN content filter.
|
||||||
//
|
//
|
||||||
|
// Purpose: obfuscation, not security. DTLS already provides confidentiality
|
||||||
|
// and integrity on the inner channel. This layer exists to make traffic look
|
||||||
|
// like SRTP so the VK content-filter does not drop it; it is not a defense
|
||||||
|
// against an active adversary on its own.
|
||||||
|
//
|
||||||
// Wire format:
|
// Wire format:
|
||||||
//
|
//
|
||||||
// [12B RTP header | 12B explicit nonce | AEAD ciphertext | 16B tag]
|
// [12B RTP header | 12B explicit nonce | AEAD ciphertext | 16B tag]
|
||||||
@@ -20,7 +25,7 @@
|
|||||||
// AAD = first 24 bytes (RTP header || nonce).
|
// AAD = first 24 bytes (RTP header || nonce).
|
||||||
//
|
//
|
||||||
// Wire format is frozen — bit-exact compatibility with deployed peers is required.
|
// Wire format is frozen — bit-exact compatibility with deployed peers is required.
|
||||||
package wrap
|
package srtpmimicry
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/cipher"
|
"crypto/cipher"
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package wrap
|
package srtpmimicry
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
@@ -270,13 +270,13 @@ internal/
|
|||||||
|
|
||||||
### Этап V2-4 — переименования (механика, без логики)
|
### Этап V2-4 — переименования (механика, без логики)
|
||||||
|
|
||||||
- [ ] **V2-4.1** `internal/wrap` → `internal/wire/srtpmimicry`. Обновить импорты + комментарий пакета (зафиксировать «obfuscation, не security»).
|
- [x] **V2-4.1** `internal/wrap` → `internal/wire/srtpmimicry`. Импорты обновлены, package-doc дополнен «obfuscation, не security».
|
||||||
- [ ] **V2-4.2** `internal/bond/frame.go` → `internal/wire/bondframe/`. `internal/bond/client` → `internal/proxy/bondclient`. `internal/bond/server` → `internal/proxy/bondserver`.
|
- [x] **V2-4.2** `internal/bond/frame.go` → `internal/wire/bondframe/`. `internal/bond/client` → `internal/proxy/bondclient`. `internal/bond/server` → `internal/proxy/bondserver`.
|
||||||
- [ ] **V2-4.3** `internal/netadapt` → `internal/netconn`.
|
- [x] **V2-4.3** `internal/netadapt` → `internal/netconn`.
|
||||||
- [ ] **V2-4.4** `internal/turnpipe` → `internal/transport/turndial`. `internal/dtlsdial` → `internal/transport/dtlsdial`.
|
- [x] **V2-4.4** `internal/turnpipe` → `internal/transport/turndial`. `internal/dtlsdial` → `internal/transport/dtlsdial`.
|
||||||
- [ ] **V2-4.5** `tcputil` → `internal/transport/kcptun`. **Закрыть side-quest `sync.Once` для `selectedKCPProfile`** в этом же PR (нагрузка маленькая, контекст подходящий).
|
- [x] **V2-4.5** `tcputil` → `internal/transport/kcptun`. Side-quest закрыт: `selectedKCPProfile` и `selectedFEC` обёрнуты в `sync.Once` (env читается один раз).
|
||||||
- [ ] **V2-4.6** `internal/proxy/udp` → `internal/proxy/udprelay`. `internal/proxy/vless` → `internal/proxy/tcpfwd` (CLI флаг `-vless` остаётся; внутреннее имя пакета честное).
|
- [x] **V2-4.6** `internal/proxy/udp` → `internal/proxy/udprelay`. `internal/proxy/vless` → `internal/proxy/tcpfwd`. CLI флаг `-vless` оставлен.
|
||||||
- [ ] **V2-4.7** `internal/ish` → `internal/client/ish` + header-doc «iSH = Linux user-mode под iOS; этот пакет — listener shim для sandbox-ограничений iSH».
|
- [x] **V2-4.7** `internal/ish` → `internal/client/ish` + расширенный header-doc (ссылка на ish.app, linux/386, sandbox).
|
||||||
|
|
||||||
### Этап V2-5 — схлопывание `client/internal/` в `internal/client/`
|
### Этап V2-5 — схлопывание `client/internal/` в `internal/client/`
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user