Skip to content

Commit 56f8016

Browse files
committed
more tweaks
Signed-off-by: Mark Pashmfouroush <mark@markpash.me>
1 parent b28634f commit 56f8016

File tree

7 files changed

+13
-6
lines changed

7 files changed

+13
-6
lines changed

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ require (
1717
github.com/quic-go/quic-go v0.40.1
1818
github.com/refraction-networking/utls v1.3.3
1919
github.com/rodaine/table v1.1.1
20+
github.com/things-go/go-socks5 v0.0.5
2021
golang.org/x/crypto v0.21.0
2122
golang.org/x/net v0.22.0
2223
golang.org/x/sys v0.18.0

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,8 @@ github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcU
204204
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
205205
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635 h1:kdXcSzyDtseVEc4yCz2qF8ZrQvIDBJLl4S1c3GCXmoI=
206206
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=
207+
github.com/things-go/go-socks5 v0.0.5 h1:qvKaGcBkfDrUL33SchHN93srAmYGzb4CxSM2DPYufe8=
208+
github.com/things-go/go-socks5 v0.0.5/go.mod h1:mtzInf8v5xmsBpHZVbIw2YQYhc4K0jRwzfsH64Uh0IQ=
207209
github.com/wader/filtertransport v0.0.0-20200316221534-bdd9e61eee78 h1:9sreu9e9KOihf2Y0NbpyfWhd1XFDcL4GTkPYL4IvMrg=
208210
github.com/wader/filtertransport v0.0.0-20200316221534-bdd9e61eee78/go.mod h1:HazXTRLhXFyq80TQp7PUXi6BKE6mS+ydEdzEqNBKopQ=
209211
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=

proxy/pkg/mixed/proxy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ type SwitchConn struct {
7070
func NewSwitchConn(conn net.Conn) *SwitchConn {
7171
return &SwitchConn{
7272
Conn: conn,
73-
Reader: bufio.NewReader(conn),
73+
Reader: bufio.NewReaderSize(conn, 1500),
7474
}
7575
}
7676

proxy/pkg/socks5/server.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"io"
88
"log/slog"
99
"net"
10+
"time"
1011

1112
"github.com/bepass-org/warp-plus/proxy/pkg/statute"
1213
)
@@ -350,13 +351,12 @@ func (s *Server) handleAssociate(req *request) error {
350351
}
351352

352353
func (s *Server) embedHandleAssociate(req *request, udpConn net.PacketConn) error {
353-
defer func() {
354-
_ = udpConn.Close()
355-
}()
354+
defer udpConn.Close()
356355

357356
go func() {
358357
var buf [1]byte
359358
for {
359+
req.Conn.SetReadDeadline(time.Now().Add(15 * time.Second))
360360
_, err := req.Conn.Read(buf[:])
361361
if err != nil {
362362
_ = udpConn.Close()
@@ -375,6 +375,7 @@ func (s *Server) embedHandleAssociate(req *request, udpConn net.PacketConn) erro
375375
)
376376

377377
for {
378+
udpConn.SetReadDeadline(time.Now().Add(15 * time.Second))
378379
n, addr, err := udpConn.ReadFrom(buf[:])
379380
if err != nil {
380381
return err

wireguard/device/queueconstants_default.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ const (
1515
QueueInboundSize = 1024
1616
QueueHandshakeSize = 1024
1717
MaxSegmentSize = (1 << 16) - 1 // largest possible UDP datagram
18-
PreallocatedBuffersPerPool = 4096 // Disable and allow for infinite memory growth
18+
PreallocatedBuffersPerPool = 2048 // Disable and allow for infinite memory growth
1919
)

wireguard/device/queueconstants_windows.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ const (
1111
QueueInboundSize = 1024
1212
QueueHandshakeSize = 1024
1313
MaxSegmentSize = 2048 - 32 // largest possible UDP datagram
14-
PreallocatedBuffersPerPool = 4096 // Disable and allow for infinite memory growth
14+
PreallocatedBuffersPerPool = 0 // Disable and allow for infinite memory growth
1515
)

wiresocks/proxy.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import (
1111
"github.com/bepass-org/warp-plus/proxy/pkg/statute"
1212
"github.com/bepass-org/warp-plus/wireguard/device"
1313
"github.com/bepass-org/warp-plus/wireguard/tun/netstack"
14+
15+
"github.com/things-go/go-socks5/bufferpool"
1416
)
1517

1618
// VirtualTun stores a reference to netstack network and DNS configuration
@@ -35,6 +37,7 @@ func (vt *VirtualTun) StartProxy(bindAddress netip.AddrPort) (netip.AddrPort, er
3537
mixed.WithUserHandler(func(request *statute.ProxyRequest) error {
3638
return vt.generalHandler(request)
3739
}),
40+
mixed.WithBytesPool(bufferpool.NewPool(256*1024)),
3841
)
3942
go func() {
4043
_ = proxy.ListenAndServe()

0 commit comments

Comments
 (0)