Remove legacy regionInfo patcher

This commit is contained in:
js6pak committed 2021-07-05 18:27:59 +02:00
1 parent 9df01d2cf7
commit 11f2ffd24d
28 files changed
+10 -3568

No files matched your search

-7
View File
@@ -114,13 +114,6 @@ Task("Build")
DotNetCoreBuild("./src/Impostor.Tests/Impostor.Tests.csproj", new DotNetCoreBuildSettings {
Configuration = configuration,
});
// Client.
ImpostorPublishNF("Impostor-Patcher", "./src/Impostor.Patcher/Impostor.Patcher.WinForms/Impostor.Patcher.WinForms.csproj");
ImpostorPublish("Impostor-Patcher-Cli", "./src/Impostor.Patcher/Impostor.Patcher.Cli/Impostor.Patcher.Cli.csproj", "win-x64");
ImpostorPublish("Impostor-Patcher-Cli", "./src/Impostor.Patcher/Impostor.Patcher.Cli/Impostor.Patcher.Cli.csproj", "osx-x64");
ImpostorPublish("Impostor-Patcher-Cli", "./src/Impostor.Patcher/Impostor.Patcher.Cli/Impostor.Patcher.Cli.csproj", "linux-x64");
// Server.
ImpostorPublish("Impostor-Server", "./src/Impostor.Server/Impostor.Server.csproj", "win-x64", true);
+1 -14
View File
@@ -1,13 +1,11 @@
# Building from source
The solution contains two main projects, the Impostor server and patcher. The server is built using [.NET 5](https://dotnet.microsoft.com/download/dotnet/5.0) and the winforms patcher is with [.NET Framework 4.7.2](https://dotnet.microsoft.com/download/dotnet-framework/net472).
## Cloning Impostor
You need to clone Impostor using git.
```bash
git clone https://github.com/AeonLucid/Impostor.git
git clone https://github.com/Impostor/Impostor.git
```
## Building the server
@@ -23,14 +21,3 @@ cd src/Impostor.Server/
dotnet build
```
To setup the server, please look at [Running the server](Running-the-server.md).
## Building the winforms patcher
### Dependencies
* [.NET Framework 4.7.2 Developer Pack](https://dotnet.microsoft.com/download/dotnet-framework/thank-you/net472-developer-pack-offline-installer) or [Mono](https://www.mono-project.com/download/)
### Build using the CLI
```bash
cd src/Impostor.Patcher/Impostor.Patcher.WinForms
dotnet build
```
+5 -5
View File
@@ -6,14 +6,14 @@ There are currently two modes to run the Impostor server in. The first way is th
### Without docker
1. Install the **.NET 5.0 runtime**.
- [Windows x64](https://dotnet.microsoft.com/download/dotnet/thank-you/runtime-5.0.0-windows-x64-installer)
- [Windows x64](https://dotnet.microsoft.com/download/dotnet/thank-you/runtime-5.0.7-windows-x64-installer)
- [Linux x64](https://docs.microsoft.com/en-us/dotnet/core/install/linux)
- [macOS x64](https://dotnet.microsoft.com/download/dotnet/thank-you/runtime-5.0.0-macos-x64-installer)
2. Find the [latest master release](https://ci.appveyor.com/project/Impostor/Impostor/branch/master/artifacts).
3. Download either the Windows or the Linux version.
- [macOS x64](https://dotnet.microsoft.com/download/dotnet/thank-you/runtime-5.0.7-macos-x64-installer)
2. Find the [latest release](https://github.com/Impostor/Impostor/releases) or the [latest CI build](https://ci.appveyor.com/project/Impostor/Impostor/branch/master/artifacts).
3. Download the version for your OS (linux/win/osx) and your architecture (x64/arm/arm64).
4. Extract the zip.
5. Modify `config.json` to your liking. Documentation can be found [here](Server-configuration.md) *(this step is mandatory if you want to expose this server to other devices)*
6. Run `Impostor.Server.exe` (Windows) / `Impostor.Server` (Linux)
6. Run `Impostor.Server` (Linux/macOS) or `Impostor.Server.exe` (Windows)
### Using docker
+4 -8
View File
@@ -31,12 +31,11 @@ The first step is creating a new C# project, it must be a **Class Library (.NET
- .NET Standard 2.0
- .NET Standard 2.1
- .NET Core 3.1
- .NET 5
For more information about compatibility, see https://docs.microsoft.com/en-us/dotnet/standard/net-standard.
> At the moment of writing this document, I recommend you to use **.NET Standard 2.1** until .NET 5 is released officially. This should give you enough functionality. If not, upgrade to .NET Core 3.1.
> At the moment of writing this document, I recommend you to use **.NET Standard 2.1**. This should give you enough functionality. If not, upgrade to .NET 5.
When the project has been created, you should have `Class.cs` and `Project.csproj` files. Your `Project.csproj` should look something like this.
@@ -62,16 +61,13 @@ Make sure to get a prerelease if you are writing a plugin for a dev release of t
1. Right click your project.
2. Click `Manage NuGet Packages`.
3. Click `Browse`.
4. Next to the search bar, enable `Include prerelease`.
5. Search for `Impostor.Api`.
6. Click the `Impostor.Api` result and press install on the right side.
4. Search for `Impostor.Api`.
5. Click the `Impostor.Api` result and press install on the right side.
### Dotnet CLI
> Make sure to grab the latest (pre-)release version from NuGet [here](https://www.nuget.org/packages/Impostor.Api).
1. Open your project folder in command prompt / bash.
2. Run `dotnet add package Impostor.Api -v "1.2.0-ci.58"`.
2. Run `dotnet add package Impostor.Api`.
## 4. The plugin class
-50
View File
@@ -1,50 +0,0 @@
using System.Collections.Generic;
using System.IO;
namespace Impostor.Api.Innersloth
{
public class RegionInfo
{
public RegionInfo(string name, string ping, IReadOnlyList<ServerInfo> servers)
{
Name = name;
Ping = ping;
Servers = servers;
}
public string Name { get; }
public string Ping { get; }
public IReadOnlyList<ServerInfo> Servers { get; }
public static RegionInfo Deserialize(BinaryReader reader)
{
var unknown = reader.ReadInt32();
var name = reader.ReadString();
var ping = reader.ReadString();
var servers = new List<ServerInfo>();
var serverCount = reader.ReadInt32();
for (var i = 0; i < serverCount; i++)
{
servers.Add(ServerInfo.Deserialize(reader));
}
return new RegionInfo(name, ping, servers);
}
public void Serialize(BinaryWriter writer)
{
writer.Write(0);
writer.Write(Name);
writer.Write(Ping);
writer.Write(Servers.Count);
foreach (var server in Servers)
{
server.Serialize(writer);
}
}
}
}
-39
View File
@@ -1,39 +0,0 @@
using System.IO;
using System.Net;
namespace Impostor.Api.Innersloth
{
public class ServerInfo
{
public ServerInfo(string name, string ip, ushort port)
{
Name = name;
Ip = ip;
Port = port;
}
public string Name { get; }
public string Ip { get; }
public ushort Port { get; }
public static ServerInfo Deserialize(BinaryReader reader)
{
var name = reader.ReadString();
var ip = new IPAddress(reader.ReadBytes(4)).ToString();
var port = reader.ReadUInt16();
var unknown = reader.ReadInt32();
return new ServerInfo(name, ip, port);
}
public void Serialize(BinaryWriter writer)
{
writer.Write(Name);
writer.Write(IPAddress.Parse(Ip).GetAddressBytes());
writer.Write(Port);
writer.Write(0);
}
}
}
@@ -1,8 +0,0 @@
<Project>
<PropertyGroup>
<AssemblyTitle>Impostor</AssemblyTitle>
<Product>Impostor</Product>
<Copyright>Copyright © AeonLucid 2020</Copyright>
<Version>1.0.0</Version>
</PropertyGroup>
</Project>
@@ -1,19 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AssemblyName>Impostor.Cli</AssemblyName>
<TargetFramework>net5.0</TargetFramework>
<RuntimeIdentifiers>win-x64;linux-x64;linux-arm;linux-arm64;osx-x64</RuntimeIdentifiers>
<OutputType>Exe</OutputType>
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Impostor.Patcher.Shared\Impostor.Patcher.Shared.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="System.CommandLine" Version="2.0.0-beta1.20478.1" />
</ItemGroup>
</Project>
@@ -1,88 +0,0 @@
using System;
using System.CommandLine;
using System.CommandLine.Invocation;
using System.Threading.Tasks;
using Impostor.Patcher.Shared;
using Impostor.Patcher.Shared.Events;
namespace Impostor.Patcher.Cli
{
internal static class Program
{
private static readonly AmongUsModifier Modifier = new AmongUsModifier();
internal static Task<int> Main(string[] args)
{
var rootCommand = new RootCommand
{
new Option<string>(
"--address",
"IP Address of the server, will prompt if not specified"
),
new Option<string>(
"--name",
() => AmongUsModifier.DefaultRegionName,
"Name for server region"
),
};
rootCommand.Handler = CommandHandler.Create<string, string>((address, name) =>
{
Modifier.RegionName = name;
Modifier.Error += ModifierOnError;
Modifier.Saved += ModifierOnSaved;
Console.WriteLine("Welcome to Impostor");
if (Modifier.TryLoadRegionInfo(out var regionInfo))
{
Console.WriteLine($"Currently selected region: {regionInfo.Name} ({regionInfo.Ping}, {regionInfo.Servers.Count} server(s))");
}
if (address != null)
{
return Modifier.SaveIpAsync(address);
}
return PromptAsync();
});
return rootCommand.InvokeAsync(args);
}
private static void ModifierOnSaved(object sender, SavedEventArgs e)
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("The IP Address was saved, please (re)start Among Us.");
Console.ResetColor();
}
private static void WriteError(string message)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(message);
Console.ResetColor();
}
private static void ModifierOnError(object sender, ErrorEventArgs e)
{
WriteError(e.Message);
}
private static async Task PromptAsync()
{
Console.WriteLine("Please enter in the IP Address of the server you would like to use for Among Us");
Console.WriteLine("If you want to stop playing on the server, simply select another region");
while (true)
{
Console.Write("> ");
if (await Modifier.SaveIpAsync(Console.ReadLine()))
{
return;
}
}
}
}
}
@@ -1,249 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using Gameloop.Vdf;
using Gameloop.Vdf.Linq;
using Impostor.Patcher.Shared.Events;
using Impostor.Patcher.Shared.Innersloth;
using ErrorEventArgs = Impostor.Patcher.Shared.Events.ErrorEventArgs;
namespace Impostor.Patcher.Shared
{
public class AmongUsModifier
{
private const uint AppId = 945360;
public const string DefaultRegionName = "Impostor";
public const ushort DefaultPort = 22023;
private readonly string _amongUsDir;
private readonly string _regionFile;
public string RegionName { get; set; } = DefaultRegionName;
public AmongUsModifier()
{
var appData = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "..", "LocalLow");
if (!Directory.Exists(appData))
{
appData = FindProtonAppData();
}
if (appData == null)
return;
_amongUsDir = Path.Combine(appData, "Innersloth", "Among Us");
_regionFile = Path.Combine(_amongUsDir, "regionInfo.dat");
}
private string FindProtonAppData()
{
string steamApps;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
steamApps = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".steam", "steam", "steamapps");
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
steamApps = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Library", "Application Support", "Steam", "steamapps");
}
else
{
return null;
}
if (!Directory.Exists(steamApps))
return null;
var libraries = new List<string>
{
steamApps,
};
var vdf = Path.Combine(steamApps, "libraryfolders.vdf");
if (File.Exists(vdf))
{
var libraryFolders = VdfConvert.Deserialize(File.ReadAllText(vdf));
foreach (var libraryFolder in libraryFolders.Value.Children<VProperty>())
{
if (!int.TryParse(libraryFolder.Key, out _))
continue;
libraries.Add(Path.Combine(libraryFolder.Value.Value<string>(), "steamapps"));
}
}
foreach (var library in libraries)
{
var path = Path.Combine(library, "compatdata", AppId.ToString(), "pfx", "drive_c", "users", "steamuser", "AppData", "LocalLow");
if (Directory.Exists(path))
{
return path;
}
}
return null;
}
public async Task<bool> SaveIpAsync(string input)
{
// Filter out whitespace.
input = input.Trim();
// Split port from ip.
// Only IPv4 is supported so just do it simple.
var ip = string.Empty;
var port = DefaultPort;
var parts = input.Split(':');
if (parts.Length >= 1)
{
ip = parts[0];
}
if (parts.Length >= 2)
{
ushort.TryParse(parts[1], out port);
}
// Check if a valid IP address was entered.
if (!IPAddress.TryParse(ip, out var ipAddress))
{
// Attempt to resolve DNS.
try
{
var hostAddresses = await Dns.GetHostAddressesAsync(ip);
if (hostAddresses.Length == 0)
{
OnError("Invalid IP Address entered");
return false;
}
// Use first IPv4 result.
ipAddress = hostAddresses.First(x => x.AddressFamily == AddressFamily.InterNetwork);
}
catch (SocketException)
{
OnError("Failed to resolve hostname.");
return false;
}
}
// Only IPv4.
if (ipAddress.AddressFamily == AddressFamily.InterNetworkV6)
{
OnError("Invalid IP Address entered, only IPv4 is allowed.");
return false;
}
var result = WriteIp(ipAddress, port);
OnSaved(ip, port);
return result;
}
/// <summary>
/// Writes an IP Address to the Among Us region file.
/// </summary>
/// <param name="ipAddress">The IPv4 address to write.</param>
/// <param name="port"></param>
private bool WriteIp(IPAddress ipAddress, ushort port)
{
if (ipAddress == null ||
ipAddress.AddressFamily != AddressFamily.InterNetwork)
{
throw new ArgumentException(nameof(ipAddress));
}
if (!Directory.Exists(_amongUsDir))
{
OnError("Among Us directory was not found, is it installed? Try running it once.");
return false;
}
using (var file = File.Open(_regionFile, FileMode.Create, FileAccess.Write))
using (var writer = new BinaryWriter(file))
{
var ip = ipAddress.ToString();
var region = new RegionInfo(RegionName, ip, new[]
{
new ServerInfo($"{RegionName}-Master-1", ip, port),
});
region.Serialize(writer);
return true;
}
}
/// <summary>
/// Loads the existing region info from the Among Us.
/// </summary>
public bool TryLoadRegionInfo(out RegionInfo regionInfo)
{
regionInfo = null;
if (!File.Exists(_regionFile))
{
return false;
}
using (var file = File.Open(_regionFile, FileMode.Open, FileAccess.Read))
using (var reader = new BinaryReader(file))
{
try
{
regionInfo = RegionInfo.Deserialize(reader);
return true;
}
catch (Exception exception)
{
OnError("Couldn't parse region info\n" + exception);
return false;
}
}
}
/// <summary>
/// Loads the existing IP Address from the Among Us region file
/// if it was set by Impostor before.
/// </summary>
public bool TryLoadIp(out string ipAddress)
{
ipAddress = null;
if (!TryLoadRegionInfo(out var regionInfo))
{
return false;
}
if ((regionInfo.Name == RegionName || regionInfo.Name == DefaultRegionName) && regionInfo.Servers.Count >= 1)
{
ipAddress = regionInfo.Servers.ElementAt(0).Ip;
return true;
}
return false;
}
private void OnError(string message)
{
Error?.Invoke(this, new ErrorEventArgs(message));
}
private void OnSaved(string ipAddress, ushort port)
{
Saved?.Invoke(this, new SavedEventArgs(ipAddress, port));
}
public event EventHandler<ErrorEventArgs> Error;
public event EventHandler<SavedEventArgs> Saved;
}
}
@@ -1,65 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
namespace Impostor.Patcher.Shared
{
public class Configuration
{
private const string FileRecentIps = @"recent_ips.txt";
private const int MaxRecentIps = 5;
private readonly string _baseDir;
private readonly string _recentIpsPath;
private readonly List<string> _recentIps;
public Configuration()
{
var appData = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData));
_baseDir = Path.Combine(appData, "Impostor");
_recentIpsPath = Path.Combine(_baseDir, FileRecentIps);
_recentIps = new List<string>();
}
public IReadOnlyList<string> RecentIps => _recentIps;
public void Load()
{
if (File.Exists(_recentIpsPath))
{
_recentIps.AddRange(File.ReadAllLines(_recentIpsPath));
}
}
public void Save()
{
Directory.CreateDirectory(_baseDir);
if (!Directory.Exists(_baseDir))
{
return;
}
if (_recentIps.Count > 0)
{
File.WriteAllLines(_recentIpsPath, _recentIps);
}
}
public void AddIp(string ip)
{
if (_recentIps.Contains(ip))
{
_recentIps.Remove(ip);
}
_recentIps.Insert(0, ip);
if (_recentIps.Count > MaxRecentIps)
{
_recentIps.RemoveAt(MaxRecentIps);
}
}
}
}
@@ -1,14 +0,0 @@
using System;
namespace Impostor.Patcher.Shared.Events
{
public class ErrorEventArgs : EventArgs
{
public ErrorEventArgs(string message)
{
Message = message;
}
public string Message { get; }
}
}
@@ -1,16 +0,0 @@
using System;
namespace Impostor.Patcher.Shared.Events
{
public class SavedEventArgs : EventArgs
{
public SavedEventArgs(string ipAddress, ushort port)
{
IpAddress = ipAddress;
Port = port;
}
public string IpAddress { get; }
public ushort Port { get; }
}
}
@@ -1,11 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Gameloop.Vdf" Version="0.6.1" />
</ItemGroup>
</Project>
@@ -1,48 +0,0 @@
using System.Collections.Generic;
using System.IO;
namespace Impostor.Patcher.Shared.Innersloth
{
public class RegionInfo
{
public RegionInfo(string name, string ping, IReadOnlyList<ServerInfo> servers)
{
Name = name;
Ping = ping;
Servers = servers;
}
public string Name { get; }
public string Ping { get; }
public IReadOnlyList<ServerInfo> Servers { get; }
public void Serialize(BinaryWriter writer)
{
writer.Write(0);
writer.Write(Name);
writer.Write(Ping);
writer.Write(Servers.Count);
foreach (var server in Servers)
{
server.Serialize(writer);
}
}
public static RegionInfo Deserialize(BinaryReader reader)
{
var unknown = reader.ReadInt32();
var name = reader.ReadString();
var ping = reader.ReadString();
var servers = new List<ServerInfo>();
var serverCount = reader.ReadInt32();
for (var i = 0; i < serverCount; i++)
{
servers.Add(ServerInfo.Deserialize(reader));
}
return new RegionInfo(name, ping, servers);
}
}
}
@@ -1,37 +0,0 @@
using System.IO;
using System.Net;
namespace Impostor.Patcher.Shared.Innersloth
{
public class ServerInfo
{
public string Name { get; }
public string Ip { get; }
public ushort Port { get; }
public ServerInfo(string name, string ip, ushort port)
{
Name = name;
Ip = ip;
Port = port;
}
public void Serialize(BinaryWriter writer)
{
writer.Write(Name);
writer.Write(IPAddress.Parse(Ip).GetAddressBytes());
writer.Write(Port);
writer.Write(0);
}
public static ServerInfo Deserialize(BinaryReader reader)
{
var name = reader.ReadString();
var ip = new IPAddress(reader.ReadBytes(4)).ToString();
var port = reader.ReadUInt16();
var unknown = reader.ReadInt32();
return new ServerInfo(name, ip, port);
}
}
}
@@ -1,7 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>
@@ -1,141 +0,0 @@
namespace Impostor.Patcher.WinForms.Forms
{
partial class FrmMain
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmMain));
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.buttonLaunch = new System.Windows.Forms.Button();
this.lblUrl = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.comboIp = new System.Windows.Forms.ComboBox();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label1.Location = new System.Drawing.Point(28, 139);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(60, 13);
this.label1.TabIndex = 1;
this.label1.Text = "IP Address";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label2.Location = new System.Drawing.Point(28, 23);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(225, 91);
this.label2.TabIndex = 0;
this.label2.Text = "Welcome to Impostor\r\n\r\nPlease enter in the IP Address of the \r\nserver you would l" +
"ike to use for Among Us\r\n\r\nIf you want to stop playing on the server, \r\nsimply s" +
"elect another region";
//
// buttonLaunch
//
this.buttonLaunch.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.buttonLaunch.Location = new System.Drawing.Point(179, 155);
this.buttonLaunch.Name = "buttonLaunch";
this.buttonLaunch.Size = new System.Drawing.Size(74, 22);
this.buttonLaunch.TabIndex = 3;
this.buttonLaunch.Text = "Save";
this.buttonLaunch.UseVisualStyleBackColor = true;
this.buttonLaunch.Click += new System.EventHandler(this.buttonLaunch_Click);
//
// lblUrl
//
this.lblUrl.AutoSize = true;
this.lblUrl.Cursor = System.Windows.Forms.Cursors.Hand;
this.lblUrl.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Underline, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblUrl.ForeColor = System.Drawing.SystemColors.Highlight;
this.lblUrl.Location = new System.Drawing.Point(39, 232);
this.lblUrl.Name = "lblUrl";
this.lblUrl.Size = new System.Drawing.Size(212, 13);
this.lblUrl.TabIndex = 5;
this.lblUrl.Text = "https://github.com/Impostor/Impostor";
this.lblUrl.Click += new System.EventHandler(this.lblUrl_Click);
//
// label3
//
this.label3.AutoSize = true;
this.label3.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label3.Location = new System.Drawing.Point(54, 216);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(182, 13);
this.label3.TabIndex = 6;
this.label3.Text = "Source code and latest versions at\r\n";
//
// comboIp
//
this.comboIp.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.comboIp.FormattingEnabled = true;
this.comboIp.Location = new System.Drawing.Point(31, 155);
this.comboIp.Name = "comboIp";
this.comboIp.Size = new System.Drawing.Size(141, 21);
this.comboIp.TabIndex = 2;
this.comboIp.KeyDown += new System.Windows.Forms.KeyEventHandler(this.textIp_KeyDown);
//
// FrmMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(283, 262);
this.Controls.Add(this.comboIp);
this.Controls.Add(this.label3);
this.Controls.Add(this.lblUrl);
this.Controls.Add(this.buttonLaunch);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.ForeColor = System.Drawing.SystemColors.ControlText;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.Name = "FrmMain";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Impostor";
this.Load += new System.EventHandler(this.FrmMain_Load);
this.Shown += new System.EventHandler(this.FrmMain_Shown);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Button buttonLaunch;
private System.Windows.Forms.Label lblUrl;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.ComboBox comboIp;
}
}
@@ -1,114 +0,0 @@
using System;
using System.Diagnostics;
using System.Windows.Forms;
using Impostor.Patcher.Shared;
using Impostor.Patcher.Shared.Events;
namespace Impostor.Patcher.WinForms.Forms
{
public partial class FrmMain : Form
{
private readonly Configuration _config;
private readonly AmongUsModifier _modifier;
public FrmMain()
{
InitializeComponent();
AcceptButton = buttonLaunch;
_config = new Configuration();
_modifier = new AmongUsModifier();
_modifier.Error += ModifierOnError;
_modifier.Saved += ModifierOnSaved;
}
private void ModifierOnError(object sender, ErrorEventArgs e)
{
MessageBox.Show(e.Message, "Error",
MessageBoxButtons.OK,
MessageBoxIcon.Error);
comboIp.Text = string.Empty;
comboIp.Focus();
comboIp.Enabled = true;
buttonLaunch.Enabled = true;
}
private void ModifierOnSaved(object sender, SavedEventArgs e)
{
MessageBox.Show("The IP Address was saved, please (re)start Among Us.", "Success",
MessageBoxButtons.OK,
MessageBoxIcon.Information);
var ipText = e.Port == AmongUsModifier.DefaultPort
? e.IpAddress
: $"{e.IpAddress}:{e.Port}";
comboIp.Text = ipText;
comboIp.Enabled = true;
buttonLaunch.Enabled = true;
_config.AddIp(ipText);
_config.Save();
RefreshComboIps();
}
private void FrmMain_Load(object sender, EventArgs e)
{
_config.Load();
RefreshComboIps();
if (_modifier.TryLoadIp(out var ipAddress))
{
comboIp.Text = ipAddress;
}
}
private void FrmMain_Shown(object sender, EventArgs e)
{
comboIp.Focus();
}
private void textIp_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode != Keys.Enter)
{
return;
}
e.Handled = true;
buttonLaunch_Click(this, EventArgs.Empty);
}
private async void buttonLaunch_Click(object sender, EventArgs e)
{
comboIp.Enabled = false;
buttonLaunch.Enabled = false;
await _modifier.SaveIpAsync(comboIp.Text);
}
private void lblUrl_Click(object sender, EventArgs e)
{
Process.Start("https://github.com/Impostor/Impostor");
}
private void RefreshComboIps()
{
comboIp.Items.Clear();
if (_config.RecentIps.Count > 0)
{
foreach (var ip in _config.RecentIps)
{
comboIp.Items.Add(ip);
}
}
}
}
}
File diff suppressed because it is too large. Load diff
@@ -1,22 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<AssemblyName>Impostor</AssemblyName>
<ProjectGuid>{804CF172-0C87-4423-9688-BD97D549891E}</ProjectGuid>
<OutputType>WinExe</OutputType>
<TargetFramework>net472</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
<Copyright>Copyright © AeonLucid 2020</Copyright>
<ApplicationIcon>icon.ico</ApplicationIcon>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateResourceUsePreserializedResources>true</GenerateResourceUsePreserializedResources>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Impostor.Patcher.Shared\Impostor.Patcher.Shared.csproj" />
<PackageReference Include="System.Resources.Extensions" Version="5.0.0" />
<Reference Include="System.Runtime.InteropServices.RuntimeInformation" />
<Reference Include="System.Windows.Forms" />
</ItemGroup>
</Project>
@@ -1,17 +0,0 @@
using System;
using System.Windows.Forms;
using Impostor.Patcher.WinForms.Forms;
namespace Impostor.Patcher.WinForms
{
internal static class Program
{
[STAThread]
private static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new FrmMain());
}
}
}
@@ -1,69 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Impostor.Patcher.WinForms.Properties
{
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder",
"4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance",
"CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState
.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp =
new global::System.Resources.ResourceManager("Impostor.Client.WinForms.Properties.Resources",
typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState
.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get { return resourceCulture; }
set { resourceCulture = value; }
}
}
}
@@ -1,117 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
@@ -1,26 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Impostor.Patcher.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute(
"Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance =
((Settings) (global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get { return defaultInstance; }
}
}
}
@@ -1,7 +0,0 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 130 KiB

-32
View File
@@ -13,14 +13,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Impostor.Server", "Impostor
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Impostor.Api", "Impostor.Api\Impostor.Api.csproj", "{E096A7D7-D693-4A13-A526-38CC574D84F8}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "patcher", "patcher", "{94FAED42-15BB-40CF-BE64-5D5C3B4ABC8F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Impostor.Patcher.Shared", "Impostor.Patcher\Impostor.Patcher.Shared\Impostor.Patcher.Shared.csproj", "{7C3EB599-2292-4532-B280-D5BED1094DD4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Impostor.Patcher.WinForms", "Impostor.Patcher\Impostor.Patcher.WinForms\Impostor.Patcher.WinForms.csproj", "{804CF172-0C87-4423-9688-BD97D549891E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Impostor.Patcher.Cli", "Impostor.Patcher\Impostor.Patcher.Cli\Impostor.Patcher.Cli.csproj", "{82B36C4C-4EBD-49B7-A2DB-0B3308FBEF69}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "plugins", "plugins", "{36AA9913-E6EA-4A6C-90E6-2FD3CC2E3124}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Impostor.Plugins.Debugger", "Impostor.Plugins.Debugger\Impostor.Plugins.Debugger.csproj", "{ECBCAA3B-B974-41CF-AFFC-6F5AA4C42FA7}"
@@ -71,11 +63,6 @@ Global
{D16B8DE9-8EE2-4F6A-9352-305D5AB0233D}.Release|Any CPU.Build.0 = Release|Any CPU
{D16B8DE9-8EE2-4F6A-9352-305D5AB0233D}.Release|x86.ActiveCfg = Release|Any CPU
{D16B8DE9-8EE2-4F6A-9352-305D5AB0233D}.Release|x86.Build.0 = Release|Any CPU
{804CF172-0C87-4423-9688-BD97D549891E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{804CF172-0C87-4423-9688-BD97D549891E}.Debug|x86.ActiveCfg = Debug|Any CPU
{804CF172-0C87-4423-9688-BD97D549891E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{804CF172-0C87-4423-9688-BD97D549891E}.Release|x86.ActiveCfg = Release|Any CPU
{804CF172-0C87-4423-9688-BD97D549891E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E096A7D7-D693-4A13-A526-38CC574D84F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E096A7D7-D693-4A13-A526-38CC574D84F8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E096A7D7-D693-4A13-A526-38CC574D84F8}.Debug|x86.ActiveCfg = Debug|Any CPU
@@ -84,22 +71,6 @@ Global
{E096A7D7-D693-4A13-A526-38CC574D84F8}.Release|Any CPU.Build.0 = Release|Any CPU
{E096A7D7-D693-4A13-A526-38CC574D84F8}.Release|x86.ActiveCfg = Release|Any CPU
{E096A7D7-D693-4A13-A526-38CC574D84F8}.Release|x86.Build.0 = Release|Any CPU
{7C3EB599-2292-4532-B280-D5BED1094DD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7C3EB599-2292-4532-B280-D5BED1094DD4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7C3EB599-2292-4532-B280-D5BED1094DD4}.Debug|x86.ActiveCfg = Debug|Any CPU
{7C3EB599-2292-4532-B280-D5BED1094DD4}.Debug|x86.Build.0 = Debug|Any CPU
{7C3EB599-2292-4532-B280-D5BED1094DD4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7C3EB599-2292-4532-B280-D5BED1094DD4}.Release|Any CPU.Build.0 = Release|Any CPU
{7C3EB599-2292-4532-B280-D5BED1094DD4}.Release|x86.ActiveCfg = Release|Any CPU
{7C3EB599-2292-4532-B280-D5BED1094DD4}.Release|x86.Build.0 = Release|Any CPU
{82B36C4C-4EBD-49B7-A2DB-0B3308FBEF69}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{82B36C4C-4EBD-49B7-A2DB-0B3308FBEF69}.Debug|Any CPU.Build.0 = Debug|Any CPU
{82B36C4C-4EBD-49B7-A2DB-0B3308FBEF69}.Debug|x86.ActiveCfg = Debug|Any CPU
{82B36C4C-4EBD-49B7-A2DB-0B3308FBEF69}.Debug|x86.Build.0 = Debug|Any CPU
{82B36C4C-4EBD-49B7-A2DB-0B3308FBEF69}.Release|Any CPU.ActiveCfg = Release|Any CPU
{82B36C4C-4EBD-49B7-A2DB-0B3308FBEF69}.Release|Any CPU.Build.0 = Release|Any CPU
{82B36C4C-4EBD-49B7-A2DB-0B3308FBEF69}.Release|x86.ActiveCfg = Release|Any CPU
{82B36C4C-4EBD-49B7-A2DB-0B3308FBEF69}.Release|x86.Build.0 = Release|Any CPU
{ECBCAA3B-B974-41CF-AFFC-6F5AA4C42FA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ECBCAA3B-B974-41CF-AFFC-6F5AA4C42FA7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ECBCAA3B-B974-41CF-AFFC-6F5AA4C42FA7}.Debug|x86.ActiveCfg = Debug|Any CPU
@@ -165,9 +136,6 @@ Global
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{D16B8DE9-8EE2-4F6A-9352-305D5AB0233D} = {56DD9707-D811-4056-9E2C-8A9CC2479B07}
{804CF172-0C87-4423-9688-BD97D549891E} = {94FAED42-15BB-40CF-BE64-5D5C3B4ABC8F}
{7C3EB599-2292-4532-B280-D5BED1094DD4} = {94FAED42-15BB-40CF-BE64-5D5C3B4ABC8F}
{82B36C4C-4EBD-49B7-A2DB-0B3308FBEF69} = {94FAED42-15BB-40CF-BE64-5D5C3B4ABC8F}
{ECBCAA3B-B974-41CF-AFFC-6F5AA4C42FA7} = {36AA9913-E6EA-4A6C-90E6-2FD3CC2E3124}
{BE44C4A8-A202-4B63-A3BA-AC0AB5E7A0EB} = {9F1919B0-915B-4749-9944-697DF7E7F67F}
{3DF86F12-7099-44F6-B98B-A148213D60B1} = {9F1919B0-915B-4749-9944-697DF7E7F67F}