public Client(Socket socket, Server server) { ClientState = new ClientState(socket); Server = server; GameLog.InfoFormat("Connection {0} from {1}:{2}", ConnectionId, ((IPEndPoint)Socket.RemoteEndPoint).Address.ToString(), ((IPEndPoint)Socket.RemoteEndPoint).Port); if (server is Lobby) { EncryptionKey = Game.Config.ApiEndpoints.EncryptionEndpoint != null?GlobalConnectionManifest.RequestEncryptionKey(Game.Config.ApiEndpoints.EncryptionEndpoint.Url, ((IPEndPoint)socket.RemoteEndPoint).Address) : Encoding.ASCII.GetBytes("UrkcnItnI"); GameLog.InfoFormat($"EncryptionKey is {Encoding.ASCII.GetString(EncryptionKey)}"); var valid = Game.Config.ApiEndpoints.ValidationEndpoint != null?GlobalConnectionManifest.ValidateEncryptionKey(Game.Config.ApiEndpoints.ValidationEndpoint.Url, new ServerToken { Ip = ((IPEndPoint)socket.RemoteEndPoint).Address.ToString(), Seed = EncryptionKey }) : true; if (!valid) { GameLog.ErrorFormat("Invalid key from {IP}", ((IPEndPoint)Socket.RemoteEndPoint).Address.ToString()); socket.Disconnect(true); } } EncryptionKeyTable = new byte[1024]; _lastReceived = DateTime.Now.Ticks; GlobalConnectionManifest.RegisterClient(this); ConnectedSince = DateTime.Now.Ticks; }