include all subdomains

This commit is contained in:
Gianni Carafa
2023-11-09 23:51:36 +01:00
parent 6c1f58e2e7
commit 81aa00c2ea
4 changed files with 10 additions and 10 deletions

View File

@@ -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. See in [ruleset.yaml](ruleset.yaml) for an example.
```yaml ```yaml
- domain: www.example.com - domain: example.com # Inbcludes all subdomains
domains: # Additional domains to apply the rule domains: # Additional domains to apply the rule
- www.example.com - www.example.de
- www.beispiel.de - www.beispiel.de
headers: headers:
x-forwarded-for: none # override X-Forwarded-For header or delete with none 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 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 cookie: privacy=1
regexRules: regexRules:

View File

@@ -209,9 +209,11 @@ func fetchRule(domain string, path string) Rule {
rule := Rule{} rule := Rule{}
for _, rule := range rulesSet { for _, rule := range rulesSet {
domains := rule.Domains domains := rule.Domains
domains = append(domains, rule.Domain) if rule.Domain != "" {
domains = append(domains, rule.Domain)
}
for _, ruleDomain := range domains { for _, ruleDomain := range domains {
if ruleDomain == domain { if ruleDomain == domain || strings.HasSuffix(domain, ruleDomain) {
if len(rule.Paths) > 0 && !StringInSlice(path, rule.Paths) { if len(rule.Paths) > 0 && !StringInSlice(path, rule.Paths) {
continue continue
} }

View File

@@ -8,7 +8,7 @@ type Regex struct {
type RuleSet []Rule type RuleSet []Rule
type Rule struct { type Rule struct {
Domain string `yaml:"domain"` Domain string `yaml:"domain,omitempty"`
Domains []string `yaml:"domains,omitempty"` Domains []string `yaml:"domains,omitempty"`
Paths []string `yaml:"paths,omitempty"` Paths []string `yaml:"paths,omitempty"`
Headers struct { Headers struct {

View File

@@ -1,4 +1,4 @@
- domain: www.example.com - domain: example.com
domains: domains:
- www.beispiel.de - www.beispiel.de
googleCache: true googleCache: true
@@ -156,9 +156,7 @@
headimage.forEach(image => { image.style.filter = ''; }); headimage.forEach(image => { image.style.filter = ''; });
}); });
</script> </script>
- domain: www.medium.com - domain: medium.com
domains:
- medium.com
headers: headers:
referer: https://t.co/x?amp=1 referer: https://t.co/x?amp=1
x-forwarded-for: none x-forwarded-for: none