Exemplo n.º 1
0
        private object IOnUserApprove(ClientConnection connection, NetworkPlayerApproval approval, ConnectionAcceptor acceptor)
        {
            // Reject invalid connections
            if (connection.UserID == 0 || string.IsNullOrEmpty(connection.UserName))
            {
                approval.Deny(uLink.NetworkConnectionError.ConnectionBanned);
                return(true);
            }

            var id = connection.UserID.ToString();
            var ip = approval.ipAddress;

            // Call out and see if we should reject
            var loginSpecific  = Interface.Call("CanClientLogin", connection);
            var loginCovalence = Interface.Call("CanUserLogin", connection.UserName, id, ip);
            var canLogin       = loginSpecific ?? loginCovalence;

            // Check if player can login
            if (canLogin is string || (canLogin is bool && !(bool)canLogin))
            {
                // Reject the user with the message
                Notice.Popup(connection.netUser.networkPlayer, "", canLogin is string?canLogin.ToString() : "Connection was rejected", 10f);   // TODO: Localization
                approval.Deny(uLink.NetworkConnectionError.NoError);
                return(true);
            }

            // Call the approval hooks
            var approvedSpecific  = Interface.Call("OnUserApprove", connection, approval, acceptor);
            var approvedCovalence = Interface.Call("OnUserApproved", connection.UserName, id, ip);

            return(approvedSpecific ?? approvedCovalence);
        }
Exemplo n.º 2
0
        private object IOnUserApprove(ClientConnection connection, NetworkPlayerApproval approval, ConnectionAcceptor acceptor)
        {
            var id = connection.UserID.ToString();

            // Reject invalid connections
            if (connection.UserID == 0 || string.IsNullOrEmpty(connection.UserName))
            {
                approval.Deny(uLink.NetworkConnectionError.ConnectionBanned);
                return(true);
            }

            // 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 = (string)Interface.CallHook("CanClientLogin", connection) ?? Interface.CallHook("CanUserLogin", connection.UserName, id);

            if (canlogin is string)
            {
                Notice.Popup(connection.netUser.networkPlayer, "", canlogin.ToString(), 10f);
                approval.Deny(uLink.NetworkConnectionError.NoError);
                return(true);
            }

            return(Interface.CallHook("OnUserApprove", connection, approval, acceptor) ?? Interface.CallHook("OnUserApproved", connection.UserName, id));
        }
Exemplo n.º 3
0
 public SteamDenyEvent(ClientConnection cc, NetworkPlayerApproval approval, string strReason, NetError errornum)
 {
     this._cc        = cc;
     this._approval  = approval;
     this._strReason = strReason;
     this._errornum  = errornum;
 }
Exemplo n.º 4
0
 public PlayerApprovalEvent(ConnectionAcceptor ca, NetworkPlayerApproval approval, ClientConnection cc, bool AboutToDeny)
 {
     this._ca       = ca;
     this._cc       = cc;
     this._approval = approval;
     this._deny     = AboutToDeny;
 }
Exemplo n.º 5
0
        private object IOnUserApprove(NetworkPlayerApproval approval)
        {
            // Set PlayerInfos
            var player = new PlayerInfos {
                account_id = approval.loginData.ReadString(), Nickname = "Unnamed"
            };

            // Steamworks.SteamFriends.GetPersonaName(); // TODO: Make use of this?

            // Reject invalid connections
            if (player.account_id == "0" /*|| string.IsNullOrEmpty(player.Nickname)*/)
            {
                approval.Deny(NetworkConnectionError.ConnectionBanned);
                return(false);
            }

            // Call out and see if we should reject
            var canlogin = Interface.CallHook("CanClientLogin", player);

            if (canlogin is NetworkConnectionError)
            {
                approval.Deny((NetworkConnectionError)canlogin);
                return(true);
            }

            return(Interface.CallHook("OnUserApprove", approval, player));
        }
 public PlayerApprovalEvent(ConnectionAcceptor ca, NetworkPlayerApproval approval, ClientConnection cc,
                            bool AboutToDeny, ulong steamid, string ip, string name)
 {
     this._ca       = ca;
     this._cc       = cc;
     this._approval = approval;
     this._deny     = AboutToDeny;
     this._steamid  = steamid;
     this._ip       = ip;
     this._name     = name;
 }
