fix: avoid setting read limit on nil conn

This commit is contained in:
Anton Kovalenko 2024-05-13 23:38:48 +03:00
parent 075bee6a00
commit b27c9fe7bc

@ -173,11 +173,11 @@ func (h *Handler) LoadPeers(filename string) error {
func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
wsConn, err := websocket.Accept(w, r, nil) wsConn, err := websocket.Accept(w, r, nil)
wsConn.SetReadLimit(-1)
if err != nil { if err != nil {
log.WithField("client", r.RemoteAddr).Error(err) log.WithField("client", r.RemoteAddr).Error(err)
return return
} }
wsConn.SetReadLimit(-1)
go h.ServeWebSocket(wsConn, r.RemoteAddr) go h.ServeWebSocket(wsConn, r.RemoteAddr)
} }