* Revert "MM-34000: Use non-epoll mode for TLS connections (#17172)"

This reverts commit 2743089b54.

* Revert "MM-33233: Fix double close of webconn pump (#17026)"

This reverts commit 0f98620b65.

* Revert "MM-33836: Detect and upgrade incorrect HTTP version for websocket handshakes (#17142)"

This reverts commit 4c5ea07aff.

* revert i18n

* Revert "MM-21012: Revamp websocket implementation (#16620)"

This reverts commit a246104d04.

* fix go.mod

* Trigger CI
Этот коммит содержится в:
Agniva De Sarker
2021-03-24 15:29:23 +05:30
коммит произвёл GitHub
родитель 6a65b6ceca
Коммит aba6471512
76 изменённых файлов: 61 добавлений и 9417 удалений

Просмотреть файл

@@ -5,12 +5,10 @@ package api4
import (
"net/http"
"time"
"github.com/gobwas/ws"
"github.com/gorilla/websocket"
"github.com/mattermost/mattermost-server/v5/model"
"github.com/mattermost/mattermost-server/v5/shared/mlog"
)
func (api *API) InitWebSocket() {
@@ -19,38 +17,23 @@ func (api *API) InitWebSocket() {
}
func connectWebSocket(c *Context, w http.ResponseWriter, r *http.Request) {
fn := c.App.OriginChecker()
if fn != nil && !fn(r) {
c.Err = model.NewAppError("origin_check", "api.web_socket.connect.check_origin.app_error", nil, "", http.StatusBadRequest)
return
upgrader := websocket.Upgrader{
ReadBufferSize: model.SOCKET_MAX_MESSAGE_SIZE_KB,
WriteBufferSize: model.SOCKET_MAX_MESSAGE_SIZE_KB,
CheckOrigin: c.App.OriginChecker(),
}
upgrader := ws.HTTPUpgrader{
Timeout: 5 * time.Second,
}
// Uprgade the HTTP version header to 1.1, if we detect a 1.0 header.
// This is a hack to work around a flaw in our proxy configs which sends the protocol version as 1.0.
// It will be removed in a future version.
if r.ProtoMajor == 1 && r.ProtoMinor == 0 {
r.ProtoMinor = 1
mlog.Warn("The HTTP version field was detected as 1.0 during WebSocket handshake. This is most probably due to an incorrect proxy configuration. Please upgrade your proxy config to set the header version to a minimum of 1.1.")
}
conn, _, _, err := upgrader.Upgrade(r, w)
ws, err := upgrader.Upgrade(w, r, nil)
if err != nil {
c.Err = model.NewAppError("connect", "api.web_socket.connect.upgrade.app_error", nil, err.Error(), http.StatusInternalServerError)
return
}
wc := c.App.NewWebConn(conn, *c.App.Session(), c.App.T, "")
wc := c.App.NewWebConn(ws, *c.App.Session(), c.App.T, "")
if c.App.Session().UserId != "" {
c.App.HubRegister(wc)
}
if !wc.Epoll() {
wc.BlockingPump()
} else {
go wc.Pump()
}
wc.Pump()
}