Compare commits
4 Commits
2ea7eb41b7
...
93eb395727
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
93eb395727 | ||
|
|
f9d237fe0d | ||
|
|
0f1fe981ef | ||
|
|
0a53e4457f |
164
ROADMAP.md
164
ROADMAP.md
@@ -1,69 +1,92 @@
|
||||
# PPF Project Roadmap
|
||||
# PPF Roadmap
|
||||
|
||||
## Project Purpose
|
||||
|
||||
PPF (Proxy Fetcher) is a Python 2 proxy scraping and validation framework designed to:
|
||||
|
||||
1. **Discover** proxy addresses by crawling websites and search engines
|
||||
2. **Validate** proxies through multi-target testing via Tor
|
||||
3. **Maintain** a database of working proxies with protocol detection (SOCKS4/SOCKS5/HTTP)
|
||||
|
||||
## Architecture Overview
|
||||
## Architecture
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────────────────────────┐
|
||||
│ PPF Architecture │
|
||||
├─────────────────────────────────────────────────────────────────────────────┤
|
||||
│ │
|
||||
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
|
||||
│ │ scraper.py │ │ ppf.py │ │proxywatchd │ │
|
||||
│ │ │ │ │ │ │ │
|
||||
│ │ Searx query │───>│ URL harvest │───>│ Proxy test │ │
|
||||
│ │ URL finding │ │ Proxy extract│ │ Validation │ │
|
||||
│ └─────────────┘ └─────────────┘ └─────────────┘ │
|
||||
│ │ │ │ │
|
||||
│ v v v │
|
||||
│ ┌─────────────────────────────────────────────────────────────────┐ │
|
||||
│ │ SQLite Databases │ │
|
||||
│ │ uris.db (URLs) proxies.db (proxy list) │ │
|
||||
│ └─────────────────────────────────────────────────────────────────┘ │
|
||||
│ │
|
||||
│ ┌─────────────────────────────────────────────────────────────────┐ │
|
||||
│ │ Network Layer │ │
|
||||
│ │ rocksock.py ─── Tor SOCKS ─── Test Proxy ─── Target Server │ │
|
||||
│ └─────────────────────────────────────────────────────────────────┘ │
|
||||
│ │
|
||||
└─────────────────────────────────────────────────────────────────────────────┘
|
||||
┌──────────────────────────────────────────┐
|
||||
│ Odin (Master) │
|
||||
│ httpd.py ─ API + SSL-only verification │
|
||||
│ proxywatchd.py ─ proxy recheck daemon │
|
||||
│ SQLite: proxies.db, websites.db │
|
||||
└──────────┬───────────────────────────────┘
|
||||
│ WireGuard (10.200.1.0/24)
|
||||
┌────────────────┼────────────────┐
|
||||
v v v
|
||||
┌───────────┐ ┌───────────┐ ┌───────────┐
|
||||
│ cassius │ │ edge │ │ sentinel │
|
||||
│ Worker │ │ Worker │ │ Worker │
|
||||
│ ppf.py │ │ ppf.py │ │ ppf.py │
|
||||
└───────────┘ └───────────┘ └───────────┘
|
||||
```
|
||||
|
||||
Workers claim URLs, extract proxies, test them, report back.
|
||||
Master verifies (SSL-only), serves API, coordinates distribution.
|
||||
|
||||
## Constraints
|
||||
|
||||
- **Python 2.7** compatibility required
|
||||
- **Minimal external dependencies** (avoid adding new modules)
|
||||
- Current dependencies: beautifulsoup4, pyasn, IP2Location
|
||||
- Data files: IP2LOCATION-LITE-DB1.BIN (country), ipasn.dat (ASN)
|
||||
- Python 2.7 runtime (container-based)
|
||||
- Minimal external dependencies
|
||||
- All traffic via Tor
|
||||
|
||||
---
|
||||
|
||||
## Phase 1: Performance and Quality (current)
|
||||
|
||||
Profiling-driven optimizations and source pipeline hardening.
|
||||
|
||||
| Item | Status | Description |
|
||||
|------|--------|-------------|
|
||||
| Extraction short-circuits | done | Guard clauses in fetch.py extractors |
|
||||
| Skip shutdown on failed sockets | pending | Avoid 39s/session wasted on dead connections |
|
||||
| SQLite connection reuse (odin) | pending | Cache per-greenlet, eliminate 2.7k opens/session |
|
||||
| Lazy-load ASN database | pending | Defer 3.6s startup cost to first lookup |
|
||||
| Add more seed sources (100+) | pending | Expand beyond 37 hardcoded URLs |
|
||||
| Protocol-aware source weighting | pending | Prioritize SOCKS5-yielding sources |
|
||||
|
||||
## Phase 2: Proxy Diversity and Consumer API
|
||||
|
||||
Address customer-reported quality gaps.
|
||||
|
||||
| Item | Status | Description |
|
||||
|------|--------|-------------|
|
||||
| ASN diversity scoring | pending | Deprioritize over-represented ASNs in testing |
|
||||
| Graduated recheck intervals | pending | Fresh proxies rechecked more often than stale |
|
||||
| API filters (proto/country/ASN/latency) | pending | Consumer-facing query parameters on /proxies |
|
||||
| Latency-based ranking | pending | Expose latency percentiles per proxy |
|
||||
|
||||
## Phase 3: Self-Expanding Source Pool
|
||||
|
||||
Worker-driven link discovery from productive pages.
|
||||
|
||||
| Item | Status | Description |
|
||||
|------|--------|-------------|
|
||||
| Link extraction from productive pages | pending | Parse HTML for links when page yields proxies |
|
||||
| Report discovered URLs to master | pending | New endpoint for worker URL submissions |
|
||||
| Conditional discovery | pending | Only extract links from confirmed-productive pages |
|
||||
|
||||
## Phase 4: Long-Term
|
||||
|
||||
| Item | Status | Description |
|
||||
|------|--------|-------------|
|
||||
| Python 3 migration | deferred | Unblocks modern deps, security patches, pyasn native |
|
||||
| Worker trust scoring | pending | Activate spot-check verification framework |
|
||||
| Dynamic target pool | pending | Auto-discover and rotate validation targets |
|
||||
| Geographic target spread | pending | Ensure targets span multiple regions |
|
||||
|
||||
---
|
||||
|
||||
## Completed
|
||||
|
||||
### Target Management
|
||||
|
||||
| Task | Description | File(s) |
|
||||
|------|-------------|---------|
|
||||
| Target health tracking | Cooldown-based health tracking for all target pools (head, SSL, IRC, judges) | stats.py, proxywatchd.py |
|
||||
| MITM field in proxy list | Expose mitm boolean in JSON proxy list endpoints | httpd.py |
|
||||
|
||||
---
|
||||
|
||||
## Open Work
|
||||
|
||||
### Target Management
|
||||
|
||||
| Task | Description | File(s) |
|
||||
|------|-------------|---------|
|
||||
| Dynamic target pool | Auto-discover and rotate validation targets | proxywatchd.py |
|
||||
| Geographic target spread | Ensure targets span multiple regions | config.py |
|
||||
| Item | Date | Description |
|
||||
|------|------|-------------|
|
||||
| last_seen freshness fix | 2026-02-22 | Watchd updates last_seen on verification |
|
||||
| Periodic re-seeding | 2026-02-22 | Reset errored sources every 6h |
|
||||
| ASN enrichment | 2026-02-22 | Pure-Python ipasn.dat reader + backfill |
|
||||
| URL pipeline stats | 2026-02-22 | /api/stats exposes source health metrics |
|
||||
| Extraction short-circuits | 2026-02-22 | Guard clauses + precompiled table regexes |
|
||||
| Target health tracking | prior | Cooldown-based health for all target pools |
|
||||
| MITM field in proxy list | prior | Expose mitm boolean in JSON endpoints |
|
||||
| V1 worker protocol removal | prior | Cleaned up legacy --worker code path |
|
||||
|
||||
---
|
||||
|
||||
@@ -71,31 +94,12 @@ PPF (Proxy Fetcher) is a Python 2 proxy scraping and validation framework design
|
||||
|
||||
| File | Purpose |
|
||||
|------|---------|
|
||||
| ppf.py | Main URL harvester daemon |
|
||||
| ppf.py | URL harvester, worker main loop |
|
||||
| proxywatchd.py | Proxy validation daemon |
|
||||
| scraper.py | Searx search integration |
|
||||
| fetch.py | HTTP fetching with proxy support |
|
||||
| dbs.py | Database schema and inserts |
|
||||
| mysqlite.py | SQLite wrapper |
|
||||
| rocksock.py | Socket/proxy abstraction (3rd party) |
|
||||
| http2.py | HTTP client implementation |
|
||||
| httpd.py | Web dashboard and REST API server |
|
||||
| fetch.py | HTTP fetching, proxy extraction |
|
||||
| httpd.py | API server, worker coordination |
|
||||
| dbs.py | Database schema, seed sources |
|
||||
| config.py | Configuration management |
|
||||
| comboparse.py | Config/arg parser framework |
|
||||
| soup_parser.py | BeautifulSoup wrapper |
|
||||
| misc.py | Utilities (timestamp, logging) |
|
||||
| export.py | Proxy export CLI tool |
|
||||
| engines.py | Search engine implementations |
|
||||
| connection_pool.py | Tor connection pooling |
|
||||
| network_stats.py | Network statistics tracking |
|
||||
| dns.py | DNS resolution with caching |
|
||||
| mitm.py | MITM certificate detection |
|
||||
| job.py | Priority job queue |
|
||||
| static/dashboard.js | Dashboard frontend logic |
|
||||
| static/dashboard.html | Dashboard HTML template |
|
||||
| tools/lib/ppf-common.sh | Shared ops library (hosts, wrappers, colors) |
|
||||
| tools/ppf-deploy | Deploy wrapper (validation + playbook) |
|
||||
| tools/ppf-logs | View container logs |
|
||||
| tools/ppf-service | Container lifecycle management |
|
||||
| tools/playbooks/deploy.yml | Ansible deploy playbook |
|
||||
| tools/playbooks/inventory.ini | Host inventory (WireGuard IPs) |
|
||||
| rocksock.py | Socket/proxy abstraction |
|
||||
| http2.py | HTTP client implementation |
|
||||
| tools/ppf-deploy | Deployment wrapper |
|
||||
|
||||
32
TASKLIST.md
Normal file
32
TASKLIST.md
Normal file
@@ -0,0 +1,32 @@
|
||||
# PPF Tasklist
|
||||
|
||||
Active execution queue. Ordered by priority.
|
||||
|
||||
---
|
||||
|
||||
## In Progress
|
||||
|
||||
| # | Task | File(s) | Notes |
|
||||
|---|------|---------|-------|
|
||||
| 1 | Skip socket.shutdown on failed connections | rocksock.py | ~39s/session saved on workers |
|
||||
| 4 | Add more seed sources (100+) | dbs.py | Expand PROXY_SOURCES list |
|
||||
| 6 | Protocol-aware source weighting | httpd.py, ppf.py | Prioritize SOCKS5-yielding sources |
|
||||
|
||||
## Queued
|
||||
|
||||
| # | Task | File(s) | Notes |
|
||||
|---|------|---------|-------|
|
||||
| 2 | SQLite connection reuse on odin | httpd.py | Cache per-greenlet handle |
|
||||
| 3 | Lazy-load ASN database | httpd.py | Defer to first lookup |
|
||||
| 12 | API filters on /proxies (proto/country/ASN) | httpd.py | Consumer query params |
|
||||
| 8 | Graduated recheck intervals | proxywatchd.py | Fresh proxies checked more often |
|
||||
|
||||
## Done
|
||||
|
||||
| # | Task | Date |
|
||||
|---|------|------|
|
||||
| - | Extraction short-circuits | 2026-02-22 |
|
||||
| - | last_seen freshness fix | 2026-02-22 |
|
||||
| - | Periodic re-seeding | 2026-02-22 |
|
||||
| - | ASN enrichment | 2026-02-22 |
|
||||
| - | URL pipeline stats | 2026-02-22 |
|
||||
82
TODO.md
82
TODO.md
@@ -1,83 +1,35 @@
|
||||
# PPF TODO
|
||||
|
||||
## Optimization
|
||||
|
||||
### [ ] JSON Stats Response Caching
|
||||
|
||||
- Cache serialized JSON response with short TTL (1-2s)
|
||||
- Only regenerate when underlying stats change
|
||||
- Use ETag/If-None-Match for client-side caching
|
||||
- Savings: ~7-9s/hour. Low priority, only matters with frequent dashboard access.
|
||||
|
||||
### [ ] Object Pooling for Test States
|
||||
|
||||
- Pool ProxyTestState and TargetTestJob, reset and reuse
|
||||
- Savings: ~11-15s/hour. **Not recommended** - high effort, medium risk, modest gain.
|
||||
|
||||
### [ ] SQLite Connection Reuse
|
||||
|
||||
- Persistent connection per thread with health checks
|
||||
- Savings: ~0.3s/hour. **Not recommended** - negligible benefit.
|
||||
Intake buffer. Items refined here move to TASKLIST.md.
|
||||
|
||||
---
|
||||
|
||||
## Dashboard
|
||||
|
||||
### [ ] Performance
|
||||
|
||||
- Cache expensive DB queries (top countries, protocol breakdown)
|
||||
- Lazy-load historical data (only when scrolled into view)
|
||||
- WebSocket option for push updates (reduce polling overhead)
|
||||
- Configurable refresh interval via URL param or localStorage
|
||||
|
||||
### [ ] Features
|
||||
|
||||
- Historical graphs (24h, 7d) using stats_history table
|
||||
- Per-ASN performance analysis
|
||||
- Alert thresholds (success rate < X%, MITM detected)
|
||||
- Mobile-responsive improvements
|
||||
|
||||
---
|
||||
- [ ] Cache expensive DB queries (top countries, protocol breakdown)
|
||||
- [ ] Historical graphs (24h, 7d) using stats_history table
|
||||
- [ ] Per-ASN performance analysis
|
||||
- [ ] Alert thresholds (success rate < X%, MITM detected)
|
||||
- [ ] WebSocket push updates (reduce polling overhead)
|
||||
- [ ] Mobile-responsive improvements
|
||||
|
||||
## Memory
|
||||
|
||||
- [ ] Lock consolidation - reduce per-proxy locks (260k LockType objects)
|
||||
- [ ] Leaner state objects - reduce dict/list count per job
|
||||
- [ ] Lock consolidation (260k LockType objects at scale)
|
||||
- [ ] Leaner state objects per job
|
||||
|
||||
Memory scales linearly with queue (~4.5 KB/job). No leaks detected.
|
||||
Optimize only if memory becomes a constraint.
|
||||
Memory scales ~4.5 KB/job. No leaks detected. Optimize only if constrained.
|
||||
|
||||
---
|
||||
## Source Pipeline
|
||||
|
||||
## Deprecation
|
||||
|
||||
### [x] Remove V1 worker protocol
|
||||
|
||||
Completed. Removed `--worker` flag, `worker_main()`, `claim_work()`,
|
||||
`submit_results()`, `/api/work`, `/api/results`, and related config
|
||||
options. `--worker` now routes to the URL-driven protocol.
|
||||
|
||||
---
|
||||
- [ ] PasteBin/GitHub API scrapers for proxy lists
|
||||
- [ ] Telegram channel scrapers (beyond t.me/s/ HTML)
|
||||
- [ ] Source quality decay tracking (flag sources going stale)
|
||||
- [ ] Deduplication of sources across different URL forms
|
||||
|
||||
## Known Issues
|
||||
|
||||
### [!] Podman Container Metadata Disappears
|
||||
|
||||
`podman ps -a` shows empty even though process is running. Service functions
|
||||
correctly despite missing metadata. Monitor via `ss -tlnp`, `ps aux`, or
|
||||
`curl localhost:8081/health`. Low impact.
|
||||
|
||||
---
|
||||
|
||||
## Container Debugging Checklist
|
||||
|
||||
```
|
||||
1. Check for orphans: ps aux | grep -E "[p]rocess_name"
|
||||
2. Check port conflicts: ss -tlnp | grep PORT
|
||||
3. Run foreground: podman run --rm (no -d) to see output
|
||||
4. Check podman state: podman ps -a
|
||||
5. Clean stale: pkill -9 -f "pattern" && podman rm -f -a
|
||||
6. Verify deps: config files, data dirs, volumes exist
|
||||
7. Check logs: podman logs container_name 2>&1 | tail -50
|
||||
8. Health check: curl -sf http://localhost:PORT/health
|
||||
```
|
||||
`podman ps -a` shows empty even though process is running.
|
||||
Monitor via `ss -tlnp`, `ps aux`, or `curl localhost:8081/health`.
|
||||
|
||||
126
dbs.py
126
dbs.py
@@ -582,34 +582,86 @@ def insert_urls(urls, search, sqlite):
|
||||
|
||||
# Known proxy list sources (GitHub raw lists, APIs)
|
||||
PROXY_SOURCES = [
|
||||
# --- GitHub raw lists (sorted by update frequency) ---
|
||||
|
||||
# TheSpeedX/PROXY-List - large, hourly updates
|
||||
'https://raw.githubusercontent.com/TheSpeedX/PROXY-List/master/http.txt',
|
||||
'https://raw.githubusercontent.com/TheSpeedX/PROXY-List/master/socks4.txt',
|
||||
'https://raw.githubusercontent.com/TheSpeedX/PROXY-List/master/socks5.txt',
|
||||
# clarketm/proxy-list - curated, daily
|
||||
'https://raw.githubusercontent.com/clarketm/proxy-list/master/proxy-list-raw.txt',
|
||||
# monosans/proxy-list - hourly updates
|
||||
'https://raw.githubusercontent.com/monosans/proxy-list/main/proxies/http.txt',
|
||||
'https://raw.githubusercontent.com/monosans/proxy-list/main/proxies/socks4.txt',
|
||||
'https://raw.githubusercontent.com/monosans/proxy-list/main/proxies/socks5.txt',
|
||||
# prxchk/proxy-list - 10 min updates
|
||||
'https://raw.githubusercontent.com/prxchk/proxy-list/main/http.txt',
|
||||
'https://raw.githubusercontent.com/prxchk/proxy-list/main/socks4.txt',
|
||||
'https://raw.githubusercontent.com/prxchk/proxy-list/main/socks5.txt',
|
||||
# jetkai/proxy-list - 10 min updates
|
||||
'https://raw.githubusercontent.com/jetkai/proxy-list/main/online-proxies/txt/proxies.txt',
|
||||
# roosterkid/openproxylist
|
||||
'https://raw.githubusercontent.com/roosterkid/openproxylist/main/HTTPS_RAW.txt',
|
||||
'https://raw.githubusercontent.com/roosterkid/openproxylist/main/SOCKS4_RAW.txt',
|
||||
'https://raw.githubusercontent.com/roosterkid/openproxylist/main/SOCKS5_RAW.txt',
|
||||
# ShiftyTR/Proxy-List
|
||||
'https://raw.githubusercontent.com/ShiftyTR/Proxy-List/master/http.txt',
|
||||
'https://raw.githubusercontent.com/ShiftyTR/Proxy-List/master/socks4.txt',
|
||||
'https://raw.githubusercontent.com/ShiftyTR/Proxy-List/master/socks5.txt',
|
||||
# hookzof/socks5_list - hourly, SOCKS5 focused
|
||||
'https://raw.githubusercontent.com/hookzof/socks5_list/master/proxy.txt',
|
||||
# mmpx12/proxy-list
|
||||
'https://raw.githubusercontent.com/mmpx12/proxy-list/master/http.txt',
|
||||
'https://raw.githubusercontent.com/mmpx12/proxy-list/master/socks4.txt',
|
||||
'https://raw.githubusercontent.com/mmpx12/proxy-list/master/socks5.txt',
|
||||
# proxyscrape API
|
||||
'https://api.proxyscrape.com/v2/?request=displayproxies&protocol=http&timeout=10000&country=all',
|
||||
'https://api.proxyscrape.com/v2/?request=displayproxies&protocol=socks4&timeout=10000&country=all',
|
||||
'https://api.proxyscrape.com/v2/?request=displayproxies&protocol=socks5&timeout=10000&country=all',
|
||||
# ShiftyTR/Proxy-List
|
||||
'https://raw.githubusercontent.com/ShiftyTR/Proxy-List/master/http.txt',
|
||||
'https://raw.githubusercontent.com/ShiftyTR/Proxy-List/master/socks4.txt',
|
||||
'https://raw.githubusercontent.com/ShiftyTR/Proxy-List/master/socks5.txt',
|
||||
# roosterkid/openproxylist
|
||||
'https://raw.githubusercontent.com/roosterkid/openproxylist/main/HTTPS_RAW.txt',
|
||||
'https://raw.githubusercontent.com/roosterkid/openproxylist/main/SOCKS4_RAW.txt',
|
||||
'https://raw.githubusercontent.com/roosterkid/openproxylist/main/SOCKS5_RAW.txt',
|
||||
# clarketm/proxy-list - curated, daily
|
||||
'https://raw.githubusercontent.com/clarketm/proxy-list/master/proxy-list-raw.txt',
|
||||
# officialputuid/KangProxy - 4-6 hour updates
|
||||
'https://raw.githubusercontent.com/officialputuid/KangProxy/KangProxy/http/http.txt',
|
||||
'https://raw.githubusercontent.com/officialputuid/KangProxy/KangProxy/socks4/socks4.txt',
|
||||
'https://raw.githubusercontent.com/officialputuid/KangProxy/KangProxy/socks5/socks5.txt',
|
||||
# iplocate/free-proxy-list - 30 min updates
|
||||
'https://raw.githubusercontent.com/iplocate/free-proxy-list/main/protocols/http.txt',
|
||||
'https://raw.githubusercontent.com/iplocate/free-proxy-list/main/protocols/socks4.txt',
|
||||
'https://raw.githubusercontent.com/iplocate/free-proxy-list/main/protocols/socks5.txt',
|
||||
# ErcinDedeworken/proxy-list - hourly
|
||||
'https://raw.githubusercontent.com/ErcinDedeworken/proxy-list/main/proxy-list/data.txt',
|
||||
# MuRongPIG/Proxy-Master - 10 min updates
|
||||
'https://raw.githubusercontent.com/MuRongPIG/Proxy-Master/main/http.txt',
|
||||
'https://raw.githubusercontent.com/MuRongPIG/Proxy-Master/main/socks4.txt',
|
||||
'https://raw.githubusercontent.com/MuRongPIG/Proxy-Master/main/socks5.txt',
|
||||
# zloi-user/hideip.me - hourly
|
||||
'https://raw.githubusercontent.com/zloi-user/hideip.me/main/http.txt',
|
||||
'https://raw.githubusercontent.com/zloi-user/hideip.me/main/socks4.txt',
|
||||
'https://raw.githubusercontent.com/zloi-user/hideip.me/main/socks5.txt',
|
||||
# FLAVIEN-music/proxy-list - 30 min updates
|
||||
'https://raw.githubusercontent.com/FLAVIEN-music/proxy-list/main/proxies/http.txt',
|
||||
'https://raw.githubusercontent.com/FLAVIEN-music/proxy-list/main/proxies/socks4.txt',
|
||||
'https://raw.githubusercontent.com/FLAVIEN-music/proxy-list/main/proxies/socks5.txt',
|
||||
# Zaeem20/FREE_PROXIES_LIST - 30 min updates
|
||||
'https://raw.githubusercontent.com/Zaeem20/FREE_PROXIES_LIST/master/http.txt',
|
||||
'https://raw.githubusercontent.com/Zaeem20/FREE_PROXIES_LIST/master/https.txt',
|
||||
'https://raw.githubusercontent.com/Zaeem20/FREE_PROXIES_LIST/master/socks4.txt',
|
||||
'https://raw.githubusercontent.com/Zaeem20/FREE_PROXIES_LIST/master/socks5.txt',
|
||||
# r00tee/Proxy-List - hourly
|
||||
'https://raw.githubusercontent.com/r00tee/Proxy-List/main/Https.txt',
|
||||
'https://raw.githubusercontent.com/r00tee/Proxy-List/main/Socks4.txt',
|
||||
'https://raw.githubusercontent.com/r00tee/Proxy-List/main/Socks5.txt',
|
||||
# casals-ar/proxy-list
|
||||
'https://raw.githubusercontent.com/casals-ar/proxy-list/main/http',
|
||||
'https://raw.githubusercontent.com/casals-ar/proxy-list/main/socks4',
|
||||
'https://raw.githubusercontent.com/casals-ar/proxy-list/main/socks5',
|
||||
# yemixzy/proxy-list
|
||||
'https://raw.githubusercontent.com/yemixzy/proxy-list/main/proxies/http.txt',
|
||||
'https://raw.githubusercontent.com/yemixzy/proxy-list/main/proxies/socks4.txt',
|
||||
'https://raw.githubusercontent.com/yemixzy/proxy-list/main/proxies/socks5.txt',
|
||||
# opsxcq/proxy-list
|
||||
'https://raw.githubusercontent.com/opsxcq/proxy-list/master/list.txt',
|
||||
# im-razvan/proxy_list - 10 min updates
|
||||
'https://raw.githubusercontent.com/im-razvan/proxy_list/main/http.txt',
|
||||
'https://raw.githubusercontent.com/im-razvan/proxy_list/main/socks4.txt',
|
||||
'https://raw.githubusercontent.com/im-razvan/proxy_list/main/socks5.txt',
|
||||
|
||||
# --- GitHub Pages / CDN hosted ---
|
||||
|
||||
# proxifly/free-proxy-list - 5 min updates (jsDelivr CDN)
|
||||
'https://cdn.jsdelivr.net/gh/proxifly/free-proxy-list@main/proxies/protocols/http/data.txt',
|
||||
'https://cdn.jsdelivr.net/gh/proxifly/free-proxy-list@main/proxies/protocols/socks4/data.txt',
|
||||
@@ -618,24 +670,42 @@ PROXY_SOURCES = [
|
||||
'https://vakhov.github.io/fresh-proxy-list/http.txt',
|
||||
'https://vakhov.github.io/fresh-proxy-list/socks4.txt',
|
||||
'https://vakhov.github.io/fresh-proxy-list/socks5.txt',
|
||||
# prxchk/proxy-list - 10 min updates
|
||||
'https://raw.githubusercontent.com/prxchk/proxy-list/main/http.txt',
|
||||
'https://raw.githubusercontent.com/prxchk/proxy-list/main/socks4.txt',
|
||||
'https://raw.githubusercontent.com/prxchk/proxy-list/main/socks5.txt',
|
||||
# sunny9577/proxy-scraper - 3 hour updates (GitHub Pages)
|
||||
'https://sunny9577.github.io/proxy-scraper/generated/http_proxies.txt',
|
||||
'https://sunny9577.github.io/proxy-scraper/generated/socks4_proxies.txt',
|
||||
'https://sunny9577.github.io/proxy-scraper/generated/socks5_proxies.txt',
|
||||
# officialputuid/KangProxy - 4-6 hour updates
|
||||
'https://raw.githubusercontent.com/officialputuid/KangProxy/KangProxy/http/http.txt',
|
||||
'https://raw.githubusercontent.com/officialputuid/KangProxy/KangProxy/socks4/socks4.txt',
|
||||
'https://raw.githubusercontent.com/officialputuid/KangProxy/KangProxy/socks5/socks5.txt',
|
||||
# hookzof/socks5_list - hourly updates
|
||||
'https://raw.githubusercontent.com/hookzof/socks5_list/master/proxy.txt',
|
||||
# iplocate/free-proxy-list - 30 min updates
|
||||
'https://raw.githubusercontent.com/iplocate/free-proxy-list/main/protocols/http.txt',
|
||||
'https://raw.githubusercontent.com/iplocate/free-proxy-list/main/protocols/socks4.txt',
|
||||
'https://raw.githubusercontent.com/iplocate/free-proxy-list/main/protocols/socks5.txt',
|
||||
|
||||
# --- API endpoints ---
|
||||
|
||||
# proxyscrape
|
||||
'https://api.proxyscrape.com/v2/?request=displayproxies&protocol=http&timeout=10000&country=all',
|
||||
'https://api.proxyscrape.com/v2/?request=displayproxies&protocol=socks4&timeout=10000&country=all',
|
||||
'https://api.proxyscrape.com/v2/?request=displayproxies&protocol=socks5&timeout=10000&country=all',
|
||||
|
||||
# --- Web scrapers (HTML pages) ---
|
||||
|
||||
# spys.one - mixed protocols, requires parsing
|
||||
'https://spys.one/en/free-proxy-list/',
|
||||
'https://spys.one/en/socks-proxy-list/',
|
||||
'https://spys.one/en/https-ssl-proxy/',
|
||||
# free-proxy-list.net
|
||||
'https://free-proxy-list.net/',
|
||||
'https://www.sslproxies.org/',
|
||||
'https://www.socks-proxy.net/',
|
||||
# geonode
|
||||
'https://proxylist.geonode.com/api/proxy-list?limit=500&page=1&sort_by=lastChecked&sort_type=desc&protocols=http',
|
||||
'https://proxylist.geonode.com/api/proxy-list?limit=500&page=1&sort_by=lastChecked&sort_type=desc&protocols=socks4',
|
||||
'https://proxylist.geonode.com/api/proxy-list?limit=500&page=1&sort_by=lastChecked&sort_type=desc&protocols=socks5',
|
||||
# openproxy.space
|
||||
'https://openproxy.space/list/http',
|
||||
'https://openproxy.space/list/socks4',
|
||||
'https://openproxy.space/list/socks5',
|
||||
|
||||
# --- Telegram channels (public HTML view) ---
|
||||
|
||||
'https://t.me/s/spys_one',
|
||||
'https://t.me/s/proxyfree1',
|
||||
'https://t.me/s/proxylist4free',
|
||||
]
|
||||
|
||||
|
||||
|
||||
45
httpd.py
45
httpd.py
@@ -350,6 +350,40 @@ def get_worker_test_rate(worker_id):
|
||||
return 0.0
|
||||
return total_tests / elapsed
|
||||
|
||||
def _get_proto_boost():
|
||||
"""Calculate protocol scarcity boost for URL scoring.
|
||||
|
||||
Returns a value 0.0-1.0 to boost SOCKS sources when SOCKS proxies
|
||||
are underrepresented relative to HTTP. Returns 0.0 when balanced.
|
||||
"""
|
||||
try:
|
||||
db = mysqlite.mysqlite(_proxy_database, str) if _proxy_database else None
|
||||
if not db:
|
||||
return 0.0
|
||||
row = db.execute(
|
||||
"SELECT "
|
||||
" SUM(CASE WHEN proto='http' THEN 1 ELSE 0 END),"
|
||||
" SUM(CASE WHEN proto IN ('socks4','socks5') THEN 1 ELSE 0 END)"
|
||||
" FROM proxylist WHERE failed=0"
|
||||
).fetchone()
|
||||
if not row or not row[0]:
|
||||
return 0.5 # no data, default mild boost
|
||||
http_count, socks_count = row[0] or 0, row[1] or 0
|
||||
total = http_count + socks_count
|
||||
if total == 0:
|
||||
return 0.5
|
||||
socks_ratio = float(socks_count) / total
|
||||
# Boost SOCKS sources when socks_ratio < 40%
|
||||
if socks_ratio >= 0.4:
|
||||
return 0.0
|
||||
return min((0.4 - socks_ratio) * 2.5, 1.0) # 0.0-1.0 scale
|
||||
except Exception:
|
||||
return 0.0
|
||||
|
||||
# Global reference to proxy database path (set by ProxyAPIServer.__init__)
|
||||
_proxy_database = None
|
||||
|
||||
|
||||
def claim_urls(url_db, worker_id, count=5):
|
||||
"""Claim a batch of URLs for worker-driven fetching. Returns list of URL dicts.
|
||||
|
||||
@@ -360,6 +394,7 @@ def claim_urls(url_db, worker_id, count=5):
|
||||
- quality_bonus: 0-0.5 based on working_ratio
|
||||
- error_penalty: 0-2.0 based on consecutive errors
|
||||
- stale_penalty: 0-1.0 based on unchanged fetches
|
||||
- proto_boost: 0-1.0 for SOCKS sources when SOCKS underrepresented
|
||||
"""
|
||||
now = time.time()
|
||||
now_int = int(now)
|
||||
@@ -385,6 +420,9 @@ def claim_urls(url_db, worker_id, count=5):
|
||||
list_max_age_seconds = _url_list_max_age_days * 86400
|
||||
min_added = now_int - list_max_age_seconds
|
||||
|
||||
# Boost SOCKS sources when protocol pool is imbalanced
|
||||
proto_boost = _get_proto_boost()
|
||||
|
||||
try:
|
||||
rows = url_db.execute(
|
||||
'''SELECT url, content_hash,
|
||||
@@ -393,6 +431,8 @@ def claim_urls(url_db, worker_id, count=5):
|
||||
+ COALESCE(working_ratio, 0) * 0.5
|
||||
- MIN(error * 0.3, 2.0)
|
||||
- MIN(stale_count * 0.1, 1.0)
|
||||
+ CASE WHEN LOWER(url) LIKE '%socks5%' OR LOWER(url) LIKE '%socks4%'
|
||||
THEN ? ELSE 0 END
|
||||
AS score
|
||||
FROM uris
|
||||
WHERE error < ?
|
||||
@@ -400,7 +440,7 @@ def claim_urls(url_db, worker_id, count=5):
|
||||
AND (added > ? OR proxies_added > 0)
|
||||
ORDER BY score DESC
|
||||
LIMIT ?''',
|
||||
(now_int, _url_max_fail, now_int, min_added, count * 3)
|
||||
(now_int, proto_boost, _url_max_fail, now_int, min_added, count * 3)
|
||||
).fetchall()
|
||||
except Exception as e:
|
||||
_log('claim_urls query error: %s' % e, 'error')
|
||||
@@ -1355,8 +1395,9 @@ class ProxyAPIServer(threading.Thread):
|
||||
self.stats_provider = stats_provider
|
||||
self.profiling = profiling
|
||||
self.daemon = True
|
||||
global _url_database_path
|
||||
global _url_database_path, _proxy_database
|
||||
_url_database_path = url_database
|
||||
_proxy_database = database
|
||||
self.server = None
|
||||
self._stop_event = threading.Event() if not GEVENT_PATCHED else None
|
||||
# Load static library files into cache
|
||||
|
||||
12
rocksock.py
12
rocksock.py
@@ -242,6 +242,7 @@ class Rocksock():
|
||||
target = RocksockProxy(host, port, RS_PT_NONE)
|
||||
self.proxychain.append(target)
|
||||
self.sock = None
|
||||
self._connected = False
|
||||
self.timeout = timeout
|
||||
|
||||
def _translate_socket_error(self, e, pnum):
|
||||
@@ -302,15 +303,18 @@ class Rocksock():
|
||||
select.select([], [self.sock], [])
|
||||
"""
|
||||
|
||||
self._connected = True
|
||||
|
||||
def disconnect(self):
|
||||
if self.sock is None: return
|
||||
try:
|
||||
self.sock.shutdown(socket.SHUT_RDWR)
|
||||
except socket.error:
|
||||
pass
|
||||
if self._connected:
|
||||
try:
|
||||
self.sock.shutdown(socket.SHUT_RDWR)
|
||||
except socket.error:
|
||||
pass
|
||||
self.sock.close()
|
||||
self.sock = None
|
||||
self._connected = False
|
||||
|
||||
def canread(self):
|
||||
return select.select([self.sock], [], [], 0)[0]
|
||||
|
||||
Reference in New Issue
Block a user