mirror of
https://github.com/SagerNet/sing-mux.git
synced 2025-04-04 20:37:44 +03:00
Fix missing HandshakeConn interface
This commit is contained in:
parent
ea4a972acd
commit
dc1639b520
3 changed files with 28 additions and 0 deletions
|
@ -20,6 +20,10 @@ type clientConn struct {
|
||||||
responseRead bool
|
responseRead bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *clientConn) NeedHandshake() bool {
|
||||||
|
return !c.requestWritten
|
||||||
|
}
|
||||||
|
|
||||||
func (c *clientConn) readResponse() error {
|
func (c *clientConn) readResponse() error {
|
||||||
response, err := ReadStreamResponse(c.Conn)
|
response, err := ReadStreamResponse(c.Conn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -94,6 +98,10 @@ type clientPacketConn struct {
|
||||||
responseRead bool
|
responseRead bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *clientPacketConn) NeedHandshake() bool {
|
||||||
|
return !c.requestWritten
|
||||||
|
}
|
||||||
|
|
||||||
func (c *clientPacketConn) readResponse() error {
|
func (c *clientPacketConn) readResponse() error {
|
||||||
response, err := ReadStreamResponse(c.ExtendedConn)
|
response, err := ReadStreamResponse(c.ExtendedConn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -276,6 +284,10 @@ type clientPacketAddrConn struct {
|
||||||
responseRead bool
|
responseRead bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *clientPacketAddrConn) NeedHandshake() bool {
|
||||||
|
return !c.requestWritten
|
||||||
|
}
|
||||||
|
|
||||||
func (c *clientPacketAddrConn) readResponse() error {
|
func (c *clientPacketAddrConn) readResponse() error {
|
||||||
response, err := ReadStreamResponse(c.ExtendedConn)
|
response, err := ReadStreamResponse(c.ExtendedConn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -32,6 +32,10 @@ func newProtocolConn(conn net.Conn, request Request) net.Conn {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *protocolConn) NeedHandshake() bool {
|
||||||
|
return !c.requestWritten
|
||||||
|
}
|
||||||
|
|
||||||
func (c *protocolConn) Write(p []byte) (n int, err error) {
|
func (c *protocolConn) Write(p []byte) (n int, err error) {
|
||||||
if c.requestWritten {
|
if c.requestWritten {
|
||||||
return c.Conn.Write(p)
|
return c.Conn.Write(p)
|
||||||
|
|
|
@ -20,6 +20,10 @@ type serverConn struct {
|
||||||
responseWritten bool
|
responseWritten bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *serverConn) NeedHandshake() bool {
|
||||||
|
return !c.responseWritten
|
||||||
|
}
|
||||||
|
|
||||||
func (c *serverConn) HandshakeFailure(err error) error {
|
func (c *serverConn) HandshakeFailure(err error) error {
|
||||||
errMessage := err.Error()
|
errMessage := err.Error()
|
||||||
buffer := buf.NewSize(1 + rw.UVariantLen(uint64(len(errMessage))) + len(errMessage))
|
buffer := buf.NewSize(1 + rw.UVariantLen(uint64(len(errMessage))) + len(errMessage))
|
||||||
|
@ -85,6 +89,10 @@ type serverPacketConn struct {
|
||||||
responseWritten bool
|
responseWritten bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *serverPacketConn) NeedHandshake() bool {
|
||||||
|
return !c.responseWritten
|
||||||
|
}
|
||||||
|
|
||||||
func (c *serverPacketConn) HandshakeFailure(err error) error {
|
func (c *serverPacketConn) HandshakeFailure(err error) error {
|
||||||
errMessage := err.Error()
|
errMessage := err.Error()
|
||||||
buffer := buf.NewSize(1 + rw.UVariantLen(uint64(len(errMessage))) + len(errMessage))
|
buffer := buf.NewSize(1 + rw.UVariantLen(uint64(len(errMessage))) + len(errMessage))
|
||||||
|
@ -186,6 +194,10 @@ type serverPacketAddrConn struct {
|
||||||
responseWritten bool
|
responseWritten bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *serverPacketAddrConn) NeedHandshake() bool {
|
||||||
|
return !c.responseWritten
|
||||||
|
}
|
||||||
|
|
||||||
func (c *serverPacketAddrConn) HandshakeFailure(err error) error {
|
func (c *serverPacketAddrConn) HandshakeFailure(err error) error {
|
||||||
errMessage := err.Error()
|
errMessage := err.Error()
|
||||||
buffer := buf.NewSize(1 + rw.UVariantLen(uint64(len(errMessage))) + len(errMessage))
|
buffer := buf.NewSize(1 + rw.UVariantLen(uint64(len(errMessage))) + len(errMessage))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue