diff --git a/main.go b/main.go index cb8d604..b58485b 100644 --- a/main.go +++ b/main.go @@ -8,7 +8,6 @@ import ( "log" "net/http" "os" - "path/filepath" "strings" "sync" "time" @@ -60,8 +59,6 @@ func wsHandler(w http.ResponseWriter, r *http.Request) { var buffer string var lastPress time.Time - var messageCount int - startTime := time.Now() for { var keyPress KeyPress @@ -76,15 +73,6 @@ func wsHandler(w http.ResponseWriter, r *http.Request) { } lastPress = now - messageCount++ - if messageCount > 1000 || now.Sub(startTime) > 10*time.Minute { - break - } - - if len(keyPress.Key) > 1 { - continue - } - buffer += keyPress.Key if len(buffer) > 20 { @@ -155,33 +143,11 @@ func wsHandler(w http.ResponseWriter, r *http.Request) { func trollingHandler(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "text/html; charset=utf-8") w.Header().Set("Server", "0BSD_FOR_EVERYONE") - w.Header().Set("X-Content-Type-Options", "nosniff") - w.Header().Set("X-Frame-Options", "DENY") - w.Header().Set("Referrer-Policy", "no-referrer") - filePath := filepath.Clean("files/trolling.gif") - if !strings.HasPrefix(filePath, "files/") { - http.Error(w, "Forbidden", http.StatusForbidden) - return - } - - fileInfo, err := os.Stat(filePath) + fileContent, err := os.ReadFile("files/trolling.gif") if err != nil { log.Printf("Ошибка чтения файла: %v", err) - http.Error(w, "File not found", http.StatusNotFound) - return - } - - if fileInfo.Size() > 10*1024*1024 { - http.Error(w, "File too large", http.StatusRequestEntityTooLarge) - return - } - - fileContent, err := os.ReadFile(filePath) - if err != nil { - log.Printf("Ошибка чтения файла: %v", err) - http.Error(w, "Internal server error", http.StatusInternalServerError) - return + fileContent = []byte("Файл не найден") } base64Content := base64.StdEncoding.EncodeToString(fileContent) @@ -191,7 +157,6 @@ func trollingHandler(w http.ResponseWriter, r *http.Request) {