dkforest

A forum and chat platform (onion)
git clone https://git.dasho.dev/n0tr1v/dkforest.git
Log | Files | Refs | LICENSE

commit e59b23c8400f806b71fd436e959fe443cac804b1
parent 0fa59d66a785862a7acc78276a6775fd0632e79c
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Fri, 24 Mar 2023 18:58:27 -0700

reset stats button

Diffstat:
Mpkg/web/handlers/admin.go | 12++++++++++++
Mpkg/web/public/views/pages/admin/ddos.gohtml | 4++++
Mpkg/web/web.go | 1+
3 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/pkg/web/handlers/admin.go b/pkg/web/handlers/admin.go @@ -332,6 +332,18 @@ func IgnoredHandler(c echo.Context) error { } func DdosHandler(c echo.Context) error { + if c.Request().Method == http.MethodPost { + config.SignupPageLoad.Store(0) + config.SignupFailed.Store(0) + config.SignupSucceed.Store(0) + config.BHCCaptchaGenerated.Store(0) + config.BHCCaptchaSuccess.Store(0) + config.BHCCaptchaFailed.Store(0) + config.CaptchaRequiredGenerated.Store(0) + config.CaptchaRequiredSuccess.Store(0) + config.CaptchaRequiredFailed.Store(0) + return c.Redirect(http.StatusFound, "/admin/ddos") + } var data adminDdosData data.ActiveTab = "ddos" data.RPS = config.RpsCounter.Rate() diff --git a/pkg/web/public/views/pages/admin/ddos.gohtml b/pkg/web/public/views/pages/admin/ddos.gohtml @@ -17,5 +17,9 @@ <tr><td>Captcha required success</td><td>{{ .Data.CaptchaRequiredSuccess }}</td></tr> <tr><td>Captcha required failed</td><td>{{ .Data.CaptchaRequiredFailed }}</td></tr> </table> + <form method="post"> + <input type="hidden" name="csrf" value="{{ .CSRF }}" /> + <button type="submit" class="btn btn-primary btn-sm">Reset counters</button> + </form> </div> {{ end }} \ No newline at end of file diff --git a/pkg/web/web.go b/pkg/web/web.go @@ -236,6 +236,7 @@ func getMainServer(db *database.DkfDB, i18nBundle *i18n.Bundle, renderer *tmp.Te adminGroup.GET("/admin/backup", handlers.BackupHandler) adminGroup.POST("/admin/backup", handlers.BackupHandler) adminGroup.GET("/admin/ddos", handlers.DdosHandler) + adminGroup.POST("/admin/ddos", handlers.DdosHandler) adminGroup.GET("/admin/audits", handlers.AdminAuditsHandler) adminGroup.POST("/admin/users/:userID/delete", handlers.AdminDeleteUserHandler) adminGroup.GET("/admin/users/:userID/security-logs", handlers.AdminUserSecurityLogsHandler)