This commit is contained in:
Lain Iwakura 2025-07-12 01:02:29 +03:00
parent 5470426373
commit 08800326da
No known key found for this signature in database
GPG Key ID: C7C18257F2ADC6F8

22
main.go
View File

@ -71,13 +71,10 @@ func wsHandler(w http.ResponseWriter, r *http.Request) {
func handler(w http.ResponseWriter, r *http.Request) { func handler(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/html; charset=utf-8") w.Header().Set("Content-Type", "text/html; charset=utf-8")
w.Header().Set("Server", "0BSD_FOR_EVERYONE")
query := r.URL.Query().Get("q") w.Header().Set("X-Powered-By", "0BSD_FOR_EVERYONE")
w.Header().Set("X-Frame-Options", "SAMEORIGIN")
if query == "lain" { w.Header().Set("X-Content-Type-Options", "nosniff")
http.Redirect(w, r, "https://fauux.neocities.org", http.StatusFound)
return
}
html := ` html := `
<!DOCTYPE html> <!DOCTYPE html>
@ -151,8 +148,17 @@ func main() {
mux := http.NewServeMux() mux := http.NewServeMux()
mux.HandleFunc("/", handler) mux.HandleFunc("/", handler)
mux.HandleFunc("/ws", wsHandler) mux.HandleFunc("/ws", wsHandler)
server := &http.Server{
Addr: ":" + p,
Handler: mux,
ReadTimeout: 30 * time.Second,
WriteTimeout: 30 * time.Second,
IdleTimeout: 60 * time.Second,
}
log.Printf("Сервер запущен на порту %s", p) log.Printf("Сервер запущен на порту %s", p)
if err := http.ListenAndServe(":"+p, mux); err != nil { if err := server.ListenAndServe(); err != nil {
log.Printf("Ошибка на порту %s: %v", p, err) log.Printf("Ошибка на порту %s: %v", p, err)
} }
}(port) }(port)