mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-05 08:56:49 -05:00
fix nil pointer deref at http upgrade transport hub
This commit is contained in:
parent
bf7684c790
commit
6cb780fea5
@ -34,6 +34,7 @@ func (s *server) Handle(conn net.Conn) (internet.Connection, error) {
|
|||||||
connection := strings.ToLower(req.Header.Get("Connection"))
|
connection := strings.ToLower(req.Header.Get("Connection"))
|
||||||
upgrade := strings.ToLower(req.Header.Get("Upgrade"))
|
upgrade := strings.ToLower(req.Header.Get("Upgrade"))
|
||||||
if connection != "upgrade" || upgrade != "websocket" {
|
if connection != "upgrade" || upgrade != "websocket" {
|
||||||
|
_ = conn.Close()
|
||||||
return nil, newError("unrecognized request")
|
return nil, newError("unrecognized request")
|
||||||
}
|
}
|
||||||
resp := &http.Response{
|
resp := &http.Response{
|
||||||
@ -48,6 +49,7 @@ func (s *server) Handle(conn net.Conn) (internet.Connection, error) {
|
|||||||
resp.Header.Set("Upgrade", "websocket")
|
resp.Header.Set("Upgrade", "websocket")
|
||||||
err = resp.Write(conn)
|
err = resp.Write(conn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
_ = conn.Close()
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return internet.Connection(conn), nil
|
return internet.Connection(conn), nil
|
||||||
@ -62,7 +64,6 @@ func (s *server) keepAccepting() {
|
|||||||
handledConn, err := s.Handle(conn)
|
handledConn, err := s.Handle(conn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
newError("failed to handle request").Base(err).WriteToLog()
|
newError("failed to handle request").Base(err).WriteToLog()
|
||||||
common.Must(handledConn.Close())
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
s.addConn(handledConn)
|
s.addConn(handledConn)
|
||||||
|
Loading…
Reference in New Issue
Block a user