From bc02972eefe4c14a0a1cea874e987ebd2bb824a7 Mon Sep 17 00:00:00 2001 From: Tim Schuster Date: Thu, 16 Mar 2017 20:28:36 +0100 Subject: [PATCH] Added some useful middleware to stop server overloads and set default to enable insecure cookies --- config/config.go | 2 +- http/board/handler.go | 2 ++ http/server.go | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/config/config.go b/config/config.go index 3e161c0..2f8cac3 100644 --- a/config/config.go +++ b/config/config.go @@ -60,7 +60,7 @@ func Load() (*Config, error) { HostnameWhiteList: []string{}, ListenOn: ":8080", MasterSecret: "changeme", - DisableSecurity: false, + DisableSecurity: true, Captcha: CaptchaConfig{ Mode: CaptchaDisabled, }, diff --git a/http/board/handler.go b/http/board/handler.go index 4ed5ff3..64f7518 100644 --- a/http/board/handler.go +++ b/http/board/handler.go @@ -75,8 +75,10 @@ func LoadTemplates() error { func Router(r chi.Router) { r.Get("/", serveDir) r.Get("/dir.html", serveDir) + r.Get("/:board/", serveBoard) r.Get("/:board/board.html", serveBoard) r.Post("/:board/new_thread.sh", handleNewThread) + r.Get("/:board/:thread/", serveThread) r.Get("/:board/:thread/thread.html", serveThread) r.Get("/:board/:thread/:reply/:unused.png", serveFullImage) r.Get("/:board/:thread/:reply/thumb.png", serveThumb) diff --git a/http/server.go b/http/server.go index ad9d6f9..77ffada 100644 --- a/http/server.go +++ b/http/server.go @@ -35,6 +35,8 @@ func Start(config *config.Config) error { r.Use(middleware.Logger) r.Use(middleware.Recoverer) r.Use(middleware.CloseNotify) + r.Use(middleware.ThrottleBacklog(1000, 6000, 10*time.Second)) + r.Use(middleware.Heartbeat("/ping")) r.Use(middle.LimitSize(config)) r.Use(middleware.DefaultCompress)