Ejemplo n.º 1
0
 internal static void OnClientCommand(Message packet)
 {
     if (packet.get_read().get_unread() > Server.maxcommandpacketsize)
     {
         Debug.LogWarning((object)"Dropping client command due to size");
     }
     else
     {
         string str = packet.get_read().String();
         if (packet.connection == null || ((Connection)packet.connection).connected == null)
         {
             Debug.LogWarning((object)("Client without connection tried to run command: " + str));
         }
         else
         {
             ConsoleSystem.Option server = ConsoleSystem.Option.get_Server();
             ConsoleSystem.Option option = ((ConsoleSystem.Option) ref server).FromConnection((Connection)packet.connection);
             string strCommand           = ConsoleSystem.Run(((ConsoleSystem.Option) ref option).Quiet(), str, (object[])Array.Empty <object>());
             if (string.IsNullOrEmpty(strCommand))
             {
                 return;
             }
             ConsoleNetwork.SendClientReply((Connection)packet.connection, strCommand);
         }
     }
 }
Ejemplo n.º 2
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;
     }
 }
Ejemplo n.º 3
0
    public static void Load()
    {
        ServerUsers.Clear();
        string serverFolder = Server.GetServerFolder("cfg");

        if (File.Exists(serverFolder + "/bans.cfg"))
        {
            string str = File.ReadAllText(serverFolder + "/bans.cfg");
            if (!string.IsNullOrEmpty(str))
            {
                Debug.Log((object)("Running " + serverFolder + "/bans.cfg"));
                ConsoleSystem.Option server = ConsoleSystem.Option.get_Server();
                ConsoleSystem.RunFile(((ConsoleSystem.Option) ref server).Quiet(), str);
            }
        }
        if (!File.Exists(serverFolder + "/users.cfg"))
        {
            return;
        }
        string str1 = File.ReadAllText(serverFolder + "/users.cfg");

        if (string.IsNullOrEmpty(str1))
        {
            return;
        }
        Debug.Log((object)("Running " + serverFolder + "/users.cfg"));
        ConsoleSystem.Option server1 = ConsoleSystem.Option.get_Server();
        ConsoleSystem.RunFile(((ConsoleSystem.Option) ref server1).Quiet(), str1);
    }
Ejemplo n.º 4
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;
     }
 }
 public static void RunFile(ConsoleSystem.Option options, string strFile)
 {
     string[] strArrays = strFile.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
     for (int i = 0; i < (int)strArrays.Length; i++)
     {
         string str = strArrays[i];
         if (str[0] != '#')
         {
             ConsoleSystem.Run(options, str, Array.Empty <object>());
         }
     }
     ConsoleSystem.HasChanges = false;
 }
Ejemplo n.º 6
0
 private object IOnRunCommandLine()
 {
     foreach (KeyValuePair <string, string> pair in Facepunch.CommandLine.GetSwitches())
     {
         string value = pair.Value;
         if (value == "")
         {
             value = "1";
         }
         string str = pair.Key.Substring(1);
         ConsoleSystem.Option options = ConsoleSystem.Option.Unrestricted;
         options.PrintOutput = false;
         ConsoleSystem.Run(options, str, value);
     }
     return(false);
 }
    public static string Run(ConsoleSystem.Option options, string strCommand, params object[] args)
    {
        ConsoleSystem.LastError = null;
        string str = ConsoleSystem.BuildCommand(strCommand, args);

        ConsoleSystem.Arg arg = new ConsoleSystem.Arg(options, str);
        bool flag             = arg.HasPermission();

        if (!arg.Invalid & flag)
        {
            ConsoleSystem.Arg currentArgs = ConsoleSystem.CurrentArgs;
            ConsoleSystem.CurrentArgs = arg;
            bool flag1 = ConsoleSystem.Internal(arg);
            ConsoleSystem.CurrentArgs = currentArgs;
            if (options.PrintOutput & flag1 && arg.Reply != null && arg.Reply.Length > 0)
            {
                DebugEx.Log(arg.Reply, StackTraceLogType.None);
            }
            return(arg.Reply);
        }
        ConsoleSystem.LastError = "Command not found";
        if (!flag)
        {
            ConsoleSystem.LastError = "Permission denied";
        }
        if (options.IsServer || options.ForwardtoServerOnMissing && ConsoleSystem.SendToServer(str))
        {
            if (options.IsServer && options.PrintOutput)
            {
                ConsoleSystem.LastError = string.Concat("Command '", strCommand, "' not found");
                DebugEx.Log(ConsoleSystem.LastError, StackTraceLogType.None);
            }
            return(null);
        }
        ConsoleSystem.LastError = string.Concat("Command '", strCommand, "' not found");
        if (options.PrintOutput)
        {
            DebugEx.Log(ConsoleSystem.LastError, StackTraceLogType.None);
        }
        return(null);
    }
    internal static void OnClientCommand(Message packet)
    {
        if (packet.read.Unread > ConVar.Server.maxcommandpacketsize)
        {
            Debug.LogWarning("Dropping client command due to size");
            return;
        }
        string str = packet.read.String();

        if (packet.connection == null || !packet.connection.connected)
        {
            Debug.LogWarning(string.Concat("Client without connection tried to run command: ", str));
            return;
        }
        ConsoleSystem.Option server = ConsoleSystem.Option.Server;
        server = server.FromConnection(packet.connection);
        string str1 = ConsoleSystem.Run(server.Quiet(), str, Array.Empty <object>());

        if (!string.IsNullOrEmpty(str1))
        {
            ConsoleNetwork.SendClientReply(packet.connection, str1);
        }
    }
 internal Arg(ConsoleSystem.Option options, string rconCommand)
 {
     this.Option = options;
     this.BuildCommand(rconCommand);
 }
Ejemplo n.º 10
0
 public void CancelLoading()
 {
     ConsoleSystem.Option client = ConsoleSystem.Option.get_Client();
     ConsoleSystem.Run(((ConsoleSystem.Option) ref client).Quiet(), "client.disconnect", (object[])Array.Empty <object>());
 }