Пример #1
0
 public FileOutputTarget(string path)
 {
     file   = new StreamWriter(path, true);
     thread = new ProgramThread("LogF", OutputThread);
     thread.IsBackground = false;
     thread.Start();
 }
 public FileOutputTarget(string path)
 {
     file = new StreamWriter (path, true);
     thread = new ProgramThread ("LogF", OutputThread);
     thread.IsBackground = false;
     thread.Start ();
 }
        static ClientConnection()
        {
            time.Start();

            All = new List<ClientConnection> ();

            var thread = new ProgramThread ("TmoL", TimeoutLoop);
            thread.IsBackground = true;
            thread.Start ();
        }
Пример #4
0
        static ClientConnection()
        {
            time.Start();

            All = new List <ClientConnection>();

            var thread = new ProgramThread("TmoL", TimeoutLoop);

            thread.IsBackground = true;
            thread.Start();
        }
Пример #5
0
 private void Initialize()
 {
     mystream               = new NetworkStream(listenersocket, true);
     myprocessor            = new ASMProcessorRS(new GetMatrixFromFar(this.GetMatrixIntoMemory));
     myprocessor.raiseerror = new RaiseError(this.SendError);
     myprocessor.currentcode.matrixmemory = new Matrix[matrixmemsize];
     myprocessor.currentcode.matrixstate  = new MatrixState[matrixmemsize];
     myprocessor.currentcode.literals     = new string[0];
     myprocessor.currentcode.bus          = this;
     memlist        = new ArrayList();
     mthread        = new ProgramThread();
     mthread.pstack = new double[RemoteMachine.threadstacksize, 2];
 }
Пример #6
0
        public static void Start(string dbPath)
        {
            LoginDatabase = new PropertiesFile(dbPath);
            LoginDatabase.Load();

            if (LoginDatabase.Count == 0)
            {
                var bytes = new byte[8];
                (new Random((int)DateTime.Now.Ticks)).NextBytes(bytes);

                string password = String.Format("{0:x2}{1:x2}-{2:x2}{3:x2}-{4:x2}{5:x2}-{6:x2}{7:x2}",
                                                bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], bytes[5], bytes[6], bytes[7]);
                string login = "******";
                ProgramLog.Admin.Log("The rcon login database was empty, a new user \"{1}\" has been created with password: {0}", password, login);

                LoginDatabase.setValue(login, Hash(login, password));
            }

            LoginDatabase.Save();

            var       bind  = Program.properties.RConBindAddress;
            var       split = bind.Split(':');
            IPAddress addr;
            ushort    port;

            if (split.Length != 2 || !IPAddress.TryParse(split[0], out addr) || !ushort.TryParse(split[1], out port) || port < 1)
            {
                ProgramLog.Error.Log("{0} is not a valid bind address, remote console disabled.", bind);
                return;
            }

            listener = new TcpListener(addr, port);

            try
            {
                listener.Start();
            }
            catch (Exception)
            {
                ProgramLog.Error.Log("Failed to bind to address {0}, remote console disabled.", bind);
                //ProgramLog.Log (exception, "Failed to bind to address 127.0.0.1:" + 7776);
                return;
            }

            thread = new ProgramThread("RCon", RConLoop);
            thread.Start();
        }
Пример #7
0
        public static void StartServer()
        {
            //var ctx = new HookContext
            //{
            //    Sender = new ConsoleSender(),
            //};

            //var args = new HookArgs.ServerStateChange
            //{
            //    ServerChangeState = ServerState.STARTING
            //};

            //HookPoints.ServerStateChange.Invoke(ref ctx, ref args);

            if (serverThread == null)
            {
                serverThread = new ProgramThread("Serv", ServerLoopLoop);
                serverThread.Start();
            }
            Netplay.disconnect = false;
        }
