private object OnUserApprove(Network.Connection connection) { // Call out and see if we should reject object canlogin = Interface.CallHook("CanClientLogin", new object[] { 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); }
public void OnNewConnection(Connection connection) { connection.connected = false; if (connection.token == null || (int)connection.token.Length < 32) { ConnectionAuth.Reject(connection, "Invalid Token"); return; } if (connection.userid == 0) { ConnectionAuth.Reject(connection, "Invalid SteamID"); return; } if (connection.protocol != 2177) { if (!DeveloperList.Contains(connection.userid)) { ConnectionAuth.Reject(connection, "Incompatible Version"); return; } DebugEx.Log(string.Concat("Not kicking ", connection.userid, " for incompatible protocol (is a developer)"), StackTraceLogType.None); } if (ServerUsers.Is(connection.userid, ServerUsers.UserGroup.Banned)) { ConnectionAuth.Reject(connection, "You are banned from this server"); return; } if (ServerUsers.Is(connection.userid, ServerUsers.UserGroup.Moderator)) { DebugEx.Log(string.Concat(connection.ToString(), " has auth level 1"), StackTraceLogType.None); connection.authLevel = 1; } if (ServerUsers.Is(connection.userid, ServerUsers.UserGroup.Owner)) { DebugEx.Log(string.Concat(connection.ToString(), " has auth level 2"), StackTraceLogType.None); connection.authLevel = 2; } if (DeveloperList.Contains(connection.userid)) { DebugEx.Log(string.Concat(connection.ToString(), " is a developer"), StackTraceLogType.None); connection.authLevel = 3; } if (this.IsConnected(connection.userid)) { ConnectionAuth.Reject(connection, "You are already connected!"); return; } if (Interface.CallHook("IOnUserApprove", connection) != null) { return; } ConnectionAuth.m_AuthConnection.Add(connection); base.StartCoroutine(this.AuthorisationRoutine(connection)); }
void UserIsFollowingCallBack(int code, string response, Network.Connection connection) { if (code != 200) { Puts($"{connection.username} tried to log in but does not follow you on Twitch"); ConnectionAuth.Reject(connection, string.Format(lang.GetMessage("RejectMessage", this, connection.userid.ToString()), twitchAccount)); } else { Puts($"{connection.username} is a follower. Allowing."); } }
public static IEnumerator Run(Connection connection) { connection.authStatus = ""; if (!SteamServer.BeginAuthSession(connection.token, connection.userid)) { ConnectionAuth.Reject(connection, "Steam Auth Failed"); yield break; } Auth_Steam.waitingList.Add(connection); Stopwatch stopwatch = Stopwatch.StartNew(); while (stopwatch.Elapsed.TotalSeconds < 30 && connection.active && !(connection.authStatus != "")) { yield return(null); } Auth_Steam.waitingList.Remove(connection); if (!connection.active) { yield break; } if (connection.authStatus.Length == 0) { ConnectionAuth.Reject(connection, "Steam Auth Timeout"); SteamServer.EndSession(connection.userid); yield break; } if (connection.authStatus == "banned") { ConnectionAuth.Reject(connection, string.Concat("Auth: ", connection.authStatus)); SteamServer.EndSession(connection.userid); yield break; } if (connection.authStatus == "gamebanned") { ConnectionAuth.Reject(connection, string.Concat("Steam Auth: ", connection.authStatus)); SteamServer.EndSession(connection.userid); yield break; } if (connection.authStatus == "vacbanned") { ConnectionAuth.Reject(connection, string.Concat("Steam Auth: ", connection.authStatus)); SteamServer.EndSession(connection.userid); yield break; } if (connection.authStatus == "ok") { SteamServer.UpdatePlayer(connection.userid, connection.username, 0); yield break; } ConnectionAuth.Reject(connection, string.Concat("Steam Auth Error: ", connection.authStatus)); SteamServer.EndSession(connection.userid); }
public static IEnumerator Run(Connection connection) { connection.authStatus = ""; if (!PlatformService.Instance.BeginPlayerSession(connection.userid, connection.token)) { ConnectionAuth.Reject(connection, "Steam Auth Failed"); yield break; } waitingList.Add(connection); Stopwatch timeout = Stopwatch.StartNew(); while (timeout.Elapsed.TotalSeconds < 30.0 && connection.active && !(connection.authStatus != "")) { yield return(null); } waitingList.Remove(connection); if (connection.active) { if (connection.authStatus.Length == 0) { ConnectionAuth.Reject(connection, "Steam Auth Timeout"); PlatformService.Instance.EndPlayerSession(connection.userid); } else if (connection.authStatus == "banned") { ConnectionAuth.Reject(connection, "Auth: " + connection.authStatus); PlatformService.Instance.EndPlayerSession(connection.userid); } else if (connection.authStatus == "gamebanned") { ConnectionAuth.Reject(connection, "Steam Auth: " + connection.authStatus); PlatformService.Instance.EndPlayerSession(connection.userid); } else if (connection.authStatus == "vacbanned") { ConnectionAuth.Reject(connection, "Steam Auth: " + connection.authStatus); PlatformService.Instance.EndPlayerSession(connection.userid); } else if (connection.authStatus != "ok") { ConnectionAuth.Reject(connection, "Steam Auth Failed", "Steam Auth Error: " + connection.authStatus); PlatformService.Instance.EndPlayerSession(connection.userid); } else { string userName = (ConVar.Server.censorplayerlist ? RandomUsernames.Get(connection.userid + (ulong)Random.Range(0, 100000)) : connection.username); PlatformService.Instance.UpdatePlayerSession(connection.userid, userName); } } }
public static IEnumerator Run(Connection connection) { connection.authStatus = (__Null)""; if (!Global.get_SteamServer().get_Auth().StartSession((byte[])connection.token, (ulong)connection.userid)) { ConnectionAuth.Reject(connection, "Steam Auth Failed"); } else { Auth_Steam.waitingList.Add(connection); Stopwatch timeout = Stopwatch.StartNew(); while (timeout.Elapsed.TotalSeconds < 30.0 && connection.active != null && !((string)connection.authStatus != "")) { yield return((object)null); } Auth_Steam.waitingList.Remove(connection); if (connection.active != null) { if (((string)connection.authStatus).Length == 0) { ConnectionAuth.Reject(connection, "Steam Auth Timeout"); Global.get_SteamServer().get_Auth().EndSession((ulong)connection.userid); } else if ((string)connection.authStatus == "banned") { ConnectionAuth.Reject(connection, "Auth: " + (string)connection.authStatus); Global.get_SteamServer().get_Auth().EndSession((ulong)connection.userid); } else if ((string)connection.authStatus == "gamebanned") { ConnectionAuth.Reject(connection, "Steam Auth: " + (string)connection.authStatus); Global.get_SteamServer().get_Auth().EndSession((ulong)connection.userid); } else if ((string)connection.authStatus == "vacbanned") { ConnectionAuth.Reject(connection, "Steam Auth: " + (string)connection.authStatus); Global.get_SteamServer().get_Auth().EndSession((ulong)connection.userid); } else if ((string)connection.authStatus != "ok") { ConnectionAuth.Reject(connection, "Steam Auth Error: " + (string)connection.authStatus); Global.get_SteamServer().get_Auth().EndSession((ulong)connection.userid); } else { Global.get_SteamServer().UpdatePlayer((ulong)connection.userid, (string)connection.username, 0); } } } }
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)); }
// ConnectionAuth.Approve() public static void On_ClientAuth(ConnectionAuth ca, Connection connection) { var ae = new Events.AuthEvent(connection); OnNext("On_ClientAuth", ae); ConnectionAuth.m_AuthConnection.Remove(connection); if (!ae.Approved) { ConnectionAuth.Reject(connection, ae.Reason); return; } SingletonComponent <ServerMgr> .Instance.ConnectionApproved(connection); }
void UserHasSteamConnectedCallBack(int code, string response, Network.Connection connection) { if (code != 200) { Puts($"{connection.username} tried to log in but does not have its Steam account connected to Twitch"); ConnectionAuth.Reject(connection, string.Format(lang.GetMessage("RejectMessage", this, connection.userid.ToString()), twitchAccount)); } else { var user = JsonConvert.DeserializeObject <TwitchUser>(response); if (!string.IsNullOrEmpty(user?.Name)) { Puts($"{connection.username} connecting. Checking if is a follower."); UserIsFollowing(user.Name, connection); } } }
static bool Prefix(Connection connection) { if (DeveloperList.Contains(connection.userid)) { ConnectionAuth.Reject(connection, "Developer SteamId"); return(false); } var message = Interface.CallHook("CanNewConnection", connection, !ShouldIgnore(connection)); if (message != null) { ConnectionAuth.Reject(connection, message.ToString()); return(false); } return(true); }
// 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); } Approval instance = new Approval(); instance.level = Application.loadedLevelName; instance.levelSeed = TerrainGenerator.Seed; instance.hostname = server.hostname; Net.sv.Approve(connection, Approval.SerializeToBytes(instance)); }
private object IOnUserApprove(Connection connection) { string name = connection.username; string id = connection.userid.ToString(); string ip = Regex.Replace(connection.ipaddress, ipPattern, ""); uint authLevel = connection.authLevel; // Update player's permissions group and name if (permission.IsLoaded) { permission.UpdateNickname(id, name); OxideConfig.DefaultGroups defaultGroups = Interface.Oxide.Config.Options.DefaultGroups; if (!permission.UserHasGroup(id, defaultGroups.Players)) { permission.AddUserGroup(id, defaultGroups.Players); } if (authLevel == 2 && !permission.UserHasGroup(id, defaultGroups.Administrators)) { permission.AddUserGroup(id, defaultGroups.Administrators); } } Covalence.PlayerManager.PlayerJoin(connection.userid, name); // TODO: Handle this automatically object loginSpecific = Interface.CallHook("CanClientLogin", connection); object loginCovalence = Interface.CallHook("CanUserLogin", name, id, ip); object canLogin = loginSpecific ?? loginCovalence; // TODO: Fix hook conflict when multiple return if (canLogin is string || canLogin is bool && !(bool)canLogin) { ConnectionAuth.Reject(connection, canLogin is string?canLogin.ToString() : lang.GetMessage("ConnectionRejected", this, id)); return(true); } // Call game and covalence hooks object approvedSpecific = Interface.CallHook("OnUserApprove", connection); object approvedCovalence = Interface.CallHook("OnUserApproved", name, id, ip); return(approvedSpecific ?? approvedCovalence); // TODO: Fix hook conflict when multiple return }
private object IOnUserApprove(Connection connection) { string playerName = connection.username; string connectionId = connection.userid.ToString(); string connectionIp = Regex.Replace(connection.ipaddress, ipPattern, ""); uint authLevel = connection.authLevel; // Update name and groups with permissions if (permission.IsLoaded) { permission.UpdateNickname(connectionId, playerName); OxideConfig.DefaultGroups defaultGroups = Interface.Oxide.Config.Options.DefaultGroups; if (!permission.UserHasGroup(connectionId, defaultGroups.Players)) { permission.AddUserGroup(connectionId, defaultGroups.Players); } if (authLevel == 2 && !permission.UserHasGroup(connectionId, defaultGroups.Administrators)) { permission.AddUserGroup(connectionId, defaultGroups.Administrators); } } // Let covalence know Covalence.PlayerManager.PlayerJoin(connection.userid, playerName); // Call hooks for plugins object loginSpecific = Interface.CallHook("CanClientLogin", connection); object loginCovalence = Interface.CallHook("CanUserLogin", playerName, connectionId, connectionIp); object canLogin = loginSpecific is null ? loginCovalence : loginSpecific; if (canLogin is string || canLogin is bool loginBlocked && !loginBlocked) { ConnectionAuth.Reject(connection, canLogin is string?canLogin.ToString() : lang.GetMessage("ConnectionRejected", this, connectionId)); return(true); } // Call hooks for plugins object approvedSpecific = Interface.CallHook("OnUserApprove", connection); object approvedCovalence = Interface.CallHook("OnUserApproved", playerName, connectionId, connectionIp); return(approvedSpecific is null ? approvedCovalence : approvedSpecific); }
private object IOnUserApprove(Connection connection) { var name = connection.username; var id = connection.userid.ToString(); var authLevel = connection.authLevel; var ip = Regex.Replace(connection.ipaddress, ipPattern, ""); // Update player's permissions group and name if (permission.IsLoaded) { permission.UpdateNickname(id, name); var defaultGroups = Interface.Oxide.Config.Options.DefaultGroups; if (!permission.UserHasGroup(id, defaultGroups.Players)) { permission.AddUserGroup(id, defaultGroups.Players); } if (authLevel == 2 && !permission.UserHasGroup(id, defaultGroups.Administrators)) { permission.AddUserGroup(id, defaultGroups.Administrators); } } // Let covalence know Covalence.PlayerManager.PlayerJoin(connection.userid, name); var loginSpecific = Interface.Call("CanClientLogin", connection); var loginCovalence = Interface.Call("CanUserLogin", name, id, ip); var canLogin = loginSpecific ?? loginCovalence; // TODO: Fix 'RustCore' hook conflict when both return if (canLogin is string || (canLogin is bool && !(bool)canLogin)) { ConnectionAuth.Reject(connection, canLogin is string?canLogin.ToString() : lang.GetMessage("ConnectionRejected", this, id)); return(true); } // Call game and covalence hooks var approvedSpecific = Interface.Call("OnUserApprove", connection); var approvedCovalence = Interface.Call("OnUserApproved", name, id, ip); return(approvedSpecific ?? approvedCovalence); // TODO: Fix 'RustCore' hook conflict when both return }
//Oxide Hook void CanClientLogin(Network.Connection connection) { //Checks if the player has been verified before, if not -> verify player. if (!verifiedPlayers.Contains(connection.userid.ToString())) { if (steamAPIKey != "insertAPIKeyHere") { string url = "http://api.steampowered.com/IPlayerService/GetOwnedGames/v0001/?key=" + steamAPIKey + "&format=json&input_json={\"appids_filter\":[252490],\"steamid\":" + connection.userid + "}"; ConnectingPlayer connectingPlayer = new ConnectingPlayer(connection); webRequests.EnqueueGet(url, (code, response) => connectingPlayer.connectionResponse = WebRequestCallback(code, response), this, null, 1.5f); RespondOnWebRequest(connectingPlayer); } else { ConnectionAuth.Reject(connection, "MinimumPlaytime has no steamAPI key entered by the server owner yet."); } } }
public IEnumerator AuthorisationRoutine(Connection connection) { ConnectionAuth connectionAuth = null; yield return(connectionAuth.StartCoroutine(Auth_Steam.Run(connection))); yield return(connectionAuth.StartCoroutine(Auth_EAC.Run(connection))); if (connection.rejected || !connection.active) { yield break; } BasePlayer basePlayer = BasePlayer.FindByID(connection.userid); if (basePlayer && basePlayer.net.connection != null) { ConnectionAuth.Reject(connection, "You are already connected as a player!"); yield break; } connectionAuth.Approve(connection); }
public IEnumerator AuthorisationRoutine(Connection connection) { ConnectionAuth connectionAuth = this; yield return((object)connectionAuth.StartCoroutine(Auth_Steam.Run(connection))); yield return((object)connectionAuth.StartCoroutine(Auth_EAC.Run(connection))); if (connection.rejected == null && connection.active != null) { BasePlayer byId = BasePlayer.FindByID((ulong)connection.userid); if (Object.op_Implicit((Object)byId) && byId.net.get_connection() != null) { ConnectionAuth.Reject(connection, "You are already connected as a player!"); } else { connectionAuth.Approve(connection); } } }
private void RespondOnWebRequest(ConnectingPlayer connectingPlayer) { timer.Once(timerDelay, () => { if (connectingPlayer.connectionResponse != null) { if (connectingPlayer.connectionResponse.Equals("LoginAllowed")) { verifiedPlayers.Add(connectingPlayer.connection.userid.ToString()); Config["verifiedPlayers"] = verifiedPlayers; SaveConfig(); } else { ConnectionAuth.Reject(connectingPlayer.connection, connectingPlayer.connectionResponse); } } else { RespondOnWebRequest(connectingPlayer); } }); }
public void Reject(string reason = "no reason") { ConnectionAuth.Reject(basePlayer.net.connection, reason); }
public void OnNewConnection(Connection connection) { connection.connected = (__Null)0; if (connection.token == null || connection.token.Length < 32) { ConnectionAuth.Reject(connection, "Invalid Token"); } else if (connection.userid == null) { ConnectionAuth.Reject(connection, "Invalid SteamID"); } else { if (connection.protocol != 2161) { if (DeveloperList.Contains((ulong)connection.userid)) { DebugEx.Log((object)("Not kicking " + (object)(ulong)connection.userid + " for incompatible protocol (is a developer)"), (StackTraceLogType)0); } else { ConnectionAuth.Reject(connection, "Incompatible Version"); return; } } if (ServerUsers.Is((ulong)connection.userid, ServerUsers.UserGroup.Banned)) { ConnectionAuth.Reject(connection, "You are banned from this server"); } else { if (ServerUsers.Is((ulong)connection.userid, ServerUsers.UserGroup.Moderator)) { DebugEx.Log((object)(((object)connection).ToString() + " has auth level 1"), (StackTraceLogType)0); connection.authLevel = (__Null)1; } if (ServerUsers.Is((ulong)connection.userid, ServerUsers.UserGroup.Owner)) { DebugEx.Log((object)(((object)connection).ToString() + " has auth level 2"), (StackTraceLogType)0); connection.authLevel = (__Null)2; } if (DeveloperList.Contains((ulong)connection.userid)) { DebugEx.Log((object)(((object)connection).ToString() + " is a developer"), (StackTraceLogType)0); connection.authLevel = (__Null)3; } if (this.IsConnected((ulong)connection.userid)) { ConnectionAuth.Reject(connection, "You are already connected!"); } else { if (Interface.CallHook("IOnUserApprove", (object)connection) != null) { return; } ConnectionAuth.m_AuthConnection.Add(connection); this.StartCoroutine(this.AuthorisationRoutine(connection)); } } } }