From e3eb866d483f521b2bfbb4bbfd642f6d3f6ee5a4 Mon Sep 17 00:00:00 2001 From: Gianni Carafa Date: Sun, 5 Nov 2023 23:37:01 +0100 Subject: [PATCH] allow disabling Ruleset --- README.md | 5 +++++ handlers/ruleset.go | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/README.md b/README.md index 97cb1d8..b5d249b 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ Freedom of information is an essential pillar of democracy and informed decision - [x] Disable logs - [x] No Tracking - [x] Limit the proxy to a list of domains +- [x] Expose Ruleset to other ladders - [ ] Optional TOR proxy - [ ] A key to share only one URL - [ ] Fetch from Google Cache if not available @@ -77,6 +78,10 @@ curl -X GET "http://localhost:8080/api/https://www.example.com" ### RAW http://localhost:8080/raw/https://www.example.com + +### Running Ruleset +http://localhost:8080/ruleset + ## Configuration ### Environment Variables diff --git a/handlers/ruleset.go b/handlers/ruleset.go index c716b3c..e15477b 100644 --- a/handlers/ruleset.go +++ b/handlers/ruleset.go @@ -1,12 +1,19 @@ package handlers import ( + "os" + "github.com/gofiber/fiber/v2" "gopkg.in/yaml.v3" ) func Ruleset(c *fiber.Ctx) error { + if os.Getenv("EXPOSE_RULESET") == "false" { + c.SendStatus(fiber.StatusForbidden) + return c.SendString("Rules Disabled") + } + body, err := yaml.Marshal(rulesSet) if err != nil { c.SendStatus(fiber.StatusInternalServerError)