Skip to content

Commit

Permalink
add ruleset route
Browse files Browse the repository at this point in the history
  • Loading branch information
mms-gianni committed Nov 5, 2023
1 parent 07513f6 commit 34a2683
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ http://localhost:8080/raw/https://www.example.com
| `DISABLE_FORM` | Disables URL Form Frontpage | `false` |
| `FORM_PATH` | Path to custom Form HTML | `` |
| `RULESET` | URL to a ruleset file | `https://raw.githubusercontent.com/kubero-dev/ladder/main/ruleset.yaml` or `/path/to/my/rules.yaml` |
| `EXPOSE_RULESET` | Make your Ruleset available to other ladders | `true` |
| `ALLOWED_DOMAINS` | Comma separated list of allowed domains. Empty = no limitations | `` |
| `ALLOWED_DOMAINS_RULESET` | Allow Domains from Ruleset. false = no limitations | `false` |

Expand All @@ -117,7 +118,8 @@ See in [ruleset.yaml](ruleset.yaml) for an example.
alert("Hello!");
</script>
- domain: www.anotherdomain.com # Domain where the rule applies
path: /article # Path where the rule applies
paths: # Paths where the rule applies
- /article
googleCache: false # Search also in Google Cache
regexRules: # Regex rules to apply
- match: <script\s+([^>]*\s+)?src="(/)([^"]*)"
Expand Down
3 changes: 2 additions & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ func main() {
Default: pf,
Help: "This will spawn multiple processes listening"})

// Parse input
err := parser.Parse(os.Args)
if err != nil {
fmt.Print(parser.Usage(err))
Expand Down Expand Up @@ -74,9 +73,11 @@ func main() {
}

app.Get("/", handlers.Form)
app.Get("ruleset", handlers.Ruleset)

app.Get("raw/*", handlers.Raw)
app.Get("api/*", handlers.Api)
app.Get("ruleset", handlers.Raw)
app.Get("/*", handlers.ProxySite)

log.Fatal(app.Listen(":" + *port))
Expand Down
17 changes: 17 additions & 0 deletions handlers/ruleset.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package handlers

import (
"github.com/gofiber/fiber/v2"
"gopkg.in/yaml.v3"
)

func Ruleset(c *fiber.Ctx) error {

body, err := yaml.Marshal(rulesSet)
if err != nil {
c.SendStatus(fiber.StatusInternalServerError)
return c.SendString(err.Error())
}

return c.SendString(string(body))
}

0 comments on commit 34a2683

Please sign in to comment.