mirror of
https://github.com/SagerNet/sing-mux.git
synced 2025-04-04 20:37:44 +03:00
Update network handler usages
This commit is contained in:
parent
5c2a0c4fa6
commit
54badfa885
6 changed files with 68 additions and 29 deletions
|
@ -10,7 +10,7 @@ import (
|
|||
"github.com/sagernet/sing/common/buf"
|
||||
M "github.com/sagernet/sing/common/metadata"
|
||||
N "github.com/sagernet/sing/common/network"
|
||||
"github.com/sagernet/sing/common/rw"
|
||||
"github.com/sagernet/sing/common/varbin"
|
||||
)
|
||||
|
||||
type serverConn struct {
|
||||
|
@ -24,11 +24,11 @@ func (c *serverConn) NeedHandshake() bool {
|
|||
|
||||
func (c *serverConn) HandshakeFailure(err error) error {
|
||||
errMessage := err.Error()
|
||||
buffer := buf.NewSize(1 + rw.UVariantLen(uint64(len(errMessage))) + len(errMessage))
|
||||
buffer := buf.NewSize(1 + varbin.UvarintLen(uint64(len(errMessage))) + len(errMessage))
|
||||
defer buffer.Release()
|
||||
common.Must(
|
||||
buffer.WriteByte(statusError),
|
||||
rw.WriteVString(buffer, errMessage),
|
||||
varbin.Write(buffer, binary.BigEndian, errMessage),
|
||||
)
|
||||
return common.Error(c.ExtendedConn.Write(buffer.Bytes()))
|
||||
}
|
||||
|
@ -88,11 +88,11 @@ func (c *serverPacketConn) NeedHandshake() bool {
|
|||
|
||||
func (c *serverPacketConn) HandshakeFailure(err error) error {
|
||||
errMessage := err.Error()
|
||||
buffer := buf.NewSize(1 + rw.UVariantLen(uint64(len(errMessage))) + len(errMessage))
|
||||
buffer := buf.NewSize(1 + varbin.UvarintLen(uint64(len(errMessage))) + len(errMessage))
|
||||
defer buffer.Release()
|
||||
common.Must(
|
||||
buffer.WriteByte(statusError),
|
||||
rw.WriteVString(buffer, errMessage),
|
||||
varbin.Write(buffer, binary.BigEndian, errMessage),
|
||||
)
|
||||
return common.Error(c.ExtendedConn.Write(buffer.Bytes()))
|
||||
}
|
||||
|
@ -188,11 +188,11 @@ func (c *serverPacketAddrConn) NeedHandshake() bool {
|
|||
|
||||
func (c *serverPacketAddrConn) HandshakeFailure(err error) error {
|
||||
errMessage := err.Error()
|
||||
buffer := buf.NewSize(1 + rw.UVariantLen(uint64(len(errMessage))) + len(errMessage))
|
||||
buffer := buf.NewSize(1 + varbin.UvarintLen(uint64(len(errMessage))) + len(errMessage))
|
||||
defer buffer.Release()
|
||||
common.Must(
|
||||
buffer.WriteByte(statusError),
|
||||
rw.WriteVString(buffer, errMessage),
|
||||
varbin.Write(buffer, binary.BigEndian, errMessage),
|
||||
)
|
||||
return common.Error(c.ExtendedConn.Write(buffer.Bytes()))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue