// TODO: Implement loading existing realms.
        // TODO: Implement existing character counts.
        static async Task HandleRealmListRequest(ClientRequest clientRequest, BnetServiceSession session)
        {
            var realmJoinRequest = clientRequest.GetVariant("Command_RealmListRequest_v1_b9")?.StringValue;
            var realmListTicket  = clientRequest.GetVariant("Param_RealmListTicket")?.BlobValue.ToByteArray();

            if (session.RealmListTicket.Compare(realmListTicket))
            {
                var realmListResponse = new ClientResponse();
                var realmlist         = new RealmListUpdates();

                realmListResponse.Attribute.Add(new Bgs.Protocol.Attribute
                {
                    Name  = "Param_RealmList",
                    Value = new Variant
                    {
                        BlobValue = ByteString.CopyFrom(Deflate("JSONRealmListUpdates", realmlist))
                    }
                });

                var realmCharacterCountList = new RealmCharacterCountList();

                realmListResponse.Attribute.Add(new Bgs.Protocol.Attribute
                {
                    Name  = "Param_CharacterCountList",
                    Value = new Variant
                    {
                        BlobValue = ByteString.CopyFrom(Deflate("JSONRealmCharacterCountList", realmCharacterCountList))
                    }
                });

                await session.Send(realmListResponse);
            }
        }
Ejemplo n.º 2
0
        public static async void HandleGetGameAccountStateRequest(GetGameAccountStateRequest getGameAccountStateRequest, BnetServiceSession session)
        {
            var gameAccount = session.Account.GameAccounts.SingleOrDefault(ga => ga.Id == getGameAccountStateRequest.GameAccountId.Low);

            if (gameAccount != null)
            {
                var getGameAccountStateResponse = new GetGameAccountStateResponse
                {
                    State = new GameAccountState
                    {
                        GameLevelInfo = new GameLevelInfo
                        {
                            // 'WoW'
                            Program = 0x576F57,
                            Name    = gameAccount.Game + gameAccount.Index
                        },
                        GameStatus = new GameStatus
                        {
                            // 'WoW'
                            Program = 0x576F57,
                        }
                    },
                    // TODO: Implement?!
                    Tags = new GameAccountFieldTags
                    {
                        GameLevelInfoTag = 4140539163,
                        GameStatusTag    = 2562154393
                    }
                };

                await session.Send(getGameAccountStateResponse);
            }
        }
Ejemplo n.º 3
0
        public static async void HandleVerifyWebCredentialsRequest(VerifyWebCredentialsRequest verifyWebCredentials, BnetServiceSession session)
        {
            var logonResult = new LogonResult();

            if (verifyWebCredentials.WebCredentials.ToStringUtf8() == session.LoginTicket)
            {
                logonResult.AccountId = new EntityId
                {
                    High = 0x100000000000000,
                    Low  = session.Account.Id
                };

                session.Account.GameAccounts.ForEach(ga =>
                {
                    logonResult.GameAccountId.Add(new EntityId
                    {
                        // TODO: Build the right High value.
                        High = 0x200000200576F57,
                        Low  = ga.Id
                    });
                });

                logonResult.SessionKey = ByteString.CopyFromUtf8(new byte[0].GenerateRandomKey(64).ToHexString());
            }
            else
            {
                logonResult.ErrorCode = (uint)BnetServiceErrorCode.Denied;
            }

            await session.Send(logonResult, BnetServiceHash.AuthenticationListenerService, 5);
        }
        public static async void HandleGetAllValuesForAttributeRequest(GetAllValuesForAttributeRequest getAllValuesForAttributeRequest, BnetServiceSession session)
        {
            if (getAllValuesForAttributeRequest.AttributeKey == "Command_RealmListRequest_v1_b9")
            {
                var getAllValuesForAttributeResponse = new GetAllValuesForAttributeResponse();

                getAllValuesForAttributeResponse.AttributeValue.Add(new Variant {
                    StringValue = "0-0-0"
                });

                await session.Send(getAllValuesForAttributeResponse);
            }
        }
Ejemplo n.º 5
0
        public static async void HandleLogonRequest(LogonRequest logonRequest, BnetServiceSession session)
        {
            // TODO: Implement version checks, etc.
            //if (DB.Auth.Any<Application>(a => a.Program == logonRequest.Program))
            {
                var challengeExternalRequest = new ChallengeExternalRequest
                {
                    PayloadType = "web_auth_url",
                    Payload     = ByteString.CopyFromUtf8($"https://{BnetConfig.RestServiceHost}:{BnetConfig.RestServiceBindPort}/login/{session.Guid}")
                };

                await session.Send(challengeExternalRequest, BnetServiceHash.AuthenticationClientService, 3);
            }
        }
        // TODO: Implement realm join function.
        static async Task HandleRealmJoinRequest(ClientRequest clientRequest, BnetServiceSession session)
        {
            var realmJoinRequest  = clientRequest.GetVariant("Command_RealmJoinRequest_v1_b9")?.StringValue;
            var realmAddress      = clientRequest.GetVariant("Param_RealmAddress")?.UintValue;
            var realmListTicket   = clientRequest.GetVariant("Param_RealmListTicket")?.BlobValue.ToByteArray();
            var ServiceSessionKey = clientRequest.GetVariant("Param_ServiceSessionKey")?.BlobValue.ToByteArray();

            // Check for valid realmlist ticket.
            if (realmListTicket.Compare(session.RealmListTicket))
            {
                var realmJoinResponse = new ClientResponse();

                await session.Send(realmJoinResponse);
            }
        }
Ejemplo n.º 7
0
 public static Task HandleGetAccountStateRequest(GetAccountStateRequest getAccountStateRequest, BnetServiceSession session)
 {
     return(session.Send(new GetAccountStateResponse
     {
         // TODO: Implement?!
         State = new AccountState
         {
             PrivacyInfo = new PrivacyInfo
             {
                 IsHiddenFromFriendFinder = true,
                 IsUsingRid = true,
             }
         },
         // TODO: Implement?!
         Tags = new AccountFieldTags
         {
             PrivacyInfoTag = 0xD7CA834D
         }
     }));
 }
        // TODO: Verify ClientRequest values.
        static async Task HandleRealmListTicketRequest(ClientRequest clientRequest, BnetServiceSession session)
        {
            var paramIdentityValue   = clientRequest.GetVariant("Param_Identity")?.BlobValue.ToStringUtf8();
            var paramClientInfoValue = clientRequest.GetVariant("Param_ClientInfo")?.BlobValue.ToStringUtf8();

            if (paramIdentityValue != null && paramClientInfoValue != null)
            {
                var realmListTicketIdentity          = CreateObject <RealmListTicketIdentity>(paramIdentityValue, true);
                var realmListTicketClientInformation = CreateObject <RealmListTicketClientInformation>(paramClientInfoValue, true);

                session.GameAccount = session.Account.GameAccounts.SingleOrDefault(ga => ga.Id == realmListTicketIdentity.GameAccountId);

                if (session.GameAccount != null)
                {
                    session.RealmListSecret = realmListTicketClientInformation.Info.Secret.Select(x => Convert.ToByte(x)).ToArray();
                    session.RealmListTicket = new byte[0].GenerateRandomKey(32);

                    var realmListTicketResponse = new ClientResponse();

                    realmListTicketResponse.Attribute.Add(new Bgs.Protocol.Attribute
                    {
                        Name  = "Param_RealmListTicket",
                        Value = new Variant
                        {
                            BlobValue = ByteString.CopyFrom(session.RealmListTicket)
                        }
                    });

                    await session.Send(realmListTicketResponse);
                }
            }
            else
            {
                session.Dispose();
            }
        }
        // TODO: Implement.
        static Task HandleLastCharPlayedRequest(ClientRequest clientRequest, BnetServiceSession session)
        {
            var lastCharPlayedResponse = new ClientResponse();

            return(session.Send(lastCharPlayedResponse));
        }