mirror of
https://github.com/chylex/Minecraft-Phantom-Panel.git
synced 2026-01-14 05:50:30 +01:00
Compare commits
1 Commits
main
...
d63089ead2
| Author | SHA1 | Date | |
|---|---|---|---|
|
d63089ead2
|
@@ -3,11 +3,11 @@
|
|||||||
"isRoot": true,
|
"isRoot": true,
|
||||||
"tools": {
|
"tools": {
|
||||||
"dotnet-ef": {
|
"dotnet-ef": {
|
||||||
"version": "10.0.1",
|
"version": "9.0.9",
|
||||||
"commands": [
|
"commands": [
|
||||||
"dotnet-ef"
|
"dotnet-ef"
|
||||||
],
|
],
|
||||||
"rollForward": false
|
"rollForward": false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,356 +0,0 @@
|
|||||||
// <auto-generated />
|
|
||||||
using System;
|
|
||||||
using System.Text.Json;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|
||||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
||||||
using Phantom.Controller.Database;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace Phantom.Controller.Database.Postgres.Migrations
|
|
||||||
{
|
|
||||||
[DbContext(typeof(ApplicationDbContext))]
|
|
||||||
[Migration("20251228053557_AgentFieldNullability")]
|
|
||||||
partial class AgentFieldNullability
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
|
||||||
{
|
|
||||||
#pragma warning disable 612, 618
|
|
||||||
modelBuilder
|
|
||||||
.HasAnnotation("ProductVersion", "9.0.9")
|
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
|
||||||
|
|
||||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
|
||||||
|
|
||||||
modelBuilder.Entity("Phantom.Controller.Database.Entities.AgentEntity", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("AgentGuid")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<byte[]>("AuthSecret")
|
|
||||||
.HasMaxLength(12)
|
|
||||||
.HasColumnType("bytea");
|
|
||||||
|
|
||||||
b.Property<string>("BuildVersion")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<int?>("MaxInstances")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<int?>("MaxMemory")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<string>("Name")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<int?>("ProtocolVersion")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.HasKey("AgentGuid");
|
|
||||||
|
|
||||||
b.ToTable("Agents", "agents");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Phantom.Controller.Database.Entities.AuditLogEntity", b =>
|
|
||||||
{
|
|
||||||
b.Property<long>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("bigint");
|
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
|
||||||
|
|
||||||
b.Property<JsonDocument>("Data")
|
|
||||||
.HasColumnType("jsonb");
|
|
||||||
|
|
||||||
b.Property<string>("EventType")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("SubjectId")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("SubjectType")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<Guid?>("UserGuid")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<DateTime>("UtcTime")
|
|
||||||
.HasColumnType("timestamp with time zone");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("UserGuid");
|
|
||||||
|
|
||||||
b.ToTable("AuditLog", "system");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Phantom.Controller.Database.Entities.EventLogEntity", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("EventGuid")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<Guid?>("AgentGuid")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<JsonDocument>("Data")
|
|
||||||
.HasColumnType("jsonb");
|
|
||||||
|
|
||||||
b.Property<string>("EventType")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("SubjectId")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("SubjectType")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<DateTime>("UtcTime")
|
|
||||||
.HasColumnType("timestamp with time zone");
|
|
||||||
|
|
||||||
b.HasKey("EventGuid");
|
|
||||||
|
|
||||||
b.ToTable("EventLog", "system");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Phantom.Controller.Database.Entities.InstanceEntity", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("InstanceGuid")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<Guid>("AgentGuid")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<string>("InstanceName")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<Guid>("JavaRuntimeGuid")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<string>("JvmArguments")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<bool>("LaunchAutomatically")
|
|
||||||
.HasColumnType("boolean");
|
|
||||||
|
|
||||||
b.Property<int>("MemoryAllocation")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<string>("MinecraftServerKind")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("MinecraftVersion")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<int>("RconPort")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<int>("ServerPort")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.HasKey("InstanceGuid");
|
|
||||||
|
|
||||||
b.ToTable("Instances", "agents");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Phantom.Controller.Database.Entities.PermissionEntity", b =>
|
|
||||||
{
|
|
||||||
b.Property<string>("Id")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("Permissions", "identity");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Phantom.Controller.Database.Entities.RoleEntity", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("RoleGuid")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<string>("Name")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("RoleGuid");
|
|
||||||
|
|
||||||
b.ToTable("Roles", "identity");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Phantom.Controller.Database.Entities.RolePermissionEntity", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("RoleGuid")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<string>("PermissionId")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("RoleGuid", "PermissionId");
|
|
||||||
|
|
||||||
b.HasIndex("PermissionId");
|
|
||||||
|
|
||||||
b.ToTable("RolePermissions", "identity");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Phantom.Controller.Database.Entities.UserAgentAccessEntity", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("UserGuid")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<Guid>("AgentGuid")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.HasKey("UserGuid", "AgentGuid");
|
|
||||||
|
|
||||||
b.HasIndex("AgentGuid");
|
|
||||||
|
|
||||||
b.ToTable("UserAgentAccess", "identity");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Phantom.Controller.Database.Entities.UserEntity", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("UserGuid")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<string>("Name")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("PasswordHash")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("UserGuid");
|
|
||||||
|
|
||||||
b.HasIndex("Name")
|
|
||||||
.IsUnique();
|
|
||||||
|
|
||||||
b.ToTable("Users", "identity");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Phantom.Controller.Database.Entities.UserPermissionEntity", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("UserGuid")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<string>("PermissionId")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("UserGuid", "PermissionId");
|
|
||||||
|
|
||||||
b.HasIndex("PermissionId");
|
|
||||||
|
|
||||||
b.ToTable("UserPermissions", "identity");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Phantom.Controller.Database.Entities.UserRoleEntity", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("UserGuid")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<Guid>("RoleGuid")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.HasKey("UserGuid", "RoleGuid");
|
|
||||||
|
|
||||||
b.HasIndex("RoleGuid");
|
|
||||||
|
|
||||||
b.ToTable("UserRoles", "identity");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Phantom.Controller.Database.Entities.AuditLogEntity", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("Phantom.Controller.Database.Entities.UserEntity", "User")
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("UserGuid")
|
|
||||||
.OnDelete(DeleteBehavior.SetNull);
|
|
||||||
|
|
||||||
b.Navigation("User");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Phantom.Controller.Database.Entities.RolePermissionEntity", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("Phantom.Controller.Database.Entities.PermissionEntity", null)
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("PermissionId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("Phantom.Controller.Database.Entities.RoleEntity", null)
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("RoleGuid")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Phantom.Controller.Database.Entities.UserAgentAccessEntity", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("Phantom.Controller.Database.Entities.AgentEntity", null)
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("AgentGuid")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("Phantom.Controller.Database.Entities.UserEntity", null)
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("UserGuid")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Phantom.Controller.Database.Entities.UserPermissionEntity", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("Phantom.Controller.Database.Entities.PermissionEntity", null)
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("PermissionId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("Phantom.Controller.Database.Entities.UserEntity", null)
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("UserGuid")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Phantom.Controller.Database.Entities.UserRoleEntity", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("Phantom.Controller.Database.Entities.RoleEntity", "Role")
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("RoleGuid")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("Phantom.Controller.Database.Entities.UserEntity", "User")
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("UserGuid")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.Navigation("Role");
|
|
||||||
|
|
||||||
b.Navigation("User");
|
|
||||||
});
|
|
||||||
#pragma warning restore 612, 618
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,98 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace Phantom.Controller.Database.Postgres.Migrations
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
public partial class AgentFieldNullability : Migration
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.AlterColumn<int>(
|
|
||||||
name: "ProtocolVersion",
|
|
||||||
schema: "agents",
|
|
||||||
table: "Agents",
|
|
||||||
type: "integer",
|
|
||||||
nullable: true,
|
|
||||||
oldClrType: typeof(int),
|
|
||||||
oldType: "integer");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<int>(
|
|
||||||
name: "MaxMemory",
|
|
||||||
schema: "agents",
|
|
||||||
table: "Agents",
|
|
||||||
type: "integer",
|
|
||||||
nullable: true,
|
|
||||||
oldClrType: typeof(int),
|
|
||||||
oldType: "integer");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<int>(
|
|
||||||
name: "MaxInstances",
|
|
||||||
schema: "agents",
|
|
||||||
table: "Agents",
|
|
||||||
type: "integer",
|
|
||||||
nullable: true,
|
|
||||||
oldClrType: typeof(int),
|
|
||||||
oldType: "integer");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
|
||||||
name: "BuildVersion",
|
|
||||||
schema: "agents",
|
|
||||||
table: "Agents",
|
|
||||||
type: "text",
|
|
||||||
nullable: true,
|
|
||||||
oldClrType: typeof(string),
|
|
||||||
oldType: "text");
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.AlterColumn<int>(
|
|
||||||
name: "ProtocolVersion",
|
|
||||||
schema: "agents",
|
|
||||||
table: "Agents",
|
|
||||||
type: "integer",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0,
|
|
||||||
oldClrType: typeof(int),
|
|
||||||
oldType: "integer",
|
|
||||||
oldNullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<int>(
|
|
||||||
name: "MaxMemory",
|
|
||||||
schema: "agents",
|
|
||||||
table: "Agents",
|
|
||||||
type: "integer",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0,
|
|
||||||
oldClrType: typeof(int),
|
|
||||||
oldType: "integer",
|
|
||||||
oldNullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<int>(
|
|
||||||
name: "MaxInstances",
|
|
||||||
schema: "agents",
|
|
||||||
table: "Agents",
|
|
||||||
type: "integer",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0,
|
|
||||||
oldClrType: typeof(int),
|
|
||||||
oldType: "integer",
|
|
||||||
oldNullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
|
||||||
name: "BuildVersion",
|
|
||||||
schema: "agents",
|
|
||||||
table: "Agents",
|
|
||||||
type: "text",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: "",
|
|
||||||
oldClrType: typeof(string),
|
|
||||||
oldType: "text",
|
|
||||||
oldNullable: true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,357 +0,0 @@
|
|||||||
// <auto-generated />
|
|
||||||
using System;
|
|
||||||
using System.Text.Json;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|
||||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
||||||
using Phantom.Controller.Database;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace Phantom.Controller.Database.Postgres.Migrations
|
|
||||||
{
|
|
||||||
[DbContext(typeof(ApplicationDbContext))]
|
|
||||||
[Migration("20251228211902_AgentAuthSecretNullability")]
|
|
||||||
partial class AgentAuthSecretNullability
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
|
||||||
{
|
|
||||||
#pragma warning disable 612, 618
|
|
||||||
modelBuilder
|
|
||||||
.HasAnnotation("ProductVersion", "9.0.9")
|
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
|
||||||
|
|
||||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
|
||||||
|
|
||||||
modelBuilder.Entity("Phantom.Controller.Database.Entities.AgentEntity", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("AgentGuid")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<byte[]>("AuthSecret")
|
|
||||||
.IsRequired()
|
|
||||||
.HasMaxLength(12)
|
|
||||||
.HasColumnType("bytea");
|
|
||||||
|
|
||||||
b.Property<string>("BuildVersion")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<int?>("MaxInstances")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<int?>("MaxMemory")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<string>("Name")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<int?>("ProtocolVersion")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.HasKey("AgentGuid");
|
|
||||||
|
|
||||||
b.ToTable("Agents", "agents");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Phantom.Controller.Database.Entities.AuditLogEntity", b =>
|
|
||||||
{
|
|
||||||
b.Property<long>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("bigint");
|
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
|
||||||
|
|
||||||
b.Property<JsonDocument>("Data")
|
|
||||||
.HasColumnType("jsonb");
|
|
||||||
|
|
||||||
b.Property<string>("EventType")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("SubjectId")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("SubjectType")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<Guid?>("UserGuid")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<DateTime>("UtcTime")
|
|
||||||
.HasColumnType("timestamp with time zone");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("UserGuid");
|
|
||||||
|
|
||||||
b.ToTable("AuditLog", "system");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Phantom.Controller.Database.Entities.EventLogEntity", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("EventGuid")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<Guid?>("AgentGuid")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<JsonDocument>("Data")
|
|
||||||
.HasColumnType("jsonb");
|
|
||||||
|
|
||||||
b.Property<string>("EventType")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("SubjectId")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("SubjectType")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<DateTime>("UtcTime")
|
|
||||||
.HasColumnType("timestamp with time zone");
|
|
||||||
|
|
||||||
b.HasKey("EventGuid");
|
|
||||||
|
|
||||||
b.ToTable("EventLog", "system");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Phantom.Controller.Database.Entities.InstanceEntity", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("InstanceGuid")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<Guid>("AgentGuid")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<string>("InstanceName")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<Guid>("JavaRuntimeGuid")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<string>("JvmArguments")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<bool>("LaunchAutomatically")
|
|
||||||
.HasColumnType("boolean");
|
|
||||||
|
|
||||||
b.Property<int>("MemoryAllocation")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<string>("MinecraftServerKind")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("MinecraftVersion")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<int>("RconPort")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.Property<int>("ServerPort")
|
|
||||||
.HasColumnType("integer");
|
|
||||||
|
|
||||||
b.HasKey("InstanceGuid");
|
|
||||||
|
|
||||||
b.ToTable("Instances", "agents");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Phantom.Controller.Database.Entities.PermissionEntity", b =>
|
|
||||||
{
|
|
||||||
b.Property<string>("Id")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("Permissions", "identity");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Phantom.Controller.Database.Entities.RoleEntity", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("RoleGuid")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<string>("Name")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("RoleGuid");
|
|
||||||
|
|
||||||
b.ToTable("Roles", "identity");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Phantom.Controller.Database.Entities.RolePermissionEntity", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("RoleGuid")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<string>("PermissionId")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("RoleGuid", "PermissionId");
|
|
||||||
|
|
||||||
b.HasIndex("PermissionId");
|
|
||||||
|
|
||||||
b.ToTable("RolePermissions", "identity");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Phantom.Controller.Database.Entities.UserAgentAccessEntity", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("UserGuid")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<Guid>("AgentGuid")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.HasKey("UserGuid", "AgentGuid");
|
|
||||||
|
|
||||||
b.HasIndex("AgentGuid");
|
|
||||||
|
|
||||||
b.ToTable("UserAgentAccess", "identity");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Phantom.Controller.Database.Entities.UserEntity", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("UserGuid")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<string>("Name")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("PasswordHash")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("UserGuid");
|
|
||||||
|
|
||||||
b.HasIndex("Name")
|
|
||||||
.IsUnique();
|
|
||||||
|
|
||||||
b.ToTable("Users", "identity");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Phantom.Controller.Database.Entities.UserPermissionEntity", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("UserGuid")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<string>("PermissionId")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("UserGuid", "PermissionId");
|
|
||||||
|
|
||||||
b.HasIndex("PermissionId");
|
|
||||||
|
|
||||||
b.ToTable("UserPermissions", "identity");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Phantom.Controller.Database.Entities.UserRoleEntity", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("UserGuid")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<Guid>("RoleGuid")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.HasKey("UserGuid", "RoleGuid");
|
|
||||||
|
|
||||||
b.HasIndex("RoleGuid");
|
|
||||||
|
|
||||||
b.ToTable("UserRoles", "identity");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Phantom.Controller.Database.Entities.AuditLogEntity", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("Phantom.Controller.Database.Entities.UserEntity", "User")
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("UserGuid")
|
|
||||||
.OnDelete(DeleteBehavior.SetNull);
|
|
||||||
|
|
||||||
b.Navigation("User");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Phantom.Controller.Database.Entities.RolePermissionEntity", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("Phantom.Controller.Database.Entities.PermissionEntity", null)
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("PermissionId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("Phantom.Controller.Database.Entities.RoleEntity", null)
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("RoleGuid")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Phantom.Controller.Database.Entities.UserAgentAccessEntity", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("Phantom.Controller.Database.Entities.AgentEntity", null)
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("AgentGuid")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("Phantom.Controller.Database.Entities.UserEntity", null)
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("UserGuid")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Phantom.Controller.Database.Entities.UserPermissionEntity", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("Phantom.Controller.Database.Entities.PermissionEntity", null)
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("PermissionId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("Phantom.Controller.Database.Entities.UserEntity", null)
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("UserGuid")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Phantom.Controller.Database.Entities.UserRoleEntity", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("Phantom.Controller.Database.Entities.RoleEntity", "Role")
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("RoleGuid")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("Phantom.Controller.Database.Entities.UserEntity", "User")
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("UserGuid")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.Navigation("Role");
|
|
||||||
|
|
||||||
b.Navigation("User");
|
|
||||||
});
|
|
||||||
#pragma warning restore 612, 618
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace Phantom.Controller.Database.Postgres.Migrations
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
public partial class AgentAuthSecretNullability : Migration
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.AlterColumn<byte[]>(
|
|
||||||
name: "AuthSecret",
|
|
||||||
schema: "agents",
|
|
||||||
table: "Agents",
|
|
||||||
type: "bytea",
|
|
||||||
maxLength: 12,
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: new byte[0],
|
|
||||||
oldClrType: typeof(byte[]),
|
|
||||||
oldType: "bytea",
|
|
||||||
oldMaxLength: 12,
|
|
||||||
oldNullable: true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.AlterColumn<byte[]>(
|
|
||||||
name: "AuthSecret",
|
|
||||||
schema: "agents",
|
|
||||||
table: "Agents",
|
|
||||||
type: "bytea",
|
|
||||||
maxLength: 12,
|
|
||||||
nullable: true,
|
|
||||||
oldClrType: typeof(byte[]),
|
|
||||||
oldType: "bytea",
|
|
||||||
oldMaxLength: 12);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -30,24 +30,24 @@ namespace Phantom.Controller.Database.Postgres.Migrations
|
|||||||
.HasColumnType("uuid");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<byte[]>("AuthSecret")
|
b.Property<byte[]>("AuthSecret")
|
||||||
.IsRequired()
|
|
||||||
.HasMaxLength(12)
|
.HasMaxLength(12)
|
||||||
.HasColumnType("bytea");
|
.HasColumnType("bytea");
|
||||||
|
|
||||||
b.Property<string>("BuildVersion")
|
b.Property<string>("BuildVersion")
|
||||||
|
.IsRequired()
|
||||||
.HasColumnType("text");
|
.HasColumnType("text");
|
||||||
|
|
||||||
b.Property<int?>("MaxInstances")
|
b.Property<int>("MaxInstances")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer");
|
||||||
|
|
||||||
b.Property<int?>("MaxMemory")
|
b.Property<int>("MaxMemory")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer");
|
||||||
|
|
||||||
b.Property<string>("Name")
|
b.Property<string>("Name")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("text");
|
.HasColumnType("text");
|
||||||
|
|
||||||
b.Property<int?>("ProtocolVersion")
|
b.Property<int>("ProtocolVersion")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer");
|
||||||
|
|
||||||
b.HasKey("AgentGuid");
|
b.HasKey("AgentGuid");
|
||||||
|
|||||||
@@ -20,16 +20,15 @@ public sealed class AgentEntity {
|
|||||||
public RamAllocationUnits? MaxMemory { get; set; }
|
public RamAllocationUnits? MaxMemory { get; set; }
|
||||||
|
|
||||||
[MaxLength(AuthSecret.Length)]
|
[MaxLength(AuthSecret.Length)]
|
||||||
public AuthSecret AuthSecret { get; set; }
|
public AuthSecret? AuthSecret { get; set; }
|
||||||
|
|
||||||
public AgentConfiguration Configuration => new (Name);
|
public AgentConfiguration Configuration => new (Name);
|
||||||
public AgentVersionInfo? VersionInfo => ProtocolVersion is {} protocolVersion && BuildVersion is {} buildVersion ? new AgentVersionInfo(protocolVersion, buildVersion) : null;
|
public AgentVersionInfo? VersionInfo => ProtocolVersion is null || BuildVersion is null ? null : new AgentVersionInfo(ProtocolVersion, BuildVersion);
|
||||||
public AgentRuntimeInfo RuntimeInfo => new (VersionInfo, MaxInstances, MaxMemory);
|
public AgentRuntimeInfo RuntimeInfo => new (VersionInfo, MaxInstances, MaxMemory);
|
||||||
|
|
||||||
internal AgentEntity(Guid agentGuid) {
|
internal AgentEntity(Guid agentGuid) {
|
||||||
AgentGuid = agentGuid;
|
AgentGuid = agentGuid;
|
||||||
Name = null!;
|
Name = null!;
|
||||||
BuildVersion = null!;
|
BuildVersion = null!;
|
||||||
AuthSecret = null!;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
<PackageReference Include="System.Linq.Async" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ using Phantom.Controller.Database.Entities;
|
|||||||
using Phantom.Controller.Database.Repositories;
|
using Phantom.Controller.Database.Repositories;
|
||||||
using Phantom.Utils.Actor;
|
using Phantom.Utils.Actor;
|
||||||
using Phantom.Utils.Logging;
|
using Phantom.Utils.Logging;
|
||||||
using Phantom.Utils.Rpc;
|
|
||||||
using Serilog;
|
using Serilog;
|
||||||
|
|
||||||
namespace Phantom.Controller.Services.Agents;
|
namespace Phantom.Controller.Services.Agents;
|
||||||
@@ -53,15 +52,12 @@ sealed class AgentDatabaseStorageActor : ReceiveActor<AgentDatabaseStorageActor.
|
|||||||
await FlushAgentRuntimeInfo();
|
await FlushAgentRuntimeInfo();
|
||||||
|
|
||||||
bool wasCreated;
|
bool wasCreated;
|
||||||
|
string agentName;
|
||||||
|
|
||||||
await using (var db = dbProvider.Lazy()) {
|
await using (var db = dbProvider.Lazy()) {
|
||||||
var entity = db.Ctx.AgentUpsert.Fetch(agentGuid, out wasCreated);
|
var entity = db.Ctx.AgentUpsert.Fetch(agentGuid, out wasCreated);
|
||||||
|
|
||||||
if (wasCreated) {
|
agentName = entity.Name = command.Configuration.AgentName;
|
||||||
entity.AuthSecret = AuthSecret.Generate();
|
|
||||||
}
|
|
||||||
|
|
||||||
entity.Name = command.Configuration.AgentName;
|
|
||||||
|
|
||||||
var auditLogWriter = new AuditLogRepository(db).Writer(command.AuditLogUserGuid);
|
var auditLogWriter = new AuditLogRepository(db).Writer(command.AuditLogUserGuid);
|
||||||
if (wasCreated) {
|
if (wasCreated) {
|
||||||
@@ -75,7 +71,7 @@ sealed class AgentDatabaseStorageActor : ReceiveActor<AgentDatabaseStorageActor.
|
|||||||
}
|
}
|
||||||
|
|
||||||
string action = wasCreated ? "Created" : "Edited";
|
string action = wasCreated ? "Created" : "Edited";
|
||||||
Logger.Information(action + " agent \"{AgentName}\" (GUID {AgentGuid}) in database.", command.Configuration.AgentName, agentGuid);
|
Logger.Information(action + " agent \"{AgentName}\" (GUID {AgentGuid}) in database.", agentName, agentGuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void StoreAgentRuntimeInfo(StoreAgentRuntimeInfoCommand command) {
|
private void StoreAgentRuntimeInfo(StoreAgentRuntimeInfoCommand command) {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Collections.Immutable;
|
using System.Collections.Immutable;
|
||||||
using Akka.Actor;
|
using Akka.Actor;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Phantom.Common.Data;
|
using Phantom.Common.Data;
|
||||||
using Phantom.Common.Data.Replies;
|
using Phantom.Common.Data.Replies;
|
||||||
using Phantom.Common.Data.Web.Agent;
|
using Phantom.Common.Data.Web.Agent;
|
||||||
@@ -8,6 +9,7 @@ using Phantom.Common.Data.Web.Users;
|
|||||||
using Phantom.Common.Messages.Agent.Handshake;
|
using Phantom.Common.Messages.Agent.Handshake;
|
||||||
using Phantom.Common.Messages.Agent.ToAgent;
|
using Phantom.Common.Messages.Agent.ToAgent;
|
||||||
using Phantom.Controller.Database;
|
using Phantom.Controller.Database;
|
||||||
|
using Phantom.Controller.Database.Entities;
|
||||||
using Phantom.Controller.Minecraft;
|
using Phantom.Controller.Minecraft;
|
||||||
using Phantom.Controller.Services.Users.Sessions;
|
using Phantom.Controller.Services.Users.Sessions;
|
||||||
using Phantom.Utils.Actor;
|
using Phantom.Utils.Actor;
|
||||||
@@ -31,11 +33,12 @@ sealed class AgentManager(
|
|||||||
|
|
||||||
public async Task Initialize() {
|
public async Task Initialize() {
|
||||||
await using var ctx = dbProvider.Eager();
|
await using var ctx = dbProvider.Eager();
|
||||||
|
await Migrate(ctx);
|
||||||
|
|
||||||
await foreach (var entity in ctx.Agents.AsAsyncEnumerable().WithCancellation(cancellationToken)) {
|
await foreach (var entity in ctx.Agents.AsAsyncEnumerable().WithCancellation(cancellationToken)) {
|
||||||
var agentGuid = entity.AgentGuid;
|
var agentGuid = entity.AgentGuid;
|
||||||
|
|
||||||
if (AddAgent(loggedInUserGuid: null, agentGuid, entity.Configuration, entity.AuthSecret, entity.RuntimeInfo)) {
|
if (AddAgent(loggedInUserGuid: null, agentGuid, entity.Configuration, entity.AuthSecret!, entity.RuntimeInfo)) {
|
||||||
Logger.Information("Loaded agent \"{AgentName}\" (GUID {AgentGuid}) from database.", entity.Name, agentGuid);
|
Logger.Information("Loaded agent \"{AgentName}\" (GUID {AgentGuid}) from database.", entity.Name, agentGuid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -47,6 +50,19 @@ sealed class AgentManager(
|
|||||||
return agentsByAgentGuid.TryAdd(agentGuid, actorSystem.ActorOf(AgentActor.Factory(init), name));
|
return agentsByAgentGuid.TryAdd(agentGuid, actorSystem.ActorOf(AgentActor.Factory(init), name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task Migrate(ApplicationDbContext ctx) {
|
||||||
|
List<AgentEntity> agentsWithoutSecrets = await ctx.Agents.Where(static entity => entity.AuthSecret == null).ToListAsync(cancellationToken);
|
||||||
|
if (agentsWithoutSecrets.Count == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var entity in agentsWithoutSecrets) {
|
||||||
|
entity.AuthSecret = AuthSecret.Generate();
|
||||||
|
}
|
||||||
|
|
||||||
|
await ctx.SaveChangesAsync(cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<ImmutableArray<ConfigureInstanceMessage>?> RegisterAgent(Guid agentGuid, AgentRegistration registration) {
|
public async Task<ImmutableArray<ConfigureInstanceMessage>?> RegisterAgent(Guid agentGuid, AgentRegistration registration) {
|
||||||
if (!agentsByAgentGuid.TryGetValue(agentGuid, out var agentActor)) {
|
if (!agentsByAgentGuid.TryGetValue(agentGuid, out var agentActor)) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<Project>
|
<Project>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net10.0</TargetFramework>
|
<TargetFramework>net9.0</TargetFramework>
|
||||||
<LangVersion>14</LangVersion>
|
<LangVersion>13</LangVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# +---------------+
|
# +---------------+
|
||||||
# | Prepare build |
|
# | Prepare build |
|
||||||
# +---------------+
|
# +---------------+
|
||||||
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/nightly/sdk:10.0 AS phantom-builder
|
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/nightly/sdk:9.0 AS phantom-builder
|
||||||
ARG TARGETARCH
|
ARG TARGETARCH
|
||||||
|
|
||||||
ADD . /app
|
ADD . /app
|
||||||
@@ -19,7 +19,7 @@ RUN find .artifacts/publish/*/* -maxdepth 0 -execdir mv '{}' 'release' \;
|
|||||||
# +---------------------+
|
# +---------------------+
|
||||||
# | Phantom Agent image |
|
# | Phantom Agent image |
|
||||||
# +---------------------+
|
# +---------------------+
|
||||||
FROM mcr.microsoft.com/dotnet/nightly/runtime:10.0 AS phantom-agent
|
FROM mcr.microsoft.com/dotnet/nightly/runtime:9.0 AS phantom-agent
|
||||||
|
|
||||||
RUN mkdir /data && chmod 777 /data
|
RUN mkdir /data && chmod 777 /data
|
||||||
WORKDIR /data
|
WORKDIR /data
|
||||||
@@ -46,7 +46,7 @@ ENTRYPOINT ["dotnet", "/app/Phantom.Agent.dll"]
|
|||||||
# +--------------------------+
|
# +--------------------------+
|
||||||
# | Phantom Controller image |
|
# | Phantom Controller image |
|
||||||
# +--------------------------+
|
# +--------------------------+
|
||||||
FROM mcr.microsoft.com/dotnet/nightly/runtime:10.0 AS phantom-controller
|
FROM mcr.microsoft.com/dotnet/nightly/runtime:9.0 AS phantom-controller
|
||||||
|
|
||||||
RUN mkdir /data && chmod 777 /data
|
RUN mkdir /data && chmod 777 /data
|
||||||
WORKDIR /data
|
WORKDIR /data
|
||||||
|
|||||||
@@ -1,14 +1,15 @@
|
|||||||
<Project>
|
<Project>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Update="Microsoft.AspNetCore.Components.Authorization" Version="10.0.1" />
|
<PackageReference Update="Microsoft.AspNetCore.Components.Authorization" Version="9.0.9" />
|
||||||
<PackageReference Update="Microsoft.AspNetCore.Components.Web" Version="10.0.1" />
|
<PackageReference Update="Microsoft.AspNetCore.Components.Web" Version="9.0.9" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Update="Microsoft.EntityFrameworkCore.Tools" Version="10.0.1" />
|
<PackageReference Update="Microsoft.EntityFrameworkCore.Relational" Version="9.0.9" />
|
||||||
<PackageReference Update="Microsoft.EntityFrameworkCore.Relational" Version="10.0.1" />
|
<PackageReference Update="Microsoft.EntityFrameworkCore.Tools" Version="9.0.9" />
|
||||||
<PackageReference Update="Npgsql.EntityFrameworkCore.PostgreSQL" Version="10.0.0" />
|
<PackageReference Update="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.4" />
|
||||||
|
<PackageReference Update="System.Linq.Async" Version="6.0.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@@ -22,7 +23,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Update="Serilog" Version="4.3.0" />
|
<PackageReference Update="Serilog" Version="4.3.0" />
|
||||||
<PackageReference Update="Serilog.AspNetCore" Version="10.0.0" />
|
<PackageReference Update="Serilog.AspNetCore" Version="9.0.0" />
|
||||||
<PackageReference Update="Serilog.Sinks.Async" Version="2.1.0" />
|
<PackageReference Update="Serilog.Sinks.Async" Version="2.1.0" />
|
||||||
<PackageReference Update="Serilog.Sinks.Console" Version="6.0.0" />
|
<PackageReference Update="Serilog.Sinks.Console" Version="6.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@@ -88,8 +88,8 @@ Use volumes to persist either the whole `/data` folder, or just `/data/data` if
|
|||||||
* **Controller Communication**
|
* **Controller Communication**
|
||||||
- `CONTROLLER_HOST` is the hostname of the Controller.
|
- `CONTROLLER_HOST` is the hostname of the Controller.
|
||||||
- `CONTROLLER_PORT` is the Agent RPC port of the Controller. Default: `9401`
|
- `CONTROLLER_PORT` is the Agent RPC port of the Controller. Default: `9401`
|
||||||
- `AGENT_KEY` is the [Agent Key](#secrets). Mutually exclusive with `AGENT_KEY_FILE`.
|
- `AGENT_KEY` is the [Agent Key](#agent--web-keys). Mutually exclusive with `AGENT_KEY_FILE`.
|
||||||
- `AGENT_KEY_FILE` is a path to a file containing the [Agent Key](#secrets). Mutually exclusive with `AGENT_KEY`.
|
- `AGENT_KEY_FILE` is a path to a file containing the [Agent Key](#agent--web-keys). Mutually exclusive with `AGENT_KEY`.
|
||||||
* **Agent Configuration**
|
* **Agent Configuration**
|
||||||
- `MAX_INSTANCES` is the number of instances that can be created.
|
- `MAX_INSTANCES` is the number of instances that can be created.
|
||||||
- `MAX_MEMORY` is the maximum amount of RAM that can be distributed among all instances. Use a positive integer with an optional suffix 'M' for MB, or 'G' for GB. Examples: `4096M`, `16G`
|
- `MAX_MEMORY` is the maximum amount of RAM that can be distributed among all instances. Use a positive integer with an optional suffix 'M' for MB, or 'G' for GB. Examples: `4096M`, `16G`
|
||||||
@@ -110,8 +110,8 @@ Use volumes to persist the whole `/data` folder.
|
|||||||
* **Controller Communication**
|
* **Controller Communication**
|
||||||
- `CONTROLLER_HOST` is the hostname of the Controller.
|
- `CONTROLLER_HOST` is the hostname of the Controller.
|
||||||
- `CONTROLLER_PORT` is the Web RPC port of the Controller. Default: `9402`
|
- `CONTROLLER_PORT` is the Web RPC port of the Controller. Default: `9402`
|
||||||
- `WEB_KEY` is the [Web Key](#secrets). Mutually exclusive with `WEB_KEY_FILE`.
|
- `WEB_KEY` is the [Web Key](#agent--web-keys). Mutually exclusive with `WEB_KEY_FILE`.
|
||||||
- `WEB_KEY_FILE` is a path to a file containing the [Web Key](#secrets). Mutually exclusive with `WEB_KEY`.
|
- `WEB_KEY_FILE` is a path to a file containing the [Web Key](#agent--web-keys). Mutually exclusive with `WEB_KEY`.
|
||||||
* **Web Server**
|
* **Web Server**
|
||||||
- `WEB_SERVER_HOST` is the host. Default: `0.0.0.0`
|
- `WEB_SERVER_HOST` is the host. Default: `0.0.0.0`
|
||||||
- `WEB_SERVER_PORT` is the port. Default: `9400`
|
- `WEB_SERVER_PORT` is the port. Default: `9400`
|
||||||
|
|||||||
@@ -2,9 +2,17 @@
|
|||||||
|
|
||||||
namespace Phantom.Utils.Processes;
|
namespace Phantom.Utils.Processes;
|
||||||
|
|
||||||
public sealed class OneShotProcess(ILogger logger, ProcessConfigurator configurator) {
|
public sealed class OneShotProcess {
|
||||||
|
private readonly ILogger logger;
|
||||||
|
private readonly ProcessConfigurator configurator;
|
||||||
|
|
||||||
public event EventHandler<Process.Output>? OutputReceived;
|
public event EventHandler<Process.Output>? OutputReceived;
|
||||||
|
|
||||||
|
public OneShotProcess(ILogger logger, ProcessConfigurator configurator) {
|
||||||
|
this.logger = logger;
|
||||||
|
this.configurator = configurator;
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<bool> Run(CancellationToken cancellationToken) {
|
public async Task<bool> Run(CancellationToken cancellationToken) {
|
||||||
using var process = configurator.CreateProcess();
|
using var process = configurator.CreateProcess();
|
||||||
process.OutputReceived += OutputReceived;
|
process.OutputReceived += OutputReceived;
|
||||||
|
|||||||
@@ -31,12 +31,6 @@ public sealed class ProcessConfigurator {
|
|||||||
set => startInfo.UseShellExecute = value;
|
set => startInfo.UseShellExecute = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProcessConfigurator() {
|
|
||||||
if (OperatingSystem.IsWindows()) {
|
|
||||||
startInfo.CreateNewProcessGroup = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Process CreateProcess() {
|
public Process CreateProcess() {
|
||||||
return new Process(new System.Diagnostics.Process { StartInfo = startInfo });
|
return new Process(new System.Diagnostics.Process { StartInfo = startInfo });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<div class="progress-label">@ChildContent</div>
|
<div class="progress-label">@ChildContent</div>
|
||||||
<div class="progress">
|
<div class="progress">
|
||||||
<div class="progress-bar" role="progressbar" style="width: @(Maximum <= 0 ? 0 : 100 * Value / Maximum)%;" aria-valuenow="@Value" aria-valuemin="0" aria-valuemax="@Maximum"></div>
|
<div class="progress-bar" role="progressbar" style="width: @(100 * Value / Maximum)%;" aria-valuenow="@Value" aria-valuemin="0" aria-valuemax="@Maximum"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
@using Phantom.Web.Errors
|
@using Phantom.Web.Services
|
||||||
@using Phantom.Web.Services
|
|
||||||
@inject Navigation Navigation
|
@inject Navigation Navigation
|
||||||
|
|
||||||
<CascadingAuthenticationState>
|
<CascadingAuthenticationState>
|
||||||
<Router AppAssembly="@typeof(App).Assembly" NotFoundPage="typeof(NotFound)">
|
<Router AppAssembly="@typeof(App).Assembly">
|
||||||
<Found Context="routeData">
|
<Found Context="routeData">
|
||||||
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)">
|
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)">
|
||||||
<NotAuthorized>
|
<NotAuthorized>
|
||||||
@@ -18,5 +17,11 @@
|
|||||||
</AuthorizeRouteView>
|
</AuthorizeRouteView>
|
||||||
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
|
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
|
||||||
</Found>
|
</Found>
|
||||||
|
<NotFound>
|
||||||
|
<LayoutView Layout="@typeof(MainLayout)">
|
||||||
|
<h1>Not Found</h1>
|
||||||
|
<p role="alert">Sorry, there's nothing at this address.</p>
|
||||||
|
</LayoutView>
|
||||||
|
</NotFound>
|
||||||
</Router>
|
</Router>
|
||||||
</CascadingAuthenticationState>
|
</CascadingAuthenticationState>
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
@page "/error/404"
|
|
||||||
@layout MainLayout
|
|
||||||
|
|
||||||
<h1>Not Found</h1>
|
|
||||||
<p role="alert">Sorry, there's nothing at this address.</p>
|
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
<script src="_framework/blazor.server.js"></script>
|
<script src="_framework/blazor.server.js"></script>
|
||||||
@* ReSharper restore Html.PathError *@
|
@* ReSharper restore Html.PathError *@
|
||||||
<script src="lib/bootstrap/bootstrap.bundle.min.js"></script>
|
<script src="lib/bootstrap/bootstrap.bundle.min.js"></script>
|
||||||
<script src="js/site.js?v=2"></script>
|
<script src="js/site.js"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -37,37 +37,35 @@
|
|||||||
<small class="font-monospace text-uppercase">@agent.AgentGuid.ToString()</small>
|
<small class="font-monospace text-uppercase">@agent.AgentGuid.ToString()</small>
|
||||||
</Cell>
|
</Cell>
|
||||||
<Cell class="text-end">
|
<Cell class="text-end">
|
||||||
<ProgressBar Value="@(usedInstances ?? 0)" Maximum="@(runtimeInfo.MaxInstances ?? 0)">
|
@if (runtimeInfo.MaxInstances is {} maxInstances) {
|
||||||
@if (runtimeInfo.MaxInstances is {} maxInstances) {
|
<ProgressBar Value="@(usedInstances ?? 0)" Maximum="@maxInstances">
|
||||||
<text>@(usedInstances?.ToString() ?? "?") / @maxInstances.ToString()</text>
|
@(usedInstances?.ToString() ?? "?") / @maxInstances.ToString()
|
||||||
}
|
</ProgressBar>
|
||||||
else {
|
}
|
||||||
@:N/A
|
else {
|
||||||
}
|
@:N/A
|
||||||
</ProgressBar>
|
}
|
||||||
</Cell>
|
</Cell>
|
||||||
<Cell class="text-end">
|
<Cell class="text-end">
|
||||||
<ProgressBar Value="@(usedMemory ?? 0)" Maximum="@(runtimeInfo.MaxMemory?.InMegabytes ?? 0)">
|
@if (runtimeInfo.MaxMemory is {} maxMemory) {
|
||||||
@if (runtimeInfo.MaxMemory is {} maxMemory) {
|
<ProgressBar Value="@(usedMemory ?? 0)" Maximum="@maxMemory.InMegabytes">
|
||||||
<text>@(usedMemory?.ToString() ?? "?") / @maxMemory.InMegabytes MB</text>
|
@(usedMemory?.ToString() ?? "?") / @maxMemory.InMegabytes.ToString() MB
|
||||||
}
|
</ProgressBar>
|
||||||
else {
|
}
|
||||||
@:N/A
|
else {
|
||||||
}
|
@:N/A
|
||||||
</ProgressBar>
|
}
|
||||||
</Cell>
|
</Cell>
|
||||||
@if (runtimeInfo.VersionInfo is {} versionInfo) {
|
<Cell class="text-condensed">
|
||||||
<Cell class="text-condensed">
|
@if (runtimeInfo.VersionInfo is {} versionInfo) {
|
||||||
Build: <span class="font-monospace">@versionInfo.BuildVersion</span>
|
<text>Build: <span class="font-monospace">@versionInfo.BuildVersion</span></text>
|
||||||
<br>
|
<br>
|
||||||
Protocol: <span class="font-monospace">v@(versionInfo.ProtocolVersion.ToString())</span>
|
<text>Protocol: <span class="font-monospace">v@(versionInfo.ProtocolVersion.ToString())</span></text>
|
||||||
</Cell>
|
}
|
||||||
}
|
else {
|
||||||
else {
|
@:N/A
|
||||||
<Cell>
|
}
|
||||||
N/A
|
</Cell>
|
||||||
</Cell>
|
|
||||||
}
|
|
||||||
@switch (agent.ConnectionStatus) {
|
@switch (agent.ConnectionStatus) {
|
||||||
case AgentIsOnline:
|
case AgentIsOnline:
|
||||||
<Cell class="fw-semibold text-center text-success">Online</Cell>
|
<Cell class="fw-semibold text-center text-success">Online</Cell>
|
||||||
@@ -91,10 +89,7 @@
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
<Cell>
|
<Cell>
|
||||||
<PermissionView Permission="Permission.ManageAllAgents">
|
<button type="button" class="btn btn-danger btn-sm" data-clipboard="@connectionKey" onclick="copyToClipboard(this);">Copy Agent Key</button>
|
||||||
<a href="agents/@agent.AgentGuid/edit" type="button" class="btn btn-primary btn-sm">Edit Agent</a>
|
|
||||||
<button type="button" class="btn btn-warning btn-sm" data-clipboard="@connectionKey" onclick="copyToClipboard(this);">Copy Agent Key</button>
|
|
||||||
</PermissionView>
|
|
||||||
</Cell>
|
</Cell>
|
||||||
</ItemRow>
|
</ItemRow>
|
||||||
<NoItemsRow>
|
<NoItemsRow>
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
<Form Model="form" OnSubmit="AddOrEditAgent">
|
<Form Model="form" OnSubmit="AddOrEditAgent">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xl-12 mb-3">
|
<div class="col-xl-5 mb-3">
|
||||||
<FormTextInput Id="agent-name" Label="Agent Name" @bind-Value="form.AgentName" />
|
<FormTextInput Id="agent-name" Label="Agent Name" @bind-Value="form.AgentName" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -31,16 +31,12 @@
|
|||||||
static RenderFragment GetAgentOption(Agent agent) {
|
static RenderFragment GetAgentOption(Agent agent) {
|
||||||
var runtimeInfo = agent.RuntimeInfo;
|
var runtimeInfo = agent.RuntimeInfo;
|
||||||
return
|
return
|
||||||
@<option value="@agent.AgentGuid" disabled="@(agent.ConnectionStatus is not AgentIsOnline)">
|
@<option value="@agent.AgentGuid">
|
||||||
@agent.Configuration.AgentName
|
@agent.Configuration.AgentName
|
||||||
@if (agent.ConnectionStatus is not AgentIsOnline) {
|
@if (runtimeInfo.MaxInstances is not null && runtimeInfo.MaxMemory is not null) {
|
||||||
<text> • </text>
|
<text>•</text>
|
||||||
<text>Offline</text>
|
|
||||||
}
|
|
||||||
else if (runtimeInfo.MaxInstances is not null && runtimeInfo.MaxMemory is not null) {
|
|
||||||
<text> • </text>
|
|
||||||
<text>@(agent.Stats?.RunningInstanceCount.ToString() ?? "?")/@(runtimeInfo.MaxInstances) @(runtimeInfo.MaxInstances == 1 ? "Instance" : "Instances")</text>
|
<text>@(agent.Stats?.RunningInstanceCount.ToString() ?? "?")/@(runtimeInfo.MaxInstances) @(runtimeInfo.MaxInstances == 1 ? "Instance" : "Instances")</text>
|
||||||
<text> • </text>
|
<text>•</text>
|
||||||
<text>@(agent.Stats?.RunningInstanceMemory.InMegabytes.ToString() ?? "?")/@(runtimeInfo.MaxMemory.Value.InMegabytes) MB RAM</text>
|
<text>@(agent.Stats?.RunningInstanceMemory.InMegabytes.ToString() ?? "?")/@(runtimeInfo.MaxMemory.Value.InMegabytes) MB RAM</text>
|
||||||
}
|
}
|
||||||
</option>;
|
</option>;
|
||||||
@@ -49,7 +45,7 @@
|
|||||||
@if (EditedInstance == null) {
|
@if (EditedInstance == null) {
|
||||||
<FormSelectInput Id="instance-agent" Label="Agent" @bind-Value="form.SelectedAgentGuid">
|
<FormSelectInput Id="instance-agent" Label="Agent" @bind-Value="form.SelectedAgentGuid">
|
||||||
<option value="" selected>Select which agent will run the instance...</option>
|
<option value="" selected>Select which agent will run the instance...</option>
|
||||||
@foreach (var agent in allAgentsByGuid.Values.OrderBy(static agent => agent.Configuration.AgentName)) {
|
@foreach (var agent in allAgentsByGuid.Values.Where(static agent => agent.ConnectionStatus is AgentIsOnline).OrderBy(static agent => agent.Configuration.AgentName)) {
|
||||||
@GetAgentOption(agent)
|
@GetAgentOption(agent)
|
||||||
}
|
}
|
||||||
</FormSelectInput>
|
</FormSelectInput>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"sdk": {
|
"sdk": {
|
||||||
"version": "10.0.0",
|
"version": "9.0.0",
|
||||||
"rollForward": "latestMinor",
|
"rollForward": "latestMinor",
|
||||||
"allowPrerelease": true
|
"allowPrerelease": true
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user