Exemplo n.º 7
0
        private object IOnUserApprove(NetworkPlayerApproval approval, string id)
        {
            var player = NetworkController.NetManager_.ServManager.GetPlayerInfos_accountID(id);

            // Call out and see if we should reject
            var canlogin = Interface.CallHook("CanClientLogin", approval, player) ?? Interface.CallHook("CanUserLogin", player.Nickname, id);

            if (canlogin != null && ((canlogin is NetworkConnectionError) || (bool)canlogin == false))
            {
                approval.Deny(NetworkConnectionError.NoError);
                return(true);
            }

            return(Interface.CallHook("OnUserApprove", approval, player) ?? Interface.CallHook("OnUserApproved", player.Nickname, id));
        }
Exemplo n.º 8
0
        private object IOnUserApprove(NetworkPlayerApproval approval, string id)
        {
            var player = NetworkController.NetManager_.ServManager.GetPlayerInfos_accountID(id);

            // Call out and see if we should reject
            var canlogin = (string)Interface.CallHook("CanClientLogin", approval, player) ?? Interface.CallHook("CanUserLogin", player.Nickname, id);

            if (canlogin is string)
            {
                NetworkController.NetManager_.NetView.RPC("NET_FATAL_ERROR", player.NetPlayer, canlogin);
                Network.CloseConnection(player.NetPlayer, true);
                return(true);
            }

            return(Interface.CallHook("OnUserApprove", approval, player) ?? Interface.CallHook("OnUserApproved", player.Nickname, id));
        }
Exemplo n.º 9
0
        private object IOnUserApprove(ClientConnection connection, NetworkPlayerApproval approval, ConnectionAcceptor acceptor)
        {
            // Reject invalid connections
            if (connection.UserID == 0 || string.IsNullOrEmpty(connection.UserName))
            {
                approval.Deny(uLink.NetworkConnectionError.ConnectionBanned);
                return(true);
            }

            // "Already connected" fix
            var netUser = NetUser.FindByUserID(connection.UserID);

            if (netUser != null)
            {
                Interface.Oxide.LogInfo($"Kicking existing {netUser.displayName} ({netUser.userID}) player (already connected fix)");
                netUser.Kick(NetError.AlreadyConnectedToAnotherServer, false);
            }

            var id = connection.UserID.ToString();
            var ip = approval.ipAddress;

            Covalence.PlayerManager.PlayerJoin(connection.UserID, connection.UserName); // TODO: Handle this automatically

            // Call out and see if we should reject
            var loginSpecific  = Interface.Call("CanClientLogin", connection);
            var loginCovalence = Interface.Call("CanUserLogin", connection.UserName, id, ip);
            var canLogin       = loginSpecific ?? loginCovalence; // TODO: Fix 'RustLegacyCore' hook conflict when both return

            // Check if player can login
            if (canLogin is string || (canLogin is bool && !(bool)canLogin))
            {
                // Reject the player with the message
                Notice.Popup(connection.netUser.networkPlayer, "", canLogin is string?canLogin.ToString() : "Connection was rejected", 10f);   // TODO: Localization
                approval.Deny(uLink.NetworkConnectionError.NoError);
                return(true);
            }

            // Call the approval hooks
            var approvedSpecific  = Interface.Call("OnUserApprove", connection, approval, acceptor);
            var approvedCovalence = Interface.Call("OnUserApproved", connection.UserName, id, ip);

            return(approvedSpecific ?? approvedCovalence); // TODO: Fix 'RustLegacyCore' hook conflict when both return
        }
