public void JoinGame(Network.Connection connection) { using (Approval url = Facepunch.Pool.Get <Approval>()) { uint num = (uint)ConVar.Server.encryption; if (num > 1 && connection.os == "editor" && DeveloperList.Contains(connection.ownerid)) { num = 1; } url.level = UnityEngine.Application.loadedLevelName; url.levelUrl = World.Url; url.levelSeed = World.Seed; url.levelSize = World.Size; url.checksum = World.Checksum; url.hostname = ConVar.Server.hostname; url.official = ConVar.Server.official; url.encryption = num; if (Network.Net.sv.write.Start()) { Network.Net.sv.write.PacketID(Message.Type.Approved); url.WriteToStream(Network.Net.sv.write); Network.Net.sv.write.Send(new SendInfo(connection)); } connection.encryptionLevel = num; connection.encryptOutgoing = true; } connection.connected = true; }
private void OnValidateAuthTicketResponse(ulong SteamId, ulong OwnerId, ServerAuth.Status Status) { if (Auth_Steam.ValidateConnecting(SteamId, OwnerId, Status)) { return; } Network.Connection connection = ((IEnumerable <Network.Connection>)((Network.Server)Network.Net.sv).connections).FirstOrDefault <Network.Connection>((Func <Network.Connection, bool>)(x => x.userid == (long)SteamId)); if (connection == null) { Debug.LogWarning((object)("Steam gave us a " + (object)Status + " ticket response for unconnected id " + (object)SteamId)); } else if (Status == null) { Debug.LogWarning((object)("Steam gave us a 'ok' ticket response for already connected id " + (object)SteamId)); } else { if (Status == 5) { return; } connection.authStatus = (__Null)Status.ToString(); ((Network.Server)Network.Net.sv).Kick(connection, "Steam: " + Status.ToString()); } }
private void SpawnNewPlayer(Network.Connection connection) { BasePlayer.SpawnPoint spawnPoint = ServerMgr.FindSpawnPoint(); BasePlayer player = GameManager.server.CreateEntity("assets/prefabs/player/player.prefab", spawnPoint.pos, spawnPoint.rot, true).ToPlayer(); if (Interface.CallHook("OnPlayerSpawn", (object)player) != null) { return; } player.health = 0.0f; player.lifestate = BaseCombatEntity.LifeState.Dead; player.ResetLifeStateOnSpawn = false; player.limitNetworking = true; player.Spawn(); player.limitNetworking = false; player.PlayerInit(connection); if (SleepingBag.FindForPlayer(player.userID, true).Length == 0 && !player.hasPreviousLife) { player.Respawn(); } else { player.SendRespawnOptions(); } DebugEx.Log((object)(((object)player.net.get_connection()).ToString() + " joined [" + (object)player.net.get_connection().os + "/" + (object)(ulong)player.net.get_connection().ownerid + "]"), (StackTraceLogType)0); }
private void messageReceived(Packet packet, Connection connection) { TalkPacket request = (TalkPacket)packet; TalkPacket response = new TalkPacket(); response.Message = "Message returning from server: " + request.Message; connection.Send(response); }
private void SpawnNewPlayer(Network.Connection connection) { BasePlayer.SpawnPoint spawnPoint = ServerMgr.FindSpawnPoint(); BasePlayer player = GameManager.server.CreateEntity("assets/prefabs/player/player.prefab", spawnPoint.pos, spawnPoint.rot, true).ToPlayer(); if (Interface.CallHook("OnPlayerSpawn", player) != null) { return; } player.health = 0f; player.lifestate = BaseCombatEntity.LifeState.Dead; player.ResetLifeStateOnSpawn = false; player.limitNetworking = true; player.Spawn(); player.limitNetworking = false; player.PlayerInit(connection); if (SleepingBag.FindForPlayer(player.userID, true).Length != 0 || player.hasPreviousLife) { player.SendRespawnOptions(); } else { player.Respawn(); } DebugEx.Log(string.Concat(new object[] { player.net.connection.ToString(), " joined [", player.net.connection.os, "/", player.net.connection.ownerid, "]" }), StackTraceLogType.None); }
public void JoinGame(Network.Connection connection) { using (Approval approval = (Approval)Pool.Get <Approval>()) { uint num = (uint)ConVar.Server.encryption; if (num > 1U && (string)connection.os == "editor" && DeveloperList.Contains((ulong)connection.ownerid)) { num = 1U; } approval.level = (__Null)Application.get_loadedLevelName(); approval.levelUrl = (__Null)World.Url; approval.levelSeed = (__Null)(int)World.Seed; approval.levelSize = (__Null)(int)World.Size; approval.checksum = (__Null)World.Checksum; approval.hostname = (__Null)ConVar.Server.hostname; approval.official = (__Null)(ConVar.Server.official ? 1 : 0); approval.encryption = (__Null)(int)num; if (((Write)((NetworkPeer)Network.Net.sv).write).Start()) { ((Write)((NetworkPeer)Network.Net.sv).write).PacketID((Message.Type) 3); approval.WriteToStream((Stream)((NetworkPeer)Network.Net.sv).write); ((Write)((NetworkPeer)Network.Net.sv).write).Send(new SendInfo(connection)); } connection.encryptionLevel = (__Null)(int)num; connection.encryptOutgoing = (__Null)1; } connection.connected = (__Null)1; }
public override ulong GetStat(Network.Connection connection, NetworkPeer.StatTypeLong type) { if (this.peer == null) { return((ulong)0); } return(this.peer.GetStat(connection, type)); }
private void connectionEstablished(Connection connection, ConnectionType connectionType) { TalkPacket talkPacket = new TalkPacket(); talkPacket.Message = "Hello World!"; Console.WriteLine("Client: Connection Established!"); connection.Send(talkPacket); }
public static void OnEnterVisibility(Network.Connection connection, Group group) { if (!((Network.Server)Network.Net.sv).IsConnected() || !((Write)((NetworkPeer)Network.Net.sv).write).Start()) { return; } ((Write)((NetworkPeer)Network.Net.sv).write).PacketID((Message.Type) 19); ((Write)((NetworkPeer)Network.Net.sv).write).GroupID((uint)group.ID); ((Write)((NetworkPeer)Network.Net.sv).write).Send(new SendInfo(connection)); }
public override string GetDebug(Network.Connection connection) { if (this.peer == null) { return(""); } if (connection == null) { return(this.peer.GetStatisticsString((ulong)0)); } return(this.peer.GetStatisticsString(connection.guid)); }
public static void OnEnterVisibility(Network.Connection connection, Group group) { if (!Network.Net.sv.IsConnected()) { return; } if (Network.Net.sv.write.Start()) { Network.Net.sv.write.PacketID(Message.Type.GroupEnter); Network.Net.sv.write.GroupID(group.ID); Network.Net.sv.write.Send(new SendInfo(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(); } }
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(); }
private void DoTick() { if (SteamServer.IsValid) { Interface.CallHook("OnTick"); SteamServer.RunCallbacks(); } RCon.Update(); for (int i = 0; i < Network.Net.sv.connections.Count; i++) { Network.Connection item = Network.Net.sv.connections[i]; if (!item.isAuthenticated && item.GetSecondsConnected() >= (float)ConVar.Server.authtimeout) { Network.Net.sv.Kick(item, "Authentication Timed Out"); } } }
private void DoTick() { if (Global.get_SteamServer() != null) { Interface.CallHook("OnTick"); ((BaseSteamworks)Global.get_SteamServer()).Update(); } RCon.Update(); for (int index = 0; index < ((List <Network.Connection>)((Network.Server)Network.Net.sv).connections).Count; ++index) { Network.Connection connection = ((List <Network.Connection>)((Network.Server)Network.Net.sv).connections)[index]; if (!connection.get_isAuthenticated() && (double)connection.GetSecondsConnected() >= (double)ConVar.Server.authtimeout) { ((Network.Server)Network.Net.sv).Kick(connection, "Authentication Timed Out"); } } }
public void Process(Connection connection) { Connection = connection; using (Reader = new BinaryReader(new MemoryStream(connection.Buffer))) { Read(); } try { Process(); } catch (Exception ex) { Log.WarnException("ARecvPacket", ex); } }
public void Process(Connection connection) { Connection = connection; using (Reader = new BinaryReader(new MemoryStream(connection.Buffer))) { Read(); } try { Process(); } catch (Exception ex) { Logger.WriteLine(LogState.Warn, "ARecvPacket:" + ex); } }
// BasePlayer.PlayerInit() public static void PlayerConnected(Network.Connection connection) { var player = connection.player as BasePlayer; var p = new Player(player); if (Server.GetServer().OfflinePlayers.ContainsKey(player.userID)) { Server.GetServer().OfflinePlayers.Remove(player.userID); } if (!Server.GetServer().Players.ContainsKey(player.userID)) { Server.GetServer().Players.Add(player.userID, p); } OnPlayerConnected.OnNext(p); p.Message("Welcome " + p.Name + "!"); p.Message(String.Format("This server is powered by Pluton[v{0}]!", Bootstrap.Version)); p.Message("Visit fougerite.com for more information or to report bugs!"); }
private bool SpawnPlayerSleeping(Network.Connection connection) { BasePlayer sleeping = BasePlayer.FindSleeping((ulong)connection.userid); if (Object.op_Equality((Object)sleeping, (Object)null)) { return(false); } if (!sleeping.IsSleeping()) { Debug.LogWarning((object)"Player spawning into sleeper that isn't sleeping!"); sleeping.Kill(BaseNetworkable.DestroyMode.None); return(false); } sleeping.PlayerInit(connection); sleeping.inventory.SendSnapshot(); DebugEx.Log((object)(((object)sleeping.net.get_connection()).ToString() + " joined [" + (object)sleeping.net.get_connection().os + "/" + (object)(ulong)sleeping.net.get_connection().ownerid + "]"), (StackTraceLogType)0); return(true); }
private bool SpawnPlayerSleeping(Network.Connection connection) { BasePlayer basePlayer = BasePlayer.FindSleeping(connection.userid); if (basePlayer == null) { return(false); } if (!basePlayer.IsSleeping()) { UnityEngine.Debug.LogWarning("Player spawning into sleeper that isn't sleeping!"); basePlayer.Kill(BaseNetworkable.DestroyMode.None); return(false); } basePlayer.PlayerInit(connection); basePlayer.inventory.SendSnapshot(); DebugEx.Log(string.Concat(new object[] { basePlayer.net.connection.ToString(), " joined [", basePlayer.net.connection.os, "/", basePlayer.net.connection.ownerid, "]" }), StackTraceLogType.None); return(true); }
public static void PlayerConnected(Network.Connection connection) { var player = connection.player as BasePlayer; var p = new Player(player); if (Server.GetInstance().OfflinePlayers.ContainsKey(player.userID)) { Server.GetInstance().OfflinePlayers.Remove(player.userID); } if (!Server.GetInstance().Players.ContainsKey(player.userID)) { Server.GetInstance().Players.Add(player.userID, p); } OnPlayerConnected.OnNext(p); if (Config.GetInstance().GetBoolValue("Config", "welcomeMessage", true)) { p.Message("Welcome " + p.Name + "!"); p.Message(String.Format("This server is powered by Pluton[v{0}]!", Bootstrap.Version)); p.Message("Visit pluton-team.org for more information or to report bugs!"); } }
private void OnValidateAuthTicketResponse(Steamworks.SteamId SteamId, Steamworks.SteamId OwnerId, AuthResponse Status) { if (Auth_Steam.ValidateConnecting(SteamId, OwnerId, Status)) { return; } Network.Connection str = Network.Net.sv.connections.FirstOrDefault <Network.Connection>((Network.Connection x) => x.userid == SteamId); if (str == null) { UnityEngine.Debug.LogWarning(string.Format("Steam gave us a {0} ticket response for unconnected id {1}", Status, SteamId)); return; } if (Status == AuthResponse.OK) { UnityEngine.Debug.LogWarning(string.Format("Steam gave us a 'ok' ticket response for already connected id {0}", SteamId)); return; } if (Status == AuthResponse.VACCheckTimedOut) { return; } str.authStatus = Status.ToString(); Network.Net.sv.Kick(str, string.Concat("Steam: ", Status.ToString())); }
private void connectionEstablished(Connection connection, ConnectionType type) { Console.WriteLine("Connection established!"); Console.WriteLine($"{connection.GetType()} connected on port {connection.IPLocalEndPoint.Port}"); connection.RegisterPacketHandler(typeof(TalkPacket), messageReceived); }
private void messageReceived(Packet packet, Connection connection) { TalkPacket response = (TalkPacket)packet; Console.WriteLine($"Client: Message received! {response.Message}"); }
/// <summary> /// Replies to the player with a specific message /// </summary> /// <param name="connection"></param> /// <param name="key"></param> /// <param name="args"></param> private void ReplyWith(Connection connection, string key, params object[] args) { var player = connection?.player as BasePlayer; if (player == null) { Interface.Oxide.LogInfo(string.Format(lang.GetMessage(key, this), args)); return; } player.SendConsoleCommand("chat.add", 0, string.Format(lang.GetMessage(key, this, connection.userid.ToString()), args)); }
private object IOnUserApprove(Connection connection) { // Call out and see if we should reject var canlogin = Interface.CallHook("CanClientLogin", connection); if (canlogin != null && (!(canlogin is bool) || !(bool)canlogin)) { // Reject the user with the message ConnectionAuth.Reject(connection, canlogin.ToString()); return true; } return Interface.CallHook("OnUserApprove", connection); }
private object OnUserApprove(Connection connection) { // Call out and see if we should reject object canlogin = Interface.CallHook("CanClientLogin", connection); if (canlogin != null) { // If it's a bool and it's true, let them in if (canlogin is bool && (bool)canlogin) return null; // If it's a string, reject them with a message if (canlogin is string) { ConnectionAuth.Reject(connection, (string)canlogin); return true; } // We don't know what type it is, reject them with it anyway ConnectionAuth.Reject(connection, canlogin.ToString()); return true; } return null; }
private object IOnUserApprove(Connection connection) { var id = connection.userid.ToString(); var ip = Regex.Replace(connection.ipaddress, @":{1}[0-9]{1}\d*", ""); // Migrate user from 'player' group to 'default' if (permission.UserHasGroup(id, "player")) { permission.AddUserGroup(id, "default"); permission.RemoveUserGroup(id, "player"); Interface.Oxide.LogWarning($"Migrated '{id}' to the new 'default' group"); } // Call out and see if we should reject var canLogin = Interface.Call("CanClientLogin", connection) ?? Interface.Call("CanUserLogin", connection.username, id, ip); if (canLogin != null && (!(canLogin is bool) || !(bool)canLogin)) { // Reject the user with the message ConnectionAuth.Reject(connection, canLogin.ToString()); return true; } return Interface.Call("OnUserApprove", connection) ?? Interface.Call("OnUserApproved", connection.username, id, ip); }
public AuthEvent(Connection connection) { Connection = connection; Approved = true; }
private object IOnUserApprove(Connection connection) { // Reject invalid connections if (connection.userid == 0 || string.IsNullOrEmpty(connection.username)) { ConnectionAuth.Reject(connection, "Your Steam ID or username is invalid"); return true; } // Call out and see if we should reject object canlogin = Interface.CallHook("CanClientLogin", connection); if (canlogin != null) { // If it's a bool and it's true, let them in if (canlogin is bool && (bool)canlogin) return null; // If it's a string, reject them with a message if (canlogin is string) { ConnectionAuth.Reject(connection, (string)canlogin); return true; } // We don't know what type it is, reject them with it anyway ConnectionAuth.Reject(connection, canlogin.ToString()); return true; } return Interface.CallHook("OnUserApprove", connection); }
private object CanBypassQueue(Connection connection) { return Interface.CallDeprecatedHook("OnBypassQueue", "CanBypassQueue", new DateTime(2016, 8, 1), connection); }
public PlayerKickEvent(Connection connection, string reason) { Connection = connection; Reason = reason; }
/// <summary> /// TCPs the or UDP connection closed. /// </summary> /// <param name="closeReason">The close reason.</param> /// <param name="connection">The connection.</param> private void tcpOrUdpConnectionClosed(CloseReason closeReason, Connection connection) { if(connection.GetType().Equals(typeof(TcpConnection))) { //If it is an tcp connection we have to close all the udp connections. this[(TcpConnection)connection].ForEach(c => c.Close(closeReason)); connections.Remove((TcpConnection)connection); } else { //Remove the udp connection from the list. this[this[(UdpConnection)connection]].Remove((UdpConnection)connection); } if (connectionLost != null && connectionLost.GetInvocationList().Length > 0 && connection.GetType().Equals(typeof(TcpConnection))) connectionLost(connection, ConnectionType.TCP, closeReason); else if (connectionLost != null && connectionLost.GetInvocationList().Length > 0 && connection.GetType().Equals(typeof(UdpConnection))) connectionLost(connection, ConnectionType.UDP, closeReason); }
public string UserIDFromConnection(Connection connection) { return connection.userid.ToString(); }
// ConnectionAuth.Approve() public static void ClientAuth(ConnectionAuth ca, Connection connection) { var ae = new Events.AuthEvent(connection); OnClientAuth.OnNext(ae); ca.m_AuthConnection.Remove(connection); if (!ae.approved) { ConnectionAuth.Reject(connection, ae._reason); return; } SingletonComponent<ServerMgr>.Instance.ConnectionApproved(connection); }