mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-03 07:56:42 -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"))
|
||||
upgrade := strings.ToLower(req.Header.Get("Upgrade"))
|
||||
if connection != "upgrade" || upgrade != "websocket" {
|
||||
_ = conn.Close()
|
||||
return nil, newError("unrecognized request")
|
||||
}
|
||||
resp := &http.Response{
|
||||
@ -48,6 +49,7 @@ func (s *server) Handle(conn net.Conn) (internet.Connection, error) {
|
||||
resp.Header.Set("Upgrade", "websocket")
|
||||
err = resp.Write(conn)
|
||||
if err != nil {
|
||||
_ = conn.Close()
|
||||
return nil, err
|
||||
}
|
||||
return internet.Connection(conn), nil
|
||||
@ -62,7 +64,6 @@ func (s *server) keepAccepting() {
|
||||
handledConn, err := s.Handle(conn)
|
||||
if err != nil {
|
||||
newError("failed to handle request").Base(err).WriteToLog()
|
||||
common.Must(handledConn.Close())
|
||||
continue
|
||||
}
|
||||
s.addConn(handledConn)
|
||||
|
Loading…
Reference in New Issue
Block a user