mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-16 11:42:43 +08:00
fix: h2 close panic
This commit is contained in:
parent
f100ce6a04
commit
47df97322d
|
@ -1,6 +1,7 @@
|
||||||
package vmess
|
package vmess
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"io"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -84,10 +85,16 @@ func (hc *h2Conn) Write(b []byte) (int, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (hc *h2Conn) Close() error {
|
func (hc *h2Conn) Close() error {
|
||||||
if err := hc.pwriter.Close(); err != nil {
|
if hc.pwriter != nil {
|
||||||
return err
|
if err := hc.pwriter.Close(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if err := hc.ClientConn.Shutdown(hc.res.Request.Context()); err != nil {
|
ctx := context.Background()
|
||||||
|
if hc.res != nil {
|
||||||
|
ctx = hc.res.Request.Context()
|
||||||
|
}
|
||||||
|
if err := hc.ClientConn.Shutdown(ctx); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return hc.Conn.Close()
|
return hc.Conn.Close()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user