Ejemplo n.º 1
0
        private static void Filter(int gameId, PackedResult data)
        {
            if (data.Type == PackedResultType.LobbyService && data.Result is LobbyServiceResult svc)
            {
                _service     = svc;
                _serviceTime = Environment.TickCount;
            }

            if (data.Type == PackedResultType.LobbyCharacter && data.Result is LobbyCharacterResult chr)
            {
                _character     = chr;
                _characterTime = Environment.TickCount;
            }
        }
Ejemplo n.º 2
0
        public int Step1(string username, LobbyServiceResult service, LobbyCharacterResult character, long[] trace)
        {
            if (CheckVendor.NotValidUsername(username) ||
                CheckVendor.NotValidService(service) ||
                CheckVendor.NotValidCharacter(character) ||
                CheckVendor.NotValidTrace(trace))
            {
                return(03_0010);
            }

            _username = username;
            var recoveryGame = new RecoveryGame();

            recoveryGame.Username = username;

            recoveryGame.Service = service;

            recoveryGame.Character = character;

            recoveryGame.Trace = trace;

            recoveryGame.ReportTime = DateTime.Now;

            for (var i = 0; i < 3; i++)
            {
                var result = ApiCall.AccountRecoveryGame.Call(null, new MilvanethProtocol {
                    Context = null, Data = recoveryGame
                });

                if (!(result.Data is ServerResponse sr))
                {
                    return(02_0007);
                }

                if (!CheckVendor.NotValidResponse(sr))
                {
                    _serverResponse = sr;
                }

                if (sr.Message != 01_0003) // retry with pow
                {
                    return(sr.Message);
                }

                recoveryGame.ProofOfWork = ProofOfWorkVendor.CalculateProofOfWork(sr.AuthToken);
            }

            return(01_0002);
        }
Ejemplo n.º 3
0
        public static bool Collect(int timeout, out LobbyServiceResult service, out LobbyCharacterResult character)
        {
            service   = null;
            character = null;

            SubprocessManagementService.SpawnAll(out _);
            SubprocessManagementService.SpawnHunter();

            lock (LockObject)
            {
                if (!_filterOn)
                {
                    TransmittingManagementService.OnDataOutput += Filter;
                    _filterOn = true;
                }
            }

            int cycle = 0;

            while (Math.Abs(_serviceTime - Environment.TickCount) > 10000 || Math.Abs(_characterTime - Environment.TickCount) > 10000)
            {
                if (100 * cycle > timeout)
                {
                    return(false);
                }

                Thread.Sleep(100);
                cycle++;
            }

            service   = _service;
            character = _character;

            lock (LockObject)
            {
                if (_filterOn)
                {
                    TransmittingManagementService.OnDataOutput -= Filter;
                    _filterOn = false;
                }
            }

            return(true);
        }
Ejemplo n.º 4
0
 public static bool NotValidService(LobbyServiceResult service)
 {
     return(service == null ||
            !service.ServiceProvider.Equals("SHANDA", StringComparison.InvariantCultureIgnoreCase) ||
            service.ServiceId == 0);
 }
Ejemplo n.º 5
0
        public int Step1(LobbyServiceResult service, LobbyCharacterResult character, string username, string displayName, string email, byte[] password, long[] trace)
        {
            var registerForm = new RegisterForm();

            if (CheckVendor.NotValidService(service))
            {
                return(03_0000);
            }

            registerForm.Service = service;

            if (CheckVendor.NotValidCharacter(character))
            {
                return(03_0000);
            }

            registerForm.Character = character;

            if (CheckVendor.NotValidTrace(trace))
            {
                return(03_0008);
            }

            registerForm.Trace = trace;

            // 4-16个字符,可使用英文、数字和下划线,必须以字母开头
            if (CheckVendor.NotValidUsername(username))
            {
                return(03_0001);
            }

            registerForm.Username = username;

            // 2-12个字符,可使用中英文、数字和下划线
            if (CheckVendor.NotValidDisplayName(displayName))
            {
                return(03_0003);
            }

            registerForm.DisplayName = displayName;

            if (CheckVendor.NotValidEmail(email))
            {
                return(03_0005);
            }

            registerForm.Email = email;

            // 4个字符以上的中文或8个字符以上的数字和字母
            if (CheckVendor.NotValidPassword(password))
            {
                return(03_0007);
            }

            _username = username;
            _password = password;

            registerForm.Verifier = Srp6Vendor.Srp6Init(username, password, out var salt).ToByteArray();

            registerForm.Salt = salt;

            registerForm.GroupParam = Srp6Vendor.BitLength;

            registerForm.ReportTime = DateTime.Now;

            for (var i = 0; i < 3; i++)
            {
                var result = ApiCall.AccountCreate.Call(null, new MilvanethProtocol {
                    Context = null, Data = registerForm
                });

                if (!(result.Data is ServerChallenge sc))
                {
                    return(02_0007);
                }

                if (!CheckVendor.NotValidResponse(sc))
                {
                    _serverChallenge = sc;
                }

                if (sc.Message != 01_0003) // retry with pow
                {
                    return(sc.Message);
                }

                registerForm.SessionId = sc.SessionId;

                registerForm.ProofOfWork = ProofOfWorkVendor.CalculateProofOfWork(sc.ProofOfWork);
            }

            return(01_0002);
        }
Ejemplo n.º 6
0
 private static bool CheckLobbyService(LobbyServiceResult info)
 {
     return(info != null &&
            info.ServiceProvider == GlobalConfig.SERVICE_PROVIDER_ID &&
            info.ServiceId != 0);
 }