diff --git a/service/updates/module.go b/service/updates/module.go index 607a5512..8b04d3db 100644 --- a/service/updates/module.go +++ b/service/updates/module.go @@ -21,6 +21,7 @@ const ( updateTaskRepeatDuration = 1 * time.Hour noNewUpdateNotificationID = "updates:no-new-update" updateAvailableNotificationID = "updates:update-available" + restartRequiredNotificationID = "updates:restart-required" updateFailedNotificationID = "updates:update-failed" corruptInstallationNotificationID = "updates:corrupt-installation" @@ -216,11 +217,19 @@ func (u *Updater) updateAndUpgrade(w *mgr.WorkerCtx, indexURLs []string, ignoreV if err := index.ShouldUpgradeTo(downloader.index); err != nil { log.Infof("updates/%s: no new or eligible update: %s", u.cfg.Name, err) if u.cfg.Notify && u.instance.Notifications() != nil { - u.instance.Notifications().NotifyInfo( - noNewUpdateNotificationID, - "No Updates Available", - "Portmaster v"+u.index.Version+" is the newest version.", - ) + u.instance.Notifications().Notify(¬ifications.Notification{ + EventID: noNewUpdateNotificationID, + Type: notifications.Info, + Title: "Portmaster Is Up-To-Date", + Message: "Portmaster v" + index.Version + " is the newest version.", + Expires: time.Now().Add(1 * time.Minute).Unix(), + AvailableActions: []*notifications.Action{ + { + ID: "ack", + Text: "OK", + }, + }, + }) } return ErrNoUpdateAvailable } @@ -229,20 +238,27 @@ func (u *Updater) updateAndUpgrade(w *mgr.WorkerCtx, indexURLs []string, ignoreV // Check if automatic downloads are enabled. if !u.cfg.AutoDownload && !forceApply { if u.cfg.Notify && u.instance.Notifications() != nil { - u.instance.Notifications().NotifyInfo( - updateAvailableNotificationID, - "New Update", - "Portmaster v"+downloader.index.Version+" is available. Click Upgrade to download and upgrade now.", - notifications.Action{ - ID: "upgrade", - Text: "Upgrade Now", - Type: notifications.ActionTypeWebhook, - Payload: notifications.ActionTypeWebhookPayload{ - Method: "POST", - URL: "updates/apply", + u.instance.Notifications().Notify(¬ifications.Notification{ + EventID: updateAvailableNotificationID, + Type: notifications.Info, + Title: "New Update Available", + Message: "Portmaster v" + downloader.index.Version + " is available. Click Upgrade to download and upgrade now.", + AvailableActions: []*notifications.Action{ + { + ID: "ack", + Text: "OK", + }, + { + ID: "upgrade", + Text: "Upgrade Now", + Type: notifications.ActionTypeWebhook, + Payload: notifications.ActionTypeWebhookPayload{ + Method: "POST", + URL: "updates/apply", + }, }, }, - ) + }) } return fmt.Errorf("%w: apply updates to download and upgrade", ErrActionRequired) } @@ -267,20 +283,27 @@ func (u *Updater) updateAndUpgrade(w *mgr.WorkerCtx, indexURLs []string, ignoreV // Notify the user that an upgrade is available. if !u.cfg.AutoApply && !forceApply { if u.cfg.Notify && u.instance.Notifications() != nil { - u.instance.Notifications().NotifyInfo( - updateAvailableNotificationID, - "New Update", - "Portmaster v"+downloader.index.Version+" is available. Click Upgrade to upgrade now.", - notifications.Action{ - ID: "upgrade", - Text: "Upgrade Now", - Type: notifications.ActionTypeWebhook, - Payload: notifications.ActionTypeWebhookPayload{ - Method: "POST", - URL: "updates/apply", + u.instance.Notifications().Notify(¬ifications.Notification{ + EventID: updateAvailableNotificationID, + Type: notifications.Info, + Title: "New Update Ready", + Message: "Portmaster v" + downloader.index.Version + " is available. Click Upgrade to upgrade now.", + AvailableActions: []*notifications.Action{ + { + ID: "ack", + Text: "OK", + }, + { + ID: "upgrade", + Text: "Upgrade Now", + Type: notifications.ActionTypeWebhook, + Payload: notifications.ActionTypeWebhookPayload{ + Method: "POST", + URL: "updates/apply", + }, }, }, - ) + }) } return fmt.Errorf("%w: apply updates to download and upgrade", ErrActionRequired) } @@ -307,6 +330,29 @@ func (u *Updater) updateAndUpgrade(w *mgr.WorkerCtx, indexURLs []string, ignoreV // Notify user that a restart is required. if u.cfg.Notify && u.instance.Notifications() != nil { + + u.instance.Notifications().Notify(¬ifications.Notification{ + EventID: restartRequiredNotificationID, + Type: notifications.Info, + Title: "Restart Required", + Message: "Portmaster v" + downloader.index.Version + " is installed. Restart to use new version.", + AvailableActions: []*notifications.Action{ + { + ID: "ack", + Text: "Later", + }, + { + ID: "restart", + Text: "Restart Now", + Type: notifications.ActionTypeWebhook, + Payload: notifications.ActionTypeWebhookPayload{ + Method: "POST", + URL: "updates/apply", + }, + }, + }, + }) + u.instance.Notifications().NotifyInfo( updateAvailableNotificationID, "Restart Required", diff --git a/service/updates/signing.go b/service/updates/signing.go deleted file mode 100644 index 71e66a5f..00000000 --- a/service/updates/signing.go +++ /dev/null @@ -1,29 +0,0 @@ -package updates - -import "github.com/safing/jess" - -var ( - // BinarySigningKeys holds the signing keys in text format. - BinarySigningKeys = []string{ - // Safing Code Signing Key #1 - "recipient:public-ed25519-key:safing-code-signing-key-1:92bgBLneQUWrhYLPpBDjqHbpFPuNVCPAaivQ951A4aq72HcTiw7R1QmPJwFM1mdePAvEVDjkeb8S4fp2pmRCsRa8HrCvWQEjd88rfZ6TznJMfY4g7P8ioGFjfpyx2ZJ8WCZJG5Qt4Z9nkabhxo2Nbi3iywBTYDLSbP5CXqi7jryW7BufWWuaRVufFFzhwUC2ryWFWMdkUmsAZcvXwde4KLN9FrkWAy61fGaJ8GCwGnGCSitANnU2cQrsGBXZzxmzxwrYD", - // Safing Code Signing Key #2 - "recipient:public-ed25519-key:safing-code-signing-key-2:92bgBLneQUWrhYLPpBDjqHbPC2d1o5JMyZFdavWBNVtdvbPfzDewLW95ScXfYPHd3QvWHSWCtB4xpthaYWxSkK1kYiGp68DPa2HaU8yQ5dZhaAUuV4Kzv42pJcWkCeVnBYqgGBXobuz52rFqhDJy3rz7soXEmYhJEJWwLwMeioK3VzN3QmGSYXXjosHMMNC76rjufSoLNtUQUWZDSnHmqbuxbKMCCsjFXUGGhtZVyb7bnu7QLTLk6SKHBJDMB6zdL9sw3", - } - - // BinarySigningTrustStore is an in-memory trust store with the signing keys. - BinarySigningTrustStore = jess.NewMemTrustStore() -) - -func init() { - for _, signingKey := range BinarySigningKeys { - rcpt, err := jess.RecipientFromTextFormat(signingKey) - if err != nil { - panic(err) - } - err = BinarySigningTrustStore.StoreSignet(rcpt) - if err != nil { - panic(err) - } - } -}