mirror of
https://github.com/immense/Remotely.git
synced 2025-10-26 11:27:15 +00:00
Code cleanup.
This commit is contained in:
parent
7dc7895dbd
commit
eea84a79b4
@ -7,6 +7,6 @@ namespace Remotely.Agent.Installer.Win
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,7 +3,6 @@ using Microsoft.VisualBasic.FileIO;
|
||||
using Microsoft.Win32;
|
||||
using Remotely.Shared.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration.Install;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
@ -68,7 +67,7 @@ namespace Remotely.Agent.Installer.Win.Services
|
||||
CreateUninstallKey();
|
||||
|
||||
CreateSupportShortcut(serverUrl, connectionInfo.DeviceID, createSupportShortcut);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -171,9 +170,9 @@ namespace Remotely.Agent.Installer.Win.Services
|
||||
}
|
||||
}
|
||||
|
||||
private async Task CreateDeviceOnServer(string deviceUuid,
|
||||
private async Task CreateDeviceOnServer(string deviceUuid,
|
||||
string serverUrl,
|
||||
string deviceGroup,
|
||||
string deviceGroup,
|
||||
string deviceAlias,
|
||||
string organizationId)
|
||||
{
|
||||
@ -210,7 +209,7 @@ namespace Remotely.Agent.Installer.Win.Services
|
||||
{
|
||||
Logger.Write(ex);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void CreateSupportShortcut(string serverUrl, string deviceUuid, bool createSupportShortcut)
|
||||
@ -439,7 +438,7 @@ namespace Remotely.Agent.Installer.Win.Services
|
||||
remotelyService.WaitForStatus(ServiceControllerStatus.Stopped);
|
||||
}
|
||||
}
|
||||
catch(Exception ex)
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Write(ex);
|
||||
}
|
||||
|
||||
@ -11,6 +11,6 @@ namespace Remotely.Agent.Installer.Win.Services
|
||||
return MessageBox.Show(message, caption, messageBoxButton, messageBoxImage);
|
||||
}
|
||||
return MessageBoxResult.None;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -108,13 +108,13 @@ namespace Remotely.Agent.Installer.Win.ViewModels
|
||||
Process.Start(logPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
MessageBoxEx.Show("Log file doesn't exist.", "No Logs", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public string OrganizationID
|
||||
{
|
||||
get
|
||||
@ -213,7 +213,7 @@ namespace Remotely.Agent.Installer.Win.ViewModels
|
||||
}
|
||||
|
||||
AddExistingConnectionInfo();
|
||||
|
||||
|
||||
if (CommandLineParser.CommandLineArgs.ContainsKey("install"))
|
||||
{
|
||||
await Install();
|
||||
@ -333,7 +333,7 @@ namespace Remotely.Agent.Installer.Win.ViewModels
|
||||
}
|
||||
|
||||
HeaderMessage = "Installing Remotely...";
|
||||
|
||||
|
||||
if (await Installer.Install(ServerUrl, OrganizationID, DeviceGroup, DeviceAlias, DeviceUuid, CreateSupportShortcut))
|
||||
{
|
||||
IsServiceInstalled = true;
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
using Microsoft.AspNetCore.SignalR.Client;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Remotely.Agent.Interfaces
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
using Remotely.Agent.Services;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Remotely.Agent.Interfaces;
|
||||
using Remotely.Agent.Services;
|
||||
using Remotely.Shared.Utilities;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.ServiceProcess;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Remotely.Shared.Utilities;
|
||||
using Remotely.Agent.Interfaces;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Remotely.Agent
|
||||
{
|
||||
@ -22,7 +22,7 @@ namespace Remotely.Agent
|
||||
{
|
||||
BuildServices();
|
||||
|
||||
Task.Run(() => {_ = Init(); });
|
||||
Task.Run(() => { _ = Init(); });
|
||||
|
||||
Thread.Sleep(Timeout.Infinite);
|
||||
|
||||
|
||||
@ -1,28 +1,28 @@
|
||||
using Remotely.Shared.Models;
|
||||
using Microsoft.AspNetCore.SignalR.Client;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Remotely.Agent.Interfaces;
|
||||
using Remotely.Shared.Enums;
|
||||
using Remotely.Shared.Models;
|
||||
using Remotely.Shared.Services;
|
||||
using Microsoft.AspNetCore.SignalR.Client;
|
||||
using Remotely.Shared.Utilities;
|
||||
using Remotely.Shared.Win32;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Timers;
|
||||
using Remotely.Shared.Win32;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System.Text.Json;
|
||||
using System.Threading;
|
||||
using Remotely.Shared.Utilities;
|
||||
using Remotely.Shared.Enums;
|
||||
using Remotely.Agent.Interfaces;
|
||||
using System.Threading.Tasks;
|
||||
using System.Timers;
|
||||
|
||||
namespace Remotely.Agent.Services
|
||||
{
|
||||
public class AgentSocket
|
||||
{
|
||||
public AgentSocket(ConfigService configService,
|
||||
Uninstaller uninstaller,
|
||||
public AgentSocket(ConfigService configService,
|
||||
Uninstaller uninstaller,
|
||||
CommandExecutor commandExecutor,
|
||||
ScriptRunner scriptRunner,
|
||||
IAppLauncher appLauncher,
|
||||
@ -145,7 +145,8 @@ namespace Remotely.Agent.Services
|
||||
// TODO: Remove possibility for circular dependencies in the future
|
||||
// by emitting these events so other services can listen for them.
|
||||
|
||||
HubConnection.On("Chat", async (string senderName, string message, string orgName, bool disconnected, string senderConnectionID) => {
|
||||
HubConnection.On("Chat", async (string senderName, string message, string orgName, bool disconnected, string senderConnectionID) =>
|
||||
{
|
||||
if (!IsServerVerified)
|
||||
{
|
||||
Logger.Write("Chat attempted before server was verified.", EventType.Warning);
|
||||
@ -231,8 +232,8 @@ namespace Remotely.Agent.Services
|
||||
}
|
||||
|
||||
Logger.Write($"File upload started by {requesterID}.");
|
||||
var sharedFilePath = Directory.CreateDirectory(Path.Combine(Path.GetTempPath(),"RemotelySharedFiles")).FullName;
|
||||
|
||||
var sharedFilePath = Directory.CreateDirectory(Path.Combine(Path.GetTempPath(), "RemotelySharedFiles")).FullName;
|
||||
|
||||
foreach (var fileID in fileIDs)
|
||||
{
|
||||
var url = $"{ConnectionInfo.Host}/API/FileSharing/{fileID}";
|
||||
@ -255,7 +256,8 @@ namespace Remotely.Agent.Services
|
||||
}
|
||||
await HubConnection.SendAsync("TransferCompleted", transferID, requesterID);
|
||||
});
|
||||
HubConnection.On("DeployScript", async (string mode, string fileID, string commandResultID, string requesterID) => {
|
||||
HubConnection.On("DeployScript", async (string mode, string fileID, string commandResultID, string requesterID) =>
|
||||
{
|
||||
if (!IsServerVerified)
|
||||
{
|
||||
Logger.Write($"Script deploy attempted before server was verified. Mode: {mode}. File ID: {fileID}. Sender: {requesterID}", EventType.Warning);
|
||||
@ -269,7 +271,7 @@ namespace Remotely.Agent.Services
|
||||
{
|
||||
Uninstaller.UninstallAgent();
|
||||
});
|
||||
|
||||
|
||||
HubConnection.On("RemoteControl", async (string requesterID, string serviceID) =>
|
||||
{
|
||||
if (!IsServerVerified)
|
||||
@ -297,7 +299,7 @@ namespace Remotely.Agent.Services
|
||||
}
|
||||
User32.SendSAS(false);
|
||||
});
|
||||
|
||||
|
||||
HubConnection.On("ServerVerificationToken", (string verificationToken) =>
|
||||
{
|
||||
if (verificationToken == ConnectionInfo.ServerVerificationToken)
|
||||
@ -309,7 +311,7 @@ namespace Remotely.Agent.Services
|
||||
Logger.Write($"Server sent an incorrect verification token. Token Sent: {verificationToken}.", EventType.Warning);
|
||||
return;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
using Remotely.Agent.Interfaces;
|
||||
using Remotely.Shared.Models;
|
||||
using Remotely.Shared.Utilities;
|
||||
using Remotely.Shared.Win32;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
||||
@ -7,7 +7,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Remotely.Agent.Services
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
using Remotely.Shared.Models;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Remotely.Shared.Models;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
using System.Collections.Concurrent;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Remotely.Agent.Services
|
||||
{
|
||||
@ -12,16 +12,20 @@ namespace Remotely.Agent.Services
|
||||
public Bash(ConfigService configService)
|
||||
{
|
||||
ConfigService = configService;
|
||||
var psi = new ProcessStartInfo("bash");
|
||||
psi.WindowStyle = ProcessWindowStyle.Hidden;
|
||||
psi.Verb = "RunAs";
|
||||
psi.UseShellExecute = false;
|
||||
psi.RedirectStandardError = true;
|
||||
psi.RedirectStandardInput = true;
|
||||
psi.RedirectStandardOutput = true;
|
||||
var psi = new ProcessStartInfo("bash")
|
||||
{
|
||||
WindowStyle = ProcessWindowStyle.Hidden,
|
||||
Verb = "RunAs",
|
||||
UseShellExecute = false,
|
||||
RedirectStandardError = true,
|
||||
RedirectStandardInput = true,
|
||||
RedirectStandardOutput = true
|
||||
};
|
||||
|
||||
BashProc = new Process();
|
||||
BashProc.StartInfo = psi;
|
||||
BashProc = new Process
|
||||
{
|
||||
StartInfo = psi
|
||||
};
|
||||
BashProc.ErrorDataReceived += CMDProc_ErrorDataReceived;
|
||||
BashProc.OutputDataReceived += CMDProc_OutputDataReceived;
|
||||
|
||||
@ -30,8 +34,10 @@ namespace Remotely.Agent.Services
|
||||
BashProc.BeginErrorReadLine();
|
||||
BashProc.BeginOutputReadLine();
|
||||
|
||||
ProcessIdleTimeout = new System.Timers.Timer(600_000); // 10 minutes.
|
||||
ProcessIdleTimeout.AutoReset = false;
|
||||
ProcessIdleTimeout = new System.Timers.Timer(600_000)
|
||||
{
|
||||
AutoReset = false
|
||||
}; // 10 minutes.
|
||||
ProcessIdleTimeout.Elapsed += ProcessIdleTimeout_Elapsed;
|
||||
ProcessIdleTimeout.Start();
|
||||
}
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
using Remotely.Shared.Models;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Remotely.Shared.Models;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Remotely.Agent.Services
|
||||
{
|
||||
@ -12,16 +12,20 @@ namespace Remotely.Agent.Services
|
||||
public CMD(ConfigService configService)
|
||||
{
|
||||
ConfigService = configService;
|
||||
var psi = new ProcessStartInfo("cmd.exe");
|
||||
psi.WindowStyle = ProcessWindowStyle.Hidden;
|
||||
psi.Verb = "RunAs";
|
||||
psi.UseShellExecute = false;
|
||||
psi.RedirectStandardError = true;
|
||||
psi.RedirectStandardInput = true;
|
||||
psi.RedirectStandardOutput = true;
|
||||
var psi = new ProcessStartInfo("cmd.exe")
|
||||
{
|
||||
WindowStyle = ProcessWindowStyle.Hidden,
|
||||
Verb = "RunAs",
|
||||
UseShellExecute = false,
|
||||
RedirectStandardError = true,
|
||||
RedirectStandardInput = true,
|
||||
RedirectStandardOutput = true
|
||||
};
|
||||
|
||||
CMDProc = new Process();
|
||||
CMDProc.StartInfo = psi;
|
||||
CMDProc = new Process
|
||||
{
|
||||
StartInfo = psi
|
||||
};
|
||||
CMDProc.ErrorDataReceived += CMDProc_ErrorDataReceived;
|
||||
CMDProc.OutputDataReceived += CMDProc_OutputDataReceived;
|
||||
|
||||
@ -30,8 +34,10 @@ namespace Remotely.Agent.Services
|
||||
CMDProc.BeginErrorReadLine();
|
||||
CMDProc.BeginOutputReadLine();
|
||||
|
||||
ProcessIdleTimeout = new System.Timers.Timer(600_000); // 10 minutes.
|
||||
ProcessIdleTimeout.AutoReset = false;
|
||||
ProcessIdleTimeout = new System.Timers.Timer(600_000)
|
||||
{
|
||||
AutoReset = false
|
||||
}; // 10 minutes.
|
||||
ProcessIdleTimeout.Elapsed += ProcessIdleTimeout_Elapsed;
|
||||
ProcessIdleTimeout.Start();
|
||||
}
|
||||
|
||||
@ -36,11 +36,11 @@ namespace Remotely.Agent.Services
|
||||
|
||||
private MemoryCache ChatClients { get; } = new MemoryCache("ChatClients");
|
||||
|
||||
public async Task SendMessage(string senderName,
|
||||
string message,
|
||||
string orgName,
|
||||
public async Task SendMessage(string senderName,
|
||||
string message,
|
||||
string orgName,
|
||||
bool disconnected,
|
||||
string senderConnectionID,
|
||||
string senderConnectionID,
|
||||
HubConnection hubConnection)
|
||||
{
|
||||
if (!await MessageLock.WaitAsync(30000))
|
||||
@ -93,12 +93,10 @@ namespace Remotely.Agent.Services
|
||||
return;
|
||||
}
|
||||
|
||||
using (var sw = new StreamWriter(chatSession.PipeStream, leaveOpen: true))
|
||||
{
|
||||
var chatMessage = new ChatMessage(senderName, message, disconnected);
|
||||
await sw.WriteLineAsync(JsonSerializer.Serialize(chatMessage));
|
||||
await sw.FlushAsync();
|
||||
}
|
||||
using var sw = new StreamWriter(chatSession.PipeStream, leaveOpen: true);
|
||||
var chatMessage = new ChatMessage(senderName, message, disconnected);
|
||||
await sw.WriteLineAsync(JsonSerializer.Serialize(chatMessage));
|
||||
await sw.FlushAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -114,15 +112,13 @@ namespace Remotely.Agent.Services
|
||||
{
|
||||
while (clientPipe.IsConnected)
|
||||
{
|
||||
using (var sr = new StreamReader(clientPipe, leaveOpen: true))
|
||||
using var sr = new StreamReader(clientPipe, leaveOpen: true);
|
||||
var messageJson = await sr.ReadLineAsync();
|
||||
if (!string.IsNullOrWhiteSpace(messageJson))
|
||||
{
|
||||
var messageJson = await sr.ReadLineAsync();
|
||||
if (!string.IsNullOrWhiteSpace(messageJson))
|
||||
{
|
||||
var chatMessage = JsonSerializer.Deserialize<ChatMessage>(messageJson);
|
||||
await hubConnection.SendAsync("Chat", chatMessage.Message, false, senderConnectionID);
|
||||
}
|
||||
}
|
||||
var chatMessage = JsonSerializer.Deserialize<ChatMessage>(messageJson);
|
||||
await hubConnection.SendAsync("Chat", chatMessage.Message, false, senderConnectionID);
|
||||
}
|
||||
}
|
||||
await hubConnection.SendAsync("Chat", string.Empty, true, senderConnectionID);
|
||||
ChatClients.Remove(senderConnectionID);
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
using Remotely.Shared.Models;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Remotely.Shared.Models;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Linq;
|
||||
using System.Management.Automation;
|
||||
using System.Timers;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Remotely.Agent.Services
|
||||
{
|
||||
@ -20,8 +20,10 @@ namespace Remotely.Agent.Services
|
||||
$WarningPreference = ""Continue"";");
|
||||
PS.Invoke();
|
||||
|
||||
ProcessIdleTimeout = new Timer(600_000); // 10 minutes.
|
||||
ProcessIdleTimeout.AutoReset = false;
|
||||
ProcessIdleTimeout = new Timer(600_000)
|
||||
{
|
||||
AutoReset = false
|
||||
}; // 10 minutes.
|
||||
ProcessIdleTimeout.Elapsed += ProcessIdleTimeout_Elapsed;
|
||||
ProcessIdleTimeout.Start();
|
||||
}
|
||||
@ -59,33 +61,31 @@ namespace Remotely.Agent.Services
|
||||
PS.AddScript(input);
|
||||
var results = PS.Invoke();
|
||||
|
||||
using (var ps = PowerShell.Create())
|
||||
using var ps = PowerShell.Create();
|
||||
ps.AddScript("$args[0] | Out-String");
|
||||
ps.AddArgument(results);
|
||||
var hostOutput = (ps.Invoke()[0].BaseObject as string);
|
||||
|
||||
var verboseOut = PS.Streams.Verbose.ReadAll().Select(x => x.Message).ToList();
|
||||
var debugOut = PS.Streams.Debug.ReadAll().Select(x => x.Message).ToList();
|
||||
var errorOut = PS.Streams.Error.ReadAll().Select(x => x.Exception.ToString() + Environment.NewLine + x.ScriptStackTrace).ToList();
|
||||
var infoOut = PS.Streams.Information.Select(x => x.MessageData.ToString()).ToList();
|
||||
var warningOut = PS.Streams.Warning.Select(x => x.Message).ToList();
|
||||
|
||||
PS.Streams.ClearStreams();
|
||||
PS.Commands.Clear();
|
||||
|
||||
return new PSCoreCommandResult()
|
||||
{
|
||||
ps.AddScript("$args[0] | Out-String");
|
||||
ps.AddArgument(results);
|
||||
var hostOutput = (ps.Invoke()[0].BaseObject as string);
|
||||
|
||||
var verboseOut = PS.Streams.Verbose.ReadAll().Select(x => x.Message).ToList();
|
||||
var debugOut = PS.Streams.Debug.ReadAll().Select(x => x.Message).ToList();
|
||||
var errorOut = PS.Streams.Error.ReadAll().Select(x => x.Exception.ToString() + Environment.NewLine + x.ScriptStackTrace).ToList();
|
||||
var infoOut = PS.Streams.Information.Select(x => x.MessageData.ToString()).ToList();
|
||||
var warningOut = PS.Streams.Warning.Select(x => x.Message).ToList();
|
||||
|
||||
PS.Streams.ClearStreams();
|
||||
PS.Commands.Clear();
|
||||
|
||||
return new PSCoreCommandResult()
|
||||
{
|
||||
CommandResultID = commandID,
|
||||
DeviceID = ConfigService.GetConnectionInfo().DeviceID,
|
||||
DebugOutput = debugOut,
|
||||
ErrorOutput = errorOut,
|
||||
VerboseOutput = verboseOut,
|
||||
HostOutput = hostOutput,
|
||||
InformationOutput = infoOut,
|
||||
WarningOutput = warningOut
|
||||
};
|
||||
}
|
||||
CommandResultID = commandID,
|
||||
DeviceID = ConfigService.GetConnectionInfo().DeviceID,
|
||||
DebugOutput = debugOut,
|
||||
ErrorOutput = errorOut,
|
||||
VerboseOutput = verboseOut,
|
||||
HostOutput = hostOutput,
|
||||
InformationOutput = infoOut,
|
||||
WarningOutput = warningOut
|
||||
};
|
||||
}
|
||||
|
||||
private void ProcessIdleTimeout_Elapsed(object sender, ElapsedEventArgs e)
|
||||
|
||||
@ -33,14 +33,10 @@ namespace Remotely.Agent.Services
|
||||
var response = await wr.GetResponseAsync();
|
||||
var cd = response.Headers["Content-Disposition"];
|
||||
var filename = cd.Split(";").FirstOrDefault(x => x.Trim().StartsWith("filename")).Split("=")[1];
|
||||
using (var rs = response.GetResponseStream())
|
||||
{
|
||||
using (var sr = new StreamReader(rs))
|
||||
{
|
||||
var result = await sr.ReadToEndAsync();
|
||||
await CommandExecutor.ExecuteCommand(mode, result, commandResultID, requesterID, hubConnection);
|
||||
}
|
||||
}
|
||||
using var rs = response.GetResponseStream();
|
||||
using var sr = new StreamReader(rs);
|
||||
var result = await sr.ReadToEndAsync();
|
||||
await CommandExecutor.ExecuteCommand(mode, result, commandResultID, requesterID, hubConnection);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,11 +1,10 @@
|
||||
using System;
|
||||
using Remotely.Shared.Utilities;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading;
|
||||
using Remotely.Shared.Utilities;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Remotely.Agent.Services
|
||||
{
|
||||
@ -69,7 +68,7 @@ namespace Remotely.Agent.Services
|
||||
}
|
||||
|
||||
var lastEtag = string.Empty;
|
||||
|
||||
|
||||
if (File.Exists("etag.txt"))
|
||||
{
|
||||
lastEtag = await File.ReadAllTextAsync("etag.txt");
|
||||
@ -180,7 +179,8 @@ namespace Remotely.Agent.Services
|
||||
|
||||
|
||||
private class WebClientEx : WebClient
|
||||
{ private readonly int _requestTimeout;
|
||||
{
|
||||
private readonly int _requestTimeout;
|
||||
|
||||
public WebClientEx(int requestTimeout)
|
||||
{
|
||||
|
||||
@ -12,16 +12,20 @@ namespace Remotely.Agent.Services
|
||||
public WindowsPS(ConfigService configService)
|
||||
{
|
||||
ConfigService = configService;
|
||||
var psi = new ProcessStartInfo("powershell.exe");
|
||||
psi.WindowStyle = ProcessWindowStyle.Hidden;
|
||||
psi.Verb = "RunAs";
|
||||
psi.RedirectStandardError = true;
|
||||
psi.RedirectStandardInput = true;
|
||||
psi.RedirectStandardOutput = true;
|
||||
var psi = new ProcessStartInfo("powershell.exe")
|
||||
{
|
||||
WindowStyle = ProcessWindowStyle.Hidden,
|
||||
Verb = "RunAs",
|
||||
RedirectStandardError = true,
|
||||
RedirectStandardInput = true,
|
||||
RedirectStandardOutput = true
|
||||
};
|
||||
|
||||
PSProc = new Process();
|
||||
PSProc.StartInfo = psi;
|
||||
PSProc.EnableRaisingEvents = true;
|
||||
PSProc = new Process
|
||||
{
|
||||
StartInfo = psi,
|
||||
EnableRaisingEvents = true
|
||||
};
|
||||
PSProc.ErrorDataReceived += CMDProc_ErrorDataReceived;
|
||||
PSProc.OutputDataReceived += CMDProc_OutputDataReceived;
|
||||
|
||||
@ -30,8 +34,10 @@ namespace Remotely.Agent.Services
|
||||
PSProc.BeginErrorReadLine();
|
||||
PSProc.BeginOutputReadLine();
|
||||
|
||||
ProcessIdleTimeout = new System.Timers.Timer(600_000); // 10 minutes.
|
||||
ProcessIdleTimeout.AutoReset = false;
|
||||
ProcessIdleTimeout = new System.Timers.Timer(600_000)
|
||||
{
|
||||
AutoReset = false
|
||||
}; // 10 minutes.
|
||||
ProcessIdleTimeout.Elapsed += ProcessIdleTimeout_Elapsed;
|
||||
ProcessIdleTimeout.Start();
|
||||
}
|
||||
|
||||
@ -1,11 +1,9 @@
|
||||
using Remotely.Shared.Models;
|
||||
using Remotely.Desktop.Core.Enums;
|
||||
using Remotely.Desktop.Core.Services;
|
||||
using Remotely.Desktop.Core.Enums;
|
||||
using Remotely.Shared.Models;
|
||||
using Remotely.Shared.Utilities;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Remotely.Shared.Utilities;
|
||||
|
||||
namespace Remotely.Desktop.Core
|
||||
{
|
||||
|
||||
@ -1,7 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Remotely.Desktop.Core.Interfaces
|
||||
{
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
using Remotely.Shared.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Remotely.Desktop.Core.Interfaces
|
||||
{
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
using Remotely.Desktop.Core.Services;
|
||||
using Remotely.Desktop.Core.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Remotely.Desktop.Core.Interfaces
|
||||
|
||||
@ -1,6 +1,4 @@
|
||||
using Remotely.Desktop.Core.Services;
|
||||
|
||||
namespace Remotely.Desktop.Core.Interfaces
|
||||
namespace Remotely.Desktop.Core.Interfaces
|
||||
{
|
||||
public interface IKeyboardMouseInput
|
||||
{
|
||||
|
||||
@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Remotely.Desktop.Core.Interfaces
|
||||
namespace Remotely.Desktop.Core.Interfaces
|
||||
{
|
||||
public interface ISessionIndicator
|
||||
{
|
||||
|
||||
@ -1,7 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Remotely.Desktop.Core.Interfaces
|
||||
{
|
||||
|
||||
@ -1,18 +1,12 @@
|
||||
using Microsoft.AspNetCore.SignalR.Client;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Remotely.Desktop.Core.Interfaces;
|
||||
using Remotely.Shared.Models;
|
||||
using Remotely.Shared.Utilities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using Remotely.Desktop.Core.Interfaces;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Remotely.Shared.Utilities;
|
||||
using System.Threading;
|
||||
using Remotely.Desktop.Core.Services;
|
||||
using Remotely.Shared.Models.RemoteControlDtos;
|
||||
|
||||
namespace Remotely.Desktop.Core.Services
|
||||
{
|
||||
@ -159,10 +153,10 @@ namespace Remotely.Desktop.Core.Services
|
||||
try
|
||||
{
|
||||
ScreenCaster.BeginScreenCasting(new ScreenCastRequest()
|
||||
{
|
||||
{
|
||||
NotifyUser = notifyUser,
|
||||
ViewerID = viewerID,
|
||||
RequesterName = requesterName
|
||||
ViewerID = viewerID,
|
||||
RequesterName = requesterName
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -205,11 +199,11 @@ namespace Remotely.Desktop.Core.Services
|
||||
|
||||
Connection.On("RequestScreenCast", (string viewerID, string requesterName, bool notifyUser) =>
|
||||
{
|
||||
conductor.InvokeScreenCastRequested(new ScreenCastRequest()
|
||||
{
|
||||
conductor.InvokeScreenCastRequested(new ScreenCastRequest()
|
||||
{
|
||||
NotifyUser = notifyUser,
|
||||
ViewerID = viewerID,
|
||||
RequesterName = requesterName
|
||||
ViewerID = viewerID,
|
||||
RequesterName = requesterName
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@ -1,17 +1,9 @@
|
||||
using MessagePack;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Remotely.Desktop.Core.Interfaces;
|
||||
using Remotely.Desktop.Core.Services;
|
||||
using Remotely.Shared.Enums;
|
||||
using Remotely.Shared.Models.RemoteControlDtos;
|
||||
using Remotely.Shared.Utilities;
|
||||
using Remotely.Shared.Win32;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Dynamic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Remotely.Desktop.Core.Services
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
using Remotely.Desktop.Core.Services;
|
||||
using Remotely.Shared.Utilities;
|
||||
using Remotely.Shared.Utilities;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Timers;
|
||||
|
||||
@ -1,25 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Remotely.Desktop.Core.Interfaces;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing.Imaging;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Remotely.Desktop.Core.Utilities;
|
||||
using Remotely.Shared.Utilities;
|
||||
using System.Collections.Concurrent;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Remotely.Desktop.Core.Enums;
|
||||
using Remotely.Desktop.Core.Interfaces;
|
||||
using Remotely.Desktop.Core.Utilities;
|
||||
using Remotely.Shared.Models;
|
||||
using Remotely.Shared.Win32;
|
||||
using Remotely.Shared.Utilities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Remotely.Desktop.Core.Services
|
||||
{
|
||||
public class ScreenCaster : IScreenCaster
|
||||
{
|
||||
public ScreenCaster(Conductor conductor,
|
||||
public ScreenCaster(Conductor conductor,
|
||||
ICursorIconWatcher cursorIconWatcher,
|
||||
ISessionIndicator sessionIndicator,
|
||||
IShutdownService shutdownService)
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
using Remotely.Desktop.Core.Interfaces;
|
||||
using Remotely.Desktop.Core.Services;
|
||||
using Remotely.Desktop.Core.ViewModels;
|
||||
using Remotely.Shared.Helpers;
|
||||
using Remotely.Shared.Models;
|
||||
@ -8,8 +7,6 @@ using Remotely.Shared.Utilities;
|
||||
using Remotely.Shared.Win32;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
@ -1,15 +1,11 @@
|
||||
using MessagePack;
|
||||
using Microsoft.MixedReality.WebRTC;
|
||||
using Remotely.Desktop.Core.Services;
|
||||
using Remotely.Shared.Helpers;
|
||||
using Remotely.Shared.Models;
|
||||
using Remotely.Shared.Models.RemoteControlDtos;
|
||||
using Remotely.Shared.Utilities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Remotely.Desktop.Core.Services
|
||||
|
||||
@ -1,10 +1,4 @@
|
||||
using Remotely.Desktop.Core.Interfaces;
|
||||
using Remotely.Desktop.Core.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Remotely.Desktop.Core.Services
|
||||
namespace Remotely.Desktop.Core.Services
|
||||
{
|
||||
public interface IWebRtcSessionFactory
|
||||
{
|
||||
|
||||
@ -12,11 +12,9 @@ namespace Remotely.Desktop.Core.Utilities
|
||||
public static ImageCodecInfo JpegEncoder { get; } = ImageCodecInfo.GetImageEncoders().FirstOrDefault(x => x.FormatID == ImageFormat.Jpeg.Guid);
|
||||
public static byte[] EncodeBitmap(Bitmap bitmap, EncoderParameters encoderParams)
|
||||
{
|
||||
using (var ms = new MemoryStream())
|
||||
{
|
||||
bitmap.Save(ms, JpegEncoder, encoderParams);
|
||||
return ms.ToArray();
|
||||
}
|
||||
using var ms = new MemoryStream();
|
||||
bitmap.Save(ms, JpegEncoder, encoderParams);
|
||||
return ms.ToArray();
|
||||
}
|
||||
|
||||
public static Rectangle GetDiffArea(Bitmap currentFrame, Bitmap previousFrame, bool captureFullscreen)
|
||||
|
||||
@ -1,7 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
namespace Remotely.Desktop.Core.ViewModels
|
||||
{
|
||||
|
||||
@ -1,10 +1,5 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls.ApplicationLifetimes;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Remotely.Desktop.Core;
|
||||
using Remotely.Desktop.Linux.ViewModels;
|
||||
using Remotely.Desktop.Linux.Views;
|
||||
|
||||
namespace Remotely.Desktop.Linux
|
||||
{
|
||||
@ -28,7 +23,7 @@ namespace Remotely.Desktop.Linux
|
||||
// };
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
base.OnFrameworkInitializationCompleted();
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Remotely.Desktop.Linux.ViewModels;
|
||||
using Remotely.Desktop.Linux.Views;
|
||||
|
||||
namespace Remotely.Desktop.Linux.Controls
|
||||
{
|
||||
|
||||
@ -3,11 +3,9 @@ using Avalonia.Controls;
|
||||
using Avalonia.Controls.ApplicationLifetimes;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Remotely.Desktop.Linux.ViewModels;
|
||||
using Remotely.Desktop.Linux.Views;
|
||||
using Remotely.Shared.Helpers;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Remotely.Desktop.Linux.Controls
|
||||
|
||||
@ -12,7 +12,6 @@ using Remotely.Desktop.Linux.Services;
|
||||
using Remotely.Desktop.Linux.Views;
|
||||
using Remotely.Shared.Utilities;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@ -20,7 +19,7 @@ namespace Remotely.Desktop.Linux
|
||||
{
|
||||
class Program
|
||||
{
|
||||
|
||||
|
||||
// Avalonia configuration, don't remove; also used by visual designer.
|
||||
public static AppBuilder BuildAvaloniaApp()
|
||||
=> AppBuilder.Configure<App>()
|
||||
|
||||
@ -7,10 +7,8 @@ using Remotely.Desktop.Linux.Views;
|
||||
using Remotely.Shared.Models;
|
||||
using Remotely.Shared.Utilities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Pipes;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@ -1,9 +1,6 @@
|
||||
using Remotely.Desktop.Core.Interfaces;
|
||||
using Remotely.Desktop.Core.Services;
|
||||
using Remotely.Shared.Utilities;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
@ -1,9 +1,7 @@
|
||||
using Remotely.Desktop.Core.Interfaces;
|
||||
using Remotely.Shared.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
|
||||
namespace Remotely.Desktop.Linux.Services
|
||||
{
|
||||
|
||||
@ -1,25 +1,24 @@
|
||||
using Remotely.Shared.Utilities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading;
|
||||
using System.Collections.Concurrent;
|
||||
using Remotely.Desktop.Linux.Controls;
|
||||
using Avalonia.Threading;
|
||||
using Remotely.Desktop.Core.Interfaces;
|
||||
using Avalonia.Controls;
|
||||
using Remotely.Desktop.Core.Services;
|
||||
using Remotely.Desktop.Core.ViewModels;
|
||||
using Avalonia.Threading;
|
||||
using Remotely.Desktop.Linux.Views;
|
||||
using Remotely.Desktop.Linux.Controls;
|
||||
using Remotely.Desktop.Linux.ViewModels;
|
||||
using Remotely.Desktop.Linux.Views;
|
||||
using Remotely.Shared.Utilities;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Remotely.Desktop.Linux.Services
|
||||
{
|
||||
public class FileTransferServiceLinux : IFileTransferService
|
||||
{
|
||||
private static readonly SemaphoreSlim _writeLock = new SemaphoreSlim(1);
|
||||
private static readonly ConcurrentDictionary<string, FileStream> _partialTransfers =
|
||||
private static readonly ConcurrentDictionary<string, FileStream> _partialTransfers =
|
||||
new ConcurrentDictionary<string, FileStream>();
|
||||
private static readonly ConcurrentDictionary<string, FileTransferWindow> _fileTransferWindows =
|
||||
new ConcurrentDictionary<string, FileTransferWindow>();
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
using Remotely.Desktop.Core.Interfaces;
|
||||
using Remotely.Desktop.Core.Services;
|
||||
using Remotely.Desktop.Linux.X11Interop;
|
||||
using System;
|
||||
using Remotely.Shared.Utilities;
|
||||
using System;
|
||||
|
||||
namespace Remotely.Desktop.Linux.Services
|
||||
{
|
||||
@ -92,9 +92,9 @@ namespace Remotely.Desktop.Linux.Services
|
||||
{
|
||||
try
|
||||
{
|
||||
LibXtst.XTestFakeMotionEvent(Display,
|
||||
LibXtst.XTestFakeMotionEvent(Display,
|
||||
viewer.Capturer.GetSelectedScreenIndex(),
|
||||
(int)(viewer.Capturer.CurrentScreenBounds.Width * percentX),
|
||||
(int)(viewer.Capturer.CurrentScreenBounds.Width * percentX),
|
||||
(int)(viewer.Capturer.CurrentScreenBounds.Height * percentY),
|
||||
0);
|
||||
LibX11.XSync(Display, false);
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
using Remotely.Desktop.Core.Interfaces;
|
||||
using Remotely.Desktop.Core.Services;
|
||||
using Remotely.Desktop.Linux.X11Interop;
|
||||
using Remotely.Shared.Utilities;
|
||||
using System;
|
||||
|
||||
@ -1,9 +1,6 @@
|
||||
using Avalonia.Threading;
|
||||
using Remotely.Desktop.Core.Interfaces;
|
||||
using Remotely.Desktop.Linux.Views;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Remotely.Desktop.Linux.Services
|
||||
{
|
||||
|
||||
@ -4,9 +4,7 @@ using Remotely.Desktop.Core.Interfaces;
|
||||
using Remotely.Desktop.Core.Services;
|
||||
using Remotely.Shared.Utilities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Remotely.Desktop.Linux.Services
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Templates;
|
||||
using Remotely.Desktop.Linux.ViewModels;
|
||||
using System;
|
||||
|
||||
namespace Remotely.Desktop.Linux
|
||||
{
|
||||
|
||||
@ -2,11 +2,8 @@
|
||||
using ReactiveUI;
|
||||
using Remotely.Desktop.Linux.Services;
|
||||
using Remotely.Shared.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
@ -40,7 +37,7 @@ namespace Remotely.Desktop.Linux.ViewModels
|
||||
public string OrganizationName
|
||||
{
|
||||
get => organizationName;
|
||||
set
|
||||
set
|
||||
{
|
||||
this.RaiseAndSetIfChanged(ref organizationName, value);
|
||||
this.RaisePropertyChanged(nameof(ChatSessionHeader));
|
||||
|
||||
@ -7,11 +7,9 @@ using Remotely.Desktop.Core.ViewModels;
|
||||
using Remotely.Desktop.Linux.Services;
|
||||
using Remotely.Desktop.Linux.Views;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
using System.Windows.Input;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls;
|
||||
using ReactiveUI;
|
||||
using Remotely.Desktop.Core.ViewModels;
|
||||
using Remotely.Desktop.Linux.Services;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace Remotely.Desktop.Linux.ViewModels
|
||||
{
|
||||
|
||||
@ -1,25 +1,22 @@
|
||||
using Avalonia.Collections;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Threading;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using ReactiveUI;
|
||||
using Remotely.Desktop.Linux.Controls;
|
||||
using Remotely.Desktop.Linux.Services;
|
||||
using Remotely.Desktop.Linux.Views;
|
||||
using Remotely.Desktop.Core;
|
||||
using Remotely.Desktop.Core.Interfaces;
|
||||
using Remotely.Desktop.Core.Services;
|
||||
using Remotely.Desktop.Linux.Controls;
|
||||
using Remotely.Desktop.Linux.Services;
|
||||
using Remotely.Desktop.Linux.Views;
|
||||
using Remotely.Shared.Models;
|
||||
using Remotely.Shared.Utilities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Remotely.Shared.Utilities;
|
||||
|
||||
namespace Remotely.Desktop.Linux.ViewModels
|
||||
{
|
||||
@ -249,8 +246,8 @@ namespace Remotely.Desktop.Linux.ViewModels
|
||||
Environment.NewLine + Environment.NewLine +
|
||||
"libx11-dev" + Environment.NewLine +
|
||||
"libc6-dev" + Environment.NewLine +
|
||||
"libgdiplus" + Environment.NewLine +
|
||||
"libxtst-dev" + Environment.NewLine +
|
||||
"libgdiplus" + Environment.NewLine +
|
||||
"libxtst-dev" + Environment.NewLine +
|
||||
"xclip";
|
||||
|
||||
await MessageBox.Show(message, "Dependencies Required", MessageBoxType.OK);
|
||||
@ -268,7 +265,7 @@ namespace Remotely.Desktop.Linux.ViewModels
|
||||
{
|
||||
_ = Task.Run(() =>
|
||||
{
|
||||
Services.GetRequiredService<IScreenCaster>().BeginScreenCasting(screenCastRequest);
|
||||
Services.GetRequiredService<IScreenCaster>().BeginScreenCasting(screenCastRequest);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
using Avalonia.Controls;
|
||||
using ReactiveUI;
|
||||
using Remotely.Desktop.Core.ViewModels;
|
||||
using Remotely.Desktop.Linux.Controls;
|
||||
using Remotely.Desktop.Linux.Services;
|
||||
using System.Windows.Input;
|
||||
|
||||
@ -1,7 +1,4 @@
|
||||
using ReactiveUI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Remotely.Desktop.Linux.ViewModels
|
||||
{
|
||||
|
||||
@ -1,12 +1,8 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.LogicalTree;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.VisualTree;
|
||||
using ReactiveUI;
|
||||
using Remotely.Desktop.Linux.ViewModels;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Remotely.Desktop.Linux.Views
|
||||
|
||||
@ -34,7 +34,7 @@ namespace Remotely.Desktop.Linux.X11Interop
|
||||
|
||||
[DllImport("libX11")]
|
||||
public static extern IntPtr XGetImage(IntPtr display, IntPtr drawable, int x, int y, int width, int height, long plane_mask, int format);
|
||||
|
||||
|
||||
[DllImport("libX11")]
|
||||
public static extern IntPtr XDefaultVisual(IntPtr display, int screen_number);
|
||||
[DllImport("libX11")]
|
||||
|
||||
@ -1,10 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows;
|
||||
|
||||
namespace Desktop.Win.Wrapper
|
||||
{
|
||||
|
||||
@ -1,6 +1,4 @@
|
||||
using System.Reflection;
|
||||
using System.Resources;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
|
||||
|
||||
@ -1,11 +1,9 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Remotely.Desktop.Core;
|
||||
using Remotely.Desktop.Core.Interfaces;
|
||||
using Remotely.Desktop.Core.Services;
|
||||
using Remotely.Shared.Utilities;
|
||||
using Remotely.Shared.Win32;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
@ -7,9 +7,9 @@ namespace Remotely.Desktop.Win.Models
|
||||
{
|
||||
public class DirectXOutput : IDisposable
|
||||
{
|
||||
public DirectXOutput(Adapter1 adapter,
|
||||
SharpDX.Direct3D11.Device device,
|
||||
OutputDuplication outputDuplication,
|
||||
public DirectXOutput(Adapter1 adapter,
|
||||
SharpDX.Direct3D11.Device device,
|
||||
OutputDuplication outputDuplication,
|
||||
Texture2D texture2D)
|
||||
{
|
||||
Adapter = adapter;
|
||||
@ -25,8 +25,8 @@ namespace Remotely.Desktop.Win.Models
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Disposer.TryDisposeAll(new IDisposable[]
|
||||
{
|
||||
Disposer.TryDisposeAll(new IDisposable[]
|
||||
{
|
||||
Adapter,
|
||||
Device,
|
||||
OutputDuplication,
|
||||
|
||||
@ -1,24 +1,23 @@
|
||||
using Remotely.Shared.Models;
|
||||
using Remotely.Desktop.Core;
|
||||
using Remotely.Desktop.Core.Services;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Remotely.Shared.Win32;
|
||||
using System.Threading;
|
||||
using Remotely.Desktop.Win.Services;
|
||||
using Remotely.Desktop.Core.Interfaces;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Remotely.Shared.Utilities;
|
||||
using System.Windows;
|
||||
using Remotely.Desktop.Core;
|
||||
using Remotely.Desktop.Core.Interfaces;
|
||||
using Remotely.Desktop.Core.Services;
|
||||
using Remotely.Desktop.Win.Services;
|
||||
using Remotely.Desktop.Win.Views;
|
||||
using Remotely.Shared.Models;
|
||||
using Remotely.Shared.Utilities;
|
||||
using Remotely.Shared.Win32;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Remotely.Desktop.Win
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
{
|
||||
public static ManualResetEvent AppExitEvent { get; } = new ManualResetEvent(false);
|
||||
public static Form BackgroundForm { get; private set; }
|
||||
private static CasterSocket CasterSocket { get; set; }
|
||||
|
||||
@ -1,12 +1,10 @@
|
||||
using System;
|
||||
using NAudio.Wave;
|
||||
using Remotely.Desktop.Core.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using NAudio.Wave;
|
||||
using Remotely.Desktop.Core;
|
||||
using Remotely.Desktop.Core.Interfaces;
|
||||
|
||||
namespace Remotely.Desktop.Win.Services
|
||||
{
|
||||
@ -36,26 +34,22 @@ namespace Remotely.Desktop.Win.Services
|
||||
return;
|
||||
}
|
||||
|
||||
using (var ms1 = new MemoryStream())
|
||||
using var ms1 = new MemoryStream();
|
||||
using (var wfw = new WaveFileWriter(ms1, Capturer.WaveFormat))
|
||||
{
|
||||
using (var wfw = new WaveFileWriter(ms1, Capturer.WaveFormat))
|
||||
{
|
||||
wfw.Write(TempBuffer.ToArray(), 0, TempBuffer.Count);
|
||||
}
|
||||
TempBuffer.Clear();
|
||||
|
||||
// Resample to 16-bit so Firefox will play it.
|
||||
using (var ms2 = new MemoryStream(ms1.ToArray()))
|
||||
using (var wfr = new WaveFileReader(ms2))
|
||||
using (var ms3 = new MemoryStream())
|
||||
{
|
||||
using (var resampler = new MediaFoundationResampler(wfr, TargetFormat))
|
||||
{
|
||||
WaveFileWriter.WriteWavFileToStream(ms3, resampler);
|
||||
}
|
||||
AudioSampleReady?.Invoke(this, ms3.ToArray());
|
||||
}
|
||||
wfw.Write(TempBuffer.ToArray(), 0, TempBuffer.Count);
|
||||
}
|
||||
TempBuffer.Clear();
|
||||
|
||||
// Resample to 16-bit so Firefox will play it.
|
||||
using var ms2 = new MemoryStream(ms1.ToArray());
|
||||
using var wfr = new WaveFileReader(ms2);
|
||||
using var ms3 = new MemoryStream();
|
||||
using (var resampler = new MediaFoundationResampler(wfr, TargetFormat))
|
||||
{
|
||||
WaveFileWriter.WriteWavFileToStream(ms3, resampler);
|
||||
}
|
||||
AudioSampleReady?.Invoke(this, ms3.ToArray());
|
||||
}
|
||||
|
||||
private void Start()
|
||||
|
||||
@ -4,10 +4,8 @@ using Remotely.Desktop.Win.Views;
|
||||
using Remotely.Shared.Models;
|
||||
using Remotely.Shared.Utilities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Pipes;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
using Remotely.Desktop.Core.Interfaces;
|
||||
using Remotely.Desktop.Core.Services;
|
||||
using Remotely.Shared.Utilities;
|
||||
using Remotely.Shared.Win32;
|
||||
using System;
|
||||
@ -53,7 +52,7 @@ namespace Remotely.Desktop.Win.Services
|
||||
});
|
||||
thread.SetApartmentState(ApartmentState.STA);
|
||||
thread.Start();
|
||||
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
using System;
|
||||
using Remotely.Desktop.Core.Interfaces;
|
||||
using Remotely.Shared.Models;
|
||||
using Remotely.Shared.Win32;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Timers;
|
||||
using System.Windows.Forms;
|
||||
using Remotely.Shared.Win32;
|
||||
using Remotely.Shared.Models;
|
||||
using Remotely.Desktop.Core.Interfaces;
|
||||
|
||||
namespace Remotely.Desktop.Win.Services
|
||||
{
|
||||
@ -43,18 +43,12 @@ namespace Remotely.Desktop.Win.Services
|
||||
return new CursorInfo(new byte[0], Point.Empty, "text");
|
||||
}
|
||||
|
||||
using (var icon = Icon.FromHandle(ci.hCursor))
|
||||
{
|
||||
using (var ms = new MemoryStream())
|
||||
{
|
||||
using (var cursor = new Cursor(ci.hCursor))
|
||||
{
|
||||
var hotspot = cursor.HotSpot;
|
||||
icon.ToBitmap().Save(ms, ImageFormat.Png);
|
||||
return new CursorInfo(ms.ToArray(), hotspot);
|
||||
}
|
||||
}
|
||||
}
|
||||
using var icon = Icon.FromHandle(ci.hCursor);
|
||||
using var ms = new MemoryStream();
|
||||
using var cursor = new Cursor(ci.hCursor);
|
||||
var hotspot = cursor.HotSpot;
|
||||
icon.ToBitmap().Save(ms, ImageFormat.Png);
|
||||
return new CursorInfo(ms.ToArray(), hotspot);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -89,18 +83,12 @@ namespace Remotely.Desktop.Win.Services
|
||||
}
|
||||
else
|
||||
{
|
||||
using (var icon = Icon.FromHandle(cursorInfo.hCursor))
|
||||
{
|
||||
using (var ms = new MemoryStream())
|
||||
{
|
||||
using (var cursor = new Cursor(cursorInfo.hCursor))
|
||||
{
|
||||
var hotspot = cursor.HotSpot;
|
||||
icon.ToBitmap().Save(ms, ImageFormat.Png);
|
||||
OnChange?.Invoke(this, new CursorInfo(ms.ToArray(), hotspot));
|
||||
}
|
||||
}
|
||||
}
|
||||
using var icon = Icon.FromHandle(cursorInfo.hCursor);
|
||||
using var ms = new MemoryStream();
|
||||
using var cursor = new Cursor(cursorInfo.hCursor);
|
||||
var hotspot = cursor.HotSpot;
|
||||
icon.ToBitmap().Save(ms, ImageFormat.Png);
|
||||
OnChange?.Invoke(this, new CursorInfo(ms.ToArray(), hotspot));
|
||||
}
|
||||
PreviousCursorHandle = currentCursor;
|
||||
}
|
||||
|
||||
@ -11,7 +11,6 @@ using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Security.AccessControl;
|
||||
using System.Security.Principal;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
@ -20,7 +19,7 @@ namespace Remotely.Desktop.Win.Services
|
||||
{
|
||||
public class FileTransferServiceWin : IFileTransferService
|
||||
{
|
||||
private static readonly ConcurrentDictionary<string, FileStream> _partialTransfers =
|
||||
private static readonly ConcurrentDictionary<string, FileStream> _partialTransfers =
|
||||
new ConcurrentDictionary<string, FileStream>();
|
||||
|
||||
private static readonly ConcurrentDictionary<string, FileTransferWindow> _fileTransferWindows =
|
||||
|
||||
@ -1,15 +1,12 @@
|
||||
using Remotely.Desktop.Core.Interfaces;
|
||||
using Remotely.Desktop.Core.Services;
|
||||
using System;
|
||||
using Remotely.Shared.Win32;
|
||||
using static Remotely.Shared.Win32.User32;
|
||||
using System.Windows.Forms;
|
||||
using System.Threading;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Threading.Tasks;
|
||||
using Remotely.Desktop.Core;
|
||||
using System.Runtime.InteropServices;
|
||||
using Remotely.Shared.Utilities;
|
||||
using Remotely.Shared.Win32;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using static Remotely.Shared.Win32.User32;
|
||||
|
||||
namespace Remotely.Desktop.Win.Services
|
||||
{
|
||||
|
||||
@ -23,7 +23,6 @@
|
||||
|
||||
using Microsoft.Win32;
|
||||
using Remotely.Desktop.Core.Interfaces;
|
||||
using Remotely.Desktop.Core.Services;
|
||||
using Remotely.Desktop.Win.Models;
|
||||
using Remotely.Shared.Utilities;
|
||||
using Remotely.Shared.Win32;
|
||||
@ -89,11 +88,11 @@ namespace Remotely.Desktop.Win.Services
|
||||
// have it fall back to BitBlt in those cases.
|
||||
if (directxScreens.ContainsKey(SelectedScreen))
|
||||
{
|
||||
var directXResult = GetDirectXFrame();
|
||||
var (result, frame) = GetDirectXFrame();
|
||||
|
||||
if (directXResult.result == GetDirectXFrameResult.Success)
|
||||
if (result == GetDirectXFrameResult.Success)
|
||||
{
|
||||
return directXResult.frame;
|
||||
return frame;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -4,11 +4,9 @@ using Remotely.Desktop.Core.Interfaces;
|
||||
using Remotely.Desktop.Core.Services;
|
||||
using Remotely.Shared.Utilities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Remotely.Desktop.Win.Services
|
||||
|
||||
@ -4,9 +4,7 @@ using Remotely.Desktop.Core.Interfaces;
|
||||
using Remotely.Desktop.Core.Services;
|
||||
using Remotely.Shared.Utilities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Remotely.Desktop.Win.Services
|
||||
@ -20,7 +18,7 @@ namespace Remotely.Desktop.Win.Services
|
||||
await casterSocket.DisconnectAllViewers();
|
||||
System.Windows.Forms.Application.Exit();
|
||||
App.Current.Shutdown();
|
||||
Environment.Exit(0);
|
||||
//Environment.Exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,11 +1,7 @@
|
||||
using Remotely.Desktop.Core.ViewModels;
|
||||
using Remotely.Shared.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.IO;
|
||||
using System.IO.Pipes;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
@ -7,7 +7,6 @@ using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Input;
|
||||
@ -40,10 +39,10 @@ namespace Remotely.Desktop.Win.ViewModels
|
||||
// Change initial directory so it doesn't open in %userprofile% path
|
||||
// for SYSTEM account.
|
||||
var rootDir = Path.GetPathRoot(Environment.SystemDirectory);
|
||||
var userDir = Path.Combine(rootDir,
|
||||
"Users",
|
||||
var userDir = Path.Combine(rootDir,
|
||||
"Users",
|
||||
Win32Interop.GetUsernameFromSessionId((uint)Process.GetCurrentProcess().SessionId));
|
||||
|
||||
|
||||
var ofd = new OpenFileDialog()
|
||||
{
|
||||
Title = "Upload File via Remotely",
|
||||
|
||||
@ -1,23 +1,22 @@
|
||||
using Remotely.Desktop.Win.Controls;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Remotely.Desktop.Core;
|
||||
using Remotely.Desktop.Core.Interfaces;
|
||||
using Remotely.Desktop.Core.Services;
|
||||
using Remotely.Desktop.Core.ViewModels;
|
||||
using Remotely.Desktop.Win.Controls;
|
||||
using Remotely.Desktop.Win.Services;
|
||||
using Remotely.Shared.Models;
|
||||
using Remotely.Desktop.Core;
|
||||
using Remotely.Desktop.Core.Services;
|
||||
using Remotely.Shared.Utilities;
|
||||
using Remotely.Shared.Win32;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Security.Principal;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Security.Principal;
|
||||
using System.Windows.Input;
|
||||
using Remotely.Desktop.Core.Interfaces;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Remotely.Shared.Win32;
|
||||
using Remotely.Shared.Utilities;
|
||||
using Remotely.Desktop.Core.ViewModels;
|
||||
|
||||
namespace Remotely.Desktop.Win.ViewModels
|
||||
{
|
||||
@ -25,7 +24,7 @@ namespace Remotely.Desktop.Win.ViewModels
|
||||
{
|
||||
private string host;
|
||||
private string sessionID;
|
||||
|
||||
|
||||
public static MainWindowViewModel Current { get; private set; }
|
||||
|
||||
public MainWindowViewModel()
|
||||
@ -186,7 +185,7 @@ namespace Remotely.Desktop.Win.ViewModels
|
||||
|
||||
public async Task Init()
|
||||
{
|
||||
|
||||
|
||||
SessionID = "Retrieving...";
|
||||
|
||||
Host = Config.GetConfig().Host;
|
||||
|
||||
@ -1,15 +1,7 @@
|
||||
using Remotely.Desktop.Win.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace Remotely.Desktop.Win.Views
|
||||
{
|
||||
|
||||
@ -1,16 +1,6 @@
|
||||
using Remotely.Desktop.Win.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace Remotely.Desktop.Win.Views
|
||||
{
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
using Remotely.Desktop.Win;
|
||||
using Remotely.Desktop.Win.ViewModels;
|
||||
using Remotely.Desktop.Win.ViewModels;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
@ -29,14 +28,16 @@ namespace Remotely.Desktop.Win.Views
|
||||
private async void CopyLinkButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ViewModel.CopyLink();
|
||||
var tooltip = new ToolTip();
|
||||
tooltip.PlacementTarget = sender as Button;
|
||||
tooltip.Placement = PlacementMode.Bottom;
|
||||
tooltip.VerticalOffset = 5;
|
||||
tooltip.Content = "Copied to clipboard!";
|
||||
tooltip.HasDropShadow = true;
|
||||
tooltip.StaysOpen = false;
|
||||
tooltip.IsOpen = true;
|
||||
var tooltip = new ToolTip
|
||||
{
|
||||
PlacementTarget = sender as Button,
|
||||
Placement = PlacementMode.Bottom,
|
||||
VerticalOffset = 5,
|
||||
Content = "Copied to clipboard!",
|
||||
HasDropShadow = true,
|
||||
StaysOpen = false,
|
||||
IsOpen = true
|
||||
};
|
||||
|
||||
await Task.Delay(750);
|
||||
var animation = new DoubleAnimation(0, TimeSpan.FromMilliseconds(750));
|
||||
|
||||
@ -15,10 +15,10 @@ namespace Remotely.Server.API
|
||||
public class AgentUpdateController : ControllerBase
|
||||
{
|
||||
private static readonly MemoryCache downloadingAgents = new MemoryCache(new MemoryCacheOptions()
|
||||
{ ExpirationScanFrequency = TimeSpan.FromSeconds(10) });
|
||||
{ ExpirationScanFrequency = TimeSpan.FromSeconds(10) });
|
||||
|
||||
|
||||
public AgentUpdateController(IWebHostEnvironment hostingEnv,
|
||||
public AgentUpdateController(IWebHostEnvironment hostingEnv,
|
||||
DataService dataService,
|
||||
ApplicationConfig appConfig)
|
||||
{
|
||||
|
||||
@ -56,7 +56,7 @@ namespace Remotely.Server.API
|
||||
{
|
||||
DataService.WriteEvent(ex, orgID);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (alertOptions.ShouldSendApiRequest)
|
||||
@ -82,7 +82,7 @@ namespace Remotely.Server.API
|
||||
{
|
||||
DataService.WriteEvent(ex, orgID);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return Ok();
|
||||
|
||||
@ -1,15 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Remotely.Server.Services;
|
||||
using System.Text;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System.Threading;
|
||||
using Remotely.Server.Attributes;
|
||||
using Remotely.Server.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Remotely.Server.API
|
||||
{
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
using System;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Remotely.Server.Attributes;
|
||||
using Remotely.Server.Services;
|
||||
using Remotely.Shared.Models;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Remotely.Shared.Models;
|
||||
using Remotely.Server.Services;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Remotely.Server.Attributes;
|
||||
|
||||
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
||||
|
||||
@ -100,33 +100,30 @@ namespace Remotely.Server.API
|
||||
[HttpPost("{resultType}")]
|
||||
public async Task Post(string resultType)
|
||||
{
|
||||
using (var sr = new StreamReader(Request.Body))
|
||||
using var sr = new StreamReader(Request.Body);
|
||||
var content = await sr.ReadToEndAsync();
|
||||
switch (resultType)
|
||||
{
|
||||
var content = await sr.ReadToEndAsync();
|
||||
switch (resultType)
|
||||
{
|
||||
case "PSCore":
|
||||
{
|
||||
var result = System.Text.Json.JsonSerializer.Deserialize<PSCoreCommandResult>(content);
|
||||
var commandResult = DataService.GetCommandResult(result.CommandResultID);
|
||||
commandResult.PSCoreResults.Add(result);
|
||||
DataService.AddOrUpdateCommandResult(commandResult);
|
||||
break;
|
||||
}
|
||||
case "WinPS":
|
||||
case "CMD":
|
||||
case "Bash":
|
||||
{
|
||||
var result = System.Text.Json.JsonSerializer.Deserialize<GenericCommandResult>(content);
|
||||
var commandResult = DataService.GetCommandResult(result.CommandResultID);
|
||||
commandResult.CommandResults.Add(result);
|
||||
DataService.AddOrUpdateCommandResult(commandResult);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
case "PSCore":
|
||||
{
|
||||
var result = System.Text.Json.JsonSerializer.Deserialize<PSCoreCommandResult>(content);
|
||||
var commandResult = DataService.GetCommandResult(result.CommandResultID);
|
||||
commandResult.PSCoreResults.Add(result);
|
||||
DataService.AddOrUpdateCommandResult(commandResult);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
case "WinPS":
|
||||
case "CMD":
|
||||
case "Bash":
|
||||
{
|
||||
var result = System.Text.Json.JsonSerializer.Deserialize<GenericCommandResult>(content);
|
||||
var commandResult = DataService.GetCommandResult(result.CommandResultID);
|
||||
commandResult.CommandResults.Add(result);
|
||||
DataService.AddOrUpdateCommandResult(commandResult);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,10 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
using Remotely.Shared.Models;
|
||||
using Remotely.Server.Services;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Http.Extensions;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Remotely.Server.Attributes;
|
||||
using Microsoft.AspNetCore.Http.Extensions;
|
||||
using Remotely.Server.Services;
|
||||
using Remotely.Shared.Models;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
||||
@ -15,14 +14,14 @@ namespace Remotely.Server.API
|
||||
[Route("api/[controller]")]
|
||||
public class DevicesController : ControllerBase
|
||||
{
|
||||
|
||||
|
||||
public DevicesController(DataService dataService)
|
||||
{
|
||||
DataService = dataService;
|
||||
}
|
||||
private DataService DataService { get; set; }
|
||||
|
||||
|
||||
|
||||
[HttpGet]
|
||||
[ServiceFilter(typeof(ApiAuthorizationFilter))]
|
||||
public IEnumerable<Device> Get()
|
||||
@ -54,7 +53,7 @@ namespace Remotely.Server.API
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> Create([FromBody]DeviceSetupOptions deviceOptions)
|
||||
public async Task<IActionResult> Create([FromBody] DeviceSetupOptions deviceOptions)
|
||||
{
|
||||
var device = await DataService.CreateDevice(deviceOptions);
|
||||
if (device is null)
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Remotely.Server.Services;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
||||
@ -17,7 +17,7 @@ namespace Remotely.Server.API
|
||||
DataService = dataService;
|
||||
}
|
||||
public DataService DataService { get; set; }
|
||||
|
||||
|
||||
[HttpGet("{id}")]
|
||||
public ActionResult Get(string id)
|
||||
{
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Remotely.Shared.Models;
|
||||
using Remotely.Server.Models;
|
||||
using Remotely.Server.Services;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Remotely.Server.Hubs;
|
||||
using Remotely.Server.Models;
|
||||
using Remotely.Server.Services;
|
||||
using Remotely.Shared.Models;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
||||
|
||||
@ -16,8 +16,8 @@ namespace Remotely.Server.API
|
||||
[ApiController]
|
||||
public class LoginController : ControllerBase
|
||||
{
|
||||
public LoginController(SignInManager<RemotelyUser> signInManager,
|
||||
DataService dataService,
|
||||
public LoginController(SignInManager<RemotelyUser> signInManager,
|
||||
DataService dataService,
|
||||
ApplicationConfig appConfig,
|
||||
IHubContext<CasterHub> casterHubContext,
|
||||
IHubContext<ViewerHub> viewerHubContext)
|
||||
@ -36,7 +36,7 @@ namespace Remotely.Server.API
|
||||
private IHubContext<ViewerHub> ViewerHubContext { get; }
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> Post([FromBody]ApiLogin login)
|
||||
public async Task<IActionResult> Post([FromBody] ApiLogin login)
|
||||
{
|
||||
if (!AppConfig.AllowApiLogin)
|
||||
{
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
using System.Text.Encodings.Web;
|
||||
using System.Threading.Tasks;
|
||||
using Remotely.Shared.Models;
|
||||
using Remotely.Server.Services;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Remotely.Shared.ViewModels.Organization;
|
||||
using System.Text;
|
||||
using Microsoft.AspNetCore.WebUtilities;
|
||||
using Remotely.Server.Attributes;
|
||||
using Remotely.Server.Services;
|
||||
using Remotely.Shared.Models;
|
||||
using Remotely.Shared.ViewModels.Organization;
|
||||
using System.Text;
|
||||
using System.Text.Encodings.Web;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
||||
|
||||
@ -31,15 +31,15 @@ namespace Remotely.Server.API
|
||||
|
||||
[HttpPost("ChangeIsAdmin/{userID}")]
|
||||
[ServiceFilter(typeof(ApiAuthorizationFilter))]
|
||||
public IActionResult ChangeIsAdmin(string userID, [FromBody]bool isAdmin)
|
||||
public IActionResult ChangeIsAdmin(string userID, [FromBody] bool isAdmin)
|
||||
{
|
||||
if (User.Identity.IsAuthenticated &&
|
||||
if (User.Identity.IsAuthenticated &&
|
||||
!DataService.GetUserByName(User.Identity.Name).IsAdministrator)
|
||||
{
|
||||
return Unauthorized();
|
||||
}
|
||||
|
||||
if (User.Identity.IsAuthenticated &&
|
||||
if (User.Identity.IsAuthenticated &&
|
||||
DataService.GetUserByName(User.Identity.Name).Id == userID)
|
||||
{
|
||||
return BadRequest("You can't remove administrator rights from yourself.");
|
||||
@ -89,7 +89,7 @@ namespace Remotely.Server.API
|
||||
|
||||
[HttpDelete("DeviceGroup")]
|
||||
[ServiceFilter(typeof(ApiAuthorizationFilter))]
|
||||
public IActionResult DeviceGroup([FromBody]string deviceGroupID)
|
||||
public IActionResult DeviceGroup([FromBody] string deviceGroupID)
|
||||
{
|
||||
if (User.Identity.IsAuthenticated &&
|
||||
!DataService.GetUserByName(User.Identity.Name).IsAdministrator)
|
||||
@ -104,7 +104,7 @@ namespace Remotely.Server.API
|
||||
|
||||
[HttpPost("DeviceGroup")]
|
||||
[ServiceFilter(typeof(ApiAuthorizationFilter))]
|
||||
public IActionResult DeviceGroup([FromBody]DeviceGroup deviceGroup)
|
||||
public IActionResult DeviceGroup([FromBody] DeviceGroup deviceGroup)
|
||||
{
|
||||
if (User.Identity.IsAuthenticated &&
|
||||
!DataService.GetUserByName(User.Identity.Name).IsAdministrator)
|
||||
@ -128,7 +128,7 @@ namespace Remotely.Server.API
|
||||
|
||||
[HttpDelete("DeviceGroup/{groupID}/Users/")]
|
||||
[ServiceFilter(typeof(ApiAuthorizationFilter))]
|
||||
public async Task<IActionResult> DeviceGroupRemoveUser([FromBody]string userID, string groupID)
|
||||
public async Task<IActionResult> DeviceGroupRemoveUser([FromBody] string userID, string groupID)
|
||||
{
|
||||
if (User.Identity.IsAuthenticated &&
|
||||
!DataService.GetUserByName(User.Identity.Name).IsAdministrator)
|
||||
@ -151,7 +151,7 @@ namespace Remotely.Server.API
|
||||
|
||||
[HttpPost("DeviceGroup/{groupID}/Users/")]
|
||||
[ServiceFilter(typeof(ApiAuthorizationFilter))]
|
||||
public IActionResult DeviceGroupAddUser([FromBody]string userID, string groupID)
|
||||
public IActionResult DeviceGroupAddUser([FromBody] string userID, string groupID)
|
||||
{
|
||||
if (User.Identity.IsAuthenticated &&
|
||||
!DataService.GetUserByName(User.Identity.Name).IsAdministrator)
|
||||
@ -170,7 +170,7 @@ namespace Remotely.Server.API
|
||||
{
|
||||
return BadRequest(resultMessage);
|
||||
}
|
||||
|
||||
|
||||
return Ok(resultMessage);
|
||||
}
|
||||
|
||||
@ -207,7 +207,7 @@ namespace Remotely.Server.API
|
||||
|
||||
[HttpPut("Name")]
|
||||
[ServiceFilter(typeof(ApiAuthorizationFilter))]
|
||||
public IActionResult Name([FromBody]string organizationName)
|
||||
public IActionResult Name([FromBody] string organizationName)
|
||||
{
|
||||
if (User.Identity.IsAuthenticated &&
|
||||
!DataService.GetUserByName(User.Identity.Name).IsAdministrator)
|
||||
@ -225,7 +225,7 @@ namespace Remotely.Server.API
|
||||
}
|
||||
[HttpPost("SendInvite")]
|
||||
[ServiceFilter(typeof(ApiAuthorizationFilter))]
|
||||
public async Task<IActionResult> SendInvite([FromBody]Invite invite)
|
||||
public async Task<IActionResult> SendInvite([FromBody] Invite invite)
|
||||
{
|
||||
if (User.Identity.IsAuthenticated &&
|
||||
!DataService.GetUserByName(User.Identity.Name).IsAdministrator)
|
||||
@ -278,7 +278,7 @@ namespace Remotely.Server.API
|
||||
|
||||
return Ok();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,16 +1,15 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Remotely.Shared.Models;
|
||||
using Remotely.Server.Attributes;
|
||||
using Remotely.Server.Hubs;
|
||||
using Remotely.Server.Models;
|
||||
using Remotely.Server.Services;
|
||||
using Remotely.Server.Attributes;
|
||||
using Remotely.Shared.Helpers;
|
||||
using Remotely.Server.Hubs;
|
||||
using Remotely.Shared.Models;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
||||
|
||||
@ -20,9 +19,9 @@ namespace Remotely.Server.API
|
||||
[ApiController]
|
||||
public class RemoteControlController : ControllerBase
|
||||
{
|
||||
public RemoteControlController(DataService dataService,
|
||||
IHubContext<AgentHub> agentHub,
|
||||
ApplicationConfig appConfig,
|
||||
public RemoteControlController(DataService dataService,
|
||||
IHubContext<AgentHub> agentHub,
|
||||
ApplicationConfig appConfig,
|
||||
SignInManager<RemotelyUser> signInManager)
|
||||
{
|
||||
DataService = dataService;
|
||||
@ -45,7 +44,7 @@ namespace Remotely.Server.API
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> Post([FromBody]RemoteControlRequest rcRequest)
|
||||
public async Task<IActionResult> Post([FromBody] RemoteControlRequest rcRequest)
|
||||
{
|
||||
if (!AppConfig.AllowApiLogin)
|
||||
{
|
||||
@ -77,7 +76,7 @@ namespace Remotely.Server.API
|
||||
|
||||
private async Task<IActionResult> InitiateRemoteControl(string deviceID, string orgID)
|
||||
{
|
||||
var targetDevice = Hubs.AgentHub.ServiceConnections.FirstOrDefault(x =>
|
||||
var targetDevice = Hubs.AgentHub.ServiceConnections.FirstOrDefault(x =>
|
||||
x.Value.OrganizationID == orgID &&
|
||||
x.Value.ID.ToLower() == deviceID.ToLower());
|
||||
|
||||
|
||||
@ -1,16 +1,16 @@
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Remotely.Server.Attributes;
|
||||
using Remotely.Server.Hubs;
|
||||
using Remotely.Server.Services;
|
||||
using Remotely.Shared.Helpers;
|
||||
using Remotely.Shared.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Remotely.Shared.Helpers;
|
||||
using System.IO;
|
||||
using Remotely.Server.Attributes;
|
||||
using Remotely.Server.Hubs;
|
||||
|
||||
namespace Remotely.Server.API
|
||||
{
|
||||
@ -18,7 +18,7 @@ namespace Remotely.Server.API
|
||||
[Route("api/[controller]")]
|
||||
public class ScriptingController : ControllerBase
|
||||
{
|
||||
public ScriptingController(DataService dataService,
|
||||
public ScriptingController(DataService dataService,
|
||||
UserManager<RemotelyUser> userManager,
|
||||
IHubContext<AgentHub> agentHub)
|
||||
{
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Remotely.Server.Attributes;
|
||||
using Remotely.Server.Services;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Remotely.Server.API
|
||||
{
|
||||
|
||||
@ -7,7 +7,8 @@ namespace Remotely.Server.Areas.Identity
|
||||
{
|
||||
public void Configure(IWebHostBuilder builder)
|
||||
{
|
||||
builder.ConfigureServices((context, services) => {
|
||||
builder.ConfigureServices((context, services) =>
|
||||
{
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.AspNetCore.WebUtilities;
|
||||
using Remotely.Shared.Models;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Remotely.Server.Areas.Identity.Pages.Account
|
||||
{
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.AspNetCore.WebUtilities;
|
||||
using Remotely.Shared.Models;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Remotely.Server.Areas.Identity.Pages.Account
|
||||
{
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Text.Encodings.Web;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.AspNetCore.WebUtilities;
|
||||
using Remotely.Shared.Models;
|
||||
using Remotely.Server.Services;
|
||||
using Remotely.Shared.Models;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Text;
|
||||
using System.Text.Encodings.Web;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Remotely.Server.Areas.Identity.Pages.Account
|
||||
{
|
||||
@ -70,7 +70,7 @@ namespace Remotely.Server.Areas.Identity.Pages.Account
|
||||
ModelState.AddModelError("EmailError", "Error sending email.");
|
||||
return Page();
|
||||
}
|
||||
|
||||
|
||||
|
||||
return RedirectToPage("./ForgotPasswordConfirmation");
|
||||
}
|
||||
|
||||
@ -1,17 +1,17 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Remotely.Shared.Models;
|
||||
using Remotely.Server.Services;
|
||||
using Microsoft.AspNetCore.WebUtilities;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Remotely.Server.Services;
|
||||
using Remotely.Shared.Models;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Remotely.Server.Areas.Identity.Pages.Account
|
||||
{
|
||||
@ -23,9 +23,9 @@ namespace Remotely.Server.Areas.Identity.Pages.Account
|
||||
private readonly UserManager<RemotelyUser> _userManager;
|
||||
private readonly ILogger<LoginModel> _logger;
|
||||
|
||||
public LoginModel(SignInManager<RemotelyUser> signInManager,
|
||||
public LoginModel(SignInManager<RemotelyUser> signInManager,
|
||||
UserManager<RemotelyUser> userManager,
|
||||
DataService dataService,
|
||||
DataService dataService,
|
||||
ILogger<LoginModel> logger)
|
||||
{
|
||||
_dataService = dataService;
|
||||
@ -65,7 +65,7 @@ namespace Remotely.Server.Areas.Identity.Pages.Account
|
||||
ModelState.AddModelError(string.Empty, ErrorMessage);
|
||||
}
|
||||
|
||||
returnUrl = returnUrl ?? Url.Content("~/");
|
||||
returnUrl ??= Url.Content("~/");
|
||||
|
||||
// Clear the existing external cookie to ensure a clean login process
|
||||
await HttpContext.SignOutAsync(IdentityConstants.ExternalScheme);
|
||||
@ -77,7 +77,7 @@ namespace Remotely.Server.Areas.Identity.Pages.Account
|
||||
|
||||
public async Task<IActionResult> OnPostAsync(string returnUrl = null)
|
||||
{
|
||||
returnUrl = returnUrl ?? Url.Content("~/");
|
||||
returnUrl ??= Url.Content("~/");
|
||||
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
@ -91,7 +91,7 @@ namespace Remotely.Server.Areas.Identity.Pages.Account
|
||||
}
|
||||
if (result.RequiresTwoFactor)
|
||||
{
|
||||
return RedirectToPage("./LoginWith2fa", new { ReturnUrl = returnUrl, RememberMe = Input.RememberMe });
|
||||
return RedirectToPage("./LoginWith2fa", new { ReturnUrl = returnUrl, Input.RememberMe });
|
||||
}
|
||||
if (result.IsLockedOut)
|
||||
{
|
||||
|
||||
@ -1,14 +1,13 @@
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Remotely.Server.Hubs;
|
||||
using Remotely.Server.Services;
|
||||
using Remotely.Shared.Models;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Remotely.Server.Areas.Identity.Pages.Account
|
||||
{
|
||||
@ -46,7 +45,7 @@ namespace Remotely.Server.Areas.Identity.Pages.Account
|
||||
await ViewerHubContext.Clients.Client(session.Value.RequesterSocketID).SendAsync("ConnectionFailed");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
await _signInManager.SignOutAsync();
|
||||
_logger.LogInformation("User logged out.");
|
||||
if (returnUrl != null)
|
||||
|
||||
@ -1,7 +1,3 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@ -9,6 +5,10 @@ using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Remotely.Server.Services;
|
||||
using Remotely.Shared.Models;
|
||||
using Remotely.Shared.Utilities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Remotely.Server.Areas.Identity.Pages.Account.Manage
|
||||
{
|
||||
@ -44,8 +44,8 @@ namespace Remotely.Server.Areas.Identity.Pages.Account.Manage
|
||||
|
||||
public async Task<IActionResult> OnPostRenameAsync()
|
||||
{
|
||||
if (ModelState.IsValid &&
|
||||
!string.IsNullOrWhiteSpace(Input.TokenId) &&
|
||||
if (ModelState.IsValid &&
|
||||
!string.IsNullOrWhiteSpace(Input.TokenId) &&
|
||||
!string.IsNullOrWhiteSpace(Input.TokenName))
|
||||
{
|
||||
await DataService.RenameApiToken(User.Identity.Name, Input.TokenId, Input.TokenName);
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Text;
|
||||
using System.Text.Encodings.Web;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Remotely.Shared.Models;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Encodings.Web;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Remotely.Server.Areas.Identity.Pages.Account.Manage
|
||||
{
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Text.Encodings.Web;
|
||||
using System.Threading.Tasks;
|
||||
using Remotely.Shared.Models;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.AspNetCore.WebUtilities;
|
||||
using System.Text;
|
||||
using Remotely.Server.Services;
|
||||
using Remotely.Shared.Models;
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Text;
|
||||
using System.Text.Encodings.Web;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Remotely.Server.Areas.Identity.Pages.Account.Manage
|
||||
{
|
||||
@ -123,7 +123,7 @@ namespace Remotely.Server.Areas.Identity.Pages.Account.Manage
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (Input.DisplayName != user.DisplayName)
|
||||
{
|
||||
@ -155,7 +155,7 @@ namespace Remotely.Server.Areas.Identity.Pages.Account.Manage
|
||||
var callbackUrl = Url.Page(
|
||||
"/Account/ConfirmEmail",
|
||||
pageHandler: null,
|
||||
values: new { area = "Identity", userId = user.Id, code = code },
|
||||
values: new { area = "Identity", userId = user.Id, code },
|
||||
protocol: Request.Scheme);
|
||||
var emailResult = await _emailSender.SendEmailAsync(
|
||||
email,
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
using System;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using System;
|
||||
|
||||
namespace Remotely.Server.Areas.Identity.Pages.Account.Manage
|
||||
{
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
using Remotely.Shared.Models;
|
||||
using Remotely.Server.Services;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Remotely.Server.Services;
|
||||
using Remotely.Shared.Models;
|
||||
|
||||
namespace Remotely.Server.Areas.Identity.Pages.Account.Manage
|
||||
{
|
||||
|
||||
@ -1,15 +1,15 @@
|
||||
using Remotely.Shared.Models;
|
||||
using Remotely.Server.Services;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Remotely.Server.Services;
|
||||
using Remotely.Shared.Models;
|
||||
using Remotely.Shared.ViewModels.Organization;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using Remotely.Shared.ViewModels.Organization;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Threading.Tasks;
|
||||
using System.Text.Encodings.Web;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Remotely.Server.Areas.Identity.Pages.Account.Manage
|
||||
{
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Remotely.Server.Services;
|
||||
using Remotely.Shared.Enums;
|
||||
using Remotely.Shared.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Remotely.Server.Areas.Identity.Pages.Account.Manage
|
||||
{
|
||||
@ -37,17 +37,17 @@ namespace Remotely.Server.Areas.Identity.Pages.Account.Manage
|
||||
{
|
||||
var from = Input.FromDate ?? DateTimeOffset.MinValue;
|
||||
var to = Input.ToDate ?? DateTimeOffset.MaxValue;
|
||||
EventLogs = DataService.GetEventLogs(User.Identity.Name,
|
||||
EventLogs = DataService.GetEventLogs(User.Identity.Name,
|
||||
from,
|
||||
to,
|
||||
to,
|
||||
Input.Type,
|
||||
Input.Message);
|
||||
}
|
||||
else
|
||||
{
|
||||
EventLogs = DataService.GetEventLogs(User.Identity.Name,
|
||||
EventLogs = DataService.GetEventLogs(User.Identity.Name,
|
||||
DateTimeOffset.Now.AddDays(-10),
|
||||
DateTimeOffset.Now,
|
||||
DateTimeOffset.Now,
|
||||
Input.Type,
|
||||
Input.Message);
|
||||
}
|
||||
|
||||
@ -1,10 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Encodings.Web;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@ -13,6 +7,12 @@ using Microsoft.AspNetCore.WebUtilities;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Remotely.Server.Services;
|
||||
using Remotely.Shared.Models;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Encodings.Web;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Remotely.Server.Areas.Identity.Pages.Account
|
||||
{
|
||||
@ -81,7 +81,7 @@ namespace Remotely.Server.Areas.Identity.Pages.Account
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
returnUrl = returnUrl ?? Url.Content("~/");
|
||||
returnUrl ??= Url.Content("~/");
|
||||
ExternalLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync()).ToList();
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
@ -102,7 +102,7 @@ namespace Remotely.Server.Areas.Identity.Pages.Account
|
||||
var callbackUrl = Url.Page(
|
||||
"/Account/ConfirmEmail",
|
||||
pageHandler: null,
|
||||
values: new { area = "Identity", userId = user.Id, code = code },
|
||||
values: new { area = "Identity", userId = user.Id, code },
|
||||
protocol: Request.Scheme);
|
||||
|
||||
await _emailSender.SendEmailAsync(Input.Email, "Confirm your email",
|
||||
|
||||
@ -1,10 +1,7 @@
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Remotely.Server.Attributes
|
||||
{
|
||||
|
||||
@ -15,7 +15,7 @@ namespace Remotely.Server.Attributes
|
||||
|
||||
public void OnAuthorization(AuthorizationFilterContext context)
|
||||
{
|
||||
|
||||
|
||||
if (context.HttpContext.User.Identity.IsAuthenticated)
|
||||
{
|
||||
var orgID = DataService.GetUserByName(context.HttpContext.User.Identity.Name)?.OrganizationID;
|
||||
@ -27,7 +27,7 @@ namespace Remotely.Server.Attributes
|
||||
{
|
||||
var apiToken = result.ToString().Split(":")[0]?.Trim();
|
||||
var apiSecret = result.ToString().Split(":")[1]?.Trim();
|
||||
|
||||
|
||||
if (DataService.ValidateApiToken(apiToken, apiSecret, context.HttpContext.Request.Path, context.HttpContext.Connection.RemoteIpAddress.ToString()))
|
||||
{
|
||||
var orgID = DataService.GetApiToken(apiToken)?.OrganizationID;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user