New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

proxy-information

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

proxy-information - pypi Package Compare versions

Comparing version
0.1
to
0.2
+11
-2
PKG-INFO
Metadata-Version: 2.1
Name: proxy_information
Version: 0.1
Version: 0.2
Summary: A tool to verify proxy information.

@@ -78,2 +78,11 @@ Home-page: https://github.com/BlackCage/Proxy-Information-Checker

Your feedback and collaboration are greatly appreciated. Thank you for your interest in this project.
Your feedback and collaboration are greatly appreciated. Thank you for your interest in this project.
## Changelog
- **Version 0.2:**
- *IP Retrieval Method:* Switched to [**`IPFy`**](ipify.org) for more reliable and unlimited public IP retrieval.
- *Geolocation Service:* Updated to use [**`ReallyFreeGeoIP`**](reallyfreegeoip.org) for improved accuracy and no request limits.
- *Code Optimization:* Reorganized and optimized code structure for better readability and maintainability.
- *Error Handling:* Implemented robust error handling to gracefully handle exceptions during API requests.
- *Documentation:* Improved function and class docstrings for better understanding.
Metadata-Version: 2.1
Name: proxy-information
Version: 0.1
Version: 0.2
Summary: A tool to verify proxy information.

@@ -78,2 +78,11 @@ Home-page: https://github.com/BlackCage/Proxy-Information-Checker

Your feedback and collaboration are greatly appreciated. Thank you for your interest in this project.
Your feedback and collaboration are greatly appreciated. Thank you for your interest in this project.
## Changelog
- **Version 0.2:**
- *IP Retrieval Method:* Switched to [**`IPFy`**](ipify.org) for more reliable and unlimited public IP retrieval.
- *Geolocation Service:* Updated to use [**`ReallyFreeGeoIP`**](reallyfreegeoip.org) for improved accuracy and no request limits.
- *Code Optimization:* Reorganized and optimized code structure for better readability and maintainability.
- *Error Handling:* Implemented robust error handling to gracefully handle exceptions during API requests.
- *Documentation:* Improved function and class docstrings for better understanding.
+73
-60
import time
import random
import requests
from fake_useragent import UserAgent as ua
import concurrent.futures
requests.packages.urllib3.disable_warnings()
requests.packages.urllib3.disable_warnings()

@@ -11,16 +11,6 @@ class ProxyInformation:

"""
ProxyInformation is a tool to verify the information and status of a proxy server.
Initializes the ProxyInformation class.
Attributes:
Parameters:
- timeout (int): The maximum time to wait for a response from the proxy server (default is 5 seconds).
- myIP (str): The public IP address of the local machine.
Methods:
- check_proxy(proxy: str) -> dict:
Verify the information and status of a proxy server.
Example:
checker = ProxyInformation(timeout=5)
proxy_info = checker.check_proxy("103.88.35.200:1080")
print(proxy_info)
"""

@@ -32,3 +22,3 @@ self.myIP = self.__get_myip()

