/// <summary> /// Enable Telepipe Proxy using JSON file downloaded from a configuration URL and an option to update Windows Host while at it. /// </summary> /// <param name="jsonUrl"></param> /// <param name="updateWindowsHost"></param> /// <returns></returns> public async Task EnableTelepipeProxy(string jsonUrl, bool updateWindowsHost = false) { Triggers.OnTelepipeProxyEnabling(); var telepipe = await DownloadTelepipeJson(jsonUrl); var blob = await DownloadPatch(telepipe.PublicKeyUrl); await Task.Run(() => { var blobPath = Path.Combine(Settings.GameDirectory, "publickey.blob"); if (File.Exists(blobPath)) { File.SetAttributes(blobPath, FileAttributes.Normal); } File.WriteAllBytes(blobPath, blob); File.SetAttributes(blobPath, FileAttributes.ReadOnly); var proxyPath = Path.Combine(Settings.GameDirectory, "proxy.txt"); if (File.Exists(proxyPath)) { File.SetAttributes(proxyPath, FileAttributes.Normal); } File.WriteAllText(proxyPath, telepipe.Host); File.SetAttributes(proxyPath, FileAttributes.ReadOnly); }); if (updateWindowsHost) { await Task.Run(() => { RemoveWindowsHostShipEntries(); AddWindowsHostShipEntries(telepipe.Host); }); } Triggers.OnTelepipeProxyEnabled(telepipe.Name); }