Skip to content

Commit

Permalink
Update fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbound committed Apr 25, 2020
1 parent 88a763d commit 9e0baa1
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 36 deletions.
5 changes: 5 additions & 0 deletions Agent.Installer.Win/Services/InstallerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,11 @@ private async Task DownloadRemotelyAgent(string serverUrl)
await client.DownloadFileTaskAsync($"{serverUrl}/Downloads/Remotely-Win10-{Platform}.zip", targetFile);
}

var wr = WebRequest.CreateHttp($"{serverUrl}/Downloads/Remotely-Win10-{Platform}.zip");
wr.Method = "Head";
var response = (HttpWebResponse)await wr.GetResponseAsync();
File.WriteAllText(Path.Combine(InstallPath, "etag.txt"), response.Headers["ETag"]);

ProgressMessageChanged.Invoke(this, "Extracting Remotely files.");
ProgressValueChanged?.Invoke(this, 0);

Expand Down
15 changes: 1 addition & 14 deletions Agent/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,6 @@ private static void BuildServices()
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
Logger.Write(e.ExceptionObject as Exception);
if (EnvironmentHelper.IsWindows)
{
// Remove Secure Attention Sequence policy to allow app to simulate Ctrl + Alt + Del.
var subkey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System", true);
if (subkey.GetValue("SoftwareSASGeneration") != null)
{
subkey.DeleteValue("SoftwareSASGeneration");
}
}
}

private static async Task Init()
Expand All @@ -87,11 +78,7 @@ private static async Task Init()
});
}

if (!EnvironmentHelper.IsDebug)
{
await Services.GetRequiredService<Updater>().BeginChecking();
}

await Services.GetRequiredService<Updater>().BeginChecking();

await Services.GetRequiredService<DeviceSocket>().Connect();
}
Expand Down
48 changes: 30 additions & 18 deletions Agent/Services/Updater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ public Updater(ConfigService configService)

public async Task BeginChecking()
{
if (EnvironmentHelper.IsDebug)
{
return;
}

await CheckForUpdates();
UpdateTimer.Elapsed += UpdateTimer_Elapsed;
UpdateTimer.Start();
Expand All @@ -37,36 +42,41 @@ public async Task CheckForUpdates()
{
try
{
if (EnvironmentHelper.IsDebug)
{
return;
}

await UpdateLock.WaitAsync();

var wc = new WebClientEx((int)UpdateTimer.Interval);
var connectionInfo = ConfigService.GetConnectionInfo();
var serverUrl = ConfigService.GetConnectionInfo().Host;

var lastEtag = string.Empty;
string fileUrl;

if (EnvironmentHelper.IsWindows)
{
var platform = Environment.Is64BitOperatingSystem ? "x64" : "x86";
fileUrl = serverUrl + $"/Downloads/Remotely-Win10-{platform}.zip";
}
else if (EnvironmentHelper.IsLinux)
{
fileUrl = serverUrl + $"/Downloads/Remotely-Linux.zip";
}
else
{
throw new PlatformNotSupportedException();
}

var lastEtag = string.Empty;

if (File.Exists("etag.txt"))
{
lastEtag = await File.ReadAllTextAsync("etag.txt");
}

try
{
string fileUrl;
if (EnvironmentHelper.IsWindows)
{
var platform = Environment.Is64BitOperatingSystem ? "x64" : "x86";
fileUrl = serverUrl + $"/Downloads/Remotely-Win10-{platform}.zip";
}
else if (EnvironmentHelper.IsLinux)
{
fileUrl = serverUrl + $"/Downloads/Remotely-Linux.zip";
}
else
{
throw new PlatformNotSupportedException();
}

var wr = WebRequest.CreateHttp(fileUrl);
wr.Method = "Head";
wr.Headers.Add("If-None-Match", lastEtag);
Expand All @@ -76,6 +86,8 @@ public async Task CheckForUpdates()
Logger.Write("Service Updater: Version is current.");
return;
}

File.WriteAllText("etag.txt", response.Headers["ETag"]);
}
catch (WebException ex) when ((ex.Response as HttpWebResponse).StatusCode == HttpStatusCode.NotModified)
{
Expand Down Expand Up @@ -133,7 +145,7 @@ await wc.DownloadFileTaskAsync(
proc.Kill();
}

Process.Start(installerPath, $"-install -quiet -path {installerPath} -serverurl {serverUrl} -organizationid {connectionInfo.OrganizationID}");
Process.Start(installerPath, $"-install -quiet -path {zipPath} -serverurl {serverUrl} -organizationid {connectionInfo.OrganizationID}");
}
else if (EnvironmentHelper.IsLinux)
{
Expand Down
1 change: 1 addition & 0 deletions Server/wwwroot/Downloads/Install-Linux-x64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ cat > ./ConnectionInfo.json << EOL
}
EOL

curl --head $HostName/Downloads/Remotely-Linux.zip | grep etag | cut -d' ' -f 2 > etag.txt

echo Creating service...

Expand Down
4 changes: 4 additions & 0 deletions Server/wwwroot/scripts/RemoteControl/UI.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Server/wwwroot/scripts/RemoteControl/UI.js.map

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions Server/wwwroot/scripts/RemoteControl/UI.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { RCBrowserSockets } from "./RCBrowserSockets.js";
import { MainRc } from "./Main.js";
import { MainRc } from "./Main.js";
import { RemoteControlMode } from "../Enums/RemoteControlMode.js";
import { Point } from "../Models/Point.js";
import { GetDistanceBetween, ConvertUInt8ArrayToBase64 } from "../Utilities.js";
import { CursorInfo } from "../Models/CursorInfo.js";
import { UploadFiles } from "./FileUploader.js";
import { Sound } from "../Sound.js";

export var AudioButton = document.getElementById("audioButton") as HTMLButtonElement;
export var MenuButton = document.getElementById("menuButton") as HTMLButtonElement;
Expand Down

0 comments on commit 9e0baa1

Please sign in to comment.