diff --git a/Remotely_Agent/Services/DeviceSocket.cs b/Remotely_Agent/Services/DeviceSocket.cs index ba657586..b97343b8 100644 --- a/Remotely_Agent/Services/DeviceSocket.cs +++ b/Remotely_Agent/Services/DeviceSocket.cs @@ -285,12 +285,11 @@ namespace Remotely_Agent.Services } try { - var filePath = ExtractScreenCasterEXE(); - // Start ScreenCast. if (OSUtils.IsWindows) { - + var filePath = ExtractScreenCasterEXE(); + if (Program.IsDebug) { Process.Start(filePath, $"-mode Unattended -requester {requesterID} -serviceid {serviceID} -host {Utilities.GetConnectionInfo().Host} -relaunch true -desktop default -viewers {String.Join(",", viewerIDs)}"); diff --git a/Remotely_Agent/Services/Logger.cs b/Remotely_Agent/Services/Logger.cs index 83b3d8c9..549c0d0c 100644 --- a/Remotely_Agent/Services/Logger.cs +++ b/Remotely_Agent/Services/Logger.cs @@ -6,7 +6,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace Remotely_Agent.Client +namespace Remotely_Agent.Services { public static class Logger { diff --git a/Remotely_Desktop/App.xaml b/Remotely_Desktop/App.xaml index 3ecfb3dd..1bee3ba4 100644 --- a/Remotely_Desktop/App.xaml +++ b/Remotely_Desktop/App.xaml @@ -4,6 +4,26 @@ xmlns:local="clr-namespace:Remotely_Desktop" StartupUri="MainWindow.xaml"> - + + + diff --git a/Remotely_Desktop/FodyWeavers.xml b/Remotely_Desktop/FodyWeavers.xml new file mode 100644 index 00000000..743daa95 --- /dev/null +++ b/Remotely_Desktop/FodyWeavers.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/Remotely_Desktop/FodyWeavers.xsd b/Remotely_Desktop/FodyWeavers.xsd new file mode 100644 index 00000000..1d113f97 --- /dev/null +++ b/Remotely_Desktop/FodyWeavers.xsd @@ -0,0 +1,140 @@ + + + + + + + + + + + + A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks + + + + + A list of assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks. + + + + + A list of unmanaged 32 bit assembly names to include, delimited with line breaks. + + + + + A list of unmanaged 64 bit assembly names to include, delimited with line breaks. + + + + + The order of preloaded assemblies, delimited with line breaks. + + + + + + This will copy embedded files to disk before loading them into memory. This is helpful for some scenarios that expected an assembly to be loaded from a physical file. + + + + + Controls if .pdbs for reference assemblies are also embedded. + + + + + Embedded assemblies are compressed by default, and uncompressed when they are loaded. You can turn compression off with this option. + + + + + As part of Costura, embedded assemblies are no longer included as part of the build. This cleanup can be turned off. + + + + + Costura by default will load as part of the module initialization. This flag disables that behavior. Make sure you call CosturaUtility.Initialize() somewhere in your code. + + + + + Costura will by default use assemblies with a name like 'resources.dll' as a satellite resource and prepend the output path. This flag disables that behavior. + + + + + A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with | + + + + + A list of assembly names to include from the default action of "embed all Copy Local references", delimited with |. + + + + + A list of unmanaged 32 bit assembly names to include, delimited with |. + + + + + A list of unmanaged 64 bit assembly names to include, delimited with |. + + + + + The order of preloaded assemblies, delimited with |. + + + + + + + + + Used to control if the On_PropertyName_Changed feature is enabled. + + + + + Used to change the name of the method that fires the notify event. This is a string that accepts multiple values in a comma separated form. + + + + + Used to control if equality checks should be inserted. If false, equality checking will be disabled for the project. + + + + + Used to control if equality checks should use the Equals method resolved from the base class. + + + + + Used to control if equality checks should use the static Equals method resolved from the base class. + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/Remotely_Desktop/MainWindow.xaml b/Remotely_Desktop/MainWindow.xaml index 23fd530d..147b798c 100644 --- a/Remotely_Desktop/MainWindow.xaml +++ b/Remotely_Desktop/MainWindow.xaml @@ -1,12 +1,52 @@ - - - - + Title="Remotely" Height="350" Width="400" MouseLeftButtonDown="Window_MouseLeftButtonDown" WindowStyle="None" ResizeMode="NoResize" Icon="favicon.ico"> + + + + + + + + Remotely + + + + + + + + + + + + + + + diff --git a/Remotely_Desktop/MainWindow.xaml.cs b/Remotely_Desktop/MainWindow.xaml.cs index 2e6ab9c1..d5a864e7 100644 --- a/Remotely_Desktop/MainWindow.xaml.cs +++ b/Remotely_Desktop/MainWindow.xaml.cs @@ -1,4 +1,5 @@ -using System; +using Remotely_Desktop.ViewModels; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -23,6 +24,27 @@ namespace Remotely_Desktop public MainWindow() { InitializeComponent(); + DataContext = new MainWindowViewModel(); + } + + private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) + { + DragMove(); + } + + private void Button_Click(object sender, RoutedEventArgs e) + { + + } + + private void CloseButton_Click(object sender, RoutedEventArgs e) + { + App.Current.Shutdown(); + } + + private void MinimizeButton_Click(object sender, RoutedEventArgs e) + { + this.WindowState = WindowState.Minimized; } } } diff --git a/Remotely_Desktop/Models/Viewer.cs b/Remotely_Desktop/Models/Viewer.cs new file mode 100644 index 00000000..43ab205d --- /dev/null +++ b/Remotely_Desktop/Models/Viewer.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Remotely_Desktop.Models +{ + public class Viewer + { + public string ConnectionId { get; set; } + public string Name { get; set; } + public bool HasControl { get; set; } + } +} diff --git a/Remotely_Desktop/Remotely_Desktop.csproj b/Remotely_Desktop/Remotely_Desktop.csproj index dc85216e..80f4dccb 100644 --- a/Remotely_Desktop/Remotely_Desktop.csproj +++ b/Remotely_Desktop/Remotely_Desktop.csproj @@ -1,5 +1,7 @@  + + Debug @@ -14,6 +16,8 @@ 4 true true + + AnyCPU @@ -34,9 +38,22 @@ prompt 4 + + favicon.ico + + + ..\packages\Costura.Fody.3.3.2\lib\net40\Costura.dll + + + ..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll + + + ..\packages\PropertyChanged.Fody.2.6.0\lib\net452\PropertyChanged.dll + + @@ -55,6 +72,9 @@ MSBuild:Compile Designer + + + MSBuild:Compile Designer @@ -69,6 +89,7 @@ + Code @@ -86,6 +107,7 @@ ResXFileCodeGenerator Resources.Designer.cs + SettingsSingleFileGenerator Settings.Designer.cs @@ -94,5 +116,24 @@ + + + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + \ No newline at end of file diff --git a/Remotely_Desktop/Resources/Remotely_ScreenCast.exe b/Remotely_Desktop/Resources/Remotely_ScreenCast.exe new file mode 100644 index 00000000..79af2630 Binary files /dev/null and b/Remotely_Desktop/Resources/Remotely_ScreenCast.exe differ diff --git a/Remotely_Desktop/Services/Config.cs b/Remotely_Desktop/Services/Config.cs new file mode 100644 index 00000000..a311dbf2 --- /dev/null +++ b/Remotely_Desktop/Services/Config.cs @@ -0,0 +1,51 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.Serialization.Json; +using System.Text; +using System.Threading.Tasks; + +namespace Remotely_Desktop.Services +{ + public class Config + { + private static string ConfigFolder => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Remotely"); + private static string ConfigFile => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Remotely", "Config.json"); + + public static Config GetConfig() + { + if (Directory.Exists(ConfigFolder)) + { + return new Config(); + } + + if (File.Exists(ConfigFile)) + { + var serializer = new DataContractJsonSerializer(typeof(Config)); + try + { + return JsonConvert.DeserializeObject(File.ReadAllText(ConfigFile)); + } + catch + { + return new Config(); + } + } + return new Config(); + } + + public static void SaveConfig(Config config) + { + try + { + File.WriteAllText(ConfigFile, JsonConvert.SerializeObject(config)); + } + catch + { + } + } + public string Host { get; set; } + } +} diff --git a/Remotely_Desktop/Services/Logger.cs b/Remotely_Desktop/Services/Logger.cs new file mode 100644 index 00000000..a79d12de --- /dev/null +++ b/Remotely_Desktop/Services/Logger.cs @@ -0,0 +1,66 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Remotely_Desktop.Services +{ + public static class Logger + { + public static void Write(string message) + { + var path = Path.Combine(Path.GetTempPath(), "Remotely_Logs.txt"); + + var jsoninfo = new + { + Type = "Info", + Timestamp = DateTime.Now.ToString(), + Message = message + }; + if (File.Exists(path)) + { + var fi = new FileInfo(path); + while (fi.Length > 1000000) + { + var content = File.ReadAllLines(path); + File.WriteAllLines(path, content.Skip(10)); + fi = new FileInfo(path); + } + } + File.AppendAllText(path, JsonConvert.SerializeObject(jsoninfo) + Environment.NewLine); + } + + public static void Write(Exception ex) + { + var exception = ex; + var path = Path.Combine(Path.GetTempPath(), "Remotely_Logs.txt"); + + while (exception != null) + { + var jsonError = new + { + Type = "Error", + Timestamp = DateTime.Now.ToString(), + Message = exception?.Message, + Source = exception?.Source, + StackTrace = exception?.StackTrace, + }; + if (File.Exists(path)) + { + var fi = new FileInfo(path); + while (fi.Length > 1000000) + { + var content = File.ReadAllLines(path); + File.WriteAllLines(path, content.Skip(10)); + fi = new FileInfo(path); + } + } + File.AppendAllText(path, JsonConvert.SerializeObject(jsonError) + Environment.NewLine); + exception = exception.InnerException; + } + } + } +} diff --git a/Remotely_Desktop/ViewModels/MainWindowViewModel.cs b/Remotely_Desktop/ViewModels/MainWindowViewModel.cs new file mode 100644 index 00000000..0ce9c072 --- /dev/null +++ b/Remotely_Desktop/ViewModels/MainWindowViewModel.cs @@ -0,0 +1,57 @@ +using Remotely_Desktop.Models; +using Remotely_Desktop.Services; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; + +namespace Remotely_Desktop.ViewModels +{ + public class MainWindowViewModel + { + public ObservableCollection Viewers { get; set; } + public string SessionID { get; set; } = "Retrieving..."; + + private Process LaunchScreenCaster() + { + var filePath = ExtractScreenCasterEXE(); + return Process.Start(filePath, $"-mode Normal -host {Config.GetConfig().Host}"); + } + private string ExtractScreenCasterEXE() + { + // Cleanup old files. + foreach (var file in Directory.GetFiles(Path.GetTempPath(), "Remotely_ScreenCast*")) + { + try + { + File.Delete(file); + } + catch { } + } + + // Get temp file name. + var count = 0; + var filePath = Path.Combine(Path.GetTempPath(), "Remotely_ScreenCast.exe"); + while (File.Exists(filePath)) + { + filePath = Path.Combine(Path.GetTempPath(), $"Remotely_ScreenCast{count}.exe"); + count++; + } + + // Extract ScreenCast. + using (var mrs = Assembly.GetExecutingAssembly().GetManifestResourceStream("Remotely_Desktop.Resources.Remotely_ScreenCast.exe")) + { + using (var fs = new FileStream(filePath, FileMode.Create)) + { + mrs.CopyTo(fs); + } + } + return filePath; + } + } +} diff --git a/Remotely_Desktop/favicon.ico b/Remotely_Desktop/favicon.ico new file mode 100644 index 00000000..55aaa8ca Binary files /dev/null and b/Remotely_Desktop/favicon.ico differ diff --git a/Remotely_Desktop/packages.config b/Remotely_Desktop/packages.config new file mode 100644 index 00000000..fd24ce1b --- /dev/null +++ b/Remotely_Desktop/packages.config @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Remotely_ScreenCast/Program.cs b/Remotely_ScreenCast/Program.cs index ed06179b..108f196a 100644 --- a/Remotely_ScreenCast/Program.cs +++ b/Remotely_ScreenCast/Program.cs @@ -60,7 +60,7 @@ namespace Remotely_ScreenCast if (desktopName.ToLower() != CurrentDesktopName.ToLower()) { CurrentDesktopName = desktopName; - Logger.Write($"Relaunching in desktop {desktopName}."); + Logger.Write($"Setting initial desktop to {desktopName}."); argDict["desktop"] = desktopName; var openProcessString = Assembly.GetExecutingAssembly().Location; foreach (var arg in argDict) @@ -81,6 +81,7 @@ namespace Remotely_ScreenCast if (argDict.ContainsKey("relaunch")) { + Logger.Write($"Resuming after relaunch in desktop {desktopName}."); var viewersString = argDict["viewers"]; var viewerIDs = viewersString.Split(",".ToCharArray()); OutgoingMessages.NotifyViewersRelaunchedScreenCasterReady(viewerIDs).Wait(); diff --git a/Remotely_Server/Pages/Shared/_Layout.cshtml b/Remotely_Server/Pages/Shared/_Layout.cshtml index 24b1fe13..d878b8cf 100644 --- a/Remotely_Server/Pages/Shared/_Layout.cshtml +++ b/Remotely_Server/Pages/Shared/_Layout.cshtml @@ -2,7 +2,7 @@ - + @ViewData["Title"] - Remotely diff --git a/Remotely_Server/Services/RCDeviceSocketHub.cs b/Remotely_Server/Services/RCDeviceSocketHub.cs index b9990024..19189696 100644 --- a/Remotely_Server/Services/RCDeviceSocketHub.cs +++ b/Remotely_Server/Services/RCDeviceSocketHub.cs @@ -76,7 +76,7 @@ namespace Remotely_Server.Services if (ViewerList.Count > 0) { await RCBrowserHub.Clients.Clients(ViewerList).SendAsync("Reconnecting"); - await DeviceHub.Clients.Client(ServiceID).SendAsync("RestartScreenCaster", ViewerList, ServiceID, Context.ConnectionId); + await DeviceHub.Clients.Client(ServiceID).SendAsync("RestartScreenCaster", ViewerList, ServiceID, Context.ConnectionId); } } await base.OnDisconnectedAsync(exception); diff --git a/Remotely_Server/wwwroot/Downloads/CurrentAgentVersion.txt b/Remotely_Server/wwwroot/Downloads/CurrentAgentVersion.txt index 57b6292d..07031ae6 100644 --- a/Remotely_Server/wwwroot/Downloads/CurrentAgentVersion.txt +++ b/Remotely_Server/wwwroot/Downloads/CurrentAgentVersion.txt @@ -1 +1 @@ -2019.03.12.1040 +2019.03.13.1044 diff --git a/Remotely_Server/wwwroot/css/Themes/cyborg.custom.css b/Remotely_Server/wwwroot/css/Themes/cyborg.custom.css index a5d3a6eb..47f72155 100644 --- a/Remotely_Server/wwwroot/css/Themes/cyborg.custom.css +++ b/Remotely_Server/wwwroot/css/Themes/cyborg.custom.css @@ -38,7 +38,7 @@ button.navbar-toggler:hover { } .table-hover > tbody > .record-row.row-selected { - background-color: rgb(75, 75, 75); + color: limegreen; } #consoleStatusDiv select {