Exemple #1
0
        /// <summary>
        /// This method uses a service from Cloudflare to obtain user's country and state.
        /// For more information you can read the summary of the Privacy Policy of this application: https://clemenskoprolin.com/lightparty/legal/
        /// And the Privacy Policy of Cloudflare: https://www.cloudflare.com/privacypolicy/
        /// </summary>
        /// <returns>A array of strings. The fist value is the user's state, the second is the user's country.</returns>
        public static async Task <string[]> GetUserLocation()
        {
            string state   = "";
            string country = "";

            string locationServiceData = await InternetRequests.SendGetRequest(locationServiceURL);

            if (locationServiceData != "null")
            {
                using (System.IO.StringReader reader = new System.IO.StringReader(locationServiceData))
                {
                    string line;
                    while ((line = reader.ReadLine()) != null)
                    {
                        if (line.Contains("colo"))
                        {
                            state = line.Split("=")[1];
                        }

                        if (line.Contains("loc"))
                        {
                            country = line.Split("=")[1];
                        }
                    }
                }
            }

            string[] location = { state, country };
            return(location);
        }
Exemple #2
0
        /// <summary>
        /// Trys to send a telemetry report which does not contain any information of the user.
        /// This method is called after the user agreed to the Privacy Policy. This process cannot be deactivated.
        /// </summary>
        /// <returns>Whether or not the request was successfully send</returns>
        public static async Task <bool> SendFirstStartTelemetry()
        {
            if (BridgeInformation.demoMode || sentFirstStartTelemetry)
            {
                return(false);
            }

            //It is probably not the best idea to use 'verifed: true' in the content of a request as verification.
            //However, it's just a very basic protection so that not everyone can just open the URL in the Browser and maniplate the collected statistics.
            string response = await InternetRequests.SendJsonPostRequest(firstTimeTelemetryURL, "{ \"verifed\": true }");

            sentFirstStartTelemetry = response != "null";
            return(sentFirstStartTelemetry);
        }
Exemple #3
0
        /// <summary>
        /// Trys to send a telemetry report which contains the user's country and state. In order to obtain this information, this application uses a service from Cloudflare.
        /// This method is called after the user started the application and when telemetry is activated.
        /// For more information you can read the summary of the Privacy Policy: https://clemenskoprolin.com/lightparty/legal/
        /// </summary>
        /// <returns>Whether or not the report was successfully send</returns>
        public static async Task <bool> SendTelemetryReport()
        {
            if (BridgeInformation.demoMode || !(bool)useTelemetry || sentTelemetryReport)
            {
                return(false);
            }

            string[] userLocation = await GetUserLocation();

            //Creates a json string from the location data.
            JsonObject jsonObject = new JsonObject();

            jsonObject["state"]   = JsonValue.CreateStringValue(userLocation[0]);
            jsonObject["country"] = JsonValue.CreateStringValue(userLocation[1]);

            string jsonString = jsonObject.Stringify();
            string response   = await InternetRequests.SendJsonPostRequest(telemetryReportURL, jsonString);

            sentTelemetryReport = response != "null";
            return(sentTelemetryReport);
        }