Skip to content

Commit 9e055af

Browse files
committed
Merge in abstractions in Server project. Remove unneeded RemoteControlSessionLimit.
1 parent 81641af commit 9e055af

33 files changed

+283
-877
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ All other configuration is done in the Server Config page once you're logged in.
121121
- Set this to -1 or increase it to a specific number to allow multi-tenancy.
122122
- RedirectToHttps: Whether ASP.NET Core will redirect all traffic from HTTP to HTTPS. This is independent of Caddy, Nginx, and IIS configurations that do the same.
123123
- RemoteControlNotifyUsers: Whether to show a notification to the end user when an unattended remote control session starts.
124-
- RemoteControlSessionLimit: How many concurrent remote control sessions are allowed per organization.
125124
- RemoteControlRequiresAuthentication: Whether the remote control page requires authentication to establish a connection.
126125
- Require2FA: Require users to set up 2FA before they can use the main app.
127126
- Smpt-: SMTP settings for auto-generated system emails (such as registration and password reset).

Server/API/RemoteControlController.cs

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using Remotely.Server.Models;
66
using Remotely.Server.Services;
77
using Remotely.Server.Auth;
8-
using Remotely.Server.Abstractions;
98
using Remotely.Shared.Helpers;
109
using Remotely.Server.Extensions;
1110
using Remotely.Shared.Entities;
@@ -24,7 +23,6 @@ public class RemoteControlController : ControllerBase
2423
private readonly IAgentHubSessionCache _serviceSessionCache;
2524
private readonly IDataService _dataService;
2625
private readonly IOtpProvider _otpProvider;
27-
private readonly IHubEventHandler _hubEvents;
2826
private readonly SignInManager<RemotelyUser> _signInManager;
2927
private readonly ILogger<RemoteControlController> _logger;
3028

@@ -35,15 +33,13 @@ public RemoteControlController(
3533
IHubContext<AgentHub, IAgentHubClient> agentHub,
3634
IAgentHubSessionCache serviceSessionCache,
3735
IOtpProvider otpProvider,
38-
IHubEventHandler hubEvents,
3936
ILogger<RemoteControlController> logger)
4037
{
4138
_dataService = dataService;
4239
_agentHub = agentHub;
4340
_remoteControlSessionCache = remoteControlSessionCache;
4441
_serviceSessionCache = serviceSessionCache;
4542
_otpProvider = otpProvider;
46-
_hubEvents = hubEvents;
4743
_signInManager = signInManager;
4844
_logger = logger;
4945
}
@@ -134,20 +130,12 @@ private async Task<IActionResult> InitiateRemoteControl(string deviceID, string
134130
}
135131
}
136132

137-
var sessionCount = _remoteControlSessionCache.Sessions
138-
.OfType<RemoteControlSessionEx>()
139-
.Count(x => x.OrganizationId == orgId);
140-
141-
var settings = await _dataService.GetSettings();
142-
if (sessionCount > settings.RemoteControlSessionLimit)
143-
{
144-
return BadRequest("There are already the maximum amount of active remote control sessions for your organization.");
145-
}
133+
var sessionCount = _remoteControlSessionCache.Sessions.Count(x => x.OrganizationId == orgId);
146134

147135
var sessionId = Guid.NewGuid();
148136
var accessKey = RandomGenerator.GenerateAccessKey();
149137