Exemplo n.º 10
0
        private object IOnUserApprove(ClientConnection connection, NetworkPlayerApproval approval, ConnectionAcceptor acceptor)
        {
            // Reject invalid connections
            if (connection.UserID == 0 || string.IsNullOrEmpty(connection.UserName))
            {
                approval.Deny(uLink.NetworkConnectionError.ConnectionBanned);
                return(false);
            }

            // Call out and see if we should reject
            var canlogin = Interface.CallHook("CanClientLogin", connection);

            if (canlogin is uLink.NetworkConnectionError)
            {
                approval.Deny((uLink.NetworkConnectionError)canlogin);
                return(true);
            }

            return(Interface.CallHook("OnUserApprove", connection, approval, acceptor));
        }
Exemplo n.º 11
0
        public static void SteamDeny(ClientConnection cc, NetworkPlayerApproval approval, string strReason, NetError errornum)
        {
            SteamDenyEvent sde = new SteamDenyEvent(cc, approval, strReason, errornum);

            if (OnSteamDeny != null)
            {
                OnSteamDeny(sde);
            }
            if (sde.ForceAllow)
            {
                return;
            }
            string deny = "Auth failed: " + strReason + " - " + cc.UserName + " (" +
                          cc.UserID.ToString() +
                          ")";

            ConsoleSystem.Print(deny, false);
            approval.Deny((uLink.NetworkConnectionError)errornum);
            ConnectionAcceptor.CloseConnection(cc);
            Rust.Steam.Server.OnUserLeave(cc.UserID);
        }
Exemplo n.º 12
0
        private object IOnUserApprove(ClientConnection connection, NetworkPlayerApproval approval, ConnectionAcceptor acceptor)
        {
            // Reject invalid connections
            if (connection.UserID == 0 || string.IsNullOrEmpty(connection.UserName))
            {
                approval.Deny(uLink.NetworkConnectionError.ConnectionBanned);
                return(true);
            }

            // Call out and see if we should reject
            var canlogin = Interface.CallHook("CanClientLogin", connection) ?? Interface.CallHook("CanUserLogin", connection.UserName, connection.UserID.ToString());

            if (canlogin != null)
            {
                Notice.Popup(connection.netUser.networkPlayer, "", canlogin.ToString(), 10f);
                approval.Deny(uLink.NetworkConnectionError.NoError);
                return(true);
            }

            return(Interface.CallHook("OnUserApprove", connection, approval, acceptor) ?? Interface.CallHook("OnUserApproved", connection.UserName, connection.UserID.ToString()));
        }
Exemplo n.º 13
0
    // Player tries to connect
    void uLink_OnPlayerApproval(NetworkPlayerApproval approval)
    {
        LogManager.General.Log("A player is trying to connect...check for approval");

        string accountId;
        bool   accountIdAvailable = approval.loginData.TryRead <string>(out accountId);

        // Account ID was sent
        if (restrictedAccounts)
        {
            if (accountIdAvailable)
            {
                // Is the account in our account list
                if (accountToParty.ContainsKey(accountId))
                {
                    approval.Approve();
                }
                else
                {
                    LogManager.General.Log("Denied client because the account ID '" + accountId + "' doesn't appear in the list.");
                    approval.Deny();
                }
                // Client didn't send an account ID
            }
            else
            {
                LogManager.General.Log("Denied client because he didn't send any account information.");
                approval.Deny();
                // Client isn't restricted to certain accounts (test client)
            }
        }
        else
        {
            LogManager.General.Log(string.Format("Approved client with ID '{0}' because server is not account restricted.", accountId));
            approval.Approve();
        }
    }
Exemplo n.º 14
0
 public static void ConnectionAcceptor_OnPlayerApproval(ConnectionAcceptor hook, NetworkPlayerApproval approval)
 {
     object[] args = new object[]
     {
         hook,
         approval
     };
     Method.Invoke("RustExtended.RustHook.ConnectionAcceptor_OnPlayerApproval", args);
 }
Exemplo n.º 15
0
 private static void Accept(ConnectionAcceptor ca, NetworkPlayerApproval approval, ClientConnection clientConnection)
 {
     ca.m_Connections.Add(clientConnection);
     ca.StartCoroutine(clientConnection.AuthorisationRoutine(approval));
     approval.Wait();
 }
