Merge pull request #776 from safing/fix/custom-filter-list-key

Improve custom filter list config key
This commit is contained in:
Daniel 2022-08-02 16:38:52 +02:00 committed by GitHub
commit fa830e4968
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 12 deletions

View file

@ -619,7 +619,7 @@ func checkCustomFilterList(_ context.Context, conn *network.Connection, p *profi
// block if the domain name appears in the custom filter list (check for subdomains if enabled)
if conn.Entity.Domain != "" {
if ok, match := customlists.LookupDomain(conn.Entity.Domain, p.FilterSubDomains()); ok {
conn.Deny(fmt.Sprintf("domain %s matches %s in custom filter list", conn.Entity.Domain, match), customlists.CfgOptionCustomListBlockingKey)
conn.Deny(fmt.Sprintf("domain %s matches %s in custom filter list", conn.Entity.Domain, match), customlists.CfgOptionCustomListFileKey)
return true
}
}
@ -628,7 +628,7 @@ func checkCustomFilterList(_ context.Context, conn *network.Connection, p *profi
if p.FilterCNAMEs() {
for _, cname := range conn.Entity.CNAME {
if ok, match := customlists.LookupDomain(cname, p.FilterSubDomains()); ok {
conn.Deny(fmt.Sprintf("domain alias (CNAME) %s matches %s in custom filter list", cname, match), customlists.CfgOptionCustomListBlockingKey)
conn.Deny(fmt.Sprintf("domain alias (CNAME) %s matches %s in custom filter list", cname, match), customlists.CfgOptionCustomListFileKey)
return true
}
}
@ -637,7 +637,7 @@ func checkCustomFilterList(_ context.Context, conn *network.Connection, p *profi
// block if ip addresses appears in the custom filter list
if conn.Entity.IP != nil {
if customlists.LookupIP(conn.Entity.IP) {
conn.Deny("IP address is in the custom filter list", customlists.CfgOptionCustomListBlockingKey)
conn.Deny("IP address is in the custom filter list", customlists.CfgOptionCustomListFileKey)
return true
}
}
@ -645,7 +645,7 @@ func checkCustomFilterList(_ context.Context, conn *network.Connection, p *profi
// block autonomous system by its number if it appears in the custom filter list
if conn.Entity.ASN != 0 {
if customlists.LookupASN(conn.Entity.ASN) {
conn.Deny("AS is in the custom filter list", customlists.CfgOptionCustomListBlockingKey)
conn.Deny("AS is in the custom filter list", customlists.CfgOptionCustomListFileKey)
return true
}
}
@ -653,7 +653,7 @@ func checkCustomFilterList(_ context.Context, conn *network.Connection, p *profi
// block if the country appears in the custom filter list
if conn.Entity.Country != "" {
if customlists.LookupCountry(conn.Entity.Country) {
conn.Deny("country is in the custom filter list", customlists.CfgOptionCustomListBlockingKey)
conn.Deny("country is in the custom filter list", customlists.CfgOptionCustomListFileKey)
return true
}
}

View file

@ -5,9 +5,9 @@ import (
)
var (
// CfgOptionCustomListBlockingKey is the config key for the listen address..
CfgOptionCustomListBlockingKey = "filter/customListBlocking"
cfgOptionCustomListBlockingOrder = 35
// CfgOptionCustomListFileKey is the config key for custom filter list file.
CfgOptionCustomListFileKey = "filter/customListFile"
cfgOptionCustomListFileOrder = 35
cfgOptionCustomListCategoryAnnotation = "Filter Lists"
)
@ -31,7 +31,7 @@ Please note that the custom filter list is fully loaded into memory. This can ha
// Register a setting for the file path in the ui
err := config.Register(&config.Option{
Name: "Custom Filter List",
Key: CfgOptionCustomListBlockingKey,
Key: CfgOptionCustomListFileKey,
Description: "Specify the file path to a custom filter list, which will be automatically refreshed. Any connections matching a domain, IP address, Country or ASN in the file will be blocked.",
Help: help,
OptType: config.OptTypeString,
@ -40,7 +40,7 @@ Please note that the custom filter list is fully loaded into memory. This can ha
DefaultValue: "",
RequiresRestart: false,
Annotations: config.Annotations{
config.DisplayOrderAnnotation: cfgOptionCustomListBlockingOrder,
config.DisplayOrderAnnotation: cfgOptionCustomListFileOrder,
config.CategoryAnnotation: cfgOptionCustomListCategoryAnnotation,
config.DisplayHintAnnotation: config.DisplayHintFilePicker,
},
@ -49,7 +49,7 @@ Please note that the custom filter list is fully loaded into memory. This can ha
return err
}
getFilePath = config.GetAsString(CfgOptionCustomListBlockingKey, "")
getFilePath = config.GetAsString(CfgOptionCustomListFileKey, "")
return nil
}

View file

@ -100,7 +100,7 @@ func parseFile(filePath string) error {
notifications.NotifyInfo(parseStatusNotificationID,
"Custom filter list loaded successfully.",
fmt.Sprintf(`Custom filter list loaded successfully from file %s - loaded:
fmt.Sprintf(`Custom filter list loaded from file %s:
%d Domains
%d IPs
%d Autonomous Systems