static void Main(string[] args) { AppDomain.CurrentDomain.ProcessExit += new EventHandler(CurrentDomain_ProcessExit); Console.CancelKeyPress += (s, e) => { if (e.SpecialKey == ConsoleSpecialKey.ControlC) { e.Cancel = true; Dispose(); } }; LoadConfig(cfgfile); client.QuitMessage = cfg[gen]["QuitMessage"]; client.OnConnected += OnConnected; client.OnDisconnected += OnDisconnected; client.OnErrorEvent += OnErrorEvent; con = new ConnectionDataFull { Address = cfg[gen]["Address"], Username = cfg[gen]["NickName"], VersionSign = VersionSign.VER_WIN_3_1_8 }; var id = Ts3Crypt.LoadIdentityDynamic(cfg[gen]["Identity"]).Unwrap(); Console.WriteLine("ID: {0}", id.PrivateKeyString); con.Identity = id; //Console.WriteLine("Connecting to {0} as \"{1}\" (UID: {2})", client.ConnectionData.Address, con.Username, con.Identity.ClientUid); client.Connect(con); }
public override void Connect() { // get or compute identity if (string.IsNullOrEmpty(ts3FullClientData.Identity)) { identity = Ts3Crypt.GenerateNewIdentity(); ts3FullClientData.Identity = identity.PrivateKeyString; ts3FullClientData.IdentityOffset = identity.ValidKeyOffset; } else { var identityResult = Ts3Crypt.LoadIdentityDynamic(ts3FullClientData.Identity, ts3FullClientData.IdentityOffset); if (!identityResult.Ok) { Log.Error("The identity from the config file is corrupted. Remove it to generate a new one next start; or try to repair it."); return; } identity = identityResult.Value; if (ts3FullClientData.Identity != identity.PrivateKeyString) { ts3FullClientData.Identity = identity.PrivateKeyString; } if (ts3FullClientData.IdentityOffset != identity.ValidKeyOffset) { ts3FullClientData.IdentityOffset = identity.ValidKeyOffset; } } // check required security level if (ts3FullClientData.IdentityLevel == "auto") { } else if (int.TryParse(ts3FullClientData.IdentityLevel, out int targetLevel)) { UpdateIndentityToSecurityLevel(targetLevel); } else { Log.Warn("Invalid value for QueryConnection::IdentityLevel, enter a number or \"auto\"."); } // get or compute password if (!string.IsNullOrEmpty(ts3FullClientData.ServerPassword) && ts3FullClientData.ServerPasswordAutoHash && !ts3FullClientData.ServerPasswordIsHashed) { ts3FullClientData.ServerPassword = Ts3Crypt.HashPassword(ts3FullClientData.ServerPassword); ts3FullClientData.ServerPasswordIsHashed = true; } tsFullClient.QuitMessage = QuitMessages[Util.Random.Next(0, QuitMessages.Length)]; tsFullClient.OnErrorEvent += TsFullClient_OnErrorEvent; tsFullClient.OnConnected += TsFullClient_OnConnected; tsFullClient.OnDisconnected += TsFullClient_OnDisconnected; ConnectClient(); }
public E <string> Connect() { // get or compute identity var identityConf = config.Connect.Identity; if (string.IsNullOrEmpty(identityConf.PrivateKey)) { identity = Ts3Crypt.GenerateNewIdentity(); identityConf.PrivateKey.Value = identity.PrivateKeyString; identityConf.Offset.Value = identity.ValidKeyOffset; } else { var identityResult = Ts3Crypt.LoadIdentityDynamic(identityConf.PrivateKey.Value, identityConf.Offset.Value); if (!identityResult.Ok) { Log.Error("The identity from the config file is corrupted. Remove it to generate a new one next start; or try to repair it."); return("Corrupted identity"); } identity = identityResult.Value; identityConf.PrivateKey.Value = identity.PrivateKeyString; identityConf.Offset.Value = identity.ValidKeyOffset; } // check required security level if (identityConf.Level.Value >= 0 && identityConf.Level.Value <= 160) { UpdateIndentityToSecurityLevel(identityConf.Level.Value); } else if (identityConf.Level.Value != -1) { Log.Warn("Invalid config value for 'Level', enter a number between '0' and '160' or '-1' to adapt automatically."); } config.SaveWhenExists(); reconnectCounter = 0; lastReconnect = null; tsFullClient.QuitMessage = QuitMessages[Util.Random.Next(0, QuitMessages.Length)]; ClearAllCaches(); return(ConnectClient()); }