mirror of
https://github.com/immense/Remotely.git
synced 2025-10-26 11:27:15 +00:00
Create scripting controller.
This commit is contained in:
parent
6662a48a13
commit
a4fd12c597
@ -114,6 +114,17 @@ namespace Remotely.Agent.Services
|
||||
|
||||
await CommandExecutor.ExecuteCommand(mode, command, commandID, senderConnectionID, HubConnection);
|
||||
}));
|
||||
HubConnection.On("ExecuteCommandFromApi", (async (string mode, string requesterID, string command, string commandID, string senderConnectionID) =>
|
||||
{
|
||||
if (!IsServerVerified)
|
||||
{
|
||||
Logger.Write($"Command attempted before server was verified. Mode: {mode}. Command: {command}. Sender: {senderConnectionID}");
|
||||
Uninstaller.UninstallAgent();
|
||||
return;
|
||||
}
|
||||
|
||||
await CommandExecutor.ExecuteCommandFromApi(mode, requesterID, command, commandID, senderConnectionID, HubConnection);
|
||||
}));
|
||||
HubConnection.On("TransferFiles", async (string transferID, List<string> fileIDs, string requesterID) =>
|
||||
{
|
||||
Logger.Write($"File transfer started by {requesterID}.");
|
||||
|
||||
@ -9,5 +9,28 @@ namespace Remotely.Server.API
|
||||
[ApiController]
|
||||
public class ScriptingController : ControllerBase
|
||||
{
|
||||
//public Task ExecuteCommand(string mode, string command, string[] deviceIDs)
|
||||
//{
|
||||
// deviceIDs = DataService.FilterDeviceIDsByUserPermission(deviceIDs, RemotelyUser);
|
||||
// var connections = GetActiveClientConnections(deviceIDs);
|
||||
|
||||
// var commandContext = new CommandContext()
|
||||
// {
|
||||
// CommandMode = mode,
|
||||
// CommandText = command,
|
||||
// SenderConnectionID = Context.ConnectionId,
|
||||
// SenderUserID = Context.UserIdentifier,
|
||||
// TargetDeviceIDs = connections.Select(x => x.Value.ID).ToArray(),
|
||||
// OrganizationID = RemotelyUser.OrganizationID
|
||||
// };
|
||||
// DataService.AddOrUpdateCommandContext(commandContext);
|
||||
// Clients.Caller.SendAsync("CommandContextCreated", commandContext);
|
||||
// foreach (var connection in connections)
|
||||
// {
|
||||
// DeviceHub.Clients.Client(connection.Key).SendAsync("ExecuteCommand", mode, command, commandContext.ID, Context.ConnectionId);
|
||||
// }
|
||||
|
||||
// return Task.CompletedTask;
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
@ -102,8 +102,7 @@ namespace Remotely.Server.Services
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
|
||||
public override async Task OnConnectedAsync()
|
||||
public override async Task OnConnectedAsync()
|
||||
{
|
||||
RemotelyUser = DataService.GetUserByID(Context.UserIdentifier);
|
||||
if (await IsConnectionValid() == false)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user