Skip to content

Commit

Permalink
more tweaks
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Pashmfouroush <[email protected]>
  • Loading branch information
markpash committed Apr 15, 2024
1 parent b28634f commit 56f8016
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 6 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ require (
github.com/quic-go/quic-go v0.40.1
github.com/refraction-networking/utls v1.3.3
github.com/rodaine/table v1.1.1
github.com/things-go/go-socks5 v0.0.5
golang.org/x/crypto v0.21.0
golang.org/x/net v0.22.0
golang.org/x/sys v0.18.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcU
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635 h1:kdXcSzyDtseVEc4yCz2qF8ZrQvIDBJLl4S1c3GCXmoI=
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=
github.com/things-go/go-socks5 v0.0.5 h1:qvKaGcBkfDrUL33SchHN93srAmYGzb4CxSM2DPYufe8=
github.com/things-go/go-socks5 v0.0.5/go.mod h1:mtzInf8v5xmsBpHZVbIw2YQYhc4K0jRwzfsH64Uh0IQ=
github.com/wader/filtertransport v0.0.0-20200316221534-bdd9e61eee78 h1:9sreu9e9KOihf2Y0NbpyfWhd1XFDcL4GTkPYL4IvMrg=
github.com/wader/filtertransport v0.0.0-20200316221534-bdd9e61eee78/go.mod h1:HazXTRLhXFyq80TQp7PUXi6BKE6mS+ydEdzEqNBKopQ=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
Expand Down
2 changes: 1 addition & 1 deletion proxy/pkg/mixed/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ type SwitchConn struct {
func NewSwitchConn(conn net.Conn) *SwitchConn {
return &SwitchConn{
Conn: conn,
Reader: bufio.NewReader(conn),
Reader: bufio.NewReaderSize(conn, 1500),
}
}

Expand Down
7 changes: 4 additions & 3 deletions proxy/pkg/socks5/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"io"
"log/slog"
"net"
"time"

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

func (s *Server) embedHandleAssociate(req *request, udpConn net.PacketConn) error {
defer func() {
_ = udpConn.Close()
}()
defer udpConn.Close()

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

for {
udpConn.SetReadDeadline(time.Now().Add(15 * time.Second))
n, addr, err := udpConn.ReadFrom(buf[:])
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion wireguard/device/queueconstants_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ const (
QueueInboundSize = 1024
QueueHandshakeSize = 1024
MaxSegmentSize = (1 << 16) - 1 // largest possible UDP datagram
PreallocatedBuffersPerPool = 4096 // Disable and allow for infinite memory growth
PreallocatedBuffersPerPool = 2048 // Disable and allow for infinite memory growth
)
2 changes: 1 addition & 1 deletion wireguard/device/queueconstants_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ const (
QueueInboundSize = 1024
QueueHandshakeSize = 1024
MaxSegmentSize = 2048 - 32 // largest possible UDP datagram
PreallocatedBuffersPerPool = 4096 // Disable and allow for infinite memory growth
PreallocatedBuffersPerPool = 0 // Disable and allow for infinite memory growth
)
3 changes: 3 additions & 0 deletions wiresocks/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
"github.com/bepass-org/warp-plus/proxy/pkg/statute"
"github.com/bepass-org/warp-plus/wireguard/device"
"github.com/bepass-org/warp-plus/wireguard/tun/netstack"

"github.com/things-go/go-socks5/bufferpool"
)

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

0 comments on commit 56f8016

Please sign in to comment.