Exemplo n.º 16
0
        private object IOnUserApprove(ClientConnection connection, NetworkPlayerApproval approval, ConnectionAcceptor acceptor)
        {
            var id = connection.UserID.ToString();
            var ip = approval.ipAddress;

            // Reject invalid connections
            if (connection.UserID == 0 || string.IsNullOrEmpty(connection.UserName))
            {
                approval.Deny(uLink.NetworkConnectionError.ConnectionBanned);
                return true;
            }

            // 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 = (string)Interface.Call("CanClientLogin", connection) ?? Interface.Call("CanUserLogin", connection.UserName, id, ip);
            if (canLogin is string)
            {
                // Reject the user with the message
                Notice.Popup(connection.netUser.networkPlayer, "", canLogin.ToString(), 10f);
                approval.Deny(uLink.NetworkConnectionError.NoError);
                return true;
            }

            return Interface.Call("OnUserApprove", connection, approval, acceptor) ?? Interface.Call("OnUserApproved", connection.UserName, id, ip);
        }
Exemplo n.º 17
0
        private object IOnUserApprove(ClientConnection connection, NetworkPlayerApproval approval, ConnectionAcceptor acceptor)
        {
            // Reject invalid connections
            if (connection.UserID == 0 || string.IsNullOrEmpty(connection.UserName))
            {
                approval.Deny(uLink.NetworkConnectionError.ConnectionBanned);
                return false;
            }

            // Call out and see if we should reject
            var canlogin = Interface.CallHook("CanClientLogin", connection);
            if (canlogin is uLink.NetworkConnectionError)
            {
                approval.Deny((uLink.NetworkConnectionError)canlogin);
                return true;
            }

            return Interface.CallHook("OnUserApprove", connection, approval, acceptor);
        }
Exemplo n.º 18
0
 private object OnUserApprove(ClientConnection connection, NetworkPlayerApproval approval, ConnectionAcceptor acceptor)
 {
     var result = Interface.CallHook("CanClientLogin", connection, approval);
     if (result is uLink.NetworkConnectionError)
     {
         approval.Deny((uLink.NetworkConnectionError)result);
         return false;
     }
     return null;
 }
Exemplo n.º 19
0
        private object IOnUserApprove(ClientConnection connection, NetworkPlayerApproval approval, ConnectionAcceptor acceptor)
        {
            // Reject invalid connections
            if (connection.UserID == 0 || string.IsNullOrEmpty(connection.UserName))
            {
                approval.Deny(uLink.NetworkConnectionError.ConnectionBanned);
                return false;
            }

            var result = Interface.CallHook("CanClientLogin", connection, approval);
            if (result is uLink.NetworkConnectionError)
            {
                approval.Deny((uLink.NetworkConnectionError)result);
                return false;
            }
            return Interface.CallHook("OnUserApprove", connection, approval, acceptor);
        }
Exemplo n.º 20
0
        private object IOnUserApprove(NetworkPlayerApproval approval, string id)
        {
            var player = NetworkController.NetManager_.ServManager.GetPlayerInfos_accountID(id);
            var ip = approval.ipAddress;

            // Call out and see if we should reject
            var canLogin = Interface.Call("CanClientLogin", approval, player) ?? Interface.Call("CanUserLogin", player.Nickname, id, ip);
            if (canLogin is string)
            {
                // Reject the user with the message
                NetworkController.NetManager_.NetView.RPC("NET_FATAL_ERROR", player.NetPlayer, canLogin);
                Network.CloseConnection(player.NetPlayer, true);
                return true;
            }

            return Interface.Call("OnUserApprove", approval, player) ?? Interface.Call("OnUserApproved", player.Nickname, id, ip);
        }
