mirror of
https://gitee.com/konyshe/goodlink.git
synced 2025-12-06 14:59:04 +08:00
improve the data transmission speed
This commit is contained in:
@@ -4,5 +4,5 @@ Website = "https://goodlink.kony.vip"
|
||||
Icon = "assert/favicon.ico"
|
||||
Name = "goodlink-windows-amd64-ui"
|
||||
ID = "goodlink.kony.vip"
|
||||
Version = "2.1.6"
|
||||
Version = "2.1.7"
|
||||
Build = 0
|
||||
|
||||
@@ -111,10 +111,13 @@ func (e *Endpoint) dispatchLoop(cancel context.CancelFunc) {
|
||||
// 获取配置参数:数据偏移量和MTU值
|
||||
offset, mtu := e.offset, int(e.mtu)
|
||||
|
||||
// 创建带偏移量的接收缓冲区(用于TUN设备头)
|
||||
data := make([]byte, offset+mtu)
|
||||
|
||||
// 数据包接收主循环
|
||||
for {
|
||||
// 创建带偏移量的接收缓冲区(用于TUN设备头)
|
||||
data := make([]byte, offset+mtu)
|
||||
// data := make([]byte, offset+mtu)
|
||||
|
||||
// 从IO接口读取原始数据
|
||||
n, err := e.rw.Read(data)
|
||||
|
||||
@@ -3,7 +3,7 @@ package netstack
|
||||
import (
|
||||
"context"
|
||||
"encoding/binary"
|
||||
pool2 "goodlink/pool"
|
||||
"goodlink/pool2"
|
||||
"goodlink/proxy"
|
||||
"log"
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package netstack
|
||||
import (
|
||||
"context"
|
||||
"encoding/binary"
|
||||
pool2 "goodlink/pool"
|
||||
"goodlink/pool2"
|
||||
"goodlink/proxy"
|
||||
"log"
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ func Start() error {
|
||||
},
|
||||
})
|
||||
|
||||
wintunEP, err := Open(GetName(), 1490) //因为要加自定义头,防止超出1500
|
||||
wintunEP, err := Open(GetName(), 0)
|
||||
if err != nil {
|
||||
return fmt.Errorf("请管理员权限运行")
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package pool
|
||||
package pool2
|
||||
|
||||
import (
|
||||
"sync"
|
||||
@@ -1,7 +1,6 @@
|
||||
package proxy
|
||||
|
||||
import (
|
||||
"goodlink/pool"
|
||||
"io"
|
||||
"net"
|
||||
|
||||
@@ -9,25 +8,19 @@ import (
|
||||
)
|
||||
|
||||
func ForwardT2Q(tc net.Conn, qc quic.Stream, stun_quic_conn quic.Connection) {
|
||||
buf := pool.Malloc(1500)
|
||||
|
||||
defer func() {
|
||||
pool.Free(buf)
|
||||
qc.Close()
|
||||
tc.Close()
|
||||
}()
|
||||
|
||||
io.CopyBuffer(tc, qc, buf)
|
||||
io.Copy(tc, qc)
|
||||
}
|
||||
|
||||
func ForwardQ2T(qc quic.Stream, tc net.Conn, stun_quic_conn quic.Connection) {
|
||||
buf := pool.Malloc(1500)
|
||||
|
||||
defer func() {
|
||||
pool.Free(buf)
|
||||
qc.Close()
|
||||
tc.Close()
|
||||
}()
|
||||
|
||||
io.CopyBuffer(qc, tc, buf)
|
||||
io.Copy(qc, tc)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package proxy
|
||||
import (
|
||||
"context"
|
||||
"encoding/binary"
|
||||
pool2 "goodlink/pool"
|
||||
"goodlink/pool2"
|
||||
"goodlink/socks5"
|
||||
"goodlink/utils"
|
||||
"io"
|
||||
|
||||
@@ -2,6 +2,7 @@ package socks5
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"goodlink/pool2"
|
||||
"io"
|
||||
)
|
||||
|
||||
@@ -88,7 +89,8 @@ func (a UserPassAuthenticator) Authenticate(reader io.Reader, writer io.Writer)
|
||||
|
||||
// Get the password
|
||||
passLen := int(header[0])
|
||||
pass := make([]byte, passLen)
|
||||
pass := pool2.Malloc(passLen) //make([]byte, passLen)
|
||||
defer pool2.Free(pass)
|
||||
if _, err := io.ReadAtLeast(reader, pass, passLen); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package socks5
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"goodlink/pool"
|
||||
"goodlink/pool2"
|
||||
"io"
|
||||
"net"
|
||||
"strconv"
|
||||
@@ -267,14 +267,16 @@ func readAddrSpec(r io.Reader) (*AddrSpec, error) {
|
||||
// Handle on a per type basis
|
||||
switch addrType[0] {
|
||||
case ipv4Address:
|
||||
addr := make([]byte, 4)
|
||||
addr := pool2.Malloc(4) //make([]byte, 4)
|
||||
defer pool2.Free(addr)
|
||||
if _, err := io.ReadAtLeast(r, addr, len(addr)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
d.IP = net.IP(addr)
|
||||
|
||||
case ipv6Address:
|
||||
addr := make([]byte, 16)
|
||||
addr := pool2.Malloc(16) //make([]byte, 16)
|
||||
defer pool2.Free(addr)
|
||||
if _, err := io.ReadAtLeast(r, addr, len(addr)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -285,7 +287,8 @@ func readAddrSpec(r io.Reader) (*AddrSpec, error) {
|
||||
return nil, err
|
||||
}
|
||||
addrLen := int(addrType[0])
|
||||
fqdn := make([]byte, addrLen)
|
||||
fqdn := pool2.Malloc(addrLen) //make([]byte, addrLen)
|
||||
defer pool2.Free(fqdn)
|
||||
if _, err := io.ReadAtLeast(r, fqdn, addrLen); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -337,7 +340,8 @@ func sendReply(w io.Writer, resp uint8, addr *AddrSpec) error {
|
||||
}
|
||||
|
||||
// Format the message
|
||||
msg := make([]byte, 6+len(addrBody))
|
||||
msg := pool2.Malloc(6 + len(addrBody)) //make([]byte, 6+len(addrBody))
|
||||
defer pool2.Free(msg)
|
||||
msg[0] = socks5Version
|
||||
msg[1] = resp
|
||||
msg[2] = 0 // Reserved
|
||||
@@ -358,10 +362,7 @@ type closeWriter interface {
|
||||
// proxy is used to suffle data from src to destination, and sends errors
|
||||
// down a dedicated channel
|
||||
func proxy(dst io.Writer, src io.Reader, errCh chan error) {
|
||||
buf := pool.Malloc(1500)
|
||||
defer pool.Free(buf)
|
||||
|
||||
_, err := io.CopyBuffer(dst, src, buf)
|
||||
_, err := io.Copy(dst, src)
|
||||
if tcpConn, ok := dst.(closeWriter); ok {
|
||||
tcpConn.CloseWrite()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user