Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assortment of updates. #894

Merged
merged 14 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions .azure-pipelines/Release Build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ pr:
- master

jobs:
- job: Build
displayName: Build
- job: Windows_Build
displayName: Windows Build
timeoutInMinutes: 360
pool:
vmImage: windows-latest
Expand Down Expand Up @@ -44,12 +44,6 @@ jobs:
- task: NuGetToolInstaller@1
displayName: 'Use NuGet'

- task: NuGetCommand@2
displayName: NuGet restore Agent.Installer.Win
inputs:
solution: Agent.Installer.Win/packages.config
packagesDirectory: $(Build.SourcesDirectory)\packages

- task: UseDotNet@2
displayName: Use .NET SDK
inputs:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -296,3 +296,4 @@ Server.Installer/Properties/launchSettings.json
!/.vscode/launch.json
!/.vscode/tasks.json
/Server/appsettings.Development.json
/Server/AppData
2 changes: 1 addition & 1 deletion Agent.Installer.Win/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ private bool CheckParams()
(serverUri.Scheme != Uri.UriSchemeHttp && serverUri.Scheme != Uri.UriSchemeHttps))
{
Logger.Write("ServerUrl is not valid.");
MessageBoxEx.Show("Server URL must be a valid Uri (e.g. https://app.remotely.one).", "Invalid Server URL", MessageBoxButton.OK, MessageBoxImage.Error);
MessageBoxEx.Show("Server URL must be a valid Uri (e.g. https://app.example.com).", "Invalid Server URL", MessageBoxButton.OK, MessageBoxImage.Error);
return false;
}

Expand Down
15 changes: 7 additions & 8 deletions Agent/Agent.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
<Product>Remotely Agent</Product>
<Company>Immense Networks</Company>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<PackageProjectUrl>https://remotely.one</PackageProjectUrl>
<Platforms>AnyCPU;x86;x64</Platforms>
<AssemblyName>Remotely_Agent</AssemblyName>
<RootNamespace>Remotely.Agent</RootNamespace>
Expand All @@ -24,18 +23,18 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Hosting.WindowsServices" Version="8.0.2" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.MessagePack" Version="8.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Hosting.WindowsServices" Version="8.0.6" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.MessagePack" Version="8.0.6" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.EventLog" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="8.0.2" />
<PackageReference Include="Microsoft.PowerShell.SDK" Version="7.4.1" />
<PackageReference Include="Microsoft.WSMan.Management" Version="7.4.1" />
<PackageReference Include="Microsoft.WSMan.Runtime" Version="7.4.1" />
<PackageReference Include="System.Management.Automation" Version="7.4.1" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="8.0.6" />
<PackageReference Include="Microsoft.PowerShell.SDK" Version="7.4.2" />
<PackageReference Include="Microsoft.WSMan.Management" Version="7.4.2" />
<PackageReference Include="Microsoft.WSMan.Runtime" Version="7.4.2" />
<PackageReference Include="System.Management.Automation" Version="7.4.2" />
<PackageReference Include="System.ServiceProcess.ServiceController" Version="8.0.0" />
</ItemGroup>

