Ejemplo n.º 1
0
        public void AuthenticateTestEmptyPassword()
        {
            RconBase client = new RconBase();

            client.Connect(Host, Port);
            client.Authenticate("");
        }
Ejemplo n.º 2
0
        public void AuthenticateTestNullPassword()
        {
            RconBase client = new RconBase();

            client.Connect(Host, Port);
            client.Authenticate(null);
        }
Ejemplo n.º 3
0
        public void ConnectTest()
        {
            RconBase client = new RconBase();

            Assert.IsTrue(client.Connect(Host, Port));
            Assert.IsTrue(client.Connected);
            client.Disconnect();
        }
Ejemplo n.º 4
0
        public void AuthenticateTest()
        {
            RconBase client = new RconBase();

            client.Connect(Host, Port);
            Assert.IsTrue(client.Authenticate(Password));
            Assert.IsTrue(client.Authenticated);
            client.Disconnect();
        }
Ejemplo n.º 5
0
        public void SendReceiveTest()
        {
            RconBase client = new RconBase();

            client.Connect(Host, Port);
            client.Authenticate(Password);
            RconPacket request  = new RconPacket(PacketType.ServerdataExeccommand, new Rcon.Commands.ListPlayers().ToString());
            RconPacket response = client.SendReceive(request);

            Assert.IsInstanceOfType(response, typeof(RconPacket));
            Assert.AreEqual(request.Id, response.Id);
            client.Disconnect();
        }
Ejemplo n.º 6
0
        public static void Connect(ArkServerInfo Server)
        {
            RconBase client = new RconBase();

            client.Connect(Server.IPAddress, Int32.Parse(Server.RCONPort));

            if (client.Connected)
            {
                client.Authenticate(Server.ServerPassword);
                //Console.WriteLine(DateTime.Now + ": Client has been successfully connected!");
                Methods.Log(Server, DateTime.Now + ": Client has been successfully connected!");
            }
            if (!client.Connected)
            {
                //Console.WriteLine(DateTime.Now + ": Client can't connect successfully!");
                Methods.Log(Server, DateTime.Now + ": Client can't connect successfully!");
            }
            client.Disconnect();
        }
Ejemplo n.º 7
0
 public static void ShutdownServer(ArkServerInfo Server)
 {
     try
     {
         RconBase client = new RconBase();
         client.Connect(Server.IPAddress, Int32.Parse(Server.RCONPort));
         if (client.Connected)
         {
             client.Authenticate(Server.ServerPassword);
             RconPacket request  = new RconPacket(PacketType.ServerdataExeccommand, new Rcon.Commands.DoExit().ToString());
             RconPacket response = client.SendReceive(request);
             Console.WriteLine(response?.Body.Trim());
             Methods.Log(Server, response?.Body.Trim());
         }
         client.Disconnect();
     }
     catch (Exception ex)
     {
         //Console.WriteLine(DateTime.Now + ": Exception occured when trying to send a Ark Server Shutdown Command. Exception: " + ex.Message);
         Methods.Log(Server, DateTime.Now + ": Exception occured when trying to send a Ark Server Shutdown Command. Exception: " + ex.Message);
     }
 }
Ejemplo n.º 8
0
        public static bool WorldSave(ArkServerInfo Server)
        {
            RconBase client = new RconBase();

            client.Connect(Server.IPAddress, Int32.Parse(Server.RCONPort));
            if (client.Connected)
            {
                client.Authenticate(Server.ServerPassword);
                RconPacket request        = new RconPacket(PacketType.ServerdataExeccommand, new Rcon.Commands.SaveWorld().ToString());
                RconPacket response       = client.SendReceive(request);
                string     stringResponse = response?.Body.Trim();
                if (stringResponse.Contains("World Saved"))
                {
                    Console.WriteLine(DateTime.Now + ": Server " + Server.Name + "- World Saved!");
                    Methods.Log(Server, DateTime.Now + ": Server " + Server.Name + "- World Saved!");
                    client.Disconnect();
                    return(true);
                }
            }
            client.Disconnect();
            return(false);
        }
Ejemplo n.º 9
0
        public static void GlobalNotification(ArkServerInfo Server, string message)
        {
            try
            {
                RconBase client = new RconBase();
                client.Connect(Server.IPAddress, Int32.Parse(Server.RCONPort));
                if (client.Connected)
                {
                    client.Authenticate(Server.ServerPassword);
                    RconPacket request  = new RconPacket(PacketType.ServerdataExeccommand, new Rcon.Commands.Broadcast(message).ToString());
                    RconPacket response = client.SendReceive(request);
                    //Console.WriteLine(DateTime.Now + ": Broadcast sent to " + Server.Name + " Server Message: " + message);
                    Methods.Log(Server, DateTime.Now + ": Broadcast sent to " + Server.Name + " Server Message: " + message);
                }

                client.Disconnect();
            }
            catch (Exception ex)
            {
                //Console.WriteLine(DateTime.Now + ": Exception occured when trying to send an Ark Server Global Notification. Exception: " + ex.Message);
                Methods.Log(Server, DateTime.Now + ": Exception occured when trying to send an Ark Server Global Notification. Exception: " + ex.Message);
            }
        }
Ejemplo n.º 10
0
        public void ConnectTestInvalidPort()
        {
            RconBase client = new RconBase();

            client.Connect(Host, 66666);
        }
Ejemplo n.º 11
0
        public void ConnectTestNegativePort()
        {
            RconBase client = new RconBase();

            client.Connect(Host, -1);
        }
Ejemplo n.º 12
0
        public void ConnectTestEmptyHost()
        {
            RconBase client = new RconBase();

            client.Connect("", Port);
        }
Ejemplo n.º 13
0
        public void ConnectTestNullHost()
        {
            RconBase client = new RconBase();

            client.Connect(null, Port);
        }
Ejemplo n.º 14
0
        public void AuthenticateTestNotConnected()
        {
            RconBase client = new RconBase();

            client.Authenticate(Password);
        }