mirror of
https://gitee.com/konyshe/goodlink.git
synced 2025-09-26 20:51:22 +08:00
pool => go2pool
This commit is contained in:
@@ -3,7 +3,7 @@ package netstack
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
pool2 "go2/pool"
|
go2pool "go2/pool"
|
||||||
"goodlink/proxy"
|
"goodlink/proxy"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
@@ -28,8 +28,8 @@ func ForwardTCPConn(originConn *TcpConn, stun_quic_conn quic.Connection) {
|
|||||||
ipv4Bytes := originConn.ID().LocalAddress.As4()
|
ipv4Bytes := originConn.ID().LocalAddress.As4()
|
||||||
new_quic_stream.Write(ipv4Bytes[:]) // 添加[:]转换为切片
|
new_quic_stream.Write(ipv4Bytes[:]) // 添加[:]转换为切片
|
||||||
|
|
||||||
portBytes := pool2.Malloc(2)
|
portBytes := go2pool.Malloc(2)
|
||||||
defer pool2.Free(portBytes)
|
defer go2pool.Free(portBytes)
|
||||||
|
|
||||||
binary.BigEndian.PutUint16(portBytes, originConn.ID().LocalPort)
|
binary.BigEndian.PutUint16(portBytes, originConn.ID().LocalPort)
|
||||||
new_quic_stream.Write(portBytes)
|
new_quic_stream.Write(portBytes)
|
||||||
|
@@ -3,7 +3,7 @@ package netstack
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
pool2 "go2/pool"
|
go2pool "go2/pool"
|
||||||
"goodlink/proxy"
|
"goodlink/proxy"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
@@ -27,8 +27,8 @@ func ForwardUdpConn(originConn *udpConn, stun_quic_conn quic.Connection) {
|
|||||||
ipv4Bytes := originConn.ID().LocalAddress.As4()
|
ipv4Bytes := originConn.ID().LocalAddress.As4()
|
||||||
new_quic_stream.Write(ipv4Bytes[:]) // 添加[:]转换为切片
|
new_quic_stream.Write(ipv4Bytes[:]) // 添加[:]转换为切片
|
||||||
|
|
||||||
portBytes := pool2.Malloc(2)
|
portBytes := go2pool.Malloc(2)
|
||||||
defer pool2.Free(portBytes)
|
defer go2pool.Free(portBytes)
|
||||||
|
|
||||||
binary.BigEndian.PutUint16(portBytes, originConn.ID().LocalPort)
|
binary.BigEndian.PutUint16(portBytes, originConn.ID().LocalPort)
|
||||||
new_quic_stream.Write(portBytes)
|
new_quic_stream.Write(portBytes)
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
package proxy
|
package proxy
|
||||||
|
|
||||||
import (
|
import (
|
||||||
pool2 "go2/pool"
|
go2pool "go2/pool"
|
||||||
"io"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
@@ -14,8 +14,8 @@ func ForwardT2Q(tc net.Conn, qc quic.Stream, stun_quic_conn quic.Connection) {
|
|||||||
tc.Close()
|
tc.Close()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
buf := pool2.Malloc(32 * 1024) // 32KB缓冲区提升吞吐量
|
buf := go2pool.Malloc(32 * 1024) // 32KB缓冲区提升吞吐量
|
||||||
defer pool2.Free(buf)
|
defer go2pool.Free(buf)
|
||||||
io.CopyBuffer(tc, qc, buf)
|
io.CopyBuffer(tc, qc, buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ func ForwardQ2T(qc quic.Stream, tc net.Conn, stun_quic_conn quic.Connection) {
|
|||||||
tc.Close()
|
tc.Close()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
buf := pool2.Malloc(32 * 1024) // 32KB缓冲区提升吞吐量
|
buf := go2pool.Malloc(32 * 1024) // 32KB缓冲区提升吞吐量
|
||||||
defer pool2.Free(buf)
|
defer go2pool.Free(buf)
|
||||||
io.CopyBuffer(qc, tc, buf)
|
io.CopyBuffer(qc, tc, buf)
|
||||||
}
|
}
|
||||||
|
@@ -4,7 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"go2/log"
|
"go2/log"
|
||||||
pool2 "go2/pool"
|
go2pool "go2/pool"
|
||||||
"io"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
proxy_handle "proxy/handle"
|
proxy_handle "proxy/handle"
|
||||||
@@ -14,8 +14,8 @@ import (
|
|||||||
|
|
||||||
func ProcessProxyServer(stun_quic_conn quic.Connection) {
|
func ProcessProxyServer(stun_quic_conn quic.Connection) {
|
||||||
head_len := 7 // 1字节传输协议类型 + 4字节IPv4地址 + 2字节端口号
|
head_len := 7 // 1字节传输协议类型 + 4字节IPv4地址 + 2字节端口号
|
||||||
buf := pool2.Malloc(head_len)
|
buf := go2pool.Malloc(head_len)
|
||||||
defer pool2.Free(buf)
|
defer go2pool.Free(buf)
|
||||||
|
|
||||||
proxy_handle.Init()
|
proxy_handle.Init()
|
||||||
log.Info("开启代理模式")
|
log.Info("开启代理模式")
|
||||||
|
Reference in New Issue
Block a user