Skip to content

Commit

Permalink
Add ability to upload custom versions of the attended support client.
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbound committed Jun 4, 2024
1 parent f46567f commit cd3057d
Show file tree
Hide file tree
Showing 15 changed files with 408 additions and 160 deletions.
132 changes: 66 additions & 66 deletions .azure-pipelines/Release Build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,71 +5,71 @@ pr:
- master

jobs:
#- job: Mac_Build
# displayName: Mac Build
# timeoutInMinutes: 360
# pool:
# vmImage: macos-latest
# steps:
#
# - task: InstallSSHKey@0
# inputs:
# knownHostsEntry: |
# github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl
# github.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==
# github.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=
# sshKeySecureFile: 'pipelines_rsa'
#
# - checkout: self
# submodules: recursive
# clean: true
# fetchTags: false
#
# - task: PowerShell@2
# displayName: Add CurrentVersion Variable
# inputs:
# targetType: inline
# script: |
# $VersionString = git show -s --format=%ci $(Build.SourceVersion)
# $VersionDate = [DateTimeOffset]::Parse($VersionString)
# $CurrentVersion = $VersionDate.ToString("yyyy.MM.dd.HHmm")
#
# [System.Console]::WriteLine("##vso[task.setvariable variable=CurrentVersion]$CurrentVersion")
#
# Write-Host "Setting current version to $CurrentVersion."
#
# - task: UseDotNet@2
# displayName: Use .NET SDK
# inputs:
# version: 8.x
#
# - task: DotNetCoreCLI@2
# displayName: dotnet publish x64
# inputs:
# command: publish
# publishWebProjects: false
# projects: '**/Agent.csproj'
# arguments: -c $(BuildConfiguration) -r osx-x64 -o "$(Build.SourcesDirectory)/Agent/bin/publish" /p:Version=$(CurrentVersion) /p:FileVersion=$(CurrentVersion)
# zipAfterPublish: false
# modifyOutputPath: false
#
# - task: PowerShell@2
# displayName: PowerShell Script
# inputs:
# targetType: inline
# script: |
# Compress-Archive -Path "$(Build.SourcesDirectory)/Agent/bin/publish/*" -DestinationPath "$(Build.SourcesDirectory)/Agent/bin/Remotely-MacOS-x64.zip" -Force
#
# - task: PublishPipelineArtifact@1
# displayName: Publish macOS x64 Agent
# inputs:
# path: $(Build.SourcesDirectory)/Agent/bin/Remotely-MacOS-x64.zip
# artifactName: Mac-x64-Agent
- job: Mac_Build
displayName: Mac Build
timeoutInMinutes: 360
pool:
vmImage: macos-latest
steps:

- task: InstallSSHKey@0
inputs:
knownHostsEntry: |
github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl
github.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==
github.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=
sshKeySecureFile: 'pipelines_rsa'

- checkout: self
submodules: recursive
clean: true
fetchTags: false

- task: PowerShell@2
displayName: Add CurrentVersion Variable
inputs:
targetType: inline
script: |
$VersionString = git show -s --format=%ci $(Build.SourceVersion)
$VersionDate = [DateTimeOffset]::Parse($VersionString)
$CurrentVersion = $VersionDate.ToString("yyyy.MM.dd.HHmm")
[System.Console]::WriteLine("##vso[task.setvariable variable=CurrentVersion]$CurrentVersion")
Write-Host "Setting current version to $CurrentVersion."
- task: UseDotNet@2
displayName: Use .NET SDK
inputs:
version: 8.x

- task: DotNetCoreCLI@2
displayName: dotnet publish x64
inputs:
command: publish
publishWebProjects: false
projects: '**/Agent.csproj'
arguments: -c $(BuildConfiguration) -r osx-x64 -o "$(Build.SourcesDirectory)/Agent/bin/publish" /p:Version=$(CurrentVersion) /p:FileVersion=$(CurrentVersion)
zipAfterPublish: false
modifyOutputPath: false

- task: PowerShell@2
displayName: PowerShell Script
inputs:
targetType: inline
script: |
Compress-Archive -Path "$(Build.SourcesDirectory)/Agent/bin/publish/*" -DestinationPath "$(Build.SourcesDirectory)/Agent/bin/Remotely-MacOS-x64.zip" -Force
- task: PublishPipelineArtifact@1
displayName: Publish macOS x64 Agent
inputs:
path: $(Build.SourcesDirectory)/Agent/bin/Remotely-MacOS-x64.zip
artifactName: Mac-x64-Agent

- job: Windows_Build
displayName: Windows Build
timeoutInMinutes: 360
#dependsOn: Mac_Build
dependsOn: Mac_Build
pool:
vmImage: windows-latest

Expand All @@ -90,11 +90,11 @@ jobs:
- task: VisualStudioTestPlatformInstaller@1
displayName: Visual Studio Test Platform Installer

# - task: DownloadPipelineArtifact@2
# displayName: Download macOS x64 Agent
# inputs:
# artifact: Mac-x64-Agent
# path: $(Build.SourcesDirectory)\Server\wwwroot\Content\
- task: DownloadPipelineArtifact@2
displayName: Download macOS x64 Agent
inputs:
artifact: Mac-x64-Agent
path: $(Build.SourcesDirectory)\Server\wwwroot\Content\

- task: PowerShell@2
displayName: Add CurrentVersion Variable
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
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 = 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
4 changes: 2 additions & 2 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
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 = 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
41 changes: 20 additions & 21 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,14 +137,9 @@ 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 effectiveScheme = settings.ForceClientHttps ? "https" : Request.Scheme;
var serverUrl = $"{effectiveScheme}://{Request.Host}";

var defaultOrg = await _dataService.GetDefaultOrganization();

// The default org will be used if unspecified, so might as well save the
Expand All @@ -154,10 +149,14 @@ private async Task<IActionResult> GetDesktopFile(string filePath, string? organi
{
organizationId = null;
}

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(filePath, embeddedData);
var fileInfo = _hostEnv.WebRootFileProvider.GetFileInfo(filePath.Replace(_hostEnv.WebRootPath, string.Empty));
return File(fileInfo.CreateReadStream(), "application/octet-stream", fileName);
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);
}
}
4 changes: 3 additions & 1 deletion Server/Components/Devices/DeviceCard.razor
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@
{
foreach (var kvp in _fileUploadProgressLookup)
{
<AlertBanner Message="@GetProgressMessage(kvp.Key)" />
<div class="alert alert-info">
@(GetProgressMessage(kvp.Key))
</div>
}
}
<div>
Expand Down
Loading

0 comments on commit cd3057d

Please sign in to comment.