Skip to content

Commit

Permalink
fix: hysteria2: handleTCP relay error in dae by implement WriteCloser (
Browse files Browse the repository at this point in the history
  • Loading branch information
mnixry authored Jun 14, 2024
1 parent ce576b5 commit 64f4b8c
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions protocol/hysteria2/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func (c *clientImpl) connect() (*HandshakeInfo, error) {
}

// openStream wraps the stream with QStream, which handles Close() properly
func (c *clientImpl) openStream() (quic.Stream, error) {
func (c *clientImpl) openStream() (*utils.QStream, error) {
stream, err := c.conn.OpenStream()
if err != nil {
return nil, err
Expand Down Expand Up @@ -231,7 +231,7 @@ func wrapIfConnectionClosed(err error) error {
}

type tcpConn struct {
Orig quic.Stream
Orig *utils.QStream
PseudoLocalAddr net.Addr
PseudoRemoteAddr net.Addr
Established bool
Expand Down Expand Up @@ -260,6 +260,17 @@ func (c *tcpConn) Close() error {
return c.Orig.Close()
}

func (c *tcpConn) CloseWrite() error {
// quic-go's default close only closes the write side
// for more info, see comments in utils.QStream struct
return c.Orig.Stream.Close()
}

func (c *tcpConn) CloseRead() error {
c.Orig.Stream.CancelRead(0)
return nil
}

func (c *tcpConn) LocalAddr() net.Addr {
return c.PseudoLocalAddr
}
Expand Down

0 comments on commit 64f4b8c

Please sign in to comment.