Exemplo n.º 1
0
        static void AppMain(string[] args)
        {
            ServiceLogger Logger = new ServiceLogger(DateTime.Now.ToString() + ".log");

            byte[] EncryptedConfig = CopyEmbeddedDataToMemory();
            string DecryptedConfig = Encoding.UTF8.GetString(EncryptedConfig); // todo: replace with DecryptEmbeddedData(EncryptedConfig);

            UpdaterConfiguration Config =
                JsonConvert.DeserializeObject <UpdaterConfiguration>(DecryptedConfig);

            UpdaterService Updater = new UpdaterService(Config, Logger);

#if DEBUG_BUILD
            Logger.WriteLog("Encrypted configuration data >\n" + BitConverter.ToString(EncryptedConfig).Replace("-", " "));
            Logger.WriteLog("Decrypted configuration data >\n" + DecryptedConfig);
#endif

            Console.Title = "[SELLER BEAST] " + Config.StoreName + " | " + Config.CompanyId;

            UpdateAutorunKey(Config);
            CreateUninstaller(Config);

            Updater.RunTimers();

            // todo: catch closes and ask if they really want to close the application.
        }
Exemplo n.º 2
0
        static void UpdateAutorunKey(UpdaterConfiguration Config)
        {
            RegistryKey StartupKey =
                Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);

            StartupKey.SetValue(
                $"SDaggerUpdateService{Config.ExtensionId}",
                '"' + Assembly.GetEntryAssembly().Location + '"',
                RegistryValueKind.String);
        }
Exemplo n.º 3
0
        static void CreateUninstaller(UpdaterConfiguration Config)
        {
            string CurrentDirectory = Directory.GetCurrentDirectory();
            string UninstallerPath  = CurrentDirectory + "/uninstall.bat";

            if (File.Exists(UninstallerPath))
            {
                File.Delete(UninstallerPath);
            }

            string Uninstaller = ReadResource("uninstall.bat");

            Uninstaller = Uninstaller.Replace("[EXTENSION_ID]", Config.ExtensionId);

            File.WriteAllText(UninstallerPath, Uninstaller);
        }
Exemplo n.º 4
0
        public UpdaterService(UpdaterConfiguration Config, ServiceLogger Logger)
        {
            string CurrentDirectory = Directory.GetCurrentDirectory();

            this.Config = Config;
            this.Logger = Logger;


            this.HttpChannel = new HttpClient();

            this.ApiBase         = Config.UpdaterApiUrl;
            this.ApiCheckVersion = this.InitRoute("last-updated");
            this.ApiGetExtension = this.InitRoute("extension");


            this.ChromeDirectory  = CurrentDirectory + "/chrome";
            this.MasterDirectory  = CurrentDirectory + "/master-extension";
            this.RunningDirectory = CurrentDirectory + "/running-extension";
            this.ProxyConfigFile  = CurrentDirectory + "/proxy.json";
            this.VersionFile      = CurrentDirectory + "/version.dat";


            this.CurrentVersion = File.Exists(this.VersionFile) ? ReadVersion() : "0";

            this.ExtensionSync = new FileSystemSync(
                this.MasterDirectory,
                this.RunningDirectory);

            this.ExtensionSync.AddBinding("ProxyAddress", "$PROXY_ADDRESS", "/?");
            this.ExtensionSync.AddBinding("ProxyUsername", "$PROXY_USERNAME", "/?");
            this.ExtensionSync.AddBinding("ProxyPassword", "$PROXY_PASSWORD", "/?");

            this.ExtensionSync.AddBinding("ExtensionId", "$EXTENSION_ID", "/?");
            this.ExtensionSync.AddBinding("ExtensionPassword", "$EXTENSION_PW", "/?");

            this.ExtensionSync.AddBinding("MerchantToken", "$MERCHANT_TOKEN", "/?");
            this.ExtensionSync.AddBinding("ExtensionApi", "$API_BASE", "/?");


            this.UpdateTimer = new Timer(Config.UpdateInterval)
            {
                AutoReset = true
            };
            this.WatchDogTimer = new Timer(Config.WatchDogInterval)
            {
                AutoReset = true
            };


            this.UpdateTimer.Elapsed   += ExtensionUpdate;
            this.WatchDogTimer.Elapsed += WatchDogUpdate;

            if (!File.Exists(this.ProxyConfigFile))
            {
                string ProxyConfig =
                    "{\n\t\"Address\":\"" + Config.ProxyAddress + "\",\n" +
                    "\t\"Username\":\"" + Config.ProxyUsername + "\",\n" +
                    "\t\"Password\":\"" + Config.ProxyPassword + "\"\n}";

                File.WriteAllText(this.ProxyConfigFile, ProxyConfig);
            }

            this.CfgWatcher = new FileSystemWatcher(Directory.GetCurrentDirectory(), ".json");
            this.CfgWatcher.NotifyFilter       |= NotifyFilters.LastWrite;
            this.CfgWatcher.Changed            += (s, e) => this.CfgChanged(s, e);
            this.CfgWatcher.EnableRaisingEvents = true;
        }