Skip wait for hysteria tcp handshake response
Co-authored-by: arm64v8a <48624112+arm64v8a@users.noreply.github.com>
This commit is contained in:
@@ -374,17 +374,35 @@ var _ net.Conn = (*Conn)(nil)
|
||||
|
||||
type Conn struct {
|
||||
quic.Stream
|
||||
destination M.Socksaddr
|
||||
responseWritten bool
|
||||
destination M.Socksaddr
|
||||
needReadResponse bool
|
||||
}
|
||||
|
||||
func NewConn(stream quic.Stream, destination M.Socksaddr) *Conn {
|
||||
func NewConn(stream quic.Stream, destination M.Socksaddr, isClient bool) *Conn {
|
||||
return &Conn{
|
||||
Stream: stream,
|
||||
destination: destination,
|
||||
Stream: stream,
|
||||
destination: destination,
|
||||
needReadResponse: isClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Conn) Read(p []byte) (n int, err error) {
|
||||
if c.needReadResponse {
|
||||
var response *ServerResponse
|
||||
response, err = ReadServerResponse(c.Stream)
|
||||
if err != nil {
|
||||
c.Close()
|
||||
return
|
||||
}
|
||||
if !response.OK {
|
||||
c.Close()
|
||||
return 0, E.New("remote error: ", response.Message)
|
||||
}
|
||||
c.needReadResponse = false
|
||||
}
|
||||
return c.Stream.Read(p)
|
||||
}
|
||||
|
||||
func (c *Conn) LocalAddr() net.Addr {
|
||||
return nil
|
||||
}
|
||||
@@ -394,7 +412,7 @@ func (c *Conn) RemoteAddr() net.Addr {
|
||||
}
|
||||
|
||||
func (c *Conn) ReaderReplaceable() bool {
|
||||
return true
|
||||
return !c.needReadResponse
|
||||
}
|
||||
|
||||
func (c *Conn) WriterReplaceable() bool {
|
||||
|
||||
Reference in New Issue
Block a user