A simple application to send CSP violation reports to an email address
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

44 lines
1.3 KiB

  1. /*
  2. * Copyright (C) 2019 bn4t
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  16. */
  17. package main
  18. import (
  19. "flag"
  20. "net/http"
  21. "github.com/labstack/echo/v4"
  22. )
  23. func main() {
  24. flag.StringVar(&Config.ConfigPath, "config", "./config.toml", "The config file for csp-handler.")
  25. flag.Parse()
  26. readConfig()
  27. // start the loop to reset the rate limit
  28. go rateLimitLoop()
  29. e := echo.New()
  30. e.POST("/report-uri/:domain", handleReport)
  31. e.GET("/", func(c echo.Context) error {
  32. return c.String(http.StatusOK, "This is a csp report handler. See https://git.bn4t.me/bn4t/csp-handler for more info.")
  33. })
  34. e.Logger.Fatal(e.Start(Config.BindTo))
  35. }