Пример #1
0
 public virtual void OnPresharedAESCheck(string passwordToCheck, ref ConnectionData connection)
 {
     if (passwordToCheck == Program.password)
     {
         Debug.Log("A user has established communication. Waiting for a username...", "User Login Success");
         connection.SetStage(ConnectionData.ConnectionStage.AwaitingNickname);
         connection.SendMessage("V");
         string newKey = Convert.ToBase64String(PresharedKeyEncryption.GenerateAESKey());
         connection.SetAESKey(PresharedKeyEncryption.GetAESHash(Program.password));
         connection.SendMessage(newKey);
         connection.SetAESKey(newKey);
         connection.SendMessage("Welcome to the server client! Please send your nickname.");
     }
     else
     {
         Debug.Log("A user tried to connect with a password which didn't match. Notifying user.", "User Login Failed");
         connection.SendMessage("Your password was invalid. Please try again.");
     }
 }
Пример #2
0
 public virtual void OnEncryptionSetup(string response, ref ConnectionData connection)
 {
     if (Program.passwordProtected)
     {
         try
         {
             OnPresharedAESCheck(PresharedKeyEncryption.AESDecrypt(Convert.FromBase64String(response), PresharedKeyEncryption.GetAESHash(Program.password)), ref connection);
         }
         catch
         {
             connection.SendMessage("Failed authentication, please try again. If you know the password you entered is correct, please contact your server admin.");
         }
     }
     else
     {
         OnNoEncryption(ref connection);
     }
 }