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"
|
||||
"time"
|
||||
|
||||
bondclient "github.com/cacggghp/vk-turn-proxy/internal/bond/client"
|
||||
"github.com/cacggghp/vk-turn-proxy/internal/client/captcha"
|
||||
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/vkauth"
|
||||
"github.com/cacggghp/vk-turn-proxy/internal/config"
|
||||
"github.com/cacggghp/vk-turn-proxy/internal/dtlsdial"
|
||||
"github.com/cacggghp/vk-turn-proxy/internal/logx"
|
||||
udpproxy "github.com/cacggghp/vk-turn-proxy/internal/proxy/udp"
|
||||
"github.com/cacggghp/vk-turn-proxy/internal/proxy/vless"
|
||||
"github.com/cacggghp/vk-turn-proxy/internal/wrap"
|
||||
bondclient "github.com/cacggghp/vk-turn-proxy/internal/proxy/bondclient"
|
||||
"github.com/cacggghp/vk-turn-proxy/internal/proxy/tcpfwd"
|
||||
"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)
|
||||
@@ -97,7 +97,7 @@ func main() {
|
||||
appDialer = dnsdial.AppDialer(cfg.DNSMode)
|
||||
dnsdial.InstallGlobalResolver(cfg.DNSMode)
|
||||
if cfg.GenWrapKey {
|
||||
key, gerr := wrap.GenKeyHex()
|
||||
key, gerr := srtpmimicry.GenKeyHex()
|
||||
if gerr != nil {
|
||||
log.Panicf("%v", gerr)
|
||||
}
|
||||
@@ -137,20 +137,20 @@ func main() {
|
||||
|
||||
if cfg.VLESSMode {
|
||||
bondH := &bondclient.Handler{Deps: bondclient.Deps{Log: logger}}
|
||||
vlessDeps := &vless.Deps{
|
||||
vlessDeps := &tcpfwd.Deps{
|
||||
DTLSDialer: vlessDtlsDialer,
|
||||
Log: logger,
|
||||
BondHandler: bondH.Handle,
|
||||
}
|
||||
vlessParams := &vless.Params{
|
||||
vlessParams := &tcpfwd.Params{
|
||||
Host: params.host,
|
||||
Port: params.port,
|
||||
Link: params.link,
|
||||
UDP: params.udp,
|
||||
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
|
||||
}
|
||||
|
||||
@@ -170,7 +170,7 @@ func main() {
|
||||
}
|
||||
|
||||
// Shared Worker Pool Queue for Aggregation
|
||||
inboundChan := make(chan *udpproxy.Packet, 2000)
|
||||
inboundChan := make(chan *udprelay.Packet, 2000)
|
||||
|
||||
go func() {
|
||||
// Pointer-cache for the last seen local peer addr. Avoids the
|
||||
@@ -182,8 +182,8 @@ func main() {
|
||||
var lastAddr net.Addr
|
||||
var lastAddrStr string
|
||||
for {
|
||||
pktIface := udpproxy.Pool.Get()
|
||||
pkt, ok := pktIface.(*udpproxy.Packet)
|
||||
pktIface := udprelay.Pool.Get()
|
||||
pkt, ok := pktIface.(*udprelay.Packet)
|
||||
if !ok {
|
||||
log.Printf("packetPool returned unexpected type: %T", pktIface)
|
||||
continue
|
||||
@@ -208,7 +208,7 @@ func main() {
|
||||
case inboundChan <- pkt:
|
||||
default:
|
||||
// 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{}
|
||||
t := time.Tick(200 * time.Millisecond)
|
||||
|
||||
udpDeps := &udpproxy.Deps{
|
||||
udpDeps := &udprelay.Deps{
|
||||
DTLSDialer: udpDtlsDialer,
|
||||
Auth: vkAuth,
|
||||
Log: logger,
|
||||
@@ -224,22 +224,22 @@ func main() {
|
||||
ConnectedStreams: &connectedStreams,
|
||||
AppCancel: cancel,
|
||||
}
|
||||
udpParams := &udpproxy.Params{
|
||||
udpParams := &udprelay.Params{
|
||||
Host: params.host,
|
||||
Port: params.port,
|
||||
Link: params.link,
|
||||
UDP: params.udp,
|
||||
WrapKey: params.wrapKey,
|
||||
GetCreds: udpproxy.GetCredsFunc(params.getCreds),
|
||||
GetCreds: udprelay.GetCredsFunc(params.getCreds),
|
||||
}
|
||||
|
||||
okchan := make(chan struct{})
|
||||
connchan := make(chan net.PacketConn)
|
||||
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() {
|
||||
udpproxy.TURNLoop(ctx, udpDeps, udpParams, peer, connchan, t, 1)
|
||||
udprelay.TURNLoop(ctx, udpDeps, udpParams, peer, connchan, t, 1)
|
||||
})
|
||||
|
||||
select {
|
||||
@@ -251,10 +251,10 @@ func main() {
|
||||
cchan := make(chan net.PacketConn)
|
||||
streamID := i
|
||||
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() {
|
||||
udpproxy.TURNLoop(ctx, udpDeps, udpParams, peer, cchan, t, streamID)
|
||||
udprelay.TURNLoop(ctx, udpDeps, udpParams, peer, cchan, t, streamID)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -12,13 +12,13 @@ import (
|
||||
"syscall"
|
||||
"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/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/wrap"
|
||||
"github.com/cacggghp/vk-turn-proxy/tcputil"
|
||||
"github.com/cacggghp/vk-turn-proxy/internal/transport/kcptun"
|
||||
"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/pkg/crypto/selfsign"
|
||||
"github.com/xtaci/smux"
|
||||
@@ -38,7 +38,7 @@ func main() {
|
||||
globalBondRegistry = bondserver.NewRegistry(bondserver.Deps{Log: logger})
|
||||
|
||||
if cfg.GenWrapKey {
|
||||
key, gerr := wrap.GenKeyHex()
|
||||
key, gerr := srtpmimicry.GenKeyHex()
|
||||
if gerr != nil {
|
||||
log.Panicf("gen-wrap-key: %v", gerr)
|
||||
}
|
||||
@@ -83,7 +83,7 @@ func main() {
|
||||
var listener net.Listener
|
||||
if cfg.WrapMode {
|
||||
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 {
|
||||
panic(werr)
|
||||
}
|
||||
@@ -277,7 +277,7 @@ func handleVLESSConnection(ctx context.Context, dtlsConn net.Conn, connectAddr s
|
||||
"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 {
|
||||
log.Printf("KCP session error: %s", err)
|
||||
return
|
||||
@@ -290,7 +290,7 @@ func handleVLESSConnection(ctx context.Context, dtlsConn net.Conn, connectAddr s
|
||||
logger.Debugf("KCP session established (server)")
|
||||
|
||||
// 2. Create smux server session over KCP
|
||||
smuxSess, err := smux.Server(kcpSess, tcputil.DefaultSmuxConfig())
|
||||
smuxSess, err := smux.Server(kcpSess, kcptun.DefaultSmuxConfig())
|
||||
if err != nil {
|
||||
log.Printf("smux server error: %s", err)
|
||||
return
|
||||
@@ -325,7 +325,7 @@ func handleVLESSConnection(ctx context.Context, dtlsConn net.Conn, connectAddr s
|
||||
_ = s.Close()
|
||||
return
|
||||
}
|
||||
if string(prefix[:]) == bond.Magic {
|
||||
if string(prefix[:]) == bondframe.Magic {
|
||||
logger.Debugf("auto-detected bond smux stream")
|
||||
globalBondRegistry.HandleStreamAfterMagic(ctx, s, connectAddr, prefix)
|
||||
return
|
||||
|
||||
Reference in new issue
Block a user