Example #1
0
        /// <summary>
        /// Get request for the given key and ip
        /// </summary>
        /// <param name="key"><see cref="IPInfoKey"/> Value to get</param>
        /// <param name="ip">IP</param>
        /// <returns>Response</returns>
        private static string GetRequest(IPInfoKey key, string ip)
        {
            WebRequest   request  = WebRequest.Create(ip == null ? "http://ipinfo.io/" + key.ToString().ToLower() : "http://ipinfo.io/" + ip + "/" + key.ToString().ToLower());
            WebResponse  response = request.GetResponse();
            StreamReader reader   = new StreamReader(response.GetResponseStream());

            return(reader.ReadToEnd());
        }
Example #2
0
 /// <summary>
 /// Get a specified information about the specified IP addres ( leave blank to get the caller's IP informations )
 /// </summary>
 /// <returns><see cref="string"/> Result</returns>
 public static string Get(IPInfoKey key, string ip = null, string token = null)
 {
     return(Request(ip, token, key));
 }
Example #3
0
        /// <summary>
        /// Get a specified information about the specified IP address ( leave blank to get the caller's IP informations ) asynchroniously
        /// </summary>
        /// <returns><see cref="string"/> Result</returns>
        public async static Task <string> GetAsync(IPInfoKey key, string ip = null, string token = null)
        {
            string text = await Task.Run(() => RequestAsync(ip, token, key));

            return(text);
        }
Example #4
0
 /// <summary>
 /// Get the specific IP information of the given IP
 /// </summary>
 /// <param name="key"><see cref="IPInfoKey"/> Value to get</param>
 /// <param name="ip">IP to check</param>
 /// <returns>Result</returns>
 public static string Get(IPInfoKey key, string ip) => GetRequest(key, ip);
Example #5
0
 /// <summary>
 /// Get a specific IP information of the current machine
 /// </summary>
 /// <param name="key"><see cref="IPInfoKey"/> Value to get</param>
 /// <returns>Result</returns>
 public static string Get(IPInfoKey key) => GetRequest(key, null);