public RequestEnvelope GetRequestEnvelope(Request[] customRequests, bool firstRequest = false)
        {
            TRandom TRandomDevice = new TRandom();
            var     e             = new RequestEnvelope
            {
                StatusCode = 2,                                                            //1
                RequestId  = 1469378659230941192,                                          //3
                Requests   = { customRequests },                                           //4
                //Unknown6 = , //6
                Latitude               = _latitude,                                        //7
                Longitude              = _longitude,                                       //8
                Accuracy               = _altitude,                                        //9
                AuthTicket             = _authTicket,                                      //11
                MsSinceLastLocationfix = (long)TRandomDevice.Triangular(300, 30000, 10000) //12
            };

            if (_authTicket != null && !firstRequest)
            {
                e.AuthTicket = _authTicket;
                e.PlatformRequests.Add(GenerateSignature(customRequests));
            }
            else
            {
                e.AuthInfo = new RequestEnvelope.Types.AuthInfo
                {
                    Provider = _authType == AuthType.Google ? "google" : "ptc",
                    Token    = new RequestEnvelope.Types.AuthInfo.Types.JWT
                    {
                        Contents = _authToken,
                        Unknown2 = _token2
                    }
                };
            }
            return(e);
        }
Example #2
0
        public async Task <RequestEnvelope> GetRequestEnvelope(Request[] customRequests, bool firstRequest = false)
        {
            TRandom TRandomDevice = new TRandom();

            var _requestEnvelope = new RequestEnvelope
            {
                StatusCode             = 2,                                                //1
                RequestId              = _requestBuilderID.Next(),                         // GetNextRequestId(), //3
                Requests               = { customRequests },                               //4
                Latitude               = _latitude,                                        //7
                Longitude              = _longitude,                                       //8
                Accuracy               = _altitude,                                        //9
                AuthTicket             = _authTicket,                                      //11
                MsSinceLastLocationfix = (long)TRandomDevice.Triangular(300, 30000, 10000) //12
            };

            // This is new code for 0.53 below
            // Note by Logxn: We do need this for ALL requests and before the main requests.
            // TODO: We need more information about when in needed UnknownPrt8
            // Charles says only sent for these 2 RequestTypes
            if (customRequests[0].RequestType == RequestType.GetPlayer || (customRequests[0].RequestType == RequestType.GetMapObjects && !GMOFirstTime))
            {
                _requestEnvelope.PlatformRequests.Add(new RequestEnvelope.Types.PlatformRequest {
                    Type           = PlatformRequestType.UnknownPtr8,
                    RequestMessage = ByteString.CopyFromUtf8(Resources.UnknownPtr8_RequestMessage)  //ByteString.CopyFrom("e40c3e64817d9c96d99d28f6488a2efc40b11046")
                });
            }

            if (customRequests[0].RequestType == RequestType.GetMapObjects && GMOFirstTime)
            {
                GMOFirstTime = false;
            }

            if (_authTicket != null && !firstRequest)
            {
                _requestEnvelope.AuthTicket = _authTicket;
                _requestEnvelope.PlatformRequests.Add(GenerateSignature(_requestEnvelope));
            }
            else
            {
                _requestEnvelope.AuthInfo = new RequestEnvelope.Types.AuthInfo
                {
                    Provider = _authType == AuthType.Google ? "google" : "ptc",
                    Token    = new RequestEnvelope.Types.AuthInfo.Types.JWT
                    {
                        Contents = _authToken,
                        Unknown2 = _token2
                    }
                };
            }

            return(_requestEnvelope);
        }
        public RequestEnvelope GetPlatformRequestEnvelope(RequestEnvelope.Types.PlatformRequest platfReq, bool firstRequest = false)
        {
            var req = new Request();

            req.RequestType = RequestType.Echo;

            var _requestEnvelope = new RequestEnvelope {
                StatusCode             = 2,                                                //1
                RequestId              = _requestBuilderID.Next(),                         //3
                Requests               = { req },                                          //4
                Latitude               = _latitude,                                        //7
                Longitude              = _longitude,                                       //8
                Accuracy               = _altitude,                                        //9
                AuthTicket             = _authTicket,                                      //11
                MsSinceLastLocationfix = (long)TRandomDevice.Triangular(300, 30000, 10000) //12
            };

            _requestEnvelope.PlatformRequests.Add(platfReq);

            if (_authTicket != null && !firstRequest)
            {
                _requestEnvelope.AuthTicket = _authTicket;
            }
            else
            {
                _requestEnvelope.AuthInfo = new RequestEnvelope.Types.AuthInfo {
                    Provider = _authType == AuthType.Google ? "google" : "ptc",
                    Token    = new RequestEnvelope.Types.AuthInfo.Types.JWT {
                        Contents = _authToken,
                        Unknown2 = _token2
                    }
                };
            }
            //Logger.Debug("GetPlatformRequestEnvelope");
            //Logger.Debug("_requestEnvelope"+ _requestEnvelope);

            _requestEnvelope.PlatformRequests.Add(GenerateSignature(_requestEnvelope));

            return(_requestEnvelope);
        }
Example #4
0
        public RequestBuilder(Client client, AuthType authType, double latitude, double longitude, double altitude, float speed,
                              ISettings settings)
        {
            _client    = client;
            _authType  = authType;
            _latitude  = latitude;
            _longitude = longitude;
            _altitude  = altitude;

            // Add small variance to speed.
            _speed = speed + ((float)Math.Round(GenRandom(-1, 1), 7));

            // If speed is 0 or negative, make it random.
            if (_speed <= 0)
            {
                _speed = (float)TRandomDevice.Triangular(0.1, 3.1, .8);
            }

            _horizontalAccuracy = TRandomDevice.Choice(new List <int>(new int[] { 5, 5, 5, 5, 10, 10, 10 }));

            _settings = settings;

            if (SessionHash == null)
            {
                GenerateNewHash();
            }
            //TODO cleanup later
            //if (_crypt == null)
            //    _crypt = new Crypt();
        }
Example #5
0
 private float GetCourse()
 {
     _course = (float)TRandomDevice.Triangular(0, 359.9, _course);
     return(_course);
 }
        public RequestBuilder(Client client, string authToken, AuthType authType, double latitude, double longitude, double altitude, float speed,
                              ISettings settings, AuthTicket authTicket = null)
        {
            _client    = client;
            _authToken = authToken;
            _authType  = authType;
            _latitude  = latitude;
            _longitude = longitude;
            _altitude  = altitude;

            // Add small variance to speed.
            _speed = speed + ((float)Math.Round(GenRandom(-1, 1), 7));

            // If speed is 0 or negative, make it random.
            if (_speed <= 0)
            {
                _speed = (float)TRandomDevice.Triangular(0.1, 3.1, .8);
            }

            _horizontalAccuracy = TRandomDevice.Choice(new List <double>(new double[] { 5, 5, 5, 5, 10, 10, 10, 30, 30, 50, 65, GenRandom(66, 80) }));

            _settings   = settings;
            _authTicket = authTicket;

            if (SessionHash == null)
            {
                GenerateNewHash();
            }

            if (_crypt == null)
            {
                _crypt = new Crypt();
            }
        }