updated
This commit is contained in:
parent
5470426373
commit
08800326da
22
main.go
22
main.go
@ -71,13 +71,10 @@ func wsHandler(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
func handler(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||
|
||||
query := r.URL.Query().Get("q")
|
||||
|
||||
if query == "lain" {
|
||||
http.Redirect(w, r, "https://fauux.neocities.org", http.StatusFound)
|
||||
return
|
||||
}
|
||||
w.Header().Set("Server", "0BSD_FOR_EVERYONE")
|
||||
w.Header().Set("X-Powered-By", "0BSD_FOR_EVERYONE")
|
||||
w.Header().Set("X-Frame-Options", "SAMEORIGIN")
|
||||
w.Header().Set("X-Content-Type-Options", "nosniff")
|
||||
|
||||
html := `
|
||||
<!DOCTYPE html>
|
||||
@ -151,8 +148,17 @@ func main() {
|
||||
mux := http.NewServeMux()
|
||||
mux.HandleFunc("/", handler)
|
||||
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)
|
||||
if err := http.ListenAndServe(":"+p, mux); err != nil {
|
||||
if err := server.ListenAndServe(); err != nil {
|
||||
log.Printf("Ошибка на порту %s: %v", p, err)
|
||||
}
|
||||
}(port)
|
||||
|
Loading…
x
Reference in New Issue
Block a user