3 Commits

Author SHA1 Message Date
Gianni Carafa
e3eb866d48 allow disabling Ruleset 2023-11-05 23:37:01 +01:00
Gianni Carafa
34a2683457 add ruleset route 2023-11-05 23:30:32 +01:00
Gianni Carafa
07513f6dc4 update README 2023-11-05 23:10:12 +01:00
3 changed files with 36 additions and 4 deletions

View File

@@ -21,15 +21,16 @@ Freedom of information is an essential pillar of democracy and informed decision
- [x] Fetch RAW HTML - [x] Fetch RAW HTML
- [x] Custom User Agent - [x] Custom User Agent
- [x] Custom X-Forwarded-For IP - [x] Custom X-Forwarded-For IP
- [x] [Docker container](https://github.com/kubero-dev/ladder/pkgs/container/ladder) - [x] [Docker container](https://github.com/kubero-dev/ladder/pkgs/container/ladder) (amd64, arm64)
- [x] Linux binary - [x] Linux binary
- [x] Mac OS binary - [x] Mac OS binary
- [x] Windows binary (untested) - [x] Windows binary (untested)
- [x] Removes most of the ads (unexpected side effect) - [x] Removes most of the ads (unexpected side effect ¯\_(ツ)_/¯ )
- [x] Basic Auth - [x] Basic Auth
- [x] Disable logs - [x] Disable logs
- [x] No Tracking - [x] No Tracking
- [x] Limit the proxy to a list of domains - [x] Limit the proxy to a list of domains
- [x] Expose Ruleset to other ladders
- [ ] Optional TOR proxy - [ ] Optional TOR proxy
- [ ] A key to share only one URL - [ ] A key to share only one URL
- [ ] Fetch from Google Cache if not available - [ ] Fetch from Google Cache if not available
@@ -77,6 +78,10 @@ curl -X GET "http://localhost:8080/api/https://www.example.com"
### RAW ### RAW
http://localhost:8080/raw/https://www.example.com http://localhost:8080/raw/https://www.example.com
### Running Ruleset
http://localhost:8080/ruleset
## Configuration ## Configuration
### Environment Variables ### Environment Variables
@@ -92,6 +97,7 @@ http://localhost:8080/raw/https://www.example.com
| `DISABLE_FORM` | Disables URL Form Frontpage | `false` | | `DISABLE_FORM` | Disables URL Form Frontpage | `false` |
| `FORM_PATH` | Path to custom Form HTML | `` | | `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` | | `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` | Comma separated list of allowed domains. Empty = no limitations | `` |
| `ALLOWED_DOMAINS_RULESET` | Allow Domains from Ruleset. false = no limitations | `false` | | `ALLOWED_DOMAINS_RULESET` | Allow Domains from Ruleset. false = no limitations | `false` |
@@ -117,7 +123,8 @@ See in [ruleset.yaml](ruleset.yaml) for an example.
alert("Hello!"); alert("Hello!");
</script> </script>
- domain: www.anotherdomain.com # Domain where the rule applies - 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 googleCache: false # Search also in Google Cache
regexRules: # Regex rules to apply regexRules: # Regex rules to apply
- match: <script\s+([^>]*\s+)?src="(/)([^"]*)" - match: <script\s+([^>]*\s+)?src="(/)([^"]*)"

View File

@@ -39,7 +39,6 @@ func main() {
Default: pf, Default: pf,
Help: "This will spawn multiple processes listening"}) Help: "This will spawn multiple processes listening"})
// Parse input
err := parser.Parse(os.Args) err := parser.Parse(os.Args)
if err != nil { if err != nil {
fmt.Print(parser.Usage(err)) fmt.Print(parser.Usage(err))
@@ -74,9 +73,11 @@ func main() {
} }
app.Get("/", handlers.Form) app.Get("/", handlers.Form)
app.Get("ruleset", handlers.Ruleset)
app.Get("raw/*", handlers.Raw) app.Get("raw/*", handlers.Raw)
app.Get("api/*", handlers.Api) app.Get("api/*", handlers.Api)
app.Get("ruleset", handlers.Raw)
app.Get("/*", handlers.ProxySite) app.Get("/*", handlers.ProxySite)
log.Fatal(app.Listen(":" + *port)) log.Fatal(app.Listen(":" + *port))

24
handlers/ruleset.go Normal file
View File

@@ -0,0 +1,24 @@
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)
return c.SendString(err.Error())
}
return c.SendString(string(body))
}