Exemplo n.º 21
0
    // Player tries to connect
    void uLink_OnPlayerApproval(NetworkPlayerApproval approval)
    {
        LogManager.General.Log("A player is trying to connect...check for approval");

        string accountId;
        bool accountIdAvailable = approval.loginData.TryRead<string>(out accountId);

        // Account ID was sent
        if(restrictedAccounts) {
            if(accountIdAvailable) {
                // Is the account in our account list
                if(accountToParty.ContainsKey(accountId)) {
                    approval.Approve();
                } else {
                    LogManager.General.Log("Denied client because the account ID '" + accountId + "' doesn't appear in the list.");
                    approval.Deny();
                }
            // Client didn't send an account ID
            } else {
                LogManager.General.Log("Denied client because he didn't send any account information.");
                approval.Deny();
            // Client isn't restricted to certain accounts (test client)
            }
        } else {
            LogManager.General.Log(string.Format("Approved client with ID '{0}' because server is not account restricted.", accountId));
            approval.Approve();
        }
    }
Exemplo n.º 22
0
 public static void PlayerApproval(ConnectionAcceptor ca, NetworkPlayerApproval approval)
 {
     if (ca.m_Connections.Count >= server.maxplayers)
     {
         approval.Deny(uLink.NetworkConnectionError.TooManyConnectedPlayers);
     }
     else
     {
         ClientConnection clientConnection = new ClientConnection();
         if (!clientConnection.ReadConnectionData(approval.loginData))
         {
             approval.Deny(uLink.NetworkConnectionError.IncorrectParameters);
             return;
         }
         Fougerite.Server srv  = Fougerite.Server.GetServer();
         ulong            uid  = clientConnection.UserID;
         string           ip   = approval.ipAddress;
         string           name = clientConnection.UserName;
         if (clientConnection.Protocol != 1069)
         {
             Debug.Log((object)("Denying entry to client with invalid protocol version (" + ip + ")"));
             approval.Deny(uLink.NetworkConnectionError.IncompatibleVersions);
         }
         else if (BanList.Contains(uid))
         {
             Debug.Log((object)("Rejecting client (" + uid.ToString() + "in banlist)"));
             approval.Deny(uLink.NetworkConnectionError.ConnectionBanned);
         }
         else if (srv.IsBannedID(uid.ToString()) || srv.IsBannedIP(ip))
         {
             if (!srv.IsBannedIP(ip))
             {
                 srv.BanPlayerIP(ip, name + "-Console");
                 Logger.LogDebug("[FougeriteBan] Detected banned ID, but IP is not banned: "
                                 + name + " - " + ip + " - " + uid);
             }
             if (!srv.IsBannedID(uid.ToString()))
             {
                 srv.BanPlayerID(uid.ToString(), name + "-Console");
                 Logger.LogDebug("[FougeriteBan] Detected banned IP, but ID is not banned: "
                                 + name + " - " + ip + " - " + uid);
             }
             Debug.Log("[FougeriteBan]  Disconnected: " + name
                       + " - " + ip + " - " + uid, null);
             Logger.LogDebug("[FougeriteBan] Disconnected: " + name
                             + " - " + ip + " - " + uid);
             approval.Deny(uLink.NetworkConnectionError.ConnectionBanned);
         }
         else if (ca.IsConnected(clientConnection.UserID))
         {
             PlayerApprovalEvent ape = new PlayerApprovalEvent(ca, approval, clientConnection, true);
             if (OnPlayerApproval != null)
             {
                 OnPlayerApproval(ape);
             }
             if (ape.ForceAccept && !ape.ServerHasPlayer)
             {
                 Accept(ca, approval, clientConnection);
                 return;
             }
             Debug.Log((object)("Denying entry to " + uid.ToString() + " because they're already connected"));
             approval.Deny(uLink.NetworkConnectionError.AlreadyConnectedToAnotherServer);
         }
         else
         {
             PlayerApprovalEvent ape = new PlayerApprovalEvent(ca, approval, clientConnection, false);
             if (OnPlayerApproval != null)
             {
                 OnPlayerApproval(ape);
             }
             Accept(ca, approval, clientConnection);
         }
     }
 }