From f299c34873b1553cd8d9a240bec525e5f2f49970 Mon Sep 17 00:00:00 2001 From: Jared Date: Sun, 3 Jan 2021 07:58:03 -0800 Subject: [PATCH] Add per-device WebRTC setting. --- Desktop.Core/Services/CasterSocket.cs | 9 +- Desktop.Core/Services/ScreenCaster.cs | 4 +- Desktop.Core/Utilities/ImageUtils.cs | 16 +- Server/Hubs/AgentHub.cs | 1 + Server/Hubs/ViewerHub.cs | 16 +- .../20210103153552_WebRtcSetting.Designer.cs | 783 +++++++++++++++++ .../20210103153552_WebRtcSetting.cs | 24 + .../PostgreSqlDbContextModelSnapshot.cs | 5 +- .../20210103153621_WebRtcSetting.Designer.cs | 785 ++++++++++++++++++ .../SqlServer/20210103153621_WebRtcSetting.cs | 60 ++ .../SqlServerDbContextModelSnapshot.cs | 5 +- .../20210103153501_WebRtcSetting.Designer.cs | 784 +++++++++++++++++ .../Sqlite/20210103153501_WebRtcSetting.cs | 24 + .../Sqlite/SqliteDbContextModelSnapshot.cs | 5 +- Server/Pages/EditDevice.cshtml | 12 + Server/Pages/EditDevice.cshtml.cs | 5 +- Server/Services/DataService.cs | 5 +- Shared/Enums/WebRtcSetting.cs | 15 + Shared/Models/Device.cs | 4 +- Shared/Models/ScreenCastRequest.cs | 1 + Tests/DataServiceTests.cs | 2 +- 21 files changed, 2540 insertions(+), 25 deletions(-) create mode 100644 Server/Migrations/PostgreSql/20210103153552_WebRtcSetting.Designer.cs create mode 100644 Server/Migrations/PostgreSql/20210103153552_WebRtcSetting.cs create mode 100644 Server/Migrations/SqlServer/20210103153621_WebRtcSetting.Designer.cs create mode 100644 Server/Migrations/SqlServer/20210103153621_WebRtcSetting.cs create mode 100644 Server/Migrations/Sqlite/20210103153501_WebRtcSetting.Designer.cs create mode 100644 Server/Migrations/Sqlite/20210103153501_WebRtcSetting.cs create mode 100644 Shared/Enums/WebRtcSetting.cs diff --git a/Desktop.Core/Services/CasterSocket.cs b/Desktop.Core/Services/CasterSocket.cs index b9c65551e..d85dd98d1 100644 --- a/Desktop.Core/Services/CasterSocket.cs +++ b/Desktop.Core/Services/CasterSocket.cs @@ -196,6 +196,7 @@ private void ApplyConnectionHandlers() string requesterName, bool notifyUser, bool enforceAttendedAccess, + bool useWebRtc, string organizationName) => { try @@ -219,7 +220,8 @@ private void ApplyConnectionHandlers() { NotifyUser = notifyUser, ViewerID = viewerID, - RequesterName = requesterName + RequesterName = requesterName, + UseWebRtc = useWebRtc }); } catch (Exception ex) @@ -260,13 +262,14 @@ private void ApplyConnectionHandlers() } }); - Connection.On("RequestScreenCast", (string viewerID, string requesterName, bool notifyUser) => + Connection.On("RequestScreenCast", (string viewerID, string requesterName, bool notifyUser, bool useWebRtc) => { conductor.InvokeScreenCastRequested(new ScreenCastRequest() { NotifyUser = notifyUser, ViewerID = viewerID, - RequesterName = requesterName + RequesterName = requesterName, + UseWebRtc = useWebRtc }); }); diff --git a/Desktop.Core/Services/ScreenCaster.cs b/Desktop.Core/Services/ScreenCaster.cs index 1d6e2078e..a10da6c08 100644 --- a/Desktop.Core/Services/ScreenCaster.cs +++ b/Desktop.Core/Services/ScreenCaster.cs @@ -105,7 +105,7 @@ await viewer.SendScreenCapture(new CaptureFrame[] } - if (EnvironmentHelper.IsWindows) + if (EnvironmentHelper.IsWindows && screenCastRequest.UseWebRtc) { await viewer.InitializeWebRtc(); } @@ -149,7 +149,7 @@ await viewer.SendScreenCapture(new CaptureFrame[] currentFrame?.Dispose(); currentFrame = viewer.Capturer.GetNextFrame(); - var diffAreas = ImageUtils.GetDiffAreas(currentFrame, previousFrame, viewer.Capturer.CaptureFullscreen); + var diffAreas = ImageUtils.GetDiffAreas2(currentFrame, previousFrame, viewer.Capturer.CaptureFullscreen); if (!diffAreas.Any()) { diff --git a/Desktop.Core/Utilities/ImageUtils.cs b/Desktop.Core/Utilities/ImageUtils.cs index fe7b55455..471572c52 100644 --- a/Desktop.Core/Utilities/ImageUtils.cs +++ b/Desktop.Core/Utilities/ImageUtils.cs @@ -499,10 +499,10 @@ private static void AddChangeToList(List changes, int left, int top, { // Bounding box is valid. Padding is necessary to prevent artifacts from // moving windows. - left = Math.Max(left - 1, 0); - top = Math.Max(top - 1, 0); - right = Math.Min(right + 1, width); - bottom = Math.Min(bottom + 1, height); + left = Math.Max(left - 5, 0); + top = Math.Max(top - 5, 0); + right = Math.Min(right + 5, width); + bottom = Math.Min(bottom + 5, height); changes.Add(new Rectangle(left, top, right - left, bottom - top)); } @@ -511,10 +511,10 @@ private static void AddChangeToList(ConcurrentQueue changes, int left { // Bounding box is valid. Padding is necessary to prevent artifacts from // moving windows. - left = Math.Max(left - 1, 0); - top = Math.Max(top - 1, 0); - right = Math.Min(right + 1, width); - bottom = Math.Min(bottom + 1, height); + left = Math.Max(left - 5, 0); + top = Math.Max(top - 5, 0); + right = Math.Min(right + 5, width); + bottom = Math.Min(bottom + 5, height); changes.Enqueue(new Rectangle(left, top, right - left, bottom - top)); } diff --git a/Server/Hubs/AgentHub.cs b/Server/Hubs/AgentHub.cs index 36c7629e9..bdc301252 100644 --- a/Server/Hubs/AgentHub.cs +++ b/Server/Hubs/AgentHub.cs @@ -168,6 +168,7 @@ public Task DeviceHeartbeat(Device device) DataService.AddOrUpdateDevice(device, out var updatedDevice); Device = updatedDevice; + ServiceConnections.AddOrUpdate(Context.ConnectionId, Device, (id, d) => Device); var userIDs = BrowserHub.ConnectionIdToUserLookup.Values.Select(x => x.Id); diff --git a/Server/Hubs/ViewerHub.cs b/Server/Hubs/ViewerHub.cs index 5c8488265..7893dc859 100644 --- a/Server/Hubs/ViewerHub.cs +++ b/Server/Hubs/ViewerHub.cs @@ -200,16 +200,23 @@ public async Task SendScreenCastRequestToDevice(string screenCasterID, string re OrganizationID = orgId }); + if (Mode == RemoteControlMode.Unattended) { + var targetDevice = AgentHub.ServiceConnections[SessionInfo.ServiceID]; + + var useWebRtc = targetDevice.WebRtcSetting == WebRtcSetting.Default ? + AppConfig.UseWebRtc : + targetDevice.WebRtcSetting == WebRtcSetting.Enabled; + + SessionInfo.Mode = RemoteControlMode.Unattended; - var deviceID = AgentHub.ServiceConnections[SessionInfo.ServiceID].ID; if ((!string.IsNullOrWhiteSpace(otp) && - RemoteControlFilterAttribute.OtpMatchesDevice(otp, deviceID)) + RemoteControlFilterAttribute.OtpMatchesDevice(otp, targetDevice.ID)) || (Context.User.Identity.IsAuthenticated && - DataService.DoesUserHaveAccessToDevice(deviceID, Context.UserIdentifier))) + DataService.DoesUserHaveAccessToDevice(targetDevice.ID, Context.UserIdentifier))) { var orgName = DataService.GetOrganizationNameById(orgId); await CasterHubContext.Clients.Client(screenCasterID).SendAsync("GetScreenCast", @@ -217,6 +224,7 @@ await CasterHubContext.Clients.Client(screenCasterID).SendAsync("GetScreenCast", RequesterName, AppConfig.RemoteControlNotifyUser, AppConfig.EnforceAttendedAccess, + useWebRtc, orgName); } else @@ -228,7 +236,7 @@ await CasterHubContext.Clients.Client(screenCasterID).SendAsync("GetScreenCast", { SessionInfo.Mode = RemoteControlMode.Normal; await Clients.Caller.SendAsync("RequestingScreenCast"); - await CasterHubContext.Clients.Client(screenCasterID).SendAsync("RequestScreenCast", Context.ConnectionId, RequesterName, AppConfig.RemoteControlNotifyUser); + await CasterHubContext.Clients.Client(screenCasterID).SendAsync("RequestScreenCast", Context.ConnectionId, RequesterName, AppConfig.RemoteControlNotifyUser, AppConfig.UseWebRtc); } } diff --git a/Server/Migrations/PostgreSql/20210103153552_WebRtcSetting.Designer.cs b/Server/Migrations/PostgreSql/20210103153552_WebRtcSetting.Designer.cs new file mode 100644 index 000000000..7056c6310 --- /dev/null +++ b/Server/Migrations/PostgreSql/20210103153552_WebRtcSetting.Designer.cs @@ -0,0 +1,783 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using Remotely.Server.Data; + +namespace Remotely.Server.Migrations.PostgreSql +{ + [DbContext(typeof(PostgreSqlDbContext))] + [Migration("20210103153552_WebRtcSetting")] + partial class WebRtcSetting + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseIdentityByDefaultColumns() + .HasAnnotation("Relational:MaxIdentifierLength", 63) + .HasAnnotation("ProductVersion", "5.0.1"); + + modelBuilder.Entity("DeviceGroupRemotelyUser", b => + { + b.Property("DeviceGroupsID") + .HasColumnType("text"); + + b.Property("UsersId") + .HasColumnType("text"); + + b.HasKey("DeviceGroupsID", "UsersId"); + + b.HasIndex("UsersId"); + + b.ToTable("DeviceGroupRemotelyUser"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.ToTable("AspNetRoles"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .UseIdentityByDefaultColumn(); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("RoleId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("AccessFailedCount") + .HasColumnType("integer"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Discriminator") + .IsRequired() + .HasColumnType("text"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("boolean"); + + b.Property("LockoutEnabled") + .HasColumnType("boolean"); + + b.Property("LockoutEnd") + .HasColumnType("timestamp with time zone"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("PasswordHash") + .HasColumnType("text"); + + b.Property("PhoneNumber") + .HasColumnType("text"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("boolean"); + + b.Property("SecurityStamp") + .HasColumnType("text"); + + b.Property("TwoFactorEnabled") + .HasColumnType("boolean"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex"); + + b.ToTable("RemotelyUsers"); + + b.HasDiscriminator("Discriminator").HasValue("IdentityUser"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .UseIdentityByDefaultColumn(); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("ProviderKey") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("ProviderDisplayName") + .HasColumnType("text"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("text"); + + b.Property("RoleId") + .HasColumnType("text"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("text"); + + b.Property("LoginProvider") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("Name") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("Value") + .HasColumnType("text"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.Alert", b => + { + b.Property("ID") + .HasColumnType("text"); + + b.Property("CreatedOn") + .HasColumnType("timestamp with time zone"); + + b.Property("DeviceID") + .HasColumnType("text"); + + b.Property("Message") + .HasColumnType("text"); + + b.Property("OrganizationID") + .HasColumnType("text"); + + b.Property("UserID") + .HasColumnType("text"); + + b.HasKey("ID"); + + b.HasIndex("DeviceID"); + + b.HasIndex("OrganizationID"); + + b.HasIndex("UserID"); + + b.ToTable("Alerts"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.ApiToken", b => + { + b.Property("ID") + .HasColumnType("text"); + + b.Property("LastUsed") + .HasColumnType("timestamp with time zone"); + + b.Property("Name") + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("OrganizationID") + .HasColumnType("text"); + + b.Property("Secret") + .HasColumnType("text"); + + b.Property("Token") + .HasColumnType("text"); + + b.HasKey("ID"); + + b.HasIndex("OrganizationID"); + + b.HasIndex("Token"); + + b.ToTable("ApiTokens"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.CommandResult", b => + { + b.Property("ID") + .HasColumnType("text"); + + b.Property("CommandMode") + .HasColumnType("text"); + + b.Property("CommandResults") + .HasColumnType("text"); + + b.Property("CommandText") + .HasColumnType("text"); + + b.Property("OrganizationID") + .HasColumnType("text"); + + b.Property("PSCoreResults") + .HasColumnType("text"); + + b.Property("SenderConnectionID") + .HasColumnType("text"); + + b.Property("SenderUserID") + .HasColumnType("text"); + + b.Property("TargetDeviceIDs") + .HasColumnType("text"); + + b.Property("TimeStamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("ID"); + + b.HasIndex("OrganizationID"); + + b.ToTable("CommandResults"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.Device", b => + { + b.Property("ID") + .HasColumnType("text"); + + b.Property("AgentVersion") + .HasColumnType("text"); + + b.Property("Alias") + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("CpuUtilization") + .HasColumnType("double precision"); + + b.Property("CurrentUser") + .HasColumnType("text"); + + b.Property("DeviceGroupID") + .HasColumnType("text"); + + b.Property("DeviceName") + .HasColumnType("text"); + + b.Property("Drives") + .HasColumnType("text"); + + b.Property("Is64Bit") + .HasColumnType("boolean"); + + b.Property("IsOnline") + .HasColumnType("boolean"); + + b.Property("LastOnline") + .HasColumnType("timestamp with time zone"); + + b.Property("Notes") + .HasColumnType("text"); + + b.Property("OSArchitecture") + .HasColumnType("integer"); + + b.Property("OSDescription") + .HasColumnType("text"); + + b.Property("OrganizationID") + .HasColumnType("text"); + + b.Property("Platform") + .HasColumnType("text"); + + b.Property("ProcessorCount") + .HasColumnType("integer"); + + b.Property("PublicIP") + .HasColumnType("text"); + + b.Property("ServerVerificationToken") + .HasColumnType("text"); + + b.Property("Tags") + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("TotalMemory") + .HasColumnType("double precision"); + + b.Property("TotalStorage") + .HasColumnType("double precision"); + + b.Property("UsedMemory") + .HasColumnType("double precision"); + + b.Property("UsedStorage") + .HasColumnType("double precision"); + + b.Property("WebRtcSetting") + .HasColumnType("integer"); + + b.HasKey("ID"); + + b.HasIndex("DeviceGroupID"); + + b.HasIndex("DeviceName"); + + b.HasIndex("OrganizationID"); + + b.ToTable("Devices"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.DeviceGroup", b => + { + b.Property("ID") + .HasColumnType("text"); + + b.Property("Name") + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("OrganizationID") + .HasColumnType("text"); + + b.HasKey("ID"); + + b.HasIndex("OrganizationID"); + + b.ToTable("DeviceGroups"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.EventLog", b => + { + b.Property("ID") + .HasColumnType("text"); + + b.Property("EventType") + .HasColumnType("integer"); + + b.Property("Message") + .HasColumnType("text"); + + b.Property("OrganizationID") + .HasColumnType("text"); + + b.Property("Source") + .HasColumnType("text"); + + b.Property("StackTrace") + .HasColumnType("text"); + + b.Property("TimeStamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("ID"); + + b.HasIndex("OrganizationID"); + + b.ToTable("EventLogs"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.InviteLink", b => + { + b.Property("ID") + .HasColumnType("text"); + + b.Property("DateSent") + .HasColumnType("timestamp with time zone"); + + b.Property("InvitedUser") + .HasColumnType("text"); + + b.Property("IsAdmin") + .HasColumnType("boolean"); + + b.Property("OrganizationID") + .HasColumnType("text"); + + b.Property("ResetUrl") + .HasColumnType("text"); + + b.HasKey("ID"); + + b.HasIndex("OrganizationID"); + + b.ToTable("InviteLinks"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.Organization", b => + { + b.Property("ID") + .HasColumnType("text"); + + b.Property("OrganizationName") + .HasMaxLength(25) + .HasColumnType("character varying(25)"); + + b.HasKey("ID"); + + b.ToTable("Organizations"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.SharedFile", b => + { + b.Property("ID") + .HasColumnType("text"); + + b.Property("ContentType") + .HasColumnType("text"); + + b.Property("FileContents") + .HasColumnType("bytea"); + + b.Property("FileName") + .HasColumnType("text"); + + b.Property("OrganizationID") + .HasColumnType("text"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("ID"); + + b.HasIndex("OrganizationID"); + + b.ToTable("SharedFiles"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.RemotelyUser", b => + { + b.HasBaseType("Microsoft.AspNetCore.Identity.IdentityUser"); + + b.Property("DisplayName") + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("IsAdministrator") + .HasColumnType("boolean"); + + b.Property("IsServerAdmin") + .HasColumnType("boolean"); + + b.Property("OrganizationID") + .HasColumnType("text"); + + b.Property("TempPassword") + .HasColumnType("text"); + + b.Property("UserOptions") + .HasColumnType("text"); + + b.HasIndex("OrganizationID"); + + b.HasIndex("UserName"); + + b.HasDiscriminator().HasValue("RemotelyUser"); + }); + + modelBuilder.Entity("DeviceGroupRemotelyUser", b => + { + b.HasOne("Remotely.Shared.Models.DeviceGroup", null) + .WithMany() + .HasForeignKey("DeviceGroupsID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Remotely.Shared.Models.RemotelyUser", null) + .WithMany() + .HasForeignKey("UsersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Remotely.Shared.Models.Alert", b => + { + b.HasOne("Remotely.Shared.Models.Device", "Device") + .WithMany("Alerts") + .HasForeignKey("DeviceID"); + + b.HasOne("Remotely.Shared.Models.Organization", "Organization") + .WithMany("Alerts") + .HasForeignKey("OrganizationID"); + + b.HasOne("Remotely.Shared.Models.RemotelyUser", "User") + .WithMany("Alerts") + .HasForeignKey("UserID"); + + b.Navigation("Device"); + + b.Navigation("Organization"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.ApiToken", b => + { + b.HasOne("Remotely.Shared.Models.Organization", "Organization") + .WithMany("ApiTokens") + .HasForeignKey("OrganizationID"); + + b.Navigation("Organization"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.CommandResult", b => + { + b.HasOne("Remotely.Shared.Models.Organization", "Organization") + .WithMany("CommandResults") + .HasForeignKey("OrganizationID"); + + b.Navigation("Organization"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.Device", b => + { + b.HasOne("Remotely.Shared.Models.DeviceGroup", "DeviceGroup") + .WithMany("Devices") + .HasForeignKey("DeviceGroupID"); + + b.HasOne("Remotely.Shared.Models.Organization", "Organization") + .WithMany("Devices") + .HasForeignKey("OrganizationID"); + + b.Navigation("DeviceGroup"); + + b.Navigation("Organization"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.DeviceGroup", b => + { + b.HasOne("Remotely.Shared.Models.Organization", "Organization") + .WithMany("DeviceGroups") + .HasForeignKey("OrganizationID"); + + b.Navigation("Organization"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.EventLog", b => + { + b.HasOne("Remotely.Shared.Models.Organization", "Organization") + .WithMany("EventLogs") + .HasForeignKey("OrganizationID"); + + b.Navigation("Organization"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.InviteLink", b => + { + b.HasOne("Remotely.Shared.Models.Organization", "Organization") + .WithMany("InviteLinks") + .HasForeignKey("OrganizationID"); + + b.Navigation("Organization"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.SharedFile", b => + { + b.HasOne("Remotely.Shared.Models.Organization", "Organization") + .WithMany("SharedFiles") + .HasForeignKey("OrganizationID"); + + b.Navigation("Organization"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.RemotelyUser", b => + { + b.HasOne("Remotely.Shared.Models.Organization", "Organization") + .WithMany("RemotelyUsers") + .HasForeignKey("OrganizationID"); + + b.Navigation("Organization"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.Device", b => + { + b.Navigation("Alerts"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.DeviceGroup", b => + { + b.Navigation("Devices"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.Organization", b => + { + b.Navigation("Alerts"); + + b.Navigation("ApiTokens"); + + b.Navigation("CommandResults"); + + b.Navigation("DeviceGroups"); + + b.Navigation("Devices"); + + b.Navigation("EventLogs"); + + b.Navigation("InviteLinks"); + + b.Navigation("RemotelyUsers"); + + b.Navigation("SharedFiles"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.RemotelyUser", b => + { + b.Navigation("Alerts"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Server/Migrations/PostgreSql/20210103153552_WebRtcSetting.cs b/Server/Migrations/PostgreSql/20210103153552_WebRtcSetting.cs new file mode 100644 index 000000000..3e99f0f8e --- /dev/null +++ b/Server/Migrations/PostgreSql/20210103153552_WebRtcSetting.cs @@ -0,0 +1,24 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +namespace Remotely.Server.Migrations.PostgreSql +{ + public partial class WebRtcSetting : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "WebRtcSetting", + table: "Devices", + type: "integer", + nullable: false, + defaultValue: 0); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "WebRtcSetting", + table: "Devices"); + } + } +} diff --git a/Server/Migrations/PostgreSql/PostgreSqlDbContextModelSnapshot.cs b/Server/Migrations/PostgreSql/PostgreSqlDbContextModelSnapshot.cs index b2b21dde9..d5f3d04d0 100644 --- a/Server/Migrations/PostgreSql/PostgreSqlDbContextModelSnapshot.cs +++ b/Server/Migrations/PostgreSql/PostgreSqlDbContextModelSnapshot.cs @@ -17,7 +17,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder .UseIdentityByDefaultColumns() .HasAnnotation("Relational:MaxIdentifierLength", 63) - .HasAnnotation("ProductVersion", "5.0.0"); + .HasAnnotation("ProductVersion", "5.0.1"); modelBuilder.Entity("DeviceGroupRemotelyUser", b => { @@ -414,6 +414,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("UsedStorage") .HasColumnType("double precision"); + b.Property("WebRtcSetting") + .HasColumnType("integer"); + b.HasKey("ID"); b.HasIndex("DeviceGroupID"); diff --git a/Server/Migrations/SqlServer/20210103153621_WebRtcSetting.Designer.cs b/Server/Migrations/SqlServer/20210103153621_WebRtcSetting.Designer.cs new file mode 100644 index 000000000..17ea30f59 --- /dev/null +++ b/Server/Migrations/SqlServer/20210103153621_WebRtcSetting.Designer.cs @@ -0,0 +1,785 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Remotely.Server.Data; + +namespace Remotely.Server.Migrations.SqlServer +{ + [DbContext(typeof(SqlServerDbContext))] + [Migration("20210103153621_WebRtcSetting")] + partial class WebRtcSetting + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseIdentityColumns() + .HasAnnotation("Relational:MaxIdentifierLength", 128) + .HasAnnotation("ProductVersion", "5.0.1"); + + modelBuilder.Entity("DeviceGroupRemotelyUser", b => + { + b.Property("DeviceGroupsID") + .HasColumnType("nvarchar(450)"); + + b.Property("UsersId") + .HasColumnType("nvarchar(450)"); + + b.HasKey("DeviceGroupsID", "UsersId"); + + b.HasIndex("UsersId"); + + b.ToTable("DeviceGroupRemotelyUser"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + { + b.Property("Id") + .HasColumnType("nvarchar(450)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex") + .HasFilter("[NormalizedName] IS NOT NULL"); + + b.ToTable("AspNetRoles"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .UseIdentityColumn(); + + b.Property("ClaimType") + .HasColumnType("nvarchar(max)"); + + b.Property("ClaimValue") + .HasColumnType("nvarchar(max)"); + + b.Property("RoleId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b => + { + b.Property("Id") + .HasColumnType("nvarchar(450)"); + + b.Property("AccessFailedCount") + .HasColumnType("int"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("nvarchar(max)"); + + b.Property("Discriminator") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("bit"); + + b.Property("LockoutEnabled") + .HasColumnType("bit"); + + b.Property("LockoutEnd") + .HasColumnType("datetimeoffset"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("PasswordHash") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("bit"); + + b.Property("SecurityStamp") + .HasColumnType("nvarchar(max)"); + + b.Property("TwoFactorEnabled") + .HasColumnType("bit"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex") + .HasFilter("[NormalizedUserName] IS NOT NULL"); + + b.ToTable("RemotelyUsers"); + + b.HasDiscriminator("Discriminator").HasValue("IdentityUser"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .UseIdentityColumn(); + + b.Property("ClaimType") + .HasColumnType("nvarchar(max)"); + + b.Property("ClaimValue") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("ProviderKey") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("ProviderDisplayName") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("RoleId") + .HasColumnType("nvarchar(450)"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("LoginProvider") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("Name") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("Value") + .HasColumnType("nvarchar(max)"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.Alert", b => + { + b.Property("ID") + .HasColumnType("nvarchar(450)"); + + b.Property("CreatedOn") + .HasColumnType("datetimeoffset"); + + b.Property("DeviceID") + .HasColumnType("nvarchar(450)"); + + b.Property("Message") + .HasColumnType("nvarchar(max)"); + + b.Property("OrganizationID") + .HasColumnType("nvarchar(450)"); + + b.Property("UserID") + .HasColumnType("nvarchar(450)"); + + b.HasKey("ID"); + + b.HasIndex("DeviceID"); + + b.HasIndex("OrganizationID"); + + b.HasIndex("UserID"); + + b.ToTable("Alerts"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.ApiToken", b => + { + b.Property("ID") + .HasColumnType("nvarchar(450)"); + + b.Property("LastUsed") + .HasColumnType("datetimeoffset"); + + b.Property("Name") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("OrganizationID") + .HasColumnType("nvarchar(450)"); + + b.Property("Secret") + .HasColumnType("nvarchar(max)"); + + b.Property("Token") + .HasColumnType("nvarchar(450)"); + + b.HasKey("ID"); + + b.HasIndex("OrganizationID"); + + b.HasIndex("Token"); + + b.ToTable("ApiTokens"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.CommandResult", b => + { + b.Property("ID") + .HasColumnType("nvarchar(450)"); + + b.Property("CommandMode") + .HasColumnType("nvarchar(max)"); + + b.Property("CommandResults") + .HasColumnType("nvarchar(max)"); + + b.Property("CommandText") + .HasColumnType("nvarchar(max)"); + + b.Property("OrganizationID") + .HasColumnType("nvarchar(450)"); + + b.Property("PSCoreResults") + .HasColumnType("nvarchar(max)"); + + b.Property("SenderConnectionID") + .HasColumnType("nvarchar(max)"); + + b.Property("SenderUserID") + .HasColumnType("nvarchar(max)"); + + b.Property("TargetDeviceIDs") + .HasColumnType("nvarchar(max)"); + + b.Property("TimeStamp") + .HasColumnType("datetimeoffset"); + + b.HasKey("ID"); + + b.HasIndex("OrganizationID"); + + b.ToTable("CommandResults"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.Device", b => + { + b.Property("ID") + .HasColumnType("nvarchar(450)"); + + b.Property("AgentVersion") + .HasColumnType("nvarchar(max)"); + + b.Property("Alias") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("CpuUtilization") + .HasColumnType("float"); + + b.Property("CurrentUser") + .HasColumnType("nvarchar(max)"); + + b.Property("DeviceGroupID") + .HasColumnType("nvarchar(450)"); + + b.Property("DeviceName") + .HasColumnType("nvarchar(450)"); + + b.Property("Drives") + .HasColumnType("nvarchar(max)"); + + b.Property("Is64Bit") + .HasColumnType("bit"); + + b.Property("IsOnline") + .HasColumnType("bit"); + + b.Property("LastOnline") + .HasColumnType("datetimeoffset"); + + b.Property("Notes") + .HasColumnType("nvarchar(max)"); + + b.Property("OSArchitecture") + .HasColumnType("int"); + + b.Property("OSDescription") + .HasColumnType("nvarchar(max)"); + + b.Property("OrganizationID") + .HasColumnType("nvarchar(450)"); + + b.Property("Platform") + .HasColumnType("nvarchar(max)"); + + b.Property("ProcessorCount") + .HasColumnType("int"); + + b.Property("PublicIP") + .HasColumnType("nvarchar(max)"); + + b.Property("ServerVerificationToken") + .HasColumnType("nvarchar(max)"); + + b.Property("Tags") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("TotalMemory") + .HasColumnType("float"); + + b.Property("TotalStorage") + .HasColumnType("float"); + + b.Property("UsedMemory") + .HasColumnType("float"); + + b.Property("UsedStorage") + .HasColumnType("float"); + + b.Property("WebRtcSetting") + .HasColumnType("int"); + + b.HasKey("ID"); + + b.HasIndex("DeviceGroupID"); + + b.HasIndex("DeviceName"); + + b.HasIndex("OrganizationID"); + + b.ToTable("Devices"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.DeviceGroup", b => + { + b.Property("ID") + .HasColumnType("nvarchar(450)"); + + b.Property("Name") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("OrganizationID") + .HasColumnType("nvarchar(450)"); + + b.HasKey("ID"); + + b.HasIndex("OrganizationID"); + + b.ToTable("DeviceGroups"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.EventLog", b => + { + b.Property("ID") + .HasColumnType("nvarchar(450)"); + + b.Property("EventType") + .HasColumnType("int"); + + b.Property("Message") + .HasColumnType("nvarchar(max)"); + + b.Property("OrganizationID") + .HasColumnType("nvarchar(450)"); + + b.Property("Source") + .HasColumnType("nvarchar(max)"); + + b.Property("StackTrace") + .HasColumnType("nvarchar(max)"); + + b.Property("TimeStamp") + .HasColumnType("datetimeoffset"); + + b.HasKey("ID"); + + b.HasIndex("OrganizationID"); + + b.ToTable("EventLogs"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.InviteLink", b => + { + b.Property("ID") + .HasColumnType("nvarchar(450)"); + + b.Property("DateSent") + .HasColumnType("datetimeoffset"); + + b.Property("InvitedUser") + .HasColumnType("nvarchar(max)"); + + b.Property("IsAdmin") + .HasColumnType("bit"); + + b.Property("OrganizationID") + .HasColumnType("nvarchar(450)"); + + b.Property("ResetUrl") + .HasColumnType("nvarchar(max)"); + + b.HasKey("ID"); + + b.HasIndex("OrganizationID"); + + b.ToTable("InviteLinks"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.Organization", b => + { + b.Property("ID") + .HasColumnType("nvarchar(450)"); + + b.Property("OrganizationName") + .HasMaxLength(25) + .HasColumnType("nvarchar(25)"); + + b.HasKey("ID"); + + b.ToTable("Organizations"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.SharedFile", b => + { + b.Property("ID") + .HasColumnType("nvarchar(450)"); + + b.Property("ContentType") + .HasColumnType("nvarchar(max)"); + + b.Property("FileContents") + .HasColumnType("varbinary(max)"); + + b.Property("FileName") + .HasColumnType("nvarchar(max)"); + + b.Property("OrganizationID") + .HasColumnType("nvarchar(450)"); + + b.Property("Timestamp") + .HasColumnType("datetimeoffset"); + + b.HasKey("ID"); + + b.HasIndex("OrganizationID"); + + b.ToTable("SharedFiles"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.RemotelyUser", b => + { + b.HasBaseType("Microsoft.AspNetCore.Identity.IdentityUser"); + + b.Property("DisplayName") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("IsAdministrator") + .HasColumnType("bit"); + + b.Property("IsServerAdmin") + .HasColumnType("bit"); + + b.Property("OrganizationID") + .HasColumnType("nvarchar(450)"); + + b.Property("TempPassword") + .HasColumnType("nvarchar(max)"); + + b.Property("UserOptions") + .HasColumnType("nvarchar(max)"); + + b.HasIndex("OrganizationID"); + + b.HasIndex("UserName"); + + b.HasDiscriminator().HasValue("RemotelyUser"); + }); + + modelBuilder.Entity("DeviceGroupRemotelyUser", b => + { + b.HasOne("Remotely.Shared.Models.DeviceGroup", null) + .WithMany() + .HasForeignKey("DeviceGroupsID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Remotely.Shared.Models.RemotelyUser", null) + .WithMany() + .HasForeignKey("UsersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Remotely.Shared.Models.Alert", b => + { + b.HasOne("Remotely.Shared.Models.Device", "Device") + .WithMany("Alerts") + .HasForeignKey("DeviceID"); + + b.HasOne("Remotely.Shared.Models.Organization", "Organization") + .WithMany("Alerts") + .HasForeignKey("OrganizationID"); + + b.HasOne("Remotely.Shared.Models.RemotelyUser", "User") + .WithMany("Alerts") + .HasForeignKey("UserID"); + + b.Navigation("Device"); + + b.Navigation("Organization"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.ApiToken", b => + { + b.HasOne("Remotely.Shared.Models.Organization", "Organization") + .WithMany("ApiTokens") + .HasForeignKey("OrganizationID"); + + b.Navigation("Organization"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.CommandResult", b => + { + b.HasOne("Remotely.Shared.Models.Organization", "Organization") + .WithMany("CommandResults") + .HasForeignKey("OrganizationID"); + + b.Navigation("Organization"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.Device", b => + { + b.HasOne("Remotely.Shared.Models.DeviceGroup", "DeviceGroup") + .WithMany("Devices") + .HasForeignKey("DeviceGroupID"); + + b.HasOne("Remotely.Shared.Models.Organization", "Organization") + .WithMany("Devices") + .HasForeignKey("OrganizationID"); + + b.Navigation("DeviceGroup"); + + b.Navigation("Organization"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.DeviceGroup", b => + { + b.HasOne("Remotely.Shared.Models.Organization", "Organization") + .WithMany("DeviceGroups") + .HasForeignKey("OrganizationID"); + + b.Navigation("Organization"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.EventLog", b => + { + b.HasOne("Remotely.Shared.Models.Organization", "Organization") + .WithMany("EventLogs") + .HasForeignKey("OrganizationID"); + + b.Navigation("Organization"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.InviteLink", b => + { + b.HasOne("Remotely.Shared.Models.Organization", "Organization") + .WithMany("InviteLinks") + .HasForeignKey("OrganizationID"); + + b.Navigation("Organization"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.SharedFile", b => + { + b.HasOne("Remotely.Shared.Models.Organization", "Organization") + .WithMany("SharedFiles") + .HasForeignKey("OrganizationID"); + + b.Navigation("Organization"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.RemotelyUser", b => + { + b.HasOne("Remotely.Shared.Models.Organization", "Organization") + .WithMany("RemotelyUsers") + .HasForeignKey("OrganizationID"); + + b.Navigation("Organization"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.Device", b => + { + b.Navigation("Alerts"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.DeviceGroup", b => + { + b.Navigation("Devices"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.Organization", b => + { + b.Navigation("Alerts"); + + b.Navigation("ApiTokens"); + + b.Navigation("CommandResults"); + + b.Navigation("DeviceGroups"); + + b.Navigation("Devices"); + + b.Navigation("EventLogs"); + + b.Navigation("InviteLinks"); + + b.Navigation("RemotelyUsers"); + + b.Navigation("SharedFiles"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.RemotelyUser", b => + { + b.Navigation("Alerts"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Server/Migrations/SqlServer/20210103153621_WebRtcSetting.cs b/Server/Migrations/SqlServer/20210103153621_WebRtcSetting.cs new file mode 100644 index 000000000..da23a7062 --- /dev/null +++ b/Server/Migrations/SqlServer/20210103153621_WebRtcSetting.cs @@ -0,0 +1,60 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +namespace Remotely.Server.Migrations.SqlServer +{ + public partial class WebRtcSetting : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "WebRtcSetting", + table: "Devices", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AlterColumn( + name: "Id", + table: "AspNetUserClaims", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .Annotation("SqlServer:Identity", "1, 1"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "AspNetRoleClaims", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .Annotation("SqlServer:Identity", "1, 1"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "WebRtcSetting", + table: "Devices"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "AspNetUserClaims", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .OldAnnotation("SqlServer:Identity", "1, 1"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "AspNetRoleClaims", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .OldAnnotation("SqlServer:Identity", "1, 1"); + } + } +} diff --git a/Server/Migrations/SqlServer/SqlServerDbContextModelSnapshot.cs b/Server/Migrations/SqlServer/SqlServerDbContextModelSnapshot.cs index 3c1d713ce..300b9e03a 100644 --- a/Server/Migrations/SqlServer/SqlServerDbContextModelSnapshot.cs +++ b/Server/Migrations/SqlServer/SqlServerDbContextModelSnapshot.cs @@ -17,7 +17,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder .UseIdentityColumns() .HasAnnotation("Relational:MaxIdentifierLength", 128) - .HasAnnotation("ProductVersion", "5.0.0"); + .HasAnnotation("ProductVersion", "5.0.1"); modelBuilder.Entity("DeviceGroupRemotelyUser", b => { @@ -416,6 +416,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("UsedStorage") .HasColumnType("float"); + b.Property("WebRtcSetting") + .HasColumnType("int"); + b.HasKey("ID"); b.HasIndex("DeviceGroupID"); diff --git a/Server/Migrations/Sqlite/20210103153501_WebRtcSetting.Designer.cs b/Server/Migrations/Sqlite/20210103153501_WebRtcSetting.Designer.cs new file mode 100644 index 000000000..57ce4f0b0 --- /dev/null +++ b/Server/Migrations/Sqlite/20210103153501_WebRtcSetting.Designer.cs @@ -0,0 +1,784 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Remotely.Server.Data; + +namespace Remotely.Server.Migrations.Sqlite +{ + [DbContext(typeof(SqliteDbContext))] + [Migration("20210103153501_WebRtcSetting")] + partial class WebRtcSetting + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "5.0.1"); + + modelBuilder.Entity("DeviceGroupRemotelyUser", b => + { + b.Property("DeviceGroupsID") + .HasColumnType("TEXT"); + + b.Property("UsersId") + .HasColumnType("TEXT"); + + b.HasKey("DeviceGroupsID", "UsersId"); + + b.HasIndex("UsersId"); + + b.ToTable("DeviceGroupRemotelyUser"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + { + b.Property("Id") + .HasColumnType("TEXT"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("TEXT"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.ToTable("AspNetRoles"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClaimType") + .HasColumnType("TEXT"); + + b.Property("ClaimValue") + .HasColumnType("TEXT"); + + b.Property("RoleId") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b => + { + b.Property("Id") + .HasColumnType("TEXT"); + + b.Property("AccessFailedCount") + .HasColumnType("INTEGER"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("TEXT"); + + b.Property("Discriminator") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("EmailConfirmed") + .HasColumnType("INTEGER"); + + b.Property("LockoutEnabled") + .HasColumnType("INTEGER"); + + b.Property("LockoutEnd") + .HasColumnType("TEXT"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("PasswordHash") + .HasColumnType("TEXT"); + + b.Property("PhoneNumber") + .HasColumnType("TEXT"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("INTEGER"); + + b.Property("SecurityStamp") + .HasColumnType("TEXT"); + + b.Property("TwoFactorEnabled") + .HasColumnType("INTEGER"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex"); + + b.ToTable("RemotelyUsers"); + + b.HasDiscriminator("Discriminator").HasValue("IdentityUser"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClaimType") + .HasColumnType("TEXT"); + + b.Property("ClaimValue") + .HasColumnType("TEXT"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasMaxLength(128) + .HasColumnType("TEXT"); + + b.Property("ProviderKey") + .HasMaxLength(128) + .HasColumnType("TEXT"); + + b.Property("ProviderDisplayName") + .HasColumnType("TEXT"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("TEXT"); + + b.Property("RoleId") + .HasColumnType("TEXT"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("TEXT"); + + b.Property("LoginProvider") + .HasMaxLength(128) + .HasColumnType("TEXT"); + + b.Property("Name") + .HasMaxLength(128) + .HasColumnType("TEXT"); + + b.Property("Value") + .HasColumnType("TEXT"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.Alert", b => + { + b.Property("ID") + .HasColumnType("TEXT"); + + b.Property("CreatedOn") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("DeviceID") + .HasColumnType("TEXT"); + + b.Property("Message") + .HasColumnType("TEXT"); + + b.Property("OrganizationID") + .HasColumnType("TEXT"); + + b.Property("UserID") + .HasColumnType("TEXT"); + + b.HasKey("ID"); + + b.HasIndex("DeviceID"); + + b.HasIndex("OrganizationID"); + + b.HasIndex("UserID"); + + b.ToTable("Alerts"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.ApiToken", b => + { + b.Property("ID") + .HasColumnType("TEXT"); + + b.Property("LastUsed") + .HasColumnType("TEXT"); + + b.Property("Name") + .HasMaxLength(200) + .HasColumnType("TEXT"); + + b.Property("OrganizationID") + .HasColumnType("TEXT"); + + b.Property("Secret") + .HasColumnType("TEXT"); + + b.Property("Token") + .HasColumnType("TEXT"); + + b.HasKey("ID"); + + b.HasIndex("OrganizationID"); + + b.HasIndex("Token"); + + b.ToTable("ApiTokens"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.CommandResult", b => + { + b.Property("ID") + .HasColumnType("TEXT"); + + b.Property("CommandMode") + .HasColumnType("TEXT"); + + b.Property("CommandResults") + .HasColumnType("TEXT"); + + b.Property("CommandText") + .HasColumnType("TEXT"); + + b.Property("OrganizationID") + .HasColumnType("TEXT"); + + b.Property("PSCoreResults") + .HasColumnType("TEXT"); + + b.Property("SenderConnectionID") + .HasColumnType("TEXT"); + + b.Property("SenderUserID") + .HasColumnType("TEXT"); + + b.Property("TargetDeviceIDs") + .HasColumnType("TEXT"); + + b.Property("TimeStamp") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("ID"); + + b.HasIndex("OrganizationID"); + + b.ToTable("CommandResults"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.Device", b => + { + b.Property("ID") + .HasColumnType("TEXT"); + + b.Property("AgentVersion") + .HasColumnType("TEXT"); + + b.Property("Alias") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("CpuUtilization") + .HasColumnType("REAL"); + + b.Property("CurrentUser") + .HasColumnType("TEXT"); + + b.Property("DeviceGroupID") + .HasColumnType("TEXT"); + + b.Property("DeviceName") + .HasColumnType("TEXT"); + + b.Property("Drives") + .HasColumnType("TEXT"); + + b.Property("Is64Bit") + .HasColumnType("INTEGER"); + + b.Property("IsOnline") + .HasColumnType("INTEGER"); + + b.Property("LastOnline") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Notes") + .HasColumnType("TEXT"); + + b.Property("OSArchitecture") + .HasColumnType("INTEGER"); + + b.Property("OSDescription") + .HasColumnType("TEXT"); + + b.Property("OrganizationID") + .HasColumnType("TEXT"); + + b.Property("Platform") + .HasColumnType("TEXT"); + + b.Property("ProcessorCount") + .HasColumnType("INTEGER"); + + b.Property("PublicIP") + .HasColumnType("TEXT"); + + b.Property("ServerVerificationToken") + .HasColumnType("TEXT"); + + b.Property("Tags") + .HasMaxLength(200) + .HasColumnType("TEXT"); + + b.Property("TotalMemory") + .HasColumnType("REAL"); + + b.Property("TotalStorage") + .HasColumnType("REAL"); + + b.Property("UsedMemory") + .HasColumnType("REAL"); + + b.Property("UsedStorage") + .HasColumnType("REAL"); + + b.Property("WebRtcSetting") + .HasColumnType("INTEGER"); + + b.HasKey("ID"); + + b.HasIndex("DeviceGroupID"); + + b.HasIndex("DeviceName"); + + b.HasIndex("OrganizationID"); + + b.ToTable("Devices"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.DeviceGroup", b => + { + b.Property("ID") + .HasColumnType("TEXT"); + + b.Property("Name") + .HasMaxLength(200) + .HasColumnType("TEXT"); + + b.Property("OrganizationID") + .HasColumnType("TEXT"); + + b.HasKey("ID"); + + b.HasIndex("OrganizationID"); + + b.ToTable("DeviceGroups"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.EventLog", b => + { + b.Property("ID") + .HasColumnType("TEXT"); + + b.Property("EventType") + .HasColumnType("INTEGER"); + + b.Property("Message") + .HasColumnType("TEXT"); + + b.Property("OrganizationID") + .HasColumnType("TEXT"); + + b.Property("Source") + .HasColumnType("TEXT"); + + b.Property("StackTrace") + .HasColumnType("TEXT"); + + b.Property("TimeStamp") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("ID"); + + b.HasIndex("OrganizationID"); + + b.ToTable("EventLogs"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.InviteLink", b => + { + b.Property("ID") + .HasColumnType("TEXT"); + + b.Property("DateSent") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("InvitedUser") + .HasColumnType("TEXT"); + + b.Property("IsAdmin") + .HasColumnType("INTEGER"); + + b.Property("OrganizationID") + .HasColumnType("TEXT"); + + b.Property("ResetUrl") + .HasColumnType("TEXT"); + + b.HasKey("ID"); + + b.HasIndex("OrganizationID"); + + b.ToTable("InviteLinks"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.Organization", b => + { + b.Property("ID") + .HasColumnType("TEXT"); + + b.Property("OrganizationName") + .HasMaxLength(25) + .HasColumnType("TEXT"); + + b.HasKey("ID"); + + b.ToTable("Organizations"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.SharedFile", b => + { + b.Property("ID") + .HasColumnType("TEXT"); + + b.Property("ContentType") + .HasColumnType("TEXT"); + + b.Property("FileContents") + .HasColumnType("BLOB"); + + b.Property("FileName") + .HasColumnType("TEXT"); + + b.Property("OrganizationID") + .HasColumnType("TEXT"); + + b.Property("Timestamp") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("ID"); + + b.HasIndex("OrganizationID"); + + b.ToTable("SharedFiles"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.RemotelyUser", b => + { + b.HasBaseType("Microsoft.AspNetCore.Identity.IdentityUser"); + + b.Property("DisplayName") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("IsAdministrator") + .HasColumnType("INTEGER"); + + b.Property("IsServerAdmin") + .HasColumnType("INTEGER"); + + b.Property("OrganizationID") + .HasColumnType("TEXT"); + + b.Property("TempPassword") + .HasColumnType("TEXT"); + + b.Property("UserOptions") + .HasColumnType("TEXT"); + + b.HasIndex("OrganizationID"); + + b.HasIndex("UserName"); + + b.HasDiscriminator().HasValue("RemotelyUser"); + }); + + modelBuilder.Entity("DeviceGroupRemotelyUser", b => + { + b.HasOne("Remotely.Shared.Models.DeviceGroup", null) + .WithMany() + .HasForeignKey("DeviceGroupsID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Remotely.Shared.Models.RemotelyUser", null) + .WithMany() + .HasForeignKey("UsersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Remotely.Shared.Models.Alert", b => + { + b.HasOne("Remotely.Shared.Models.Device", "Device") + .WithMany("Alerts") + .HasForeignKey("DeviceID"); + + b.HasOne("Remotely.Shared.Models.Organization", "Organization") + .WithMany("Alerts") + .HasForeignKey("OrganizationID"); + + b.HasOne("Remotely.Shared.Models.RemotelyUser", "User") + .WithMany("Alerts") + .HasForeignKey("UserID"); + + b.Navigation("Device"); + + b.Navigation("Organization"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.ApiToken", b => + { + b.HasOne("Remotely.Shared.Models.Organization", "Organization") + .WithMany("ApiTokens") + .HasForeignKey("OrganizationID"); + + b.Navigation("Organization"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.CommandResult", b => + { + b.HasOne("Remotely.Shared.Models.Organization", "Organization") + .WithMany("CommandResults") + .HasForeignKey("OrganizationID"); + + b.Navigation("Organization"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.Device", b => + { + b.HasOne("Remotely.Shared.Models.DeviceGroup", "DeviceGroup") + .WithMany("Devices") + .HasForeignKey("DeviceGroupID"); + + b.HasOne("Remotely.Shared.Models.Organization", "Organization") + .WithMany("Devices") + .HasForeignKey("OrganizationID"); + + b.Navigation("DeviceGroup"); + + b.Navigation("Organization"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.DeviceGroup", b => + { + b.HasOne("Remotely.Shared.Models.Organization", "Organization") + .WithMany("DeviceGroups") + .HasForeignKey("OrganizationID"); + + b.Navigation("Organization"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.EventLog", b => + { + b.HasOne("Remotely.Shared.Models.Organization", "Organization") + .WithMany("EventLogs") + .HasForeignKey("OrganizationID"); + + b.Navigation("Organization"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.InviteLink", b => + { + b.HasOne("Remotely.Shared.Models.Organization", "Organization") + .WithMany("InviteLinks") + .HasForeignKey("OrganizationID"); + + b.Navigation("Organization"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.SharedFile", b => + { + b.HasOne("Remotely.Shared.Models.Organization", "Organization") + .WithMany("SharedFiles") + .HasForeignKey("OrganizationID"); + + b.Navigation("Organization"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.RemotelyUser", b => + { + b.HasOne("Remotely.Shared.Models.Organization", "Organization") + .WithMany("RemotelyUsers") + .HasForeignKey("OrganizationID"); + + b.Navigation("Organization"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.Device", b => + { + b.Navigation("Alerts"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.DeviceGroup", b => + { + b.Navigation("Devices"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.Organization", b => + { + b.Navigation("Alerts"); + + b.Navigation("ApiTokens"); + + b.Navigation("CommandResults"); + + b.Navigation("DeviceGroups"); + + b.Navigation("Devices"); + + b.Navigation("EventLogs"); + + b.Navigation("InviteLinks"); + + b.Navigation("RemotelyUsers"); + + b.Navigation("SharedFiles"); + }); + + modelBuilder.Entity("Remotely.Shared.Models.RemotelyUser", b => + { + b.Navigation("Alerts"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Server/Migrations/Sqlite/20210103153501_WebRtcSetting.cs b/Server/Migrations/Sqlite/20210103153501_WebRtcSetting.cs new file mode 100644 index 000000000..b2c598a8d --- /dev/null +++ b/Server/Migrations/Sqlite/20210103153501_WebRtcSetting.cs @@ -0,0 +1,24 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +namespace Remotely.Server.Migrations.Sqlite +{ + public partial class WebRtcSetting : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "WebRtcSetting", + table: "Devices", + type: "INTEGER", + nullable: false, + defaultValue: 0); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "WebRtcSetting", + table: "Devices"); + } + } +} diff --git a/Server/Migrations/Sqlite/SqliteDbContextModelSnapshot.cs b/Server/Migrations/Sqlite/SqliteDbContextModelSnapshot.cs index 7da19dbeb..1f0a0b170 100644 --- a/Server/Migrations/Sqlite/SqliteDbContextModelSnapshot.cs +++ b/Server/Migrations/Sqlite/SqliteDbContextModelSnapshot.cs @@ -14,7 +14,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "5.0.0"); + .HasAnnotation("ProductVersion", "5.0.1"); modelBuilder.Entity("DeviceGroupRemotelyUser", b => { @@ -412,6 +412,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("UsedStorage") .HasColumnType("REAL"); + b.Property("WebRtcSetting") + .HasColumnType("INTEGER"); + b.HasKey("ID"); b.HasIndex("DeviceGroupID"); diff --git a/Server/Pages/EditDevice.cshtml b/Server/Pages/EditDevice.cshtml index bc3fdfa4f..187bfe0d0 100644 --- a/Server/Pages/EditDevice.cshtml +++ b/Server/Pages/EditDevice.cshtml @@ -44,8 +44,17 @@ else
+
+
+ +
+ + +
+ +
@@ -55,18 +64,21 @@ else +
+
+
diff --git a/Server/Pages/EditDevice.cshtml.cs b/Server/Pages/EditDevice.cshtml.cs index 2fdc52b48..d152ccaa1 100644 --- a/Server/Pages/EditDevice.cshtml.cs +++ b/Server/Pages/EditDevice.cshtml.cs @@ -87,7 +87,7 @@ public IActionResult OnPost(string deviceID) AgentHubContext.Clients.Clients(onlineOrgAgents).SendAsync("TriggerHeartbeat"); - DataService.UpdateDevice(deviceID, Input.Tags, Input.Alias, Input.DeviceGroupID, Input.Notes); + DataService.UpdateDevice(deviceID, Input.Tags, Input.Alias, Input.DeviceGroupID, Input.Notes, Input.WebRtcSetting); return RedirectToPage("EditDevice", new { deviceID, success = true }); } @@ -105,6 +105,7 @@ private void PopulateViewModel(string deviceID) Input.DeviceGroupID = device?.DeviceGroupID; Input.Tags = device?.Tags; Input.Notes = device?.Notes; + Input.WebRtcSetting = device?.WebRtcSetting ?? default; } var groups = DataService.GetDeviceGroups(User.Identity.Name); @@ -122,6 +123,8 @@ public class InputModel public string Tags { get; set; } public string Notes { get; set; } + + public WebRtcSetting WebRtcSetting { get; set; } } } } diff --git a/Server/Services/DataService.cs b/Server/Services/DataService.cs index 64940f83e..b8de8629f 100644 --- a/Server/Services/DataService.cs +++ b/Server/Services/DataService.cs @@ -78,7 +78,7 @@ public interface IDataService void SetServerVerificationToken(string deviceID, string verificationToken); Task TempPasswordSignIn(string email, string password); Task UpdateDevice(DeviceSetupOptions deviceOptions, string organizationId); - void UpdateDevice(string deviceID, string tag, string alias, string deviceGroupID, string notes); + void UpdateDevice(string deviceID, string tag, string alias, string deviceGroupID, string notes, WebRtcSetting webRtcSetting); void UpdateOrganizationName(string orgID, string organizationName); Task UpdateServerAdmins(List serverAdmins, string callerUserName); void UpdateTags(string deviceID, string tags); @@ -1023,7 +1023,7 @@ public void SetServerVerificationToken(string deviceID, string verificationToken } } - public void UpdateDevice(string deviceID, string tag, string alias, string deviceGroupID, string notes) + public void UpdateDevice(string deviceID, string tag, string alias, string deviceGroupID, string notes, WebRtcSetting webRtcSetting) { var device = RemotelyContext.Devices.Find(deviceID); if (device == null) @@ -1035,6 +1035,7 @@ public void UpdateDevice(string deviceID, string tag, string alias, string devic device.DeviceGroupID = deviceGroupID; device.Alias = alias; device.Notes = notes; + device.WebRtcSetting = webRtcSetting; RemotelyContext.SaveChanges(); } diff --git a/Shared/Enums/WebRtcSetting.cs b/Shared/Enums/WebRtcSetting.cs new file mode 100644 index 000000000..250cd3d4d --- /dev/null +++ b/Shared/Enums/WebRtcSetting.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Remotely.Shared.Enums +{ + public enum WebRtcSetting + { + Default, + Enabled, + Disabled + } +} diff --git a/Shared/Models/Device.cs b/Shared/Models/Device.cs index 29a262230..3e60a969c 100644 --- a/Shared/Models/Device.cs +++ b/Shared/Models/Device.cs @@ -1,4 +1,5 @@ -using System; +using Remotely.Shared.Enums; +using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Runtime.InteropServices; @@ -44,5 +45,6 @@ public class Device public double UsedMemory { get; set; } public double UsedStorage { get; set; } + public WebRtcSetting WebRtcSetting { get; set; } } } \ No newline at end of file diff --git a/Shared/Models/ScreenCastRequest.cs b/Shared/Models/ScreenCastRequest.cs index afb9d2a12..1fd0f2397 100644 --- a/Shared/Models/ScreenCastRequest.cs +++ b/Shared/Models/ScreenCastRequest.cs @@ -5,5 +5,6 @@ public class ScreenCastRequest public bool NotifyUser { get; set; } public string RequesterName { get; set; } public string ViewerID { get; set; } + public bool UseWebRtc { get; set; } } } diff --git a/Tests/DataServiceTests.cs b/Tests/DataServiceTests.cs index fbfc90c7d..56195fd79 100644 --- a/Tests/DataServiceTests.cs +++ b/Tests/DataServiceTests.cs @@ -82,7 +82,7 @@ public void DeviceGroupPermissions() var groupID = DataService.GetDeviceGroups(TestData.Admin1.UserName).First().ID; - DataService.UpdateDevice(TestData.Device1.ID, "", "", groupID, ""); + DataService.UpdateDevice(TestData.Device1.ID, "", "", groupID, "", Shared.Enums.WebRtcSetting.Default); DataService.AddUserToDeviceGroup(TestData.OrganizationID, groupID, TestData.User1.UserName, out _); Assert.IsTrue(DataService.GetDevicesForUser(TestData.Admin1.UserName).Count() == 2);