Пример #8
0
        public void ProcessFile(string filename)
        {
            Console.WriteLine("Loading Program --- {0}.....", filename);
            localprocessor.currentcode = LoadFile(filename);

            localprocessor.currentcode.matrixmemory = new ASMMath.Matrix[matrixmemsize];
            localprocessor.currentcode.bus          = this;

            ProgramThread mthread = new ProgramThread();

            mthread.inspointer   = 0;
            mthread.endthread    = localprocessor.currentcode.instructions.Length - 1;
            mthread.stackpointer = -1;
            mthread.pstack       = new double[threadstacksize, 2];

            RemoteProcessorsManager.SendNumConstants(ref localprocessor.currentcode);
            RemoteProcessorsManager.SendLiterals(ref localprocessor.currentcode);

            Console.WriteLine("Start running....");
            localprocessor.raiseerror = new RaiseError(this.ErrorEvent);
            localprocessor.Process(ref mthread);
        }
 public InteractiveLogTarget(string name, TextWriter writer)
 {
     this.writer = writer;
     thread = new ProgramThread (name, OutputThread);
     thread.Start ();
 }
        public static void Start(string dbPath)
        {
            LoginDatabase = new PropertiesFile(dbPath);
            LoginDatabase.Load();

            if (String.IsNullOrEmpty(Entry.RConHashNonce))
            {
                var nonceFile = Path.Combine(Globals.DataPath, "rcon.nonce");

                if (File.Exists(nonceFile))
                    Entry.RConHashNonce = File.ReadAllText(nonceFile);

                if (String.IsNullOrEmpty(Entry.RConHashNonce))
                {
                    ProgramLog.Admin.Log("The rcon nonce value has not been set, one is being generated...");
                    var rand = new Random(Main.rand.Next(Int32.MinValue, Int32.MaxValue));
                    var length = rand.Next(12, 32);
                    var sb = new StringBuilder(length);

                    while (sb.Length != length)
                    {
                        System.Threading.Thread.Sleep(rand.Next(0, 200));

                        var chr = (char)(byte)rand.Next(0x20, 0x7E);
                        sb.Append(chr);
                    }
                    Entry.RConHashNonce = sb.ToString();
                    File.WriteAllText(nonceFile, Entry.RConHashNonce);
                    ProgramLog.Admin.Log("Saved nonce to {0}", nonceFile);
                }
            }

            if (LoginDatabase.Count == 0)
            {
                var bytes = new byte[8];
                (new Random((int)DateTime.Now.Ticks)).NextBytes(bytes);

                string password = String.Format("{0:x2}{1:x2}-{2:x2}{3:x2}-{4:x2}{5:x2}-{6:x2}{7:x2}",
                    bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], bytes[5], bytes[6], bytes[7]);
                string login = "******";
                ProgramLog.Admin.Log("The rcon login database was empty, a new user \"{1}\" has been created with password: {0}", password, login);

                LoginDatabase.SetValue(login, Hash(login, password));
            }

            LoginDatabase.Save();

            var bind = Entry.RConBindAddress;
            var split = bind.Split(':');
            IPAddress addr;
            ushort port;

            if (split.Length != 2 || !IPAddress.TryParse(split[0], out addr) || !ushort.TryParse(split[1], out port) || port < 1)
            {
                ProgramLog.Error.Log("{0} is not a valid bind address, remote console disabled.", bind);
                return;
            }

            listener = new TcpListener(addr, port);

            try
            {
                listener.Start();
            }
            catch (Exception)
            {
                ProgramLog.Error.Log("Failed to bind to address {0}, remote console disabled.", bind);
                //ProgramLog.Log (exception, "Failed to bind to address 127.0.0.1:" + 7776);
                return;
            }

            thread = new ProgramThread("RCon", RConLoop);
            thread.Start();
        }
Пример #11
0
 public InteractiveLogTarget(string name, TextWriter writer)
 {
     this.writer = writer;
     thread      = new ProgramThread(name, OutputThread);
     thread.Start();
 }
        public static void Start(string dbPath)
        {
            LoginDatabase = new PropertiesFile (dbPath);
            LoginDatabase.Load ();

            if (LoginDatabase.Count == 0)
            {
                var bytes = new byte [8];
                (new Random ((int) DateTime.Now.Ticks)).NextBytes (bytes);

                string password = String.Format ("{0:x2}{1:x2}-{2:x2}{3:x2}-{4:x2}{5:x2}-{6:x2}{7:x2}",
                    bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], bytes[5], bytes[6], bytes[7]);
                string login = "******";
                ProgramLog.Admin.Log ("The rcon login database was empty, a new user \"{1}\" has been created with password: {0}", password, login);

                LoginDatabase.setValue (login, Hash (login, password));
            }

            LoginDatabase.Save ();

            var bind = Program.properties.RConBindAddress;
            var split = bind.Split(':');
            IPAddress addr;
            ushort port;

            if (split.Length != 2 || !IPAddress.TryParse (split[0], out addr) || !ushort.TryParse (split[1], out port) || port < 1)
            {
                ProgramLog.Error.Log ("{0} is not a valid bind address, remote console disabled.", bind);
                return;
            }

            listener = new TcpListener (addr, port);

            try
            {
                listener.Start();
            }
            catch (Exception)
            {
                ProgramLog.Error.Log ("Failed to bind to address {0}, remote console disabled.", bind);
                //ProgramLog.Log (exception, "Failed to bind to address 127.0.0.1:" + 7776);
                return;
            }

            thread = new ProgramThread ("RCon", RConLoop);
            thread.Start ();
        }
        public static void Start(string dbPath)
        {
            LoginDatabase = new PropertiesFile(dbPath);
            LoginDatabase.Load();

            if (String.IsNullOrEmpty(_nonce))
            {
                var nonceFile = Path.Combine(Globals.DataPath, "rcon.nonce");

                if (File.Exists(nonceFile))
                {
                    _nonce = File.ReadAllText(nonceFile);
                }

                if (String.IsNullOrEmpty(_nonce))
                {
                    ProgramLog.Admin.Log("The rcon nonce value has not been set, one is being generated...");
                    var rand   = new Random(Main.rand.Next(Int32.MinValue, Int32.MaxValue));
                    var length = rand.Next(12, 32);
                    var sb     = new StringBuilder(length);

                    while (sb.Length != length)
                    {
                        System.Threading.Thread.Sleep(rand.Next(0, 200));

                        var chr = (char)(byte)rand.Next(0x20, 0x7E);
                        sb.Append(chr);
                    }
                    _nonce = sb.ToString();
                    File.WriteAllText(nonceFile, _nonce);
                    ProgramLog.Admin.Log("Saved nonce to {0}", nonceFile);
                }
            }

            if (LoginDatabase.Count == 0)
            {
                var bytes = new byte[8];
                (new Random((int)DateTime.Now.Ticks)).NextBytes(bytes);

                string password = String.Format("{0:x2}{1:x2}-{2:x2}{3:x2}-{4:x2}{5:x2}-{6:x2}{7:x2}",
                                                bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], bytes[5], bytes[6], bytes[7]);
                string login = "******";
                ProgramLog.Admin.Log("The rcon login database was empty, a new user \"{1}\" has been created with password: {0}", password, login);

                LoginDatabase.SetValue(login, Hash(login, password));
            }

            LoginDatabase.Save();

            var       bind  = _bindAddress;
            var       split = bind.Split(':');
            IPAddress addr;
            ushort    port;

            if (split.Length != 2 || !IPAddress.TryParse(split[0], out addr) || !ushort.TryParse(split[1], out port) || port < 1)
            {
                ProgramLog.Error.Log("{0} is not a valid bind address, remote console disabled.", bind);
                return;
            }

            listener = new TcpListener(addr, port);

            try
            {
                listener.Start();
            }
            catch (Exception)
            {
                ProgramLog.Error.Log("Failed to bind to address {0}, remote console disabled.", bind);
                //ProgramLog.Log (exception, "Failed to bind to address 127.0.0.1:" + 7776);
                return;
            }

            thread = new ProgramThread("RCon", RConLoop);
            thread.Start();
        }
        public static void StartServer()
        {
            //var ctx = new HookContext
            //{
            //    Sender = new ConsoleSender(),
            //};

            //var args = new HookArgs.ServerStateChange
            //{
            //    ServerChangeState = ServerState.STARTING
            //};

            //HookPoints.ServerStateChange.Invoke(ref ctx, ref args);

            if (serverThread == null)
            {
                serverThread = new ProgramThread("Serv", ServerLoopLoop);
                serverThread.Start();
            }
            Netplay.disconnect = false;
        }
Пример #15
0
 public RemoteProcessor()
 {
     mthread = new ProgramThread();
     state   = RemoteProcessorStates.STOP;
 }