diff --git a/transport/tuic/protocol.go b/transport/tuic/protocol.go index f7456e95..f7b85a23 100644 --- a/transport/tuic/protocol.go +++ b/transport/tuic/protocol.go @@ -349,7 +349,7 @@ func NewHeartbeat() Heartbeat { } } -func ReadHeartbeatWithHead(head CommandHead, reader BufferedReader) (c Response, err error) { +func ReadHeartbeatWithHead(head CommandHead, reader BufferedReader) (c Heartbeat, err error) { c.CommandHead = head if c.CommandHead.TYPE != HeartbeatType { err = fmt.Errorf("error command type: %s", c.CommandHead.TYPE) @@ -357,7 +357,7 @@ func ReadHeartbeatWithHead(head CommandHead, reader BufferedReader) (c Response, return } -func ReadHeartbeat(reader BufferedReader) (c Response, err error) { +func ReadHeartbeat(reader BufferedReader) (c Heartbeat, err error) { head, err := ReadCommandHead(reader) if err != nil { return diff --git a/transport/tuic/server.go b/transport/tuic/server.go index 07b4c6c1..78344589 100644 --- a/transport/tuic/server.go +++ b/transport/tuic/server.go @@ -261,6 +261,13 @@ func (s *serverHandler) handleUniStream() (err error) { writeClosed := v.(*atomic.Bool) writeClosed.Store(true) } + case HeartbeatType: + var heartbeat Heartbeat + heartbeat, err = ReadHeartbeatWithHead(commandHead, reader) + if err != nil { + return + } + heartbeat.BytesLen() } return }()