150-
var session = new RemoteControlSessionEx()
138+
var session = new RemoteControlSession()
151139
{
152140
UnattendedSessionId = sessionId,
153141
UserConnectionId = HttpContext.Connection.Id,
@@ -158,13 +146,8 @@ private async Task<IActionResult> InitiateRemoteControl(string deviceID, string
158146

159147
_remoteControlSessionCache.AddOrUpdate($"{sessionId}", session, (k, v) =>
160148
{
161-
if (v is RemoteControlSessionEx ex)
162-
{
163-
ex.AgentConnectionId = HttpContext.Connection.Id;
164-
return ex;
165-
}
166-
v.Dispose();
167-
return session;
149+
v.AgentConnectionId = HttpContext.Connection.Id;
150+
return v;
168151
});
169152

170153
var orgNameResult = await _dataService.GetOrganizationNameById(orgId);

Server/Abstractions/IHubEventHandler.cs

Lines changed: 0 additions & 94 deletions
This file was deleted.

Server/Abstractions/ISessionRecordingSink.cs

Lines changed: 0 additions & 26 deletions
This file was deleted.

Server/Abstractions/IViewerAuthorizer.cs

Lines changed: 0 additions & 26 deletions
This file was deleted.

Server/Abstractions/IViewerOptionsProvider.cs

Lines changed: 0 additions & 18 deletions
This file was deleted.

Server/Abstractions/IViewerPageDataProvider.cs

Lines changed: 0 additions & 20 deletions
This file was deleted.

Server/Components/Devices/Terminal.razor.cs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
using Remotely.Server.Abstractions;
2-
using Bitbound.SimpleMessenger;
3-
using Microsoft.AspNetCore.Components;
1+
using Microsoft.AspNetCore.Components;
42
using Microsoft.AspNetCore.Components.Rendering;
53
using Microsoft.AspNetCore.Components.Web;
6-
using Microsoft.Extensions.Logging;
74
using Remotely.Server.Components.ModalContents;
85
using Remotely.Server.Hubs;
96
using Remotely.Server.Models.Messages;
@@ -13,10 +10,6 @@
1310
using Remotely.Shared.Enums;
1411
using Remotely.Shared.Models;
1512
using Remotely.Shared.Utilities;
16-
using System;
17-
using System.Collections.Generic;
18-
using System.Linq;
19-
using System.Threading.Tasks;
2013

2114
namespace Remotely.Server.Components.Devices;
2215

@@ -122,7 +115,7 @@ private void ApplyCompletion(PwshCommandCompletion completion)
122115
var match = completion.CompletionMatches[completion.CurrentMatchIndex];
123116

124117
var replacementText = string.Concat(
125-
_lastCompletionInput.Substring(0, completion.ReplacementIndex),
118+
_lastCompletionInput[..completion.ReplacementIndex],
126119
match.CompletionText,
127120
_lastCompletionInput[(completion.ReplacementIndex + completion.ReplacementLength)..]);
128121

@@ -170,7 +163,7 @@ private void EvaluateInputKeypress(KeyboardEventArgs ev)
170163
}
171164

172165
var devices = CardStore.SelectedDevices.ToArray();
173-
if (!devices.Any())
166+
if (devices.Length == 0)
174167
{
175168
ToastService.ShowToast("You must select at least one device.", classString: "bg-warning");
176169
return;
@@ -281,7 +274,7 @@ private async Task ShowQuickScripts()
281274
EnsureUserSet();
282275

283276
var quickScripts = await DataService.GetQuickScripts(User.Id);
284-
if (quickScripts?.Any() != true)
277+
if (quickScripts.Count == 0)
285278
{
286279
ToastService.ShowToast("No quick scripts saved.", classString: "bg-warning");
287280
return;
@@ -307,8 +300,8 @@ void showModal(RenderTreeBuilder builder)
307300

308301
private void ShowTerminalHelp()
309302
{
310-
ModalService.ShowModal("Terminal Help", new[]
311-
{
303+
ModalService.ShowModal("Terminal Help",
304+
[
312305
"Enter terminal commands that will execute on all selected devices.",
313306

314307
"Tab completion is available for PowerShell Core (PSCore) and Windows PowerShell (WinPS). Tab and Shift + Tab " +
@@ -324,7 +317,7 @@ private void ShowTerminalHelp()
324317

325318
"Note: The first PS Core command or tab completion takes a few moments while the service is " +
326319
"starting on the remote device."
327-
});
320+
]);
328321
}
329322

330323
private async void TerminalStore_TerminalLinesChanged(object? sender, EventArgs e)

Server/Components/ModalHarness.razor

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@
3737
</div>
3838

3939
@code {
40-
private string? _showClass;
41-
private string? _displayStyle;
42-
4340
private IJSObjectReference? _module;
4441
private ElementReference _modalRef;
4542

Server/Components/Pages/ServerConfig.razor

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -215,13 +215,6 @@
215215
<br />
216216
<ValidationMessage For="() => Input.RemoteControlRequiresAuthentication" />
217217
</div>
218-
<div class="form-group">
219-
<label class="control-label">Remote Control Session Limit</label>
220-
<br />
221-
<InputNumber @bind-Value="Input.RemoteControlSessionLimit" class="form-control" autocomplete="off" />
222-
<br />
223-
<ValidationMessage For="() => Input.RemoteControlSessionLimit" />
224-
</div>
225218
<div class="form-group">
226219
<label>Require 2FA</label>
227220
<br />

0 commit comments

Comments
 (0)