This project is a simple but robust proxy filtering system designed to manage, test, and categorize proxy servers. It provides functionality to process both new and historical proxy data, test proxy connectivity, and maintain organized lists of proxies based on their status and performance.
Proxy reliability is a critical issue in network operations. Surprisingly, many proxies provided by various services are not even routable IP addresses, which can lead to numerous issues. This tool is particularly valuable for projects that rely on dynamic proxy pools, such as:
By using this tool, you can mitigate the risks associated with unreliable proxies. Making requests through non-functional proxies can have serious consequences:
These issues often result in automated systems or network administrators reporting your traffic as potential network abuse. By validating proxies before use, you can significantly reduce these risks and improve the overall reliability and safety of your proxy-dependent operations.
The Routability
class checks if the address is:
- private
- behind Cloudflare
- reachable: ICMP, TCP.
- tunnelable (optionally)
Tasks involved managed by ProxyFilter
:
- Process and categorize proxy servers
- Test proxy connectivity asynchronously
- Handle historical proxy data
- Maintain lists of routable, unroutable, and Cloudflare addresses
- File-based storage for proxy lists
- Concurrent proxy testing with progress tracking
To use the proxy filtering system, you can import the ProxyFilter
class from the main module and use its methods.
Here's a basic example:
from proxy.proxy_filter import ProxyFilter
async def main():
proxy_filter = ProxyFilter()
# Add and process new potential proxies
# Acceptable formats are as so, where everything passed the port is optional:
# "8.8.8.8:80|1~provider1,provider2+5" <--> "<ip>:<port>|<validity>~<*providers>+<calls>" <-->
new_proxies = ["1.1.1.1:80", "2.2.2.2:8080"]
await proxy_filter.process_proxies(proxies=new_proxies, historical=True, test_proxies=True)
proxy_filter = ProxyFilter()
# Load historical proxies and test them
await proxy_filter.process_proxies(historical=True, test_proxies=True)
proxy_filter = ProxyFilter()
# Load historical proxies and test them
await proxy_filter.process_proxies(reprocess_historical=True)
# parameters:
# historical: if files in proxies are existant, we will use their information to avoid reprocessing already
# test_proxies: tunnels through the proxies and makes a simple http request, if functional the proxy is validated.
# While files will be generated in proxy/proxies, the relevant information will be also accessible after processing in:
# Port{port number, validity status, providers, number of calls}
proxy_filter.ips #: Dict[str, Dict](lambda: {"ports": OrderedDict(Port), "routable": False, "cloudflare": False})
proxy_filter.routable_addresses # 212.252.72.106
proxy_filter.unroutable_addresses # 3.87.195.240
proxy_filter.cloudflare_addresses # 1.1.1.1
proxy_filter.untested_proxies # 67.43.236.20:28545
proxy_filter.working_proxies # 212.252.72.106:3128|1~bigprovider,smallguy,unreliablelist+3
# The results will be saved in the respective files in the 'proxy/proxies/' directory
if __name__ == "__main__":
import asyncio
asyncio.run(main())
proxy/
proxyfilter.py
: Main ProxyFilter class implementationroutability.py
: Handles IP routability checksproxy_file_manager.py
: Manages file operations for proxy liststests/
: Contains unit tests for the projectmain.py
: Example script to run the proxy filtering systemrequirements.txt
: List of Python dependenciesThis is optional, they will be generated provided candidate proxy addresses.
The system uses several configuration files located in the proxy/proxies/
directory:
_working_proxies.txt
: List of working proxies_broken_proxies.txt
: List of non-working proxies_untested_proxies.txt
: List of proxies that haven't been tested yet_routable_addresses.txt
: List of routable IP addresses_unroutable_addresses.txt
: List of unroutable IP addresses_cloudflare_addresses.txt
: List of Cloudflare IP addressesContributions to this project are welcome. Please follow these steps to contribute: