mirror of
				https://github.com/chylex/Minecraft-Phantom-Panel.git
				synced 2025-10-31 20:17:16 +01:00 
			
		
		
		
	Compare commits
	
		
			1 Commits
		
	
	
		
			94148add2d
			...
			experiment
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 0cf2975acd | 
							
								
								
									
										476
									
								
								Agent/Phantom.Agent/AgentNameGenerator.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										476
									
								
								Agent/Phantom.Agent/AgentNameGenerator.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,476 @@ | ||||
| using Phantom.Utils.Cryptography; | ||||
|  | ||||
| namespace Phantom.Agent; | ||||
|  | ||||
| static class AgentNameGenerator { | ||||
| 	private static readonly string[] Prefixes = { | ||||
| 		"Abundant", | ||||
| 		"Ancient", | ||||
| 		"Broken", | ||||
| 		"Crushed", | ||||
| 		"Damaged", | ||||
| 		"Dark", | ||||
| 		"Divine", | ||||
| 		"Enchanted", | ||||
| 		"Flaming", | ||||
| 		"Frozen", | ||||
| 		"Gilded", | ||||
| 		"Glowing", | ||||
| 		"Immaculate", | ||||
| 		"Infested", | ||||
| 		"Invisible", | ||||
| 		"Luxurious", | ||||
| 		"Mossy", | ||||
| 		"Mysterious", | ||||
| 		"Opulent", | ||||
| 		"Perplexing", | ||||
| 		"Possessed", | ||||
| 		"Pristine", | ||||
| 		"Rotting", | ||||
| 		"Sophisticated", | ||||
| 		"Spectacular", | ||||
| 		"Stunning", | ||||
| 		"Tenacious", | ||||
| 		"Twisted", | ||||
| 		"Unique", | ||||
| 		"Venerable", | ||||
| 		"Withering" | ||||
| 	}; | ||||
|  | ||||
| 	private static readonly string[] Suffixes = { | ||||
| 		"Acacia Button", | ||||
| 		"Acacia Door", | ||||
| 		"Acacia Fence", | ||||
| 		"Acacia Leaves", | ||||
| 		"Acacia Log", | ||||
| 		"Acacia Planks", | ||||
| 		"Acacia Sapling", | ||||
| 		"Acacia Sign", | ||||
| 		"Acacia Slab", | ||||
| 		"Acacia Stairs", | ||||
| 		"Acacia Trapdoor", | ||||
| 		"Acacia Wood", | ||||
| 		"Activator Rail", | ||||
| 		"Allium", | ||||
| 		"Ancient Debris", | ||||
| 		"Andesite Slab", | ||||
| 		"Andesite Stairs", | ||||
| 		"Andesite Wall", | ||||
| 		"Andesite", | ||||
| 		"Anvil", | ||||
| 		"Azalea Leaves", | ||||
| 		"Azalea", | ||||
| 		"Azure Bluet", | ||||
| 		"Bamboo", | ||||
| 		"Barrel", | ||||
| 		"Basalt", | ||||
| 		"Beacon", | ||||
| 		"Bedrock", | ||||
| 		"Bee Nest", | ||||
| 		"Beehive", | ||||
| 		"Beetroots", | ||||
| 		"Bell", | ||||
| 		"Birch Button", | ||||
| 		"Birch Door", | ||||
| 		"Birch Fence", | ||||
| 		"Birch Leaves", | ||||
| 		"Birch Log", | ||||
| 		"Birch Planks", | ||||
| 		"Birch Sapling", | ||||
| 		"Birch Sign", | ||||
| 		"Birch Slab", | ||||
| 		"Birch Stairs", | ||||
| 		"Birch Trapdoor", | ||||
| 		"Birch Wood", | ||||
| 		"Black Candle", | ||||
| 		"Black Carpet", | ||||
| 		"Black Concrete", | ||||
| 		"Black Terracotta", | ||||
| 		"Black Wool", | ||||
| 		"Blackstone Slab", | ||||
| 		"Blackstone Stairs", | ||||
| 		"Blackstone Wall", | ||||
| 		"Blackstone", | ||||
| 		"Blast Furnace", | ||||
| 		"Blue Candle", | ||||
| 		"Blue Carpet", | ||||
| 		"Blue Concrete", | ||||
| 		"Blue Ice", | ||||
| 		"Blue Orchid", | ||||
| 		"Blue Terracotta", | ||||
| 		"Blue Wool", | ||||
| 		"Bone Block", | ||||
| 		"Bookshelf", | ||||
| 		"Brain Coral", | ||||
| 		"Brewing Stand", | ||||
| 		"Brick Slab", | ||||
| 		"Brick Stairs", | ||||
| 		"Brick Wall", | ||||
| 		"Bricks", | ||||
| 		"Brown Candle", | ||||
| 		"Brown Carpet", | ||||
| 		"Brown Concrete", | ||||
| 		"Brown Mushroom", | ||||
| 		"Brown Terracotta", | ||||
| 		"Brown Wool", | ||||
| 		"Bubble Column", | ||||
| 		"Bubble Coral", | ||||
| 		"Cactus", | ||||
| 		"Cake", | ||||
| 		"Calcite", | ||||
| 		"Campfire", | ||||
| 		"Candle", | ||||
| 		"Carrots", | ||||
| 		"Cartography Table", | ||||
| 		"Carved Pumpkin", | ||||
| 		"Cauldron", | ||||
| 		"Cave Vines", | ||||
| 		"Chain", | ||||
| 		"Chest", | ||||
| 		"Chorus Flower", | ||||
| 		"Chorus Plant", | ||||
| 		"Clay", | ||||
| 		"Coal Ore", | ||||
| 		"Coarse Dirt", | ||||
| 		"Cobbled Deepslate", | ||||
| 		"Cobblestone Slab", | ||||
| 		"Cobblestone Stairs", | ||||
| 		"Cobblestone Wall", | ||||
| 		"Cobblestone", | ||||
| 		"Cobweb", | ||||
| 		"Cocoa", | ||||
| 		"Composter", | ||||
| 		"Conduit", | ||||
| 		"Copper Ore", | ||||
| 		"Cornflower", | ||||
| 		"Crafting Table", | ||||
| 		"Creeper Head", | ||||
| 		"Crimson Button", | ||||
| 		"Crimson Door", | ||||
| 		"Crimson Fence", | ||||
| 		"Crimson Fungus", | ||||
| 		"Crimson Hyphae", | ||||
| 		"Crimson Nylium", | ||||
| 		"Crimson Planks", | ||||
| 		"Crimson Roots", | ||||
| 		"Crimson Sign", | ||||
| 		"Crimson Slab", | ||||
| 		"Crimson Stairs", | ||||
| 		"Crimson Stem", | ||||
| 		"Crimson Trapdoor", | ||||
| 		"Crying Obsidian", | ||||
| 		"Cyan Candle", | ||||
| 		"Cyan Carpet", | ||||
| 		"Cyan Concrete", | ||||
| 		"Cyan Terracotta", | ||||
| 		"Cyan Wool", | ||||
| 		"Dandelion", | ||||
| 		"Dead Bush", | ||||
| 		"Deepslate Bricks", | ||||
| 		"Deepslate Tiles", | ||||
| 		"Deepslate", | ||||
| 		"Detector Rail", | ||||
| 		"Diamond Ore", | ||||
| 		"Diorite Slab", | ||||
| 		"Diorite Stairs", | ||||
| 		"Diorite Wall", | ||||
| 		"Diorite", | ||||
| 		"Dirt", | ||||
| 		"Dispenser", | ||||
| 		"Dragon Egg", | ||||
| 		"Dragon Head", | ||||
| 		"Dripstone Block", | ||||
| 		"Dropper", | ||||
| 		"Emerald Ore", | ||||
| 		"Enchanting Table", | ||||
| 		"End Gateway", | ||||
| 		"End Portal", | ||||
| 		"End Rod", | ||||
| 		"End Stone", | ||||
| 		"Ender Chest", | ||||
| 		"Farmland", | ||||
| 		"Fern", | ||||
| 		"Fire Coral", | ||||
| 		"Fletching Table", | ||||
| 		"Flower Pot", | ||||
| 		"Flowering Azalea", | ||||
| 		"Frosted Ice", | ||||
| 		"Furnace", | ||||
| 		"Glass Pane", | ||||
| 		"Glass", | ||||
| 		"Glowstone", | ||||
| 		"Gold Ore", | ||||
| 		"Granite Slab", | ||||
| 		"Granite Stairs", | ||||
| 		"Granite Wall", | ||||
| 		"Granite", | ||||
| 		"Grass Block", | ||||
| 		"Grass", | ||||
| 		"Gravel", | ||||
| 		"Gray Candle", | ||||
| 		"Gray Carpet", | ||||
| 		"Gray Concrete", | ||||
| 		"Gray Terracotta", | ||||
| 		"Gray Wool", | ||||
| 		"Green Candle", | ||||
| 		"Green Carpet", | ||||
| 		"Green Concrete", | ||||
| 		"Green Terracotta", | ||||
| 		"Green Wool", | ||||
| 		"Grindstone", | ||||
| 		"Hay Bale", | ||||
| 		"Honey Block", | ||||
| 		"Hopper", | ||||
| 		"Horn Coral", | ||||
| 		"Ice", | ||||
| 		"Iron Bars", | ||||
| 		"Iron Door", | ||||
| 		"Iron Ore", | ||||
| 		"Iron Trapdoor", | ||||
| 		"Jack o'Lantern", | ||||
| 		"Jigsaw Block", | ||||
| 		"Jukebox", | ||||
| 		"Jungle Button", | ||||
| 		"Jungle Door", | ||||
| 		"Jungle Fence", | ||||
| 		"Jungle Leaves", | ||||
| 		"Jungle Log", | ||||
| 		"Jungle Planks", | ||||
| 		"Jungle Sapling", | ||||
| 		"Jungle Sign", | ||||
| 		"Jungle Slab", | ||||
| 		"Jungle Stairs", | ||||
| 		"Jungle Trapdoor", | ||||
| 		"Jungle Wood", | ||||
| 		"Kelp Plant", | ||||
| 		"Kelp", | ||||
| 		"Ladder", | ||||
| 		"Lantern", | ||||
| 		"Large Fern", | ||||
| 		"Lava", | ||||
| 		"Lectern", | ||||
| 		"Lever", | ||||
| 		"Lightning Rod", | ||||
| 		"Lilac", | ||||
| 		"Lily Pad", | ||||
| 		"Lime Candle", | ||||
| 		"Lime Carpet", | ||||
| 		"Lime Concrete", | ||||
| 		"Lime Terracotta", | ||||
| 		"Lime Wool", | ||||
| 		"Lodestone", | ||||
| 		"Loom", | ||||
| 		"Magenta Candle", | ||||
| 		"Magenta Carpet", | ||||
| 		"Magenta Concrete", | ||||
| 		"Magenta Terracotta", | ||||
| 		"Magenta Wool", | ||||
| 		"Magma Block", | ||||
| 		"Mangrove Button", | ||||
| 		"Mangrove Door", | ||||
| 		"Mangrove Fence", | ||||
| 		"Mangrove Leaves", | ||||
| 		"Mangrove Log", | ||||
| 		"Mangrove Planks", | ||||
| 		"Mangrove Propagule", | ||||
| 		"Mangrove Roots", | ||||
| 		"Mangrove Sign", | ||||
| 		"Mangrove Slab", | ||||
| 		"Mangrove Stairs", | ||||
| 		"Mangrove Trapdoor", | ||||
| 		"Mangrove Wood", | ||||
| 		"Melon Stem", | ||||
| 		"Melon", | ||||
| 		"Moss Block", | ||||
| 		"Moss Carpet", | ||||
| 		"Mossy Cobblestone", | ||||
| 		"Mud Bricks", | ||||
| 		"Mud", | ||||
| 		"Mushroom Stem", | ||||
| 		"Mycelium", | ||||
| 		"Nether Bricks", | ||||
| 		"Nether Portal", | ||||
| 		"Nether Sprouts", | ||||
| 		"Nether Wart", | ||||
| 		"Netherrack", | ||||
| 		"Note Block", | ||||
| 		"Oak Button", | ||||
| 		"Oak Door", | ||||
| 		"Oak Fence", | ||||
| 		"Oak Leaves", | ||||
| 		"Oak Log", | ||||
| 		"Oak Planks", | ||||
| 		"Oak Sapling", | ||||
| 		"Oak Sign", | ||||
| 		"Oak Slab", | ||||
| 		"Oak Stairs", | ||||
| 		"Oak Trapdoor", | ||||
| 		"Oak Wood", | ||||
| 		"Observer", | ||||
| 		"Obsidian", | ||||
| 		"Ominous Banner", | ||||
| 		"Orange Candle", | ||||
| 		"Orange Carpet", | ||||
| 		"Orange Concrete", | ||||
| 		"Orange Terracotta", | ||||
| 		"Orange Tulip", | ||||
| 		"Orange Wool", | ||||
| 		"Oxeye Daisy", | ||||
| 		"Oxidized Copper", | ||||
| 		"Packed Ice", | ||||
| 		"Packed Mud", | ||||
| 		"Peony", | ||||
| 		"Pink Candle", | ||||
| 		"Pink Carpet", | ||||
| 		"Pink Concrete", | ||||
| 		"Pink Terracotta", | ||||
| 		"Pink Tulip", | ||||
| 		"Pink Wool", | ||||
| 		"Piston", | ||||
| 		"Podzol", | ||||
| 		"Pointed Dripstone", | ||||
| 		"Polished Andesite", | ||||
| 		"Polished Basalt", | ||||
| 		"Polished Blackstone", | ||||
| 		"Polished Deepslate", | ||||
| 		"Polished Diorite", | ||||
| 		"Polished Granite", | ||||
| 		"Poppy", | ||||
| 		"Potatoes", | ||||
| 		"Powder Snow", | ||||
| 		"Powered Rail", | ||||
| 		"Prismarine Bricks", | ||||
| 		"Prismarine Slab", | ||||
| 		"Prismarine Stairs", | ||||
| 		"Prismarine Wall", | ||||
| 		"Prismarine", | ||||
| 		"Pumpkin Stem", | ||||
| 		"Pumpkin", | ||||
| 		"Purple Candle", | ||||
| 		"Purple Carpet", | ||||
| 		"Purple Concrete", | ||||
| 		"Purple Terracotta", | ||||
| 		"Purple Wool", | ||||
| 		"Purpur Block", | ||||
| 		"Purpur Pillar", | ||||
| 		"Purpur Slab", | ||||
| 		"Purpur Stairs", | ||||
| 		"Quartz Bricks", | ||||
| 		"Quartz Pillar", | ||||
| 		"Quartz Slab", | ||||
| 		"Quartz Stairs", | ||||
| 		"Rail", | ||||
| 		"Red Candle", | ||||
| 		"Red Carpet", | ||||
| 		"Red Concrete", | ||||
| 		"Red Mushroom", | ||||
| 		"Red Sand", | ||||
| 		"Red Sandstone", | ||||
| 		"Red Terracotta", | ||||
| 		"Red Tulip", | ||||
| 		"Red Wool", | ||||
| 		"Redstone Lamp", | ||||
| 		"Redstone Ore", | ||||
| 		"Redstone Torch", | ||||
| 		"Redstone Wire", | ||||
| 		"Reinforced Deepslate", | ||||
| 		"Rooted Dirt", | ||||
| 		"Rose Bush", | ||||
| 		"Sand", | ||||
| 		"Sandstone Slab", | ||||
| 		"Sandstone Stairs", | ||||
| 		"Sandstone Wall", | ||||
| 		"Sandstone", | ||||
| 		"Scaffolding", | ||||
| 		"Sea Lantern", | ||||
| 		"Sea Pickle", | ||||
| 		"Seagrass", | ||||
| 		"Shroomlight", | ||||
| 		"Shulker Box", | ||||
| 		"Skeleton Skull", | ||||
| 		"Slime Block", | ||||
| 		"Smithing Table", | ||||
| 		"Smoker", | ||||
| 		"Smooth Basalt", | ||||
| 		"Smooth Sandstone", | ||||
| 		"Smooth Stone", | ||||
| 		"Snow Block", | ||||
| 		"Snow", | ||||
| 		"Soul Lantern", | ||||
| 		"Soul Sand", | ||||
| 		"Soul Torch", | ||||
| 		"Sponge", | ||||
| 		"Spore Blossom", | ||||
| 		"Spruce Button", | ||||
| 		"Spruce Door", | ||||
| 		"Spruce Fence", | ||||
| 		"Spruce Leaves", | ||||
| 		"Spruce Log", | ||||
| 		"Spruce Planks", | ||||
| 		"Spruce Sapling", | ||||
| 		"Spruce Sign", | ||||
| 		"Spruce Slab", | ||||
| 		"Spruce Stairs", | ||||
| 		"Spruce Trapdoor", | ||||
| 		"Spruce Wood", | ||||
| 		"Sticky Piston", | ||||
| 		"Stone Bricks", | ||||
| 		"Stone Button", | ||||
| 		"Stone Slab", | ||||
| 		"Stone Stairs", | ||||
| 		"Stone", | ||||
| 		"Stonecutter", | ||||
| 		"Sugar Cane", | ||||
| 		"Sunflower", | ||||
| 		"TNT", | ||||
| 		"Target", | ||||
| 		"Terracotta", | ||||
| 		"Tinted Glass", | ||||
| 		"Torch", | ||||
| 		"Trapped Chest", | ||||
| 		"Tripwire Hook", | ||||
| 		"Tripwire", | ||||
| 		"Tube Coral", | ||||
| 		"Tuff", | ||||
| 		"Turtle Egg", | ||||
| 		"Twisting Vines", | ||||
| 		"Verdant Froglight", | ||||
| 		"Vines", | ||||
| 		"Warped Button", | ||||
| 		"Warped Door", | ||||
| 		"Warped Fence", | ||||
| 		"Warped Fungus", | ||||
| 		"Warped Hyphae", | ||||
| 		"Warped Nylium", | ||||
| 		"Warped Planks", | ||||
| 		"Warped Roots", | ||||
| 		"Warped Sign", | ||||
| 		"Warped Slab", | ||||
| 		"Warped Stairs", | ||||
| 		"Warped Stem", | ||||
| 		"Warped Trapdoor", | ||||
| 		"Water", | ||||
| 		"Weeping Vines", | ||||
| 		"Wheat Crops", | ||||
| 		"White Candle", | ||||
| 		"White Carpet", | ||||
| 		"White Concrete", | ||||
| 		"White Terracotta", | ||||
| 		"White Tulip", | ||||
| 		"White Wool", | ||||
| 		"Wither Rose", | ||||
| 		"Yellow Candle", | ||||
| 		"Yellow Carpet", | ||||
| 		"Yellow Concrete", | ||||
| 		"Yellow Terracotta", | ||||
| 		"Yellow Wool", | ||||
| 		"Zombie Head" | ||||
| 	}; | ||||
|  | ||||
| 	public static string GenerateFrom(Guid guid) { | ||||
| 		var rand = new Random(StableHashCode.ForString(guid.ToString())); | ||||
| 		string prefix = Prefixes[rand.Next(Prefixes.Length)]; | ||||
| 		string suffix = Suffixes[rand.Next(Suffixes.Length)]; | ||||
| 		return string.Concat(prefix, " ", suffix); | ||||
| 	} | ||||
| } | ||||
| @@ -18,7 +18,7 @@ PosixSignals.RegisterCancellation(cancellationTokenSource, static () => { | ||||
| try { | ||||
| 	PhantomLogger.Root.InformationHeading("Initializing Phantom Panel agent..."); | ||||
|  | ||||
| 	var (serverHost, serverPort, javaSearchPath, authToken, authTokenFilePath, agentName, maxInstances, maxMemory, allowedServerPorts, allowedRconPorts) = Variables.LoadOrExit(); | ||||
| 	var (serverHost, serverPort, javaSearchPath, authToken, authTokenFilePath, agentNameOrEmpty, maxInstances, maxMemory, allowedServerPorts, allowedRconPorts) = Variables.LoadOrExit(); | ||||
| 	 | ||||
| 	AgentAuthToken agentAuthToken; | ||||
| 	try { | ||||
| @@ -46,6 +46,7 @@ try { | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	var agentName = string.IsNullOrEmpty(agentNameOrEmpty) ? AgentNameGenerator.GenerateFrom(agentGuid.Value) : agentNameOrEmpty; | ||||
| 	var agentInfo = new AgentInfo(agentGuid.Value, agentName, AgentVersion, maxInstances, maxMemory, allowedServerPorts, allowedRconPorts); | ||||
| 	var agentServices = new AgentServices(agentInfo, folders); | ||||
|  | ||||
|   | ||||
| @@ -11,7 +11,7 @@ sealed record Variables( | ||||
| 	string JavaSearchPath, | ||||
| 	string? AuthToken, | ||||
| 	string? AuthTokenFilePath, | ||||
| 	string AgentName, | ||||
| 	string AgentNameOrEmpty, | ||||
| 	ushort MaxInstances, | ||||
| 	RamAllocationUnits MaxMemory, | ||||
| 	AllowedPorts AllowedServerPorts, | ||||
| @@ -27,7 +27,7 @@ sealed record Variables( | ||||
| 			javaSearchPath, | ||||
| 			authToken, | ||||
| 			authTokenFilePath, | ||||
| 			EnvironmentVariables.GetString("AGENT_NAME").OrThrow, | ||||
| 			EnvironmentVariables.GetString("AGENT_NAME").OrDefault(string.Empty), | ||||
| 			(ushort) EnvironmentVariables.GetInteger("MAX_INSTANCES", min: 1, max: 10000).OrThrow, | ||||
| 			EnvironmentVariables.GetString("MAX_MEMORY").MapParse(RamAllocationUnits.FromString).OrThrow, | ||||
| 			EnvironmentVariables.GetString("ALLOWED_SERVER_PORTS").MapParse(AllowedPorts.FromString).OrThrow, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user