Compare commits
4 Commits
v0.0.10
...
feature/ad
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
797a33068d | ||
|
|
e3eb866d48 | ||
|
|
34a2683457 | ||
|
|
07513f6dc4 |
0
.github/pull_request_template.md
vendored
Normal file
0
.github/pull_request_template.md
vendored
Normal file
15
README.md
15
README.md
@@ -21,15 +21,16 @@ Freedom of information is an essential pillar of democracy and informed decision
|
||||
- [x] Fetch RAW HTML
|
||||
- [x] Custom User Agent
|
||||
- [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] Mac OS binary
|
||||
- [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] 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
|
||||
@@ -91,7 +96,8 @@ http://localhost:8080/raw/https://www.example.com
|
||||
| `LOG_URLS` | Log fetched URL's | `true` |
|
||||
| `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` |
|
||||
| `RULESET` | URL to a ruleset file | `https://raw.githubusercontent.com/kubero-dev/ladder/main/ruleset.yaml` or `/path/to/my/rules.yaml` or `default` |
|
||||
| `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` |
|
||||
|
||||
@@ -117,7 +123,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="(/)([^"]*)"
|
||||
|
||||
12
cmd/main.go
12
cmd/main.go
@@ -33,13 +33,19 @@ func main() {
|
||||
Help: "Port the webserver will listen on"})
|
||||
|
||||
pf, _ := strconv.ParseBool(os.Getenv("PREFORK"))
|
||||
|
||||
prefork := parser.Flag("P", "prefork", &argparse.Options{
|
||||
Required: false,
|
||||
Default: pf,
|
||||
Help: "This will spawn multiple processes listening"})
|
||||
|
||||
// Parse input
|
||||
r := os.Getenv("RULESET")
|
||||
ruleset := parser.String("r", "ruleset", &argparse.Options{
|
||||
Required: false,
|
||||
Default: r,
|
||||
Help: "Path or URL to your ruleset"})
|
||||
|
||||
handlers.LoadRules(*ruleset)
|
||||
|
||||
err := parser.Parse(os.Args)
|
||||
if err != nil {
|
||||
fmt.Print(parser.Usage(err))
|
||||
@@ -74,9 +80,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))
|
||||
|
||||
@@ -17,8 +17,11 @@ import (
|
||||
|
||||
var UserAgent = getenv("USER_AGENT", "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)")
|
||||
var ForwardedFor = getenv("X_FORWARDED_FOR", "66.249.66.1")
|
||||
var rulesSet = loadRules()
|
||||
var rulesSet RuleSet
|
||||
|
||||
// var rulesSet = loadRules()
|
||||
var allowedDomains = strings.Split(os.Getenv("ALLOWED_DOMAINS"), ",")
|
||||
var Aaaa = "aaaa"
|
||||
|
||||
func ProxySite(c *fiber.Ctx) error {
|
||||
// Get the url from the URL
|
||||
@@ -117,13 +120,18 @@ func getenv(key, fallback string) string {
|
||||
return value
|
||||
}
|
||||
|
||||
func loadRules() RuleSet {
|
||||
rulesUrl := os.Getenv("RULESET")
|
||||
func LoadRules(rulesUrl string) RuleSet {
|
||||
//rulesUrl := os.Getenv("RULESET")
|
||||
if rulesUrl == "" {
|
||||
RulesList := RuleSet{}
|
||||
return RulesList
|
||||
}
|
||||
log.Println("Loading rules")
|
||||
|
||||
if rulesUrl == "default" {
|
||||
rulesUrl = "https://raw.githubusercontent.com/kubero-dev/ladder/main/ruleset.yaml"
|
||||
}
|
||||
|
||||
log.Println("Loading rules: " + rulesUrl)
|
||||
|
||||
var ruleSet RuleSet
|
||||
if strings.HasPrefix(rulesUrl, "http") {
|
||||
|
||||
24
handlers/ruleset.go
Normal file
24
handlers/ruleset.go
Normal 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))
|
||||
}
|
||||
Reference in New Issue
Block a user