Exemple #1
0
 public static void Update()
 {
     lock (RCon.Commands)
     {
         while (RCon.Commands.Count > 0)
         {
             RCon.OnCommand(RCon.Commands.Dequeue());
         }
     }
     if (RCon.listener == null)
     {
         return;
     }
     if (RCon.lastRunTime + 0.02f >= UnityEngine.Time.realtimeSinceStartup)
     {
         return;
     }
     RCon.lastRunTime = UnityEngine.Time.realtimeSinceStartup;
     try
     {
         RCon.bannedAddresses.RemoveAll((RCon.BannedAddresses x) => x.banTime < UnityEngine.Time.realtimeSinceStartup);
         RCon.listener.Cycle();
     }
     catch (Exception exception)
     {
         Debug.LogWarning("Rcon Exception");
         Debug.LogException(exception);
     }
 }
Exemple #2
0
            private void ProcessConnections()
            {
                if (!this.server.Pending())
                {
                    return;
                }
                Socket socket = this.server.AcceptSocket();

                if (socket == null)
                {
                    return;
                }
                IPEndPoint remoteEndPoint = socket.RemoteEndPoint as IPEndPoint;

                if (Interface.CallHook("OnRconConnection", remoteEndPoint) != null)
                {
                    socket.Close();
                    return;
                }
                if (!RCon.IsBanned(remoteEndPoint.Address))
                {
                    this.clients.Add(new RCon.RConClient(socket));
                    return;
                }
                Debug.Log(string.Concat("[RCON] Ignoring connection - banned. ", remoteEndPoint.Address.ToString()));
                socket.Close();
            }
Exemple #3
0
 private static void OnCommand(RCon.Command cmd)
 {
     try
     {
         RCon.responseIdentifier = cmd.Identifier;
         RCon.responseConnection = cmd.ConnectionId;
         RCon.isInput            = true;
         if (RCon.Print)
         {
             Debug.Log(string.Concat(new object[] { "[rcon] ", cmd.Ip, ": ", cmd.Message }));
         }
         RCon.isInput = false;
         ConsoleSystem.Option server = ConsoleSystem.Option.Server;
         string str = ConsoleSystem.Run(server.Quiet(), cmd.Message, Array.Empty <object>());
         if (str != null)
         {
             RCon.OnMessage(str, string.Empty, UnityEngine.LogType.Log);
         }
     }
     finally
     {
         RCon.responseIdentifier = 0;
         RCon.responseConnection = string.Empty;
     }
 }
Exemple #4
0
            private void ProcessConnections()
            {
                if (!this.server.Pending())
                {
                    return;
                }
                Socket cl = this.server.AcceptSocket();

                if (cl == null)
                {
                    return;
                }
                IPEndPoint remoteEndPoint = cl.RemoteEndPoint as IPEndPoint;

                if (Interface.CallHook("OnRconConnection", (object)remoteEndPoint) != null)
                {
                    cl.Close();
                }
                else if (RCon.IsBanned(remoteEndPoint.Address))
                {
                    Debug.Log((object)("[RCON] Ignoring connection - banned. " + remoteEndPoint.Address.ToString()));
                    cl.Close();
                }
                else
                {
                    this.clients.Add(new RCon.RConClient(cl));
                }
            }
Exemple #5
0
 private static void OnCommand(RCon.Command cmd)
 {
     try
     {
         RCon.responseIdentifier = cmd.Identifier;
         RCon.responseConnection = cmd.ConnectionId;
         RCon.isInput            = true;
         if (RCon.Print)
         {
             Debug.Log((object)("[rcon] " + (object)cmd.Ip + ": " + cmd.Message));
         }
         RCon.isInput = false;
         ConsoleSystem.Option server = ConsoleSystem.Option.get_Server();
         string message = ConsoleSystem.Run(((ConsoleSystem.Option) ref server).Quiet(), cmd.Message, (object[])Array.Empty <object>());
         if (message == null)
         {
             return;
         }
         RCon.OnMessage(message, string.Empty, (UnityEngine.LogType) 3);
     }
     finally
     {
         RCon.responseIdentifier = 0;
         RCon.responseConnection = string.Empty;
     }
 }
Exemple #6
0
 public static void Update()
 {
     lock (RCon.Commands)
     {
         while (RCon.Commands.Count > 0)
         {
             RCon.OnCommand(RCon.Commands.Dequeue());
         }
     }
     if (RCon.listener == null || (double)RCon.lastRunTime + 0.0199999995529652 >= (double)Time.get_realtimeSinceStartup())
     {
         return;
     }
     RCon.lastRunTime = Time.get_realtimeSinceStartup();
     try
     {
         RCon.bannedAddresses.RemoveAll((Predicate <RCon.BannedAddresses>)(x => (double)x.banTime < (double)Time.get_realtimeSinceStartup()));
         RCon.listener.Cycle();
     }
     catch (Exception ex)
     {
         Debug.LogWarning((object)"Rcon Exception");
         Debug.LogException(ex);
     }
 }
Exemple #7
0
 internal bool HandleMessage_UnAuthed(int type, string msg)
 {
     if (type != RCon.SERVERDATA_AUTH)
     {
         RCon.BanIP((this.socket.RemoteEndPoint as IPEndPoint).Address, 60f);
         this.Close("Invalid Command - Not Authed");
         return(false);
     }
     this.Reply(this.lastMessageID, RCon.SERVERDATA_RESPONSE_VALUE, "");
     this.isAuthorised = RCon.Password == msg;
     if (!this.isAuthorised)
     {
         this.Reply(-1, RCon.SERVERDATA_AUTH_RESPONSE, "");
         RCon.BanIP((this.socket.RemoteEndPoint as IPEndPoint).Address, 60f);
         this.Close("Invalid Password");
         return(true);
     }
     this.Reply(this.lastMessageID, RCon.SERVERDATA_AUTH_RESPONSE, "");
     Debug.Log(string.Concat("[RCON] Auth: ", this.connectionName));
     Output.OnMessage += new Action <string, string, UnityEngine.LogType>(this.Output_OnMessage);
     return(true);
 }