mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-10-29 06:31:56 +00:00
WebSocket transport: Treat normal close frames as io.EOF (#7236)
Fixes https://github.com/XTLS/Xray-core/issues/7235#issuecomment-6353389899 --------- Co-authored-by: 风扇滑翔翼 <Fangliding.fshxy@outlook.com>
This commit is contained in:
1 parent
8a3c0cbf1d
commit
ec124ff9e0
1 file changed
+6
@@ -46,6 +46,12 @@ func (c *connection) Read(b []byte) (int, error) {
|
|||||||
for {
|
for {
|
||||||
reader, err := c.getReader()
|
reader, err := c.getReader()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
// A close frame with a normal status (1000) or no status (1005) ends
|
||||||
|
// the byte stream the same way a FIN does, so report io.EOF instead
|
||||||
|
// of an error. Other close codes keep their error semantics.
|
||||||
|
if websocket.IsCloseError(err, websocket.CloseNormalClosure, websocket.CloseNoStatusReceived) {
|
||||||
|
return 0, io.EOF
|
||||||
|
}
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user