Exemplo n.º 1
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;
     }
 }
Exemplo 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((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;
     }
 }
Exemplo n.º 3
0
 public static void Initialize()
 {
     if (Interface.CallHook("IOnRconInitialize") != null)
     {
         return;
     }
     if (RCon.Port == 0)
     {
         RCon.Port = Server.port;
     }
     RCon.Password = Facepunch.CommandLine.GetSwitch("-rcon.password", Facepunch.CommandLine.GetSwitch("+rcon.password", ""));
     if (RCon.Password == "password")
     {
         return;
     }
     if (RCon.Password == "")
     {
         return;
     }
     Output.OnMessage += new Action <string, string, UnityEngine.LogType>(RCon.OnMessage);
     if (!RCon.Web)
     {
         RCon.listener = new RCon.RConListener();
         Debug.Log(string.Concat("RCon Started on ", RCon.Port));
         Debug.Log("Source style TCP Rcon is deprecated. Please switch to Websocket Rcon before it goes away.");
         return;
     }
     RCon.listenerNew = new Listener();
     if (!string.IsNullOrEmpty(RCon.Ip))
     {
         RCon.listenerNew.Address = RCon.Ip;
     }
     RCon.listenerNew.Password               = RCon.Password;
     RCon.listenerNew.Port                   = RCon.Port;
     RCon.listenerNew.SslCertificate         = Facepunch.CommandLine.GetSwitch("-rcon.ssl", null);
     RCon.listenerNew.SslCertificatePassword = Facepunch.CommandLine.GetSwitch("-rcon.sslpwd", null);
     RCon.listenerNew.OnMessage              = (IPEndPoint ip, string id, string msg) => {
         lock (RCon.Commands)
         {
             RCon.Command command = JsonConvert.DeserializeObject <RCon.Command>(msg);
             command.Ip           = ip;
             command.ConnectionId = id;
             RCon.Commands.Enqueue(command);
         }
     };
     RCon.listenerNew.Start();
     Debug.Log(string.Concat("WebSocket RCon Started on ", RCon.Port));
 }