From 5eb132063e03697ad682918bf5f203d86359e320 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Sat, 12 Nov 2022 03:53:42 +0800 Subject: [PATCH] Fix connect packet connection for mux client --- common/mux/client.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/common/mux/client.go b/common/mux/client.go index c1d3daa3..c4b2a6f9 100644 --- a/common/mux/client.go +++ b/common/mux/client.go @@ -329,6 +329,23 @@ func (c *ClientPacketConn) Write(b []byte) (n int, err error) { return c.ExtendedConn.Write(b) } +func (c *ClientPacketConn) ReadBuffer(buffer *buf.Buffer) (err error) { + if !c.responseRead { + err = c.readResponse() + if err != nil { + return + } + c.responseRead = true + } + var length uint16 + err = binary.Read(c.ExtendedConn, binary.BigEndian, &length) + if err != nil { + return + } + _, err = buffer.ReadFullFrom(c.ExtendedConn, int(length)) + return +} + func (c *ClientPacketConn) WriteBuffer(buffer *buf.Buffer) error { if !c.requestWrite { defer buffer.Release() @@ -343,6 +360,11 @@ func (c *ClientPacketConn) FrontHeadroom() int { return 2 } +func (c *ClientPacketConn) ReadPacket(buffer *buf.Buffer) (destination M.Socksaddr, err error) { + err = c.ReadBuffer(buffer) + return +} + func (c *ClientPacketConn) WritePacket(buffer *buf.Buffer, destination M.Socksaddr) error { return c.WriteBuffer(buffer) }