private void CloseConnection() { if (this.persistance != null) { this.persistance.Dispose(); this.persistance = null; } EACServer.DoShutdown(); Network.Net.sv.callbackHandler = null; using (TimeWarning timeWarning = TimeWarning.New("sv.Stop", 0.1f)) { Network.Net.sv.Stop("Shutting Down"); } using (timeWarning = TimeWarning.New("RCon.Shutdown", 0.1f)) { RCon.Shutdown(); } using (timeWarning = TimeWarning.New("Steamworks.GameServer.Shutdown", 0.1f)) { if (SteamServer.IsValid) { UnityEngine.Debug.Log("Steamworks Shutting Down"); SteamServer.Shutdown(); UnityEngine.Debug.Log("Okay"); } } }
private void CloseConnection() { if (this.persistance != null) { this.persistance.Dispose(); this.persistance = (UserPersistance)null; } EACServer.DoShutdown(); ((Network.Server)Network.Net.sv).callbackHandler = null; using (TimeWarning.New("sv.Stop", 0.1f)) ((Network.Server)Network.Net.sv).Stop("Shutting Down"); using (TimeWarning.New("RCon.Shutdown", 0.1f)) RCon.Shutdown(); using (TimeWarning.New("Steamworks.GameServer.Shutdown", 0.1f)) { if (Global.get_SteamServer() == null) { return; } Debug.Log((object)"Steamworks Shutting Down"); ((BaseSteamworks)Global.get_SteamServer()).Dispose(); Global.set_SteamServer((Facepunch.Steamworks.Server)null); Debug.Log((object)"Okay"); } }
public void IN_OnNetworkMessage(Message packet) { switch (packet.type) { case Message.Type.Approved: OnApproved(packet); break; case Message.Type.EAC: EACServer.OnMessageReceived(packet); SendPacket(BaseServer, packet); break; case Message.Type.DisconnectReason: SendPacket(BaseServer, packet); if (BaseServer != null && BaseServer.connections.Count > 0) { packet.read.Position = 1L; string reasone = packet.read.String(); BaseServer?.Kick(BaseServer.connections[0], reasone); ConsoleSystem.LogWarning("[VirtualServer]: От игрового сервера получена причина дисконнекта: " + reasone); } break; case Message.Type.Entities: packet.read.UInt32(); using (Entity entity = Entity.Deserialize(packet.read)) { if (EntityManager.OnEntity(entity) == false) { if (BaseServer.write.Start()) { BaseServer.write.PacketID(Message.Type.Entities); BaseServer.write.UInt32(TakeEntityNUM); entity.WriteToStream(BaseServer.write); BaseServer.write.Send(new SendInfo(BaseServer.connections[0])); } } } break; case Message.Type.EntityDestroy: EntityManager.OnEntityDestroy(packet); SendPacket(BaseServer, packet); break; case Message.Type.EntityPosition: EntityManager.OnEntityPosition(packet); SendPacket(BaseServer, packet); break; default: if (NetworkManager.Instance.IN_NetworkMessage(packet) == false) { SendPacket(BaseServer, packet); } break; } }
public static void OnStartLoading(Connection connection) { if (EACServer.easyAntiCheat != null) { EasyAntiCheat.Server.Hydra.Client client = EACServer.GetClient(connection); EACServer.easyAntiCheat.SetClientNetworkState(client, false); } }
private static void HandleClientUpdate(ClientStatusUpdate <EasyAntiCheat.Server.Hydra.Client> clientStatus) { using (TimeWarning.New("AntiCheatKickPlayer", 10L)) { EasyAntiCheat.Server.Hydra.Client client = clientStatus.get_Client(); Connection connection = EACServer.GetConnection(client); if (connection == null) { Debug.LogError((object)("EAC status update for invalid client: " + (object)((EasyAntiCheat.Server.Hydra.Client) ref client).get_ClientID())); } else { if (EACServer.ShouldIgnore(connection)) { return; } if (clientStatus.get_RequiresKick()) { string message = clientStatus.get_Message(); if (string.IsNullOrEmpty(message)) { message = clientStatus.get_Status().ToString(); } Debug.Log((object)("[EAC] Kicking " + (object)(ulong)connection.userid + " (" + message + ")")); connection.authStatus = (__Null)"eac"; ((Network.Server)Net.sv).Kick(connection, "EAC: " + message); DateTime?nullable = new DateTime?(); if (clientStatus.IsBanned(ref nullable)) { connection.authStatus = (__Null)"eacbanned"; Interface.CallHook("OnPlayerBanned", (object)connection, (object)connection.authStatus); ConsoleNetwork.BroadcastToAllClients("chat.add", (object)0, (object)("<color=#fff>SERVER</color> Kicking " + (string)connection.username + " (banned by anticheat)")); if (!nullable.HasValue) { Entity.DeleteBy((ulong)connection.userid); } } EACServer.easyAntiCheat.UnregisterClient(client); EACServer.client2connection.Remove(client); EACServer.connection2client.Remove(connection); EACServer.connection2status.Remove(connection); } else if (clientStatus.get_Status() == 2) { EACServer.OnAuthenticatedLocal(connection); EACServer.easyAntiCheat.SetClientNetworkState(client, false); } else { if (clientStatus.get_Status() != 5) { return; } EACServer.OnAuthenticatedRemote(connection); } } } }
public static void OnFinishLoading(Connection connection) { if (EACServer.easyAntiCheat == null) { return; } EasyAntiCheat.Server.Hydra.Client client = EACServer.GetClient(connection); EACServer.easyAntiCheat.SetClientNetworkState(client, true); }
public static void Decrypt( Connection connection, MemoryStream src, int srcOffset, MemoryStream dst, int dstOffset) { EACServer.easyAntiCheat.get_NetProtect().UnprotectMessage(EACServer.GetClient(connection), src, (long)srcOffset, dst, (long)dstOffset); }
protected override void EncryptionHandler(Connection connection, MemoryStream src, int srcOffset, MemoryStream dst, int dstOffset) { if (connection.encryptionLevel <= 1) { Craptography.XOR(2177, src, srcOffset, dst, dstOffset); return; } EACServer.Encrypt(connection, src, srcOffset, dst, dstOffset); }
public static void OnLeaveGame(Connection connection) { if (EACServer.easyAntiCheat != null) { EasyAntiCheat.Server.Hydra.Client client = EACServer.GetClient(connection); EACServer.easyAntiCheat.UnregisterClient(client); EACServer.client2connection.Remove(client); EACServer.connection2client.Remove(connection); EACServer.connection2status.Remove(connection); } }
// Methods protected override void DecryptionHandler(Connection connection, MemoryStream src, int srcOffset, MemoryStream dst, int dstOffset) { if (connection.encryptionLevel <= 1) { Cryptography.XOR(2031, src, srcOffset, dst, dstOffset); } else { EACServer.Decrypt(connection, src, srcOffset, dst, dstOffset); } }
public static IEnumerator Run(Connection connection) { if (connection.active != null && connection.rejected == null) { connection.authStatus = (__Null)string.Empty; EACServer.OnJoinGame(connection); while (connection.active != null && connection.rejected == null && (string)connection.authStatus == string.Empty) { yield return((object)null); } } }
public static IEnumerator Run(Connection connection) { if (connection.active && !connection.rejected) { connection.authStatus = string.Empty; EACServer.OnJoinGame(connection); while (connection.active && !connection.rejected && connection.authStatus == string.Empty) { yield return(null); } } }
private bool RPC_StartLoading(ERPCNetworkType type, Message message) { ConsoleSystem.Log("StartLoading"); EACServer.OnStartLoading(VirtualServer.BaseClient.Connection); EACServer.OnStartLoading(VirtualServer.BaseServer.connections[0]); BaseNetworkable.DestroyAll(); ListNetworkables.Add(this.UID, this); ListPlayers.Add(this); return(false); }
public static void OnMessageReceived(Message message) { if (!EACServer.connection2client.ContainsKey((Connection)message.connection)) { Debug.LogError((object)("EAC network packet from invalid connection: " + (object)(ulong)((Connection)message.connection).userid)); } else { EasyAntiCheat.Server.Hydra.Client client = EACServer.GetClient((Connection)message.connection); MemoryStream memoryStream = message.get_read().MemoryStreamWithSize(); EACServer.easyAntiCheat.PushNetworkMessage(client, memoryStream.GetBuffer(), (int)memoryStream.Length); } }
private static void HandleClientUpdate(ClientStatusUpdate <EasyAntiCheat.Server.Hydra.Client> clientStatus) { using (TimeWarning timeWarning = TimeWarning.New("AntiCheatKickPlayer", (long)10)) { EasyAntiCheat.Server.Hydra.Client client = clientStatus.Client; Connection connection = EACServer.GetConnection(client); if (connection == null) { Debug.LogError(string.Concat("EAC status update for invalid client: ", client.ClientID)); } else if (!EACServer.ShouldIgnore(connection)) { if (clientStatus.RequiresKick) { string message = clientStatus.Message; if (string.IsNullOrEmpty(message)) { message = clientStatus.Status.ToString(); } Debug.Log(string.Concat(new object[] { "[EAC] Kicking ", connection.userid, " (", message, ")" })); connection.authStatus = "eac"; Network.Net.sv.Kick(connection, string.Concat("EAC: ", message)); DateTime?nullable = null; if (clientStatus.IsBanned(out nullable)) { connection.authStatus = "eacbanned"; Interface.CallHook("OnPlayerBanned", connection, connection.authStatus); ConsoleNetwork.BroadcastToAllClients("chat.add", new object[] { 0, string.Concat("<color=#fff>SERVER</color> Kicking ", connection.username, " (banned by anticheat)") }); if (!nullable.HasValue) { Entity.DeleteBy(connection.userid); } } EACServer.easyAntiCheat.UnregisterClient(client); EACServer.client2connection.Remove(client); EACServer.connection2client.Remove(connection); EACServer.connection2status.Remove(connection); } else if (clientStatus.Status == ClientStatus.ClientAuthenticatedLocal) { EACServer.OnAuthenticatedLocal(connection); EACServer.easyAntiCheat.SetClientNetworkState(client, false); } else if (clientStatus.Status == ClientStatus.ClientAuthenticatedRemote) { EACServer.OnAuthenticatedRemote(connection); } } } }
public void OnDisconnected(string strReason, Network.Connection connection) { this.connectionQueue.RemoveConnection(connection); ConnectionAuth.OnDisconnect(connection); SteamServer.EndSession(connection.userid); EACServer.OnLeaveGame(connection); BasePlayer basePlayer = connection.player as BasePlayer; if (basePlayer) { Interface.CallHook("OnPlayerDisconnected", basePlayer, strReason); basePlayer.OnDisconnected(); } }
private void InitializationEAC() { try { ConsoleSystem.Log("[VirtualServer]: ParseEncryptionHash запускается..."); EACServer.DoStartup(); Timer.SetInterval(EACServer.DoUpdate, 1f); ConsoleSystem.Log("[VirtualServer]: ParseEncryptionHash успешно запущен!"); } catch (Exception ex) { ConsoleSystem.LogError("[VirtualServer]: Исключение в InitializationEAC(): " + ex.Message); } }
public void OnDisconnected(string strReason, Network.Connection connection) { this.connectionQueue.RemoveConnection(connection); ConnectionAuth.OnDisconnect(connection); Global.get_SteamServer().get_Auth().EndSession((ulong)connection.userid); EACServer.OnLeaveGame(connection); BasePlayer player = connection.player as BasePlayer; if (!Object.op_Implicit((Object)player)) { return; } Interface.CallHook("OnPlayerDisconnected", (object)player, (object)strReason); player.OnDisconnected(); }
public static void OnMessageReceived(Message message) { byte[] numArray; int num; if (!EACServer.connection2client.ContainsKey(message.connection)) { Debug.LogError(string.Concat("EAC network packet from invalid connection: ", message.connection.userid)); return; } EasyAntiCheat.Server.Hydra.Client client = EACServer.GetClient(message.connection); if (!message.read.TemporaryBytesWithSize(out numArray, out num)) { return; } EACServer.easyAntiCheat.PushNetworkMessage(client, numArray, num); }
private static void SendToClient(EasyAntiCheat.Server.Hydra.Client client, byte[] message, int messageLength) { Connection connection = EACServer.GetConnection(client); if (connection == null) { Debug.LogError(string.Concat("EAC network packet for invalid client: ", client.ClientID)); return; } if (Network.Net.sv.write.Start()) { Network.Net.sv.write.PacketID(Message.Type.EAC); Network.Net.sv.write.UInt32((uint)messageLength); Network.Net.sv.write.Write(message, 0, messageLength); Network.Net.sv.write.Send(new SendInfo(connection)); } }
public static void DoUpdate() { EasyAntiCheat.Server.Hydra.Client client; byte[] numArray; int num; if (EACServer.easyAntiCheat != null) { EACServer.easyAntiCheat.HandleClientUpdates(); if (Network.Net.sv != null && Network.Net.sv.IsConnected()) { while (EACServer.easyAntiCheat.PopNetworkMessage(out client, out numArray, out num)) { EACServer.SendToClient(client, numArray, num); } } } }
public void OUT_OnDisconnected(string reason, Connection conn) { if (BaseClient?.IsConnected() == true) { ConsoleSystem.LogWarning("[VirtualServer]: Соеденение с игровым клиентом разорвано: " + reason); BaseClient?.Disconnect(reason, false); if (BaseClient != null & BaseClient.Connection != null) { BaseClient.Connection.decryptIncoming = false; BaseClient.Connection.encryptOutgoing = false; } NetworkManager.Instance.OnDisconnected(); ConnectionInformation = null; LastEntityNUM = 0; } EACServer.OnLeaveGame(conn); }
public void OnNewConnection(Connection connection) { try { if (BaseServer.connections.Count <= 1) { ConsoleSystem.Log($"[VirtualServer]: Есть новое подключение [{BaseServer.connections[0].ipaddress}]"); ConsoleSystem.Log($"[VirtualServer]: Подключаемся к игровому серверу [{Settings.TargetServer_IP}:{Settings.TargetServer_Port}]"); if (BaseClient.Connect(Settings.TargetServer_IP, Settings.TargetServer_Port)) { BaseClient.Connection.ipaddress = "127.0.0.1"; BaseClient.Connection.userid = Settings.Connection1_SteamID; BaseClient.Connection.ownerid = Settings.Connection1_SteamID; BaseClient.Connection.username = Settings.Connection1_Username; BaseClient.Connection.authLevel = 1; EACServer.OnJoinGame(BaseClient.Connection); //EACServer.OnStartLoading(BaseClient.Connection); //EACServer.OnFinishLoading(BaseClient.Connection); BaseServer.connections[0].ipaddress = "127.0.0.1"; BaseServer.connections[0].userid = Settings.Connection2_SteamID; BaseServer.connections[0].ownerid = Settings.Connection2_SteamID; BaseServer.connections[0].username = Settings.Connection2_Username; BaseServer.connections[0].authLevel = 1; EACServer.OnJoinGame(BaseServer.connections[0]); //EACServer.OnStartLoading(BaseServer.connections[0]); //EACServer.OnFinishLoading(BaseServer.connections[0]); ConsoleSystem.Log("[VirtualServer]: Инициализация подключения успешно завершена!"); } else { ConsoleSystem.LogError($"[VirtualServer]: В попытке подключения отказано!"); } } else { ConsoleSystem.LogError($"[VirtualServer]: Уже есть одно подключение, больше подключений не может быть!"); } } catch (Exception ex) { ConsoleSystem.LogError("[VirtualServer]: Исключение в OnNewConnection(): " + ex.Message); } }
public void OUT_OnNetworkMessage(Message packet) { switch (packet.type) { case Message.Type.Ready: packet.connection.decryptIncoming = true; SendPacket(BaseClient, packet); BaseClient.Connection.encryptOutgoing = true; return; case Message.Type.GiveUserInformation: ConnectionInformation = UserInformation.ParsePacket(packet); if (Settings.UseCustomToken) { ConnectionInformation.SteamToken = Settings.CustomToken; if (BaseClient.write.Start()) { BaseClient.write.PacketID(Message.Type.GiveUserInformation); ConnectionInformation.Write(BaseClient); BaseClient.Send(); } } else { SendPacket(BaseClient, packet); } break; case Message.Type.EAC: EACServer.OnMessageReceived(packet); SendPacket(BaseClient, packet); break; default: if (NetworkManager.Instance.Out_NetworkMessage(packet) == false) { SendPacket(BaseClient, packet); } break; } }
public void OpenConnection() { this.useQueryPort = (ConVar.Server.queryport <= 0 ? false : ConVar.Server.queryport != ConVar.Server.port); Network.Net.sv.ip = ConVar.Server.ip; Network.Net.sv.port = ConVar.Server.port; if (!Network.Net.sv.Start()) { UnityEngine.Debug.LogWarning("Couldn't Start Server."); return; } this.StartSteamServer(); Network.Net.sv.callbackHandler = this; Network.Net.sv.cryptography = new NetworkCryptographyServer(); EACServer.DoStartup(); base.InvokeRepeating("EACUpdate", 1f, 1f); base.InvokeRepeating("DoTick", 1f, 1f / (float)ConVar.Server.tickrate); base.InvokeRepeating("DoHeartbeat", 1f, 1f); this.runFrameUpdate = true; Interface.CallHook("IOnServerInitialized"); }
private static void SendToClient(EasyAntiCheat.Server.Hydra.Client client, byte[] message, int messageLength) { Connection connection = EACServer.GetConnection(client); if (connection == null) { Debug.LogError((object)("EAC network packet for invalid client: " + (object)((EasyAntiCheat.Server.Hydra.Client) ref client).get_ClientID())); } else { if (!((Write)((NetworkPeer)Net.sv).write).Start()) { return; } ((Write)((NetworkPeer)Net.sv).write).PacketID((Message.Type) 22); ((Write)((NetworkPeer)Net.sv).write).UInt32((uint)messageLength); ((Stream)((NetworkPeer)Net.sv).write).Write(message, 0, messageLength); ((Write)((NetworkPeer)Net.sv).write).Send(new SendInfo(connection)); } }
public static void DoUpdate() { if (EACServer.easyAntiCheat == null) { return; } EACServer.easyAntiCheat.HandleClientUpdates(); if (Net.sv == null || !((Network.Server)Net.sv).IsConnected()) { return; } EasyAntiCheat.Server.Hydra.Client client; byte[] message; int messageLength; while (EACServer.easyAntiCheat.PopNetworkMessage(ref client, ref message, ref messageLength)) { EACServer.SendToClient(client, message, messageLength); } }
public void OpenConnection() { this.useQueryPort = ConVar.Server.queryport > 0 && ConVar.Server.queryport != ConVar.Server.port; ((Network.Server)Network.Net.sv).ip = (__Null)ConVar.Server.ip; ((Network.Server)Network.Net.sv).port = (__Null)ConVar.Server.port; if (!((Network.Server)Network.Net.sv).Start()) { Debug.LogWarning((object)"Couldn't Start Server."); } else { this.StartSteamServer(); ((Network.Server)Network.Net.sv).callbackHandler = (__Null)this; ((NetworkPeer)Network.Net.sv).cryptography = (__Null) new NetworkCryptographyServer(); EACServer.DoStartup(); ((MonoBehaviour)this).InvokeRepeating("EACUpdate", 1f, 1f); ((MonoBehaviour)this).InvokeRepeating("DoTick", 1f, 1f / (float)ConVar.Server.tickrate); ((MonoBehaviour)this).InvokeRepeating("DoHeartbeat", 1f, 1f); this.runFrameUpdate = true; Interface.CallHook("IOnServerInitialized"); } }
public static void OnJoinGame(Connection connection) { if (EACServer.easyAntiCheat == null) { EACServer.OnAuthenticatedLocal(connection); EACServer.OnAuthenticatedRemote(connection); } else { EasyAntiCheat.Server.Hydra.Client client = EACServer.easyAntiCheat.GenerateCompatibilityClient(); EACServer.easyAntiCheat.RegisterClient(client, connection.userid.ToString(), connection.ipaddress, connection.ownerid.ToString(), connection.username, (connection.authLevel > 0 ? PlayerRegisterFlags.PlayerRegisterFlagAdmin : PlayerRegisterFlags.PlayerRegisterFlagNone)); EACServer.client2connection.Add(client, connection); EACServer.connection2client.Add(connection, client); EACServer.connection2status.Add(connection, ClientStatus.ClientDisconnected); if (EACServer.ShouldIgnore(connection)) { EACServer.OnAuthenticatedLocal(connection); EACServer.OnAuthenticatedRemote(connection); return; } } }
public static void OnJoinGame(Connection connection) { if (EACServer.easyAntiCheat != null) { EasyAntiCheat.Server.Hydra.Client compatibilityClient = EACServer.easyAntiCheat.GenerateCompatibilityClient(); // ISSUE: explicit non-virtual call // ISSUE: explicit non-virtual call EACServer.easyAntiCheat.RegisterClient(compatibilityClient, __nonvirtual(connection.userid.ToString()), (string)connection.ipaddress, __nonvirtual(connection.ownerid.ToString()), (string)connection.username, connection.authLevel > 0 ? (PlayerRegisterFlags)1 : (PlayerRegisterFlags)0); EACServer.client2connection.Add(compatibilityClient, connection); EACServer.connection2client.Add(connection, compatibilityClient); EACServer.connection2status.Add(connection, (ClientStatus)0); if (!EACServer.ShouldIgnore(connection)) { return; } EACServer.OnAuthenticatedLocal(connection); EACServer.OnAuthenticatedRemote(connection); } else { EACServer.OnAuthenticatedLocal(connection); EACServer.OnAuthenticatedRemote(connection); } }