Skip to content

Commit

Permalink
include all subdomains
Browse files Browse the repository at this point in the history
  • Loading branch information
mms-gianni committed Nov 9, 2023
1 parent 6c1f58e commit 81aa00c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,13 @@ It is possible to apply custom rules to modify the response. This can be used to
See in [ruleset.yaml](ruleset.yaml) for an example.

```yaml
- domain: www.example.com
- domain: example.com # Inbcludes all subdomains
domains: # Additional domains to apply the rule
- www.example.com
- www.example.de
- www.beispiel.de
headers:
x-forwarded-for: none # override X-Forwarded-For header or delete with none
referer: none # override Referer header or delete with none
referer: none # override Referer header or delete with none
user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36
cookie: privacy=1
regexRules:
Expand Down
6 changes: 4 additions & 2 deletions handlers/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,11 @@ func fetchRule(domain string, path string) Rule {
rule := Rule{}
for _, rule := range rulesSet {
domains := rule.Domains
domains = append(domains, rule.Domain)
if rule.Domain != "" {
domains = append(domains, rule.Domain)
}
for _, ruleDomain := range domains {
if ruleDomain == domain {
if ruleDomain == domain || strings.HasSuffix(domain, ruleDomain) {
if len(rule.Paths) > 0 && !StringInSlice(path, rule.Paths) {
continue
}
Expand Down
2 changes: 1 addition & 1 deletion handlers/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ type Regex struct {
type RuleSet []Rule

type Rule struct {
Domain string `yaml:"domain"`
Domain string `yaml:"domain,omitempty"`
Domains []string `yaml:"domains,omitempty"`
Paths []string `yaml:"paths,omitempty"`
Headers struct {
Expand Down
6 changes: 2 additions & 4 deletions ruleset.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
- domain: www.example.com
- domain: example.com
domains:
- www.beispiel.de
googleCache: true
Expand Down Expand Up @@ -156,9 +156,7 @@
headimage.forEach(image => { image.style.filter = ''; });
});
</script>
- domain: www.medium.com
domains:
- medium.com
- domain: medium.com
headers:
referer: https://t.co/x?amp=1
x-forwarded-for: none
Expand Down

0 comments on commit 81aa00c

Please sign in to comment.