Beispiel #1
0
 public void ReplaceByIndex(Int32 iIndex, CMaster New_Master)
 {
     lock (lstMaster)
     {
         lstMaster[iIndex] = New_Master;
     }
 }
Beispiel #2
0
 public void ReplaceBySocket(CClient Client, CMaster Master)
 {
     lock (lstMaster)
     {
         for (int i = 0; i < lstMaster.Count; i++)
         {
             if (lstMaster[i].MasterClient == Client)
             {
                 lstMaster[i] = Master;
             }
         }
     }
 }
Beispiel #3
0
        public Boolean AddMaster(CClient Client, String[] arr_strArguments)
        {
            if (Client == null)
            {
                return(false);
            }

            if (arr_strArguments.Length != CConstants.MASTER_LOGIN_ARGUMENT_LENGTH)
            {
                return(false);
            }

            try
            {
                Int32  iMasterID    = -1;
                String strPublicKey = String.Empty;
                Int32  iAuthorized  = AuthorizeMaster(arr_strArguments[0], arr_strArguments[1], out iMasterID, out strPublicKey);

                Console.WriteLine("iMasterID: {0}", iMasterID);

                if (iAuthorized >= 1)
                {
                    CMaster Master = new CMaster();
                    Master.Master_ID    = iMasterID;
                    Master.MasterClient = Client;
                    Master.Username     = arr_strArguments[0];
                    Master.Password     = arr_strArguments[1];
                    Master.IsAuthorized = false;
                    Master.Public_Key   = strPublicKey;

                    lock (lstMaster)
                    {
                        lstMaster.Add(Master);
                    }

                    if (iAuthorized == 2)
                    {
                        if (Master.AskForKey())
                        {
                            Console.WriteLine("[EVENT] Detected first login from Master. Requested Master: {0} Public key.", Master.Username);
                        }
                    }
                    else
                    {
                        if (Master.SendRSAAuth())
                        {
                            return(true);
                        }
#if DEBUG
                        else
                        {
                            Console.WriteLine(CConstants.SendRSAAuth_FAILED);
                            return(false);
                        }
#endif
                    }
                    return(true);
                }
                else if (iAuthorized == 0)
                {
                    Console.WriteLine("[ERROR] AuthorizeMaster failed. Incorrect Username or Password.");
                }
            }
            catch { }

            return(false);
        }