11using System ;
22using System . Collections . Generic ;
33using System . ComponentModel . DataAnnotations ;
4+ using System . Runtime . InteropServices ;
45using System . Threading ;
56using System . Threading . Tasks ;
67using Coder . Desktop . App . ViewModels ;
@@ -43,7 +44,7 @@ public class UpdaterConfig
4344 public bool EnableUpdater { get ; set ; } = true ;
4445 //[Required] public string UpdateAppCastUrl { get; set; } = "https://releases.coder.com/coder-desktop/windows/appcast.xml";
4546 [ Required ] public string UpdateAppCastUrl { get ; set ; } = "http://localhost:8000/appcast.xml" ;
46- [ Required ] public string UpdatePublicKeyBase64 { get ; set ; } = "Uxc0ir6j3GMhkL5D1O/W3lsD4BNk5puwM9hohNfm32k =" ;
47+ [ Required ] public string UpdatePublicKeyBase64 { get ; set ; } = "NNWN4c+3PmMuAf2G1ERLlu0EwhzHfSiUugOt120hrH8 =" ;
4748 public UpdateChannel ? ForcedUpdateChannel { get ; set ; } = null ;
4849}
4950
@@ -83,8 +84,7 @@ public SparkleUpdateController(ILogger<SparkleUpdateController> logger, IOptions
8384 // Swift's Sparkle does not support verifying app cast signatures yet,
8485 // but we use this functionality on Windows for added security against
8586 // malicious release notes.
86- // TODO: REENABLE STRICT CHECKING
87- var checker = new Ed25519Checker ( SecurityMode . Unsafe ,
87+ var checker = new Ed25519Checker ( SecurityMode . Strict ,
8888 publicKey : _config . UpdatePublicKeyBase64 ,
8989 readFileBeingVerifiedInChunks : true ) ;
9090
@@ -93,7 +93,7 @@ public SparkleUpdateController(ILogger<SparkleUpdateController> logger, IOptions
9393 // TODO: custom Configuration for persistence, could just specify
9494 // our own save path with JSONConfiguration TBH
9595 LogWriter = new CoderSparkleLogger ( logger ) ,
96- AppCastHelper = new CoderSparkleAppCastHelper ( logger , _config . ForcedUpdateChannel ) ,
96+ AppCastHelper = new CoderSparkleAppCastHelper ( _config . ForcedUpdateChannel ) ,
9797 UIFactory = uiFactory ,
9898 UseNotificationToast = uiFactory . CanShowToastMessages ( ) ,
9999 RelaunchAfterUpdate = true ,
@@ -103,7 +103,7 @@ public SparkleUpdateController(ILogger<SparkleUpdateController> logger, IOptions
103103
104104 // TODO: user preference for automatic checking. Remember to
105105 // StopLoop/StartLoop if it changes.
106- #if ! DEBUG || true
106+ #if ! DEBUG
107107 _ = _sparkle . StartLoop ( true , UpdateCheckInterval ) ;
108108#endif
109109 }
@@ -157,22 +157,20 @@ public void PrintMessage(string message, params object[]? arguments)
157157 }
158158}
159159
160- public class CoderSparkleAppCastHelper : AppCastHelper
160+ public class CoderSparkleAppCastHelper ( UpdateChannel ? forcedChannel ) : AppCastHelper
161161{
162- private readonly UpdateChannel ? _forcedChannel ;
163-
164- public CoderSparkleAppCastHelper ( ILogger < SparkleUpdateController > logger , UpdateChannel ? forcedChannel ) : base ( )
165- {
166- _forcedChannel = forcedChannel ;
167- }
162+ // This might return some other OS if the user compiled the app for some
163+ // different arch, but the end result is the same: no updates will be found
164+ // for that arch.
165+ private static string CurrentOperatingSystem => $ "win-{ RuntimeInformation . ProcessArchitecture . ToString ( ) . ToLowerInvariant ( ) } ";
168166
169167 public override List < AppCastItem > FilterUpdates ( List < AppCastItem > items )
170168 {
171169 items = base . FilterUpdates ( items ) ;
172170
173- // TODO: factor in user choice too once we have a settings page
174- var channel = _forcedChannel ?? UpdateChannel . Stable ;
175- return items . FindAll ( i => i . Channel != null && i . Channel == channel . ChannelName ( ) ) ;
171+ // TODO: factor in user channel choice too once we have a settings page
172+ var channel = forcedChannel ?? UpdateChannel . Stable ;
173+ return items . FindAll ( i => i . Channel == channel . ChannelName ( ) && i . OperatingSystem == CurrentOperatingSystem ) ;
176174 }
177175}
178176
0 commit comments