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 { identity = Ts3Crypt.LoadIdentity(ts3FullClientData.Identity, ts3FullClientData.IdentityOffset); } // check required security level Ts3Crypt.ImproveSecurity(identity, ts3FullClientData.IdentityLevel); ts3FullClientData.IdentityOffset = identity.ValidKeyOffset; // 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.OnDisconnected += TsFullClient_OnDisconnected; ConnectClient(); }
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 override void Connect() { // get or compute identity if (string.IsNullOrEmpty(ts3FullClientData.Identity)) { identity = Ts3Crypt.GenerateNewIdentity(); ts3FullClientData.Identity = identity.PrivateKeyString; ts3FullClientData.IdentityOffset = identity.ValidKeyOffset; } else { identity = Ts3Crypt.LoadIdentity(ts3FullClientData.Identity, ts3FullClientData.IdentityOffset); } // check required security level if (ts3FullClientData.IdentityLevel == "auto") { } else if (int.TryParse(ts3FullClientData.IdentityLevel, out int targetLevel)) { if (Ts3Crypt.GetSecurityLevel(identity) < targetLevel) { Log.Info("Calculating up to required security level: {0}", targetLevel); Ts3Crypt.ImproveSecurity(identity, targetLevel); ts3FullClientData.IdentityOffset = identity.ValidKeyOffset; } } 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.OnDisconnected += TsFullClient_OnDisconnected; ConnectClient(); }
public static ChannelCreated ChannelCreate(Ts3FullClient cli, string name, string password, string neededTP, string phoname) { var cmd = new Ts3Command("channelcreate", new List <ICommandPart>() { new CommandParameter("channel_name", name), new CommandParameter("channel_password", Ts3Crypt.HashPassword(password)), new CommandParameter("channel_needed_talk_power", neededTP), new CommandParameter("channel_name_phonetic", phoname) }); var createdchan = cli.SendSpecialCommand(cmd, NotificationType.ChannelCreated).Notifications.Cast <ChannelCreated>(); foreach (var chan in createdchan) { Console.WriteLine("#{0} CID: {1} CNAME: {2}", cli.ClientId, chan.ChannelId, chan.Name); if (chan.Name == name) { return(chan); } } return(null); }
public string CommandHashPassword(ExecutionInformation info, string pw) { return(Ts3Crypt.HashPassword(pw)); }
public static Password FromPlain(string pass) => new Password(Ts3Crypt.HashPassword(pass));