mirror of
https://github.com/safing/portmaster
synced 2025-09-02 02:29:12 +00:00
Improve custom filter list config key
This commit is contained in:
parent
e0e729230a
commit
5c6fc6ee9c
3 changed files with 12 additions and 12 deletions
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue