Пример #1
0
        private string CreateGamespyCode(AccountRequestCreate info)
        {
            byte[] bytes        = Base16.Decode(info.DeviceMAC);
            string bitsAsString = Base32.Encode(bytes, 0x00000000ffffffff).PadLeft(7, '0');

            return("ADAJ0u8vj0h"); // info.GameCode + bitsAsString;
        }
Пример #2
0
 public void Update(AccountRequestCreate info)
 {
     UniqueNick = CalculateUniqueNick(info);
     Password   = info.Password;
     DeviceName = info.DevinceName;
     // store DeviceMAC, AccessPtMAC, GameCode, Language, Birthday, DeviceTime, DeviceName?
 }
Пример #3
0
        private static void EventSink_AccountRequest(AccountRequestCreate info)
        {
            if (string.IsNullOrEmpty(info.GamespyCode))
            {
                info.HandleFailure("002"); // no gsbrcd!
                return;
            }
            Account a = GetOrCreateAccountFromInfo(info);

            LoginAccount(a);
            info.HandleSuccess(a);
        }
Пример #4
0
        private static Account GetOrCreateAccountFromInfo(AccountRequestCreate info)
        {
            Account account = null;

            if (_MapUserIDsToProfileIDs.TryGetValue(info.ClientUserID, out int profileID))
            {
                account = _Accounts[profileID];
            }
            if (account == null)
            {
                account = new Account(info);
                _Accounts[account.ProfileID] = account;
                _MapUserIDsToProfileIDs[info.ClientUserID] = account.ProfileID;
            }
            account.Update(info);
            return(account);
        }
Пример #5
0
 private string CalculateUniqueNick(AccountRequestCreate info)
 {
     if (string.IsNullOrEmpty(info.GamespyCode))
     {
         string userIDbase32 = Base32.Encode(info.ClientUserID).PadLeft(9, '0');
         string gscd         = CreateGamespyCode(info);
         string uniquenick   = userIDbase32 + gscd;
         Kernel.WriteLine("Account", $"Created unique nick '{uniquenick}'.");
         return(uniquenick);
     }
     else
     {
         string userIDbase32 = Base32.Encode(info.ClientUserID).PadLeft(9, '0');
         string uniquenick   = userIDbase32 + info.GamespyCode;
         Kernel.WriteLine("Account", $"Has unique nick '{uniquenick}'.");
         return(uniquenick);
     }
 }
Пример #6
0
        private string OnRequestAcLogin(HttpRequest request, FormUrlEncodedBody body, bool isCreate)
        {
            AccountRequestCreate info = new AccountRequestCreate(body, isCreate);

            EventSink.InvokeAccountCreate(info);
            if (info.IsHandled && info.IsSuccess)
            {
                Kernel.WriteLine(Host, $"{request.NetState} authenticated as account '{info.Account}'.");
                return(new HttpResponse(request, contentType: HttpResponse.ContentTypeTextPlain)
                       .AddHeader("NODE", "wifiappe2")
                       .AddHeader("Server", "Nintendo Wii (http)")
                       .AddHeaderDateGMT()
                       .Append(new FormUrlEncodedBody()
                               .AddParamAscii("challenge", info.Account.GsLoginPassword)
                               .AddParamAscii("locator", "gamespy.com")
                               .AddParamAscii("retry", "0")
                               .AddParamAscii("returncd", "001")
                               .AddParamAscii("token", info.Account.GsLoginToken)
                               .AddParamAscii("datetime", DateTime.UtcNow.ToString("yyyyMMddHHmmss"))
                               .Compile()
                               ).Compile());
            }
            else if (info.IsHandled)   // but failed to login, prompt DS for retry
            {
                Console.WriteLine($"{Host}: {request.ClientName} failed to authenticate.");
                return(new HttpResponse(request, contentType: HttpResponse.ContentTypeTextPlain)
                       .AddHeader("NODE", "wifiappw1")
                       .AddHeader("Server", "Nintendo Wii (https)")
                       .AddHeaderDateGMT()
                       .Append(new FormUrlEncodedBody()
                               .AddParamAscii("retry", "0")
                               .AddParamAscii("returncd", info.FailReason)
                               .AddParamAscii("userid", info.ClientUserID)
                               .AddParamAscii("datetime", DateTime.UtcNow.ToString("yyyyMMddHHmmss"))
                               .Compile()
                               ).Compile());
            }
            else
            {
                return(OnUnhandledRequest(request));
            }
        }
Пример #7
0
 internal static void InvokeAccountCreate(AccountRequestCreate info)
 {
     AccountCreate?.Invoke(info);
 }
Пример #8
0
 public Account(AccountRequestCreate info)
 {
     ProfileID = AccountSystem.GetNextUniqueId();
 }