Expand Down
3 changes: 0 additions & 3 deletions Agent/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@
using Microsoft.Extensions.Logging;
using Remotely.Agent.Interfaces;
using Remotely.Agent.Services;
using Remotely.Shared.Enums;
using Remotely.Shared.Utilities;
using Remotely.Shared.Services;
using System;
using System.Diagnostics;
using System.IO;
using System.ServiceProcess;
using System.Threading.Tasks;
using System.Runtime.Versioning;
using Remotely.Agent.Services.Linux;
Expand Down
1 change: 0 additions & 1 deletion Desktop.Linux/Desktop.Linux.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
<Product>Remotely Desktop</Product>
<Description>Desktop client for allowing your IT admin to provide remote support.</Description>
<Copyright>Copyright © 2023 Immense Networks</Copyright>
<PackageProjectUrl>https://remotely.one</PackageProjectUrl>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions Desktop.Linux/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static async Task Main(string[] args)
var logger = new FileLogger("Remotely_Desktop", version, "Program.cs");
var filePath = Environment.ProcessPath ?? Environment.GetCommandLineArgs().First();
var serverUrl = Debugger.IsAttached ? "http://localhost:5000" : string.Empty;
var getEmbeddedResult = await EmbeddedServerDataSearcher.Instance.TryGetEmbeddedData(filePath);
var getEmbeddedResult = EmbeddedServerDataProvider.Instance.TryGetEmbeddedData(filePath);
if (getEmbeddedResult.IsSuccess)
{
serverUrl = getEmbeddedResult.Value.ServerUrl.AbsoluteUri;
Expand All @@ -46,7 +46,7 @@ public static async Task Main(string[] args)
var services = new ServiceCollection();

services.AddSingleton<IOrganizationIdProvider, OrganizationIdProvider>();
services.AddSingleton<IEmbeddedServerDataSearcher, EmbeddedServerDataSearcher>();
services.AddSingleton<IEmbeddedServerDataProvider, EmbeddedServerDataProvider>();

services.AddRemoteControlLinux(
config =>
Expand Down
6 changes: 3 additions & 3 deletions Desktop.Shared/Services/BrandingProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Desktop.Shared.Services;
public class BrandingProvider : IBrandingProvider
{
private readonly IAppState _appState;
private readonly IEmbeddedServerDataSearcher _embeddedDataSearcher;
private readonly IEmbeddedServerDataProvider _embeddedDataSearcher;
private readonly ILogger<BrandingProvider> _logger;
private readonly IOrganizationIdProvider _orgIdProvider;
private BrandingInfoBase? _brandingInfo;
Expand All @@ -22,7 +22,7 @@ public class BrandingProvider : IBrandingProvider
public BrandingProvider(
IAppState appState,
IOrganizationIdProvider orgIdProvider,
IEmbeddedServerDataSearcher embeddedServerDataSearcher,
IEmbeddedServerDataProvider embeddedServerDataSearcher,
ILogger<BrandingProvider> logger)
{
_appState = appState;
Expand Down Expand Up @@ -85,7 +85,7 @@ private async Task<Result<BrandingInfo>> TryGetBrandingInfo()
return Result.Fail<BrandingInfo>("Failed to retrieve executing file name.");
}

var result = await _embeddedDataSearcher.TryGetEmbeddedData(filePath);
var result = _embeddedDataSearcher.TryGetEmbeddedData(filePath);

if (!result.IsSuccess)
{
Expand Down
1 change: 0 additions & 1 deletion Desktop.Win/Desktop.Win.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
<Authors>Jared Goodwin</Authors>
<Company>Immense Networks</Company>
<Product>Remotely Desktop</Product>
<PackageProjectUrl>https://remotely.one</PackageProjectUrl>
<Platforms>AnyCPU;x86;x64</Platforms>
<StartupObject></StartupObject>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
Expand Down
4 changes: 2 additions & 2 deletions Desktop.Win/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static async Task Main(string[] args)
var logger = new FileLogger("Remotely_Desktop", version, "Program.cs");
var filePath = Environment.ProcessPath ?? Environment.GetCommandLineArgs().First();
var serverUrl = Debugger.IsAttached ? "https://localhost:5001" : string.Empty;
var getEmbeddedResult = await EmbeddedServerDataSearcher.Instance.TryGetEmbeddedData(filePath);
var getEmbeddedResult = EmbeddedServerDataProvider.Instance.TryGetEmbeddedData(filePath);
if (getEmbeddedResult.IsSuccess)
{
serverUrl = getEmbeddedResult.Value.ServerUrl.AbsoluteUri;
Expand All @@ -47,7 +47,7 @@ public static async Task Main(string[] args)
var services = new ServiceCollection();

services.AddSingleton<IOrganizationIdProvider, OrganizationIdProvider>();
services.AddSingleton<IEmbeddedServerDataSearcher>(EmbeddedServerDataSearcher.Instance);
services.AddSingleton<IEmbeddedServerDataProvider>(EmbeddedServerDataProvider.Instance);

services.AddRemoteControlWindows(
config =>
Expand Down
37 changes: 37 additions & 0 deletions Remotely.slnLaunch
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[
{
"Name": "Agent \u002B Server \u002B Desktop",
"Projects": [
{
"Path": "Agent\\Agent.csproj",
"Action": "Start",
"DebugTarget": "Agent"
},
{
"Path": "Desktop.Win\\Desktop.Win.csproj",
"Action": "Start",
"DebugTarget": "Desktop.Win"
},
{
"Path": "Server\\Server.csproj",
"Action": "Start",
"DebugTarget": "Server"
}
]
},
{
"Name": "Agent \u002B Server",
"Projects": [
{
"Path": "Agent\\Agent.csproj",
"Action": "Start",
"DebugTarget": "Agent"
},
{
"Path": "Server\\Server.csproj",
"Action": "Start",
"DebugTarget": "Server"
}
]
}
]
48 changes: 26 additions & 22 deletions Server/API/ClientDownloadsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ namespace Remotely.Server.API;
public class ClientDownloadsController : ControllerBase
{
private readonly IDataService _dataService;
private readonly IEmbeddedServerDataSearcher _embeddedDataSearcher;
private readonly IEmbeddedServerDataProvider _embeddedDataSearcher;
private readonly SemaphoreSlim _fileLock = new(1, 1);
private readonly IWebHostEnvironment _hostEnv;
private readonly ILogger<ClientDownloadsController> _logger;

public ClientDownloadsController(
IWebHostEnvironment hostEnv,
IEmbeddedServerDataSearcher embeddedDataSearcher,
IEmbeddedServerDataProvider embeddedDataSearcher,
IDataService dataService,
ILogger<ClientDownloadsController> logger)
{
Expand All @@ -39,27 +39,27 @@ public async Task<IActionResult> GetDesktop(string platformID)
{
case "WindowsDesktop-x64":
{
var filePath = Path.Combine(_hostEnv.WebRootPath, "Content", "Win-x64", "Remotely_Desktop.exe");
var filePath = Path.Combine("Content", "Win-x64", "Remotely_Desktop.exe");
return await GetDesktopFile(filePath);
}
case "WindowsDesktop-x86":
{
var filePath = Path.Combine(_hostEnv.WebRootPath, "Content", "Win-x86", "Remotely_Desktop.exe");
var filePath = Path.Combine("Content", "Win-x86", "Remotely_Desktop.exe");
return await GetDesktopFile(filePath);
}
case "UbuntuDesktop":
{
var filePath = Path.Combine(_hostEnv.WebRootPath, "Content", "Linux-x64", "Remotely_Desktop");
var filePath = Path.Combine("Content", "Linux-x64", "Remotely_Desktop");
return await GetDesktopFile(filePath);
}
case "MacOS-x64":
{
var filePath = Path.Combine(_hostEnv.WebRootPath, "Content", "MacOS-x64", "Remotely_Desktop");
var filePath = Path.Combine("Content", "MacOS-x64", "Remotely_Desktop");
return await GetDesktopFile(filePath);
}
case "MacOS-arm64":
{
var filePath = Path.Combine(_hostEnv.WebRootPath, "Content", "MacOS-arm64", "Remotely_Desktop");
var filePath = Path.Combine("Content", "MacOS-arm64", "Remotely_Desktop");
return await GetDesktopFile(filePath);
}
default:
Expand All @@ -75,27 +75,27 @@ public async Task<IActionResult> GetDesktop(string platformId, string organizati
{
case "WindowsDesktop-x64":
{
var filePath = Path.Combine(_hostEnv.WebRootPath, "Content", "Win-x64", "Remotely_Desktop.exe");
var filePath = Path.Combine("Content", "Win-x64", "Remotely_Desktop.exe");
return await GetDesktopFile(filePath, organizationId);
}
case "WindowsDesktop-x86":
{
var filePath = Path.Combine(_hostEnv.WebRootPath, "Content", "Win-x86", "Remotely_Desktop.exe");
var filePath = Path.Combine("Content", "Win-x86", "Remotely_Desktop.exe");
return await GetDesktopFile(filePath, organizationId);
}
case "UbuntuDesktop":
{
var filePath = Path.Combine(_hostEnv.WebRootPath, "Content", "Linux-x64", "Remotely_Desktop");
var filePath = Path.Combine("Content", "Linux-x64", "Remotely_Desktop");
return await GetDesktopFile(filePath, organizationId);
}
case "MacOS-x64":
{
var filePath = Path.Combine(_hostEnv.WebRootPath, "Content", "MacOS-x64", "Remotely_Desktop");
var filePath = Path.Combine("Content", "MacOS-x64", "Remotely_Desktop");
return await GetDesktopFile(filePath);
}
case "MacOS-arm64":
{
var filePath = Path.Combine(_hostEnv.WebRootPath, "Content", "MacOS-arm64", "Remotely_Desktop");
var filePath = Path.Combine("Content", "MacOS-arm64", "Remotely_Desktop");
return await GetDesktopFile(filePath);
}
default:
Expand Down Expand Up @@ -137,22 +137,26 @@ private async Task<IActionResult> GetBashInstaller(string fileName, string organ
return File(fileBytes, "application/octet-stream", fileName);
}

private async Task<IActionResult> GetDesktopFile(string filePath, string? organizationId = null)
private async Task<IActionResult> GetDesktopFile(string relativeFilePath, string? organizationId = null)
{
var settings = await _dataService.GetSettings();
await LogRequest(nameof(GetDesktopFile));
var defaultOrg = await _dataService.GetDefaultOrganization();

var effectiveScheme = settings.ForceClientHttps ? "https" : Request.Scheme;
var serverUrl = $"{effectiveScheme}://{Request.Host}";
var embeddedData = new EmbeddedServerData(new Uri(serverUrl), organizationId);
var result = await _embeddedDataSearcher.GetAppendedStream(filePath, embeddedData);

if (!result.IsSuccess)
// The default org will be used if unspecified, so might as well save the
// space in the file name.
if (defaultOrg.IsSuccess &&
defaultOrg.Value.ID.Equals(organizationId, StringComparison.OrdinalIgnoreCase))
{
throw result.Exception ?? new Exception(result.Reason);
organizationId = null;
}

return File(result.Value, "application/octet-stream", Path.GetFileName(filePath));
var settings = await _dataService.GetSettings();
var effectiveScheme = settings.ForceClientHttps ? "https" : Request.Scheme;
var serverUrl = $"{effectiveScheme}://{Request.Host}";

var embeddedData = new EmbeddedServerData(new Uri(serverUrl), organizationId);
var fileName = _embeddedDataSearcher.GetEncodedFileName(relativeFilePath, embeddedData);
return File(relativeFilePath, "application/octet-stream", fileName);
}

private async Task<IActionResult> GetInstallFile(string organizationId, string platformID)
Expand Down
52 changes: 52 additions & 0 deletions Server/API/CustomBinariesController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using Microsoft.AspNetCore.Mvc;
using Remotely.Server.Services;
using Remotely.Shared.Models;
using Remotely.Shared.Services;

namespace Remotely.Server.API;

[Route("api/custom-binaries")]
[ApiController]
public class CustomBinariesController(
IDataService _dataService,
IWebHostEnvironment _hostingEnvironment,
IEmbeddedServerDataProvider _embeddedData) : ControllerBase
{
[HttpGet("win-x86/desktop/{organizationId}")]
public async Task<IActionResult> GetWinX86Desktop(string organizationId)
{
var embeddedData = await GetEmbeddedData(organizationId);
var filePath = Path.Combine(_hostingEnvironment.ContentRootPath, "AppData", "Win-x86", "Remotely_Desktop.exe");
var fileName = _embeddedData.GetEncodedFileName(filePath, embeddedData);
var rs = System.IO.File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.Read);
return File(rs, "application/octet-stream", fileName);
}

[HttpGet("win-x64/desktop/{organizationId}")]
public async Task<IActionResult> GetWinX64Desktop(string organizationId)
{
var embeddedData = await GetEmbeddedData(organizationId);
var filePath = Path.Combine(_hostingEnvironment.ContentRootPath, "AppData", "Win-x64", "Remotely_Desktop.exe");
var fileName = _embeddedData.GetEncodedFileName(filePath, embeddedData);
var rs = System.IO.File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.Read);
return File(rs, "application/octet-stream", fileName);
}

private async Task<EmbeddedServerData> GetEmbeddedData(string? organizationId)
{
var defaultOrg = await _dataService.GetDefaultOrganization();

// The default org will be used if unspecified, so might as well save the
// space in the file name.
if (defaultOrg.IsSuccess &&
defaultOrg.Value.ID.Equals(organizationId, StringComparison.OrdinalIgnoreCase))
{
organizationId = null;
}

var settings = await _dataService.GetSettings();
var effectiveScheme = settings.ForceClientHttps ? "https" : Request.Scheme;
var serverUrl = $"{effectiveScheme}://{Request.Host}";
return new EmbeddedServerData(new Uri(serverUrl), organizationId);
}
}
Loading
Loading