mirror of
https://github.com/SagerNet/sing-box.git
synced 2024-11-25 10:01:30 +00:00
Fix connect packet connection for mux client
This commit is contained in:
parent
13ab5d3348
commit
5eb132063e
|
@ -329,6 +329,23 @@ func (c *ClientPacketConn) Write(b []byte) (n int, err error) {
|
||||||
return c.ExtendedConn.Write(b)
|
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 {
|
func (c *ClientPacketConn) WriteBuffer(buffer *buf.Buffer) error {
|
||||||
if !c.requestWrite {
|
if !c.requestWrite {
|
||||||
defer buffer.Release()
|
defer buffer.Release()
|
||||||
|
@ -343,6 +360,11 @@ func (c *ClientPacketConn) FrontHeadroom() int {
|
||||||
return 2
|
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 {
|
func (c *ClientPacketConn) WritePacket(buffer *buf.Buffer, destination M.Socksaddr) error {
|
||||||
return c.WriteBuffer(buffer)
|
return c.WriteBuffer(buffer)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue