예제 #1
0
        public override void ParsePayload(int payloadSize, Stream stream)
        {
            base.ParsePayload(payloadSize, stream);
            byte[] buffer = new byte[payloadSize];

            Utils.ReadFull(stream, buffer, payloadSize);
            cryptor.Write(buffer, 0, buffer.Length);
            cryptor.Decrypt(buffer, 0, buffer.Length);
            string str = Encoding.UTF8.GetString(buffer);

            Payload = AuthInfo.FromString(Account.FromString(str), str);
        }
예제 #2
0
        /// <summary>
        /// Read the list of bots from the configuration file.
        /// </summary>
        private void ReadBotsFromConfigFile()
        {
            using (StreamReader file = new StreamReader(new FileStream(configFile, FileMode.Open)))
            {
                string line = null;
                while ((line = file.ReadLine()) != null)
                {
                    if (String.IsNullOrEmpty(line))
                    {
                        break;
                    }

                    if (line.StartsWith("#"))
                    {
                        continue;
                    }

                    try
                    {
                        string[] data = line.Split(new char[] { '=' }, 2, StringSplitOptions.None);
                        Type     type = Type.GetType("VTankBotRunner." + data[0].Trim());
                        if (type == null)
                        {
                            type = Type.GetType(data[0].Trim());
                            if (type == null)
                            {
                                throw new Exception("Bot type does not exist.");
                            }
                        }

                        AuthInfo auth = AuthInfo.FromString(data[1].Trim());
                        runner.Register(type, auth, null);

                        InsertTextIntoConsole(String.Format("Adding bot: {0}", auth.Username));
                    }
                    catch (Exception e)
                    {
                        Console.Error.WriteLine(
                            "Warning: Found corrupted bot in file: {0}", e);
                    }
                }
            }
        }
예제 #3
0
        public void Parse(string configFile)
        {
            using (StreamReader file = new StreamReader(new FileStream(configFile, FileMode.Open)))
            {
                string line = null;
                while ((line = file.ReadLine()) != null)
                {
                    if (String.IsNullOrEmpty(line))
                    {
                        break;
                    }

                    if (line.StartsWith("#"))
                    {
                        continue;
                    }

                    try
                    {
                        string[] data = line.Split(new char[] { '=' }, 2, StringSplitOptions.None);
                        Type     type = Type.GetType("VTankBotRunner." + data[0].Trim());
                        if (type == null)
                        {
                            type = Type.GetType(data[0].Trim());
                        }

                        AuthInfo auth = AuthInfo.FromString(data[1].Trim());

                        Register(type, auth, null);
                    }
                    catch (Exception e)
                    {
                        Console.Error.WriteLine(
                            "Warning: Found corrupted bot in file: {0}", e);
                    }
                }
            }
        }