Update config options, add options to turn off system notifications

This commit is contained in:
Daniel 2020-04-24 10:55:49 +02:00
parent 95041d217c
commit 5209a090c4
6 changed files with 63 additions and 16 deletions

View file

@ -11,6 +11,8 @@ import (
var ( var (
CfgDevModeKey = "core/devMode" CfgDevModeKey = "core/devMode"
defaultDevMode bool defaultDevMode bool
CfgUseSystemNotificationsKey = "core/useSystemNotifications"
) )
func init() { func init() {
@ -28,6 +30,7 @@ func registerConfig() error {
Name: "Development Mode", Name: "Development Mode",
Key: CfgDevModeKey, Key: CfgDevModeKey,
Description: "In Development Mode security restrictions are lifted/softened to enable easier access to Portmaster for debugging and testing purposes.", Description: "In Development Mode security restrictions are lifted/softened to enable easier access to Portmaster for debugging and testing purposes.",
Order: 127,
OptType: config.OptTypeBool, OptType: config.OptTypeBool,
ExpertiseLevel: config.ExpertiseLevelDeveloper, ExpertiseLevel: config.ExpertiseLevelDeveloper,
ReleaseLevel: config.ReleaseLevelStable, ReleaseLevel: config.ReleaseLevelStable,
@ -37,5 +40,19 @@ func registerConfig() error {
return err return err
} }
err = config.Register(&config.Option{
Name: "Use System Notifications",
Key: CfgUseSystemNotificationsKey,
Description: "Send notifications to your operating system's notification system. When this setting is turned off, notifications will only be visible in the Portmaster App. This affects both alerts from the Portmaster and questions from the Privacy Filter.",
Order: 32,
OptType: config.OptTypeBool,
ExpertiseLevel: config.ExpertiseLevelUser,
ReleaseLevel: config.ReleaseLevelStable,
DefaultValue: true, // TODO: turn off by default on unsupported systems
})
if err != nil {
return err
}
return nil return nil
} }

View file

@ -1,16 +1,23 @@
package firewall package firewall
import ( import (
"github.com/safing/portbase/api"
"github.com/safing/portbase/config" "github.com/safing/portbase/config"
"github.com/safing/portmaster/core"
) )
// Configuration Keys // Configuration Keys
var ( var (
CfgOptionEnableFilterKey = "filter/enable" CfgOptionEnableFilterKey = "filter/enable"
CfgOptionPromptTimeoutKey = "filter/promptTimeout" CfgOptionAskWithSystemNotificationsKey = "filter/askWithSystemNotifications"
CfgOptionPromptTimeoutOrder = 2 CfgOptionAskWithSystemNotificationsOrder = 2
promptTimeout config.IntOption askWithSystemNotifications config.BoolOption
useSystemNotifications config.BoolOption
CfgOptionAskTimeoutKey = "filter/askTimeout"
CfgOptionAskTimeoutOrder = 3
askTimeout config.IntOption
CfgOptionPermanentVerdictsKey = "filter/permanentVerdicts" CfgOptionPermanentVerdictsKey = "filter/permanentVerdicts"
CfgOptionPermanentVerdictsOrder = 128 CfgOptionPermanentVerdictsOrder = 128
@ -37,22 +44,38 @@ func registerConfig() error {
permanentVerdicts = config.Concurrent.GetAsBool(CfgOptionPermanentVerdictsKey, true) permanentVerdicts = config.Concurrent.GetAsBool(CfgOptionPermanentVerdictsKey, true)
err = config.Register(&config.Option{ err = config.Register(&config.Option{
Name: "Timeout for prompt notifications", Name: "Ask with System Notifications",
Key: CfgOptionPromptTimeoutKey, Key: CfgOptionAskWithSystemNotificationsKey,
Description: "Amount of time how long Portmaster will wait for a response when prompting about a connection via a notification. In seconds.", Description: `Ask about connections using your operating system's notification system. For this to be enabled, the setting "Use System Notifications" must enabled too. This only affects questions from the Privacy Filter, and does not affect alerts from the Portmaster.`,
Order: CfgOptionPromptTimeoutOrder, Order: CfgOptionAskWithSystemNotificationsOrder,
OptType: config.OptTypeBool,
ExpertiseLevel: config.ExpertiseLevelUser,
ReleaseLevel: config.ReleaseLevelStable,
DefaultValue: true,
})
if err != nil {
return err
}
askWithSystemNotifications = config.Concurrent.GetAsBool(CfgOptionAskWithSystemNotificationsKey, true)
useSystemNotifications = config.Concurrent.GetAsBool(core.CfgUseSystemNotificationsKey, true)
err = config.Register(&config.Option{
Name: "Timeout for Ask Notifications",
Key: CfgOptionAskTimeoutKey,
Description: "Amount of time (in seconds) how long the Portmaster will wait for a response when prompting about a connection via a notification. Please note that system notifications might not respect this or have it's own limits.",
Order: CfgOptionAskTimeoutOrder,
OptType: config.OptTypeInt, OptType: config.OptTypeInt,
ExpertiseLevel: config.ExpertiseLevelUser, ExpertiseLevel: config.ExpertiseLevelUser,
ReleaseLevel: config.ReleaseLevelBeta, ReleaseLevel: config.ReleaseLevelStable,
DefaultValue: 60, DefaultValue: 60,
}) })
if err != nil { if err != nil {
return err return err
} }
promptTimeout = config.Concurrent.GetAsInt(CfgOptionPromptTimeoutKey, 60) askTimeout = config.Concurrent.GetAsInt(CfgOptionAskTimeoutKey, 60)
devMode = config.Concurrent.GetAsBool("core/devMode", false) devMode = config.Concurrent.GetAsBool(core.CfgDevModeKey, false)
apiListenAddress = config.GetAsString("api/listenAddress", "") apiListenAddress = config.GetAsString(api.CfgDefaultListenAddressKey, "")
return nil return nil
} }

View file

@ -26,16 +26,16 @@ const (
) )
func prompt(conn *network.Connection, pkt packet.Packet) { //nolint:gocognit // TODO func prompt(conn *network.Connection, pkt packet.Packet) { //nolint:gocognit // TODO
nTTL := time.Duration(promptTimeout()) * time.Second nTTL := time.Duration(askTimeout()) * time.Second
// first check if there is an existing notification for this. // first check if there is an existing notification for this.
// build notification ID // build notification ID
var nID string var nID string
switch { switch {
case conn.Inbound, conn.Entity.Domain == "": // connection to/from IP case conn.Inbound, conn.Entity.Domain == "": // connection to/from IP
nID = fmt.Sprintf("firewall-prompt-%d-%s-%s", conn.Process().Pid, conn.Scope, pkt.Info().RemoteIP()) nID = fmt.Sprintf("filter:prompt-%d-%s-%s", conn.Process().Pid, conn.Scope, pkt.Info().RemoteIP())
default: // connection to domain default: // connection to domain
nID = fmt.Sprintf("firewall-prompt-%d-%s", conn.Process().Pid, conn.Scope) nID = fmt.Sprintf("filter:prompt-%d-%s", conn.Process().Pid, conn.Scope)
} }
n := notifications.Get(nID) n := notifications.Get(nID)
saveResponse := true saveResponse := true

View file

@ -17,6 +17,7 @@ func registerConfiguration() error {
Name: "Enable Process Detection", Name: "Enable Process Detection",
Key: CfgOptionEnableProcessDetectionKey, Key: CfgOptionEnableProcessDetectionKey,
Description: "This option enables the attribution of network traffic to processes. This should be always enabled, and effectively disables app profiles if disabled.", Description: "This option enables the attribution of network traffic to processes. This should be always enabled, and effectively disables app profiles if disabled.",
Order: 144,
OptType: config.OptTypeBool, OptType: config.OptTypeBool,
ExpertiseLevel: config.ExpertiseLevelDeveloper, ExpertiseLevel: config.ExpertiseLevelDeveloper,
DefaultValue: true, DefaultValue: true,

View file

@ -300,7 +300,7 @@ Examples:
err = config.Register(&config.Option{ err = config.Register(&config.Option{
Name: "Block Peer to Peer Connections", Name: "Block Peer to Peer Connections",
Key: CfgOptionBlockP2PKey, Key: CfgOptionBlockP2PKey,
Description: "Block peer to peer connections. These are connections that are established directly to an IP address on the Internet without resolving a domain name via DNS first.", Description: "These are connections that are established directly to an IP address on the Internet without resolving a domain name via DNS first.",
Order: cfgOptionBlockP2POrder, Order: cfgOptionBlockP2POrder,
OptType: config.OptTypeInt, OptType: config.OptTypeInt,
ExternalOptType: "security level", ExternalOptType: "security level",
@ -317,7 +317,7 @@ Examples:
err = config.Register(&config.Option{ err = config.Register(&config.Option{
Name: "Block Inbound Connections", Name: "Block Inbound Connections",
Key: CfgOptionBlockInboundKey, Key: CfgOptionBlockInboundKey,
Description: "Block inbound connections to your device. This will usually only be the case if you are running a network service or are using peer to peer software.", Description: "Connections initiated towards your device. This will usually only be the case if you are running a network service or are using peer to peer software.",
Order: cfgOptionBlockInboundOrder, Order: cfgOptionBlockInboundOrder,
OptType: config.OptTypeInt, OptType: config.OptTypeInt,
ExternalOptType: "security level", ExternalOptType: "security level",

View file

@ -8,6 +8,10 @@ import (
"github.com/safing/portbase/log" "github.com/safing/portbase/log"
) )
const (
cfgDevModeKey = "core/devMode"
)
var ( var (
releaseChannel config.StringOption releaseChannel config.StringOption
devMode config.BoolOption devMode config.BoolOption
@ -23,6 +27,7 @@ func registerConfig() error {
Name: "Release Channel", Name: "Release Channel",
Key: releaseChannelKey, Key: releaseChannelKey,
Description: "The Release Channel changes which updates are applied. When using beta, you will receive new features earlier and Portmaster will update more frequently. Some beta or experimental features are also available in the stable release channel.", Description: "The Release Channel changes which updates are applied. When using beta, you will receive new features earlier and Portmaster will update more frequently. Some beta or experimental features are also available in the stable release channel.",
Order: 1,
OptType: config.OptTypeString, OptType: config.OptTypeString,
ExpertiseLevel: config.ExpertiseLevelExpert, ExpertiseLevel: config.ExpertiseLevelExpert,
ReleaseLevel: config.ReleaseLevelBeta, ReleaseLevel: config.ReleaseLevelBeta,
@ -39,6 +44,7 @@ func registerConfig() error {
Name: "Disable Updates", Name: "Disable Updates",
Key: disableUpdatesKey, Key: disableUpdatesKey,
Description: "Disable automatic updates.", Description: "Disable automatic updates.",
Order: 64,
OptType: config.OptTypeBool, OptType: config.OptTypeBool,
ExpertiseLevel: config.ExpertiseLevelExpert, ExpertiseLevel: config.ExpertiseLevelExpert,
ReleaseLevel: config.ReleaseLevelStable, ReleaseLevel: config.ReleaseLevelStable,