Exemple #1
0
 public static void Shutdown()
 {
     if (RCon.listenerNew != null)
     {
         RCon.listenerNew.Shutdown();
         RCon.listenerNew = null;
     }
     if (RCon.listener != null)
     {
         RCon.listener.Shutdown();
         RCon.listener = null;
     }
 }
Exemple #2
0
 public static void Shutdown()
 {
     if (RCon.listenerNew != null)
     {
         RCon.listenerNew.Shutdown();
         RCon.listenerNew = (Listener)null;
     }
     if (RCon.listener == null)
     {
         return;
     }
     RCon.listener.Shutdown();
     RCon.listener = (RCon.RConListener)null;
 }
Exemple #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));
 }
Exemple #4
0
 static RCon()
 {
     RCon.Password                  = "";
     RCon.Port                      = 0;
     RCon.Ip                        = "";
     RCon.Web                       = true;
     RCon.Print                     = false;
     RCon.listener                  = null;
     RCon.listenerNew               = null;
     RCon.Commands                  = new Queue <RCon.Command>();
     RCon.lastRunTime               = 0f;
     RCon.bannedAddresses           = new List <RCon.BannedAddresses>();
     RCon.SERVERDATA_AUTH           = 3;
     RCon.SERVERDATA_EXECCOMMAND    = 2;
     RCon.SERVERDATA_AUTH_RESPONSE  = 2;
     RCon.SERVERDATA_RESPONSE_VALUE = 0;
     RCon.SERVERDATA_CONSOLE_LOG    = 4;
     RCon.SERVERDATA_SWITCH_UTF8    = 5;
 }