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] 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
|
||||||
@@ -91,7 +96,8 @@ http://localhost:8080/raw/https://www.example.com
|
|||||||
| `LOG_URLS` | Log fetched URL's | `true` |
|
| `LOG_URLS` | Log fetched URL's | `true` |
|
||||||
| `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` 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` | 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="(/)([^"]*)"
|
||||||
|
|||||||
12
cmd/main.go
12
cmd/main.go
@@ -33,13 +33,19 @@ func main() {
|
|||||||
Help: "Port the webserver will listen on"})
|
Help: "Port the webserver will listen on"})
|
||||||
|
|
||||||
pf, _ := strconv.ParseBool(os.Getenv("PREFORK"))
|
pf, _ := strconv.ParseBool(os.Getenv("PREFORK"))
|
||||||
|
|
||||||
prefork := parser.Flag("P", "prefork", &argparse.Options{
|
prefork := parser.Flag("P", "prefork", &argparse.Options{
|
||||||
Required: false,
|
Required: false,
|
||||||
Default: pf,
|
Default: pf,
|
||||||
Help: "This will spawn multiple processes listening"})
|
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)
|
err := parser.Parse(os.Args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Print(parser.Usage(err))
|
fmt.Print(parser.Usage(err))
|
||||||
@@ -74,9 +80,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))
|
||||||
|
|||||||
@@ -17,8 +17,11 @@ import (
|
|||||||
|
|
||||||
var UserAgent = getenv("USER_AGENT", "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)")
|
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 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 allowedDomains = strings.Split(os.Getenv("ALLOWED_DOMAINS"), ",")
|
||||||
|
var Aaaa = "aaaa"
|
||||||
|
|
||||||
func ProxySite(c *fiber.Ctx) error {
|
func ProxySite(c *fiber.Ctx) error {
|
||||||
// Get the url from the URL
|
// Get the url from the URL
|
||||||
@@ -117,13 +120,18 @@ func getenv(key, fallback string) string {
|
|||||||
return value
|
return value
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadRules() RuleSet {
|
func LoadRules(rulesUrl string) RuleSet {
|
||||||
rulesUrl := os.Getenv("RULESET")
|
//rulesUrl := os.Getenv("RULESET")
|
||||||
if rulesUrl == "" {
|
if rulesUrl == "" {
|
||||||
RulesList := RuleSet{}
|
RulesList := RuleSet{}
|
||||||
return RulesList
|
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
|
var ruleSet RuleSet
|
||||||
if strings.HasPrefix(rulesUrl, "http") {
|
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