1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-08-03 08:28:31 +00:00

Refuse connections if not enough RAM

This commit is contained in:
Kane York 2015-11-17 11:01:42 -08:00
parent 0c1d6ed725
commit da790fbaa6
4 changed files with 40 additions and 3 deletions

View file

@ -107,6 +107,13 @@ var BannerHTML []byte
// It either uses the SocketUpgrader or writes out the BannerHTML.
func HTTPHandleRootURL(w http.ResponseWriter, r *http.Request) {
if r.Header.Get("Connection") == "Upgrade" {
updateSysMem()
if Statistics.SysMemTotal-Statistics.SysMemFree < Configuration.MinMemoryBytes {
w.WriteHeader(503)
return
}
conn, err := SocketUpgrader.Upgrade(w, r, nil)
if err != nil {
fmt.Fprintf(w, "error: %v", err)