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); }
/// <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); } } } }
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); } } } }