| Impostor version | Among Us version | Experimental | Download |
|-|-|-|-|
| 1.1.0 | 2020.09.07 - 2020.09.22 | No | [](https://github.com/Impostor/Impostor/releases/tag/v1.1.0) |
-| 1.2.1 | 2020.09.22 - 2020.10.22 | Yes | [](https://ci.appveyor.com/project/Impostor/Impostor/branch/dev/artifacts) |
+| 1.2.2 | 2020.09.22 - 2020.10.22 | Yes | [](https://ci.appveyor.com/project/Impostor/Impostor/branch/dev/artifacts) |
There are no special features at this moment, the goal is aiming to be as close as possible to the real server, for now. In a later stage, making modifications to game logic by modifying `GameData` packets can be looked at.
version: '{build}'
environment:
- IMPOSTOR_VERSION: '1.2.1'
+ IMPOSTOR_VERSION: '1.2.2'
DOTNET_CLI_TELEMETRY_OPTOUT: 1
branches:
| Key | Default | Description |
|-|-|-|
-| **PublicIp** | `127.0.0.1` | This needs to the IPv4 address of the server, what you give to others to connect. You can find the your IPv4 address [here](http://whatismyip.host/). |
+| **PublicIp** | `127.0.0.1` | This needs to the IPv4 address of the server, what you give to others to connect. You can find the your IPv4 address [here](http://whatismyip.host/). Since 1.2.2 it is also possible to use hostnames instead of IPv4 addresses, these must resolve to a valid IPv4 address. |
| **PublicPort** | `22023` | The public port of the server, what you give to others to connect. Usually `22023`. |
-| **ListenIp** | `0.0.0.0` | The network interface to listen on. If you do not know what to put here, use `0.0.0.0`. |
+| **ListenIp** | `0.0.0.0` | The network interface to listen on. If you do not know what to put here, use `0.0.0.0`. Since 1.2.2 it is also possible to use hostnames instead of IPv4 addresses, these must resolve to a valid IPv4 address. |
| **ListenPort** | `22023` | The listen port of the server, usually `22023`. |
### AntiCheat
--- /dev/null
+using System;
+using System.Runtime.Serialization;
+
+namespace Impostor.Api
+{
+ public class ImpostorConfigException : ImpostorException
+ {
+ public ImpostorConfigException()
+ {
+ }
+
+ protected ImpostorConfigException(SerializationInfo info, StreamingContext context) : base(info, context)
+ {
+ }
+
+ public ImpostorConfigException(string? message) : base(message)
+ {
+ }
+
+ public ImpostorConfigException(string? message, Exception? innerException) : base(message, innerException)
+ {
+ }
+ }
+}
-namespace Impostor.Server.Config
+using Impostor.Server.Utils;
+
+namespace Impostor.Server.Config
{
internal class ServerConfig
{
+ private string? _resolvedPublicIp;
+ private string? _resolvedListenIp;
+
public const string Section = "Server";
public string PublicIp { get; set; } = "127.0.0.1";
public string ListenIp { get; set; } = "127.0.0.1";
public ushort ListenPort { get; set; } = 22023;
+
+ public string ResolvePublicIp()
+ {
+ return _resolvedPublicIp ??= IpUtils.ResolveIp(PublicIp);
+ }
+
+ public string ResolveListenIp()
+ {
+ return _resolvedListenIp ??= IpUtils.ResolveIp(ListenIp);
+ }
}
-}
\ No newline at end of file
+}
_serviceProvider = serviceProvider;
_eventManager = eventManager;
_gameCodeFactory = gameCodeFactory;
- _publicIp = new IPEndPoint(IPAddress.Parse(config.Value.PublicIp), config.Value.PublicPort);
+ _publicIp = new IPEndPoint(IPAddress.Parse(config.Value.ResolvePublicIp()), config.Value.PublicPort);
_games = new ConcurrentDictionary<int, Game>();
}
public async Task StartAsync(CancellationToken cancellationToken)
{
- var endpoint = new IPEndPoint(IPAddress.Parse(_serverConfig.ListenIp), _serverConfig.ListenPort);
+ var endpoint = new IPEndPoint(IPAddress.Parse(_serverConfig.ResolveListenIp()), _serverConfig.ListenPort);
await _matchmaker.StartAsync(endpoint);
"Matchmaker is listening on {0}:{1}, the public server ip is {2}:{3}.",
endpoint.Address,
endpoint.Port,
- _serverConfig.PublicIp,
+ _serverConfig.ResolvePublicIp(),
_serverConfig.PublicPort);
if (_redirectorConfig.Enabled)
await _matchmaker.StopAsync();
}
}
-}
\ No newline at end of file
+}
--- /dev/null
+using System.Linq;
+using System.Net;
+using System.Net.Sockets;
+using Impostor.Api;
+
+namespace Impostor.Server.Utils
+{
+ internal static class IpUtils
+ {
+ public static string ResolveIp(string ip)
+ {
+ // Check if valid ip was entered.
+ if (!IPAddress.TryParse(ip, out var ipAddress))
+ {
+ // Attempt to resolve DNS.
+ try
+ {
+ var hostAddresses = Dns.GetHostAddresses(ip);
+ if (hostAddresses.Length == 0)
+ {
+ throw new ImpostorConfigException($"Invalid IP Address entered '{ip}'.");
+ }
+
+ // Use first IPv4 result.
+ ipAddress = hostAddresses.First(x => x.AddressFamily == AddressFamily.InterNetwork);
+ }
+ catch (SocketException)
+ {
+ throw new ImpostorConfigException($"Failed to resolve hostname '{ip}'.");
+ }
+ }
+
+ // Only IPv4.
+ if (ipAddress.AddressFamily == AddressFamily.InterNetworkV6)
+ {
+ throw new ImpostorConfigException($"Invalid IP Address entered '{ipAddress}', only IPv4 is supported by Among Us.");
+ }
+
+ return ipAddress.ToString();
+ }
+ }
+}