"""
Get the public IP address of the local machine using ipinfo.io.
Gets the public IP address of the local machine using ipify.org.

@@ -38,8 +28,11 @@ Returns:

"""
ip = requests.get("https://ipinfo.io/json", headers={"User-Agent": ua().random}).json()["ip"]
return ip
try:
ip = requests.get("https://api.ipify.org?format=json").json()["ip"]
return ip
except requests.RequestException:
return None
def __geolocation(self, ip):
"""
Get geolocation information for a given IP address using ipwhois.app.
Gets geolocation information for a given IP address using reallyfreegeoip.org.

@@ -50,17 +43,21 @@ Args:

Returns:
str: The country of the IP address.
str: The country name of the IP address.
str: The country code of the IP address.
"""
info = requests.get(f"https://ipwhois.app/json/{ip}", headers={"User-Agent": ua().random}).json()
try:
info = requests.get(f"https://reallyfreegeoip.org/json/{ip}").json()
country_name = info["country_name"]
country_code = info["country_code"]
return country_name, country_code
except requests.RequestException:
return None, None
country = info["country"]
country_code = info["country_code"]
return country, country_code
def __get_info(self, proxy):
def __test_protocol(self, proxy, protocol, sites):
"""
Get information and status of a proxy server.
Tests a proxy server for a specific protocol.
Args:
proxy (str): The proxy server in the format "ip:port".
protocol (str): The protocol to test (e.g., "http", "socks4", "socks5").
sites (list): List of websites to test the proxy against.

@@ -70,48 +67,64 @@ Returns:

"""
ip, port = proxy.split(":")
proxies = {"http": f"{protocol}://{proxy}", "https": f"{protocol}://{proxy}"}
result = {}
protocols = ["http", "socks4", "socks5"]
sites = ["https://ipinfo.io/json", "http://proxyjudge.us", "http://azenv.net"]
try:
start = time.time()
r = requests.get(random.choice(sites), proxies=proxies, timeout=self.timeout, verify=False)
finish = time.time() - start
for protocol in protocols:
proxies = {
"http": f"{protocol}://{proxy}",
"https": f"{protocol}://{proxy}"
info = {
"ip": proxy.split(":")[0],
"port": proxy.split(":")[1],
"protocol": protocol,
"responseTime": finish
}
try:
start = time.time()
r = requests.get(random.choice(sites), headers={"User-Agent": ua().random}, proxies=proxies, timeout=self.timeout, verify=False)
finish = time.time() - start
if "HTTP_X_FORWARDED_FOR" in r.text:
info["anonymity"] = "Transparent"
else:
ip, myIP = proxy.split(":")[0], self.myIP
if ip not in r.text and myIP not in r.text:
info["anonymity"] = "Elite"
if ip in r.text and myIP not in r.text:
info["anonymity"] = "Anonymous"
result["ip"] = ip
result["port"] = port
result["protocol"] = protocol
result["responseTime"] = finish
country, country_code = self.__geolocation(ip)
info.update({
"country": country,
"country_code": country_code
})
if "HTTP_X_FORWARDED_FOR" in r.text:
result["anonymity"] = "Transparent"
else:
if ip not in r.text and self.myIP not in r.text:
result["anonymity"] = "Elite"
if ip in r.text and self.myIP not in r.text:
result["anonymity"] = "Anonymous"
return info
except (requests.RequestException, ValueError):
return None
country, country_code = self.__geolocation(ip)
result["country"] = country
result["country_code"] = country_code
def __get_info(self, proxy):
"""
Gets information and status of a proxy server by testing multiple protocols.
Args:
proxy (str): The proxy server in the format "ip:port".
Returns:
dict: A dictionary containing information about the proxy server, including its status, response time, anonymity level, country, etc.
"""
result = {"status": False}
protocols = ["http", "socks4", "socks5"]
sites = ["https://ipinfo.io/json", "http://proxyjudge.us", "http://azenv.net"]
with concurrent.futures.ThreadPoolExecutor() as executor:
futures = [executor.submit(self.__test_protocol, proxy, protocol, sites) for protocol in protocols]
for future in concurrent.futures.as_completed(futures):
info = future.result()
if info:
result = {"status": True, "info": info}
break
except (requests.RequestException, ValueError):
pass
if result == {}:
result["status"] = False
return result
def check_proxy(self, proxy):
"""
Verify the information and status of a proxy server.
Verifies the information and status of a proxy server by testing multiple protocols.

@@ -118,0 +131,0 @@ Args:

@@ -59,2 +59,11 @@ # Proxy Information Checker

Your feedback and collaboration are greatly appreciated. Thank you for your interest in this project.
Your feedback and collaboration are greatly appreciated. Thank you for your interest in this project.
## Changelog
- **Version 0.2:**
- *IP Retrieval Method:* Switched to [**`IPFy`**](ipify.org) for more reliable and unlimited public IP retrieval.
- *Geolocation Service:* Updated to use [**`ReallyFreeGeoIP`**](reallyfreegeoip.org) for improved accuracy and no request limits.
- *Code Optimization:* Reorganized and optimized code structure for better readability and maintainability.
- *Error Handling:* Implemented robust error handling to gracefully handle exceptions during API requests.
- *Documentation:* Improved function and class docstrings for better understanding.

@@ -12,3 +12,3 @@ from setuptools import setup, find_packages

name="proxy_information",
version="0.1",
version="0.2",
description="A tool to verify proxy information.",

@@ -15,0 +15,0 @@ long_description_content_type="text/markdown",