mirror of
https://github.com/immense/Remotely.git
synced 2025-10-26 11:27:15 +00:00
Don't uninstall agent after server verification fails. A server misconfiguration could cause all agents to uninstall.
This commit is contained in:
parent
2024779cf5
commit
eea444c2fc
@ -150,10 +150,22 @@ namespace Remotely.Agent.Services
|
||||
// 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) => {
|
||||
if (!IsServerVerified)
|
||||
{
|
||||
Logger.Write("Chat attempted before server was verified.", EventType.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
await ChatService.SendMessage(senderName, message, orgName, disconnected, senderConnectionID, HubConnection);
|
||||
});
|
||||
HubConnection.On("DownloadFile", async (string filePath, string senderConnectionID) =>
|
||||
{
|
||||
if (!IsServerVerified)
|
||||
{
|
||||
Logger.Write("File download attempted before server was verified.", EventType.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
filePath = filePath.Replace("\"", "");
|
||||
if (!File.Exists(filePath))
|
||||
{
|
||||
@ -168,14 +180,19 @@ namespace Remotely.Agent.Services
|
||||
});
|
||||
HubConnection.On("ChangeWindowsSession", async (string serviceID, string viewerID, int targetSessionID) =>
|
||||
{
|
||||
if (!IsServerVerified)
|
||||
{
|
||||
Logger.Write("Session change attempted before server was verified.", EventType.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
await AppLauncher.RestartScreenCaster(new List<string>() { viewerID }, serviceID, viewerID, HubConnection, targetSessionID);
|
||||
});
|
||||
HubConnection.On("ExecuteCommand", (async (string mode, string command, string commandID, string senderConnectionID) =>
|
||||
{
|
||||
if (!IsServerVerified)
|
||||
{
|
||||
Logger.Write($"Command attempted before server was verified. Mode: {mode}. Command: {command}. Sender: {senderConnectionID}");
|
||||
Uninstaller.UninstallAgent();
|
||||
Logger.Write($"Command attempted before server was verified. Mode: {mode}. Command: {command}. Sender: {senderConnectionID}", EventType.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -185,8 +202,7 @@ namespace Remotely.Agent.Services
|
||||
{
|
||||
if (!IsServerVerified)
|
||||
{
|
||||
Logger.Write($"Command attempted before server was verified. Mode: {mode}. Command: {command}. Sender: {senderUserName}");
|
||||
Uninstaller.UninstallAgent();
|
||||
Logger.Write($"Command attempted before server was verified. Mode: {mode}. Command: {command}. Sender: {senderUserName}", EventType.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -194,6 +210,12 @@ namespace Remotely.Agent.Services
|
||||
}));
|
||||
HubConnection.On("UploadFiles", async (string transferID, List<string> fileIDs, string requesterID) =>
|
||||
{
|
||||
if (!IsServerVerified)
|
||||
{
|
||||
Logger.Write("File upload attempted before server was verified.", EventType.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
Logger.Write($"File upload started by {requesterID}.");
|
||||
var sharedFilePath = Directory.CreateDirectory(Path.Combine(Path.GetTempPath(),"RemotelySharedFiles")).FullName;
|
||||
|
||||
@ -226,13 +248,13 @@ namespace Remotely.Agent.Services
|
||||
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}");
|
||||
Uninstaller.UninstallAgent();
|
||||
Logger.Write($"Script deploy attempted before server was verified. Mode: {mode}. File ID: {fileID}. Sender: {requesterID}", EventType.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
await ScriptRunner.RunScript(mode, fileID, commandResultID, requesterID, HubConnection);
|
||||
});
|
||||
|
||||
HubConnection.On("UninstallClient", () =>
|
||||
{
|
||||
Uninstaller.UninstallAgent();
|
||||
@ -242,8 +264,7 @@ namespace Remotely.Agent.Services
|
||||
{
|
||||
if (!IsServerVerified)
|
||||
{
|
||||
Logger.Write("Remote control attempted before server was verified.");
|
||||
Uninstaller.UninstallAgent();
|
||||
Logger.Write("Remote control attempted before server was verified.", EventType.Warning);
|
||||
return;
|
||||
}
|
||||
await AppLauncher.LaunchRemoteControl(-1, requesterID, serviceID, HubConnection);
|
||||
@ -252,14 +273,18 @@ namespace Remotely.Agent.Services
|
||||
{
|
||||
if (!IsServerVerified)
|
||||
{
|
||||
Logger.Write("Remote control attempted before server was verified.");
|
||||
Uninstaller.UninstallAgent();
|
||||
Logger.Write("Remote control attempted before server was verified.", EventType.Warning);
|
||||
return;
|
||||
}
|
||||
await AppLauncher.RestartScreenCaster(viewerIDs, serviceID, requesterID, HubConnection);
|
||||
});
|
||||
HubConnection.On("CtrlAltDel", () =>
|
||||
{
|
||||
if (!IsServerVerified)
|
||||
{
|
||||
Logger.Write("CtrlAltDel attempted before server was verified.", EventType.Warning);
|
||||
return;
|
||||
}
|
||||
User32.SendSAS(false);
|
||||
});
|
||||
|
||||
@ -271,8 +296,7 @@ namespace Remotely.Agent.Services
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Write($"Server sent an incorrect verification token. Token Sent: {verificationToken}.");
|
||||
Uninstaller.UninstallAgent();
|
||||
Logger.Write($"Server sent an incorrect verification token. Token Sent: {verificationToken}.", EventType.Warning);
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user