Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Console.BackgroundColor = ConsoleColor.DarkBlue;
            Console.ForegroundColor = ConsoleColor.White;
            Console.Clear();

            centerText("------------------------------------------------------");
            centerText("| This program is heavily inspired and based on Coob |");
            centerText("|   Coob and CWSRestart are licensed under the GPL   |");
            centerText("------------------------------------------------------");
            Console.WriteLine();
            Console.WriteLine("You can start this program with CubeWorldMITM [port1] [port2] [internal ip] [server ip]");
            Console.WriteLine("\t [port1] - the port on which the MITM server should listen");
            Console.WriteLine("\t \t - default 12345");
            Console.WriteLine();
            Console.WriteLine("\t [port2] - the port on which the cubeworld server is listening");
            Console.WriteLine("\t \t - default 12346");
            Console.WriteLine();
            Console.WriteLine("\t [internal ip] - the ip on wich the MITM should listen");
            Console.WriteLine("\t \t - defaults to any IP");
            Console.WriteLine();
            Console.WriteLine("\t [server ip] - the ip on wich the CubeWorld Server is listening");
            Console.WriteLine("\t \t - defaults to loopback");
            Console.WriteLine();
            Console.WriteLine();

            parseSettings(args);

            if (Helper.Settings.Instance.StartServer == true)
            {
                if (File.Exists(Helper.Settings.Instance.ServerLocation))
                    Helper.Launcher.LaunchServerConfigured(Helper.Settings.Instance.ServerLocation);
                else
                    Console.WriteLine("The specified file does not exist: {0}", Helper.Settings.Instance.ServerLocation);

                Console.WriteLine();
                Console.WriteLine();
            }

            accessManager = new Helper.AccessManager(ref ConnectedPlayers, ref PremiumPlayers);
            mitm = new TcpListener(mitmIP, (int)port);

            Thread listenerThread = new Thread(new ThreadStart(ConnectionLoop));
            listenerThread.Start();

            messageLoop();

            shouldExit = true;

            Dictionary<string, MITMMessageHandler> tmp = new Dictionary<string, MITMMessageHandler>(ConnectedPlayers);
            foreach (KeyValuePair<string, MITMMessageHandler> h in tmp)
                if (h.Value.Connected)
                    h.Value.Disconnect();

            listenerThread.Abort();
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Console.BackgroundColor = ConsoleColor.DarkBlue;
            Console.ForegroundColor = ConsoleColor.White;
            Console.Clear();

            centerText("------------------------------------------------------");
            centerText("| This program is heavily inspired and based on Coob |");
            centerText("|   Coob and CWSRestart are licensed under the GPL   |");
            centerText("------------------------------------------------------");
            Console.WriteLine();
            Console.WriteLine("You can start this program with CubeWorldMITM [port1] [port2] [internal ip] [server ip]");
            Console.WriteLine("\t [port1] - the port on which the MITM server should listen");
            Console.WriteLine("\t \t - default 12345");
            Console.WriteLine();
            Console.WriteLine("\t [port2] - the port on which the cubeworld server is listening");
            Console.WriteLine("\t \t - default 12346");
            Console.WriteLine();
            Console.WriteLine("\t [internal ip] - the ip on wich the MITM should listen");
            Console.WriteLine("\t \t - defaults to any IP");
            Console.WriteLine();
            Console.WriteLine("\t [server ip] - the ip on wich the CubeWorld Server is listening");
            Console.WriteLine("\t \t - defaults to loopback");
            Console.WriteLine();
            Console.WriteLine();

            parseSettings(args);

            if (Helper.Settings.Instance.StartServer == true)
            {
                if (File.Exists(Helper.Settings.Instance.ServerLocation))
                {
                    Helper.Launcher.LaunchServerConfigured(Helper.Settings.Instance.ServerLocation);
                }
                else
                {
                    Console.WriteLine("The specified file does not exist: {0}", Helper.Settings.Instance.ServerLocation);
                }

                Console.WriteLine();
                Console.WriteLine();
            }

            accessManager = new Helper.AccessManager(ref ConnectedPlayers, ref PremiumPlayers);
            mitm          = new TcpListener(mitmIP, (int)port);

            Thread listenerThread = new Thread(new ThreadStart(ConnectionLoop));

            listenerThread.Start();

            messageLoop();

            shouldExit = true;

            Dictionary <string, MITMMessageHandler> tmp = new Dictionary <string, MITMMessageHandler>(ConnectedPlayers);

            foreach (KeyValuePair <string, MITMMessageHandler> h in tmp)
            {
                if (h.Value.Connected)
                {
                    h.Value.Disconnect();
                }
            }

            listenerThread.Abort();
        }