proxy-search 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- proxy_search-1.0.0/PKG-INFO +62 -0
- proxy_search-1.0.0/README.md +40 -0
- proxy_search-1.0.0/main.py +301 -0
- proxy_search-1.0.0/proxy_search.egg-info/PKG-INFO +62 -0
- proxy_search-1.0.0/proxy_search.egg-info/SOURCES.txt +10 -0
- proxy_search-1.0.0/proxy_search.egg-info/dependency_links.txt +1 -0
- proxy_search-1.0.0/proxy_search.egg-info/entry_points.txt +2 -0
- proxy_search-1.0.0/proxy_search.egg-info/requires.txt +3 -0
- proxy_search-1.0.0/proxy_search.egg-info/top_level.txt +1 -0
- proxy_search-1.0.0/pyproject.toml +37 -0
- proxy_search-1.0.0/setup.cfg +4 -0
- proxy_search-1.0.0/tests/test_parser.py +31 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: proxy-search
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Search GitHub for Telegram proxy lists and verify HTTP/SOCKS proxies against Telegram.
|
|
5
|
+
Project-URL: Homepage, https://github.com/zmlsaggg/proxy-search
|
|
6
|
+
Project-URL: Repository, https://github.com/zmlsaggg/proxy-search
|
|
7
|
+
Project-URL: Issues, https://github.com/zmlsaggg/proxy-search/issues
|
|
8
|
+
Classifier: Environment :: Console
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
14
|
+
Classifier: Topic :: Communications :: Chat
|
|
15
|
+
Classifier: Topic :: Internet
|
|
16
|
+
Classifier: Topic :: Utilities
|
|
17
|
+
Requires-Python: >=3.11
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
Requires-Dist: httpx[socks]<1,>=0.27
|
|
20
|
+
Requires-Dist: rich<15,>=13.7
|
|
21
|
+
Requires-Dist: pyperclip<2,>=1.9
|
|
22
|
+
|
|
23
|
+
# TELEGRAM PROXY SEARCHER
|
|
24
|
+
|
|
25
|
+
## Установка через PyPI
|
|
26
|
+
|
|
27
|
+
```powershell
|
|
28
|
+
py -m pip install proxy-search
|
|
29
|
+
telegram-proxy-searcher
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Для изолированной установки CLI можно использовать `pipx install proxy-search`.
|
|
33
|
+
После установки локальная база и список рабочих прокси сохраняются в пользовательской папке данных Windows, macOS или Linux, а не внутри каталога Python.
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
Console utility by **zmlsag**. Searches GitHub repositories for Telegram proxy lists, extracts supported formats, checks HTTP/SOCKS proxies against Telegram from the user's current network, and stores results locally.
|
|
37
|
+
|
|
38
|
+
## Windows
|
|
39
|
+
1. Install Python 3.11+.
|
|
40
|
+
2. Run install.bat once.
|
|
41
|
+
3. Run start.bat.
|
|
42
|
+
|
|
43
|
+
Optional GitHub token (PowerShell):
|
|
44
|
+
$env:GITHUB_TOKEN="github_pat_..."
|
|
45
|
+
.\start.bat
|
|
46
|
+
|
|
47
|
+
## Menu
|
|
48
|
+
1. Find working proxies — search GitHub, index repositories, extract endpoints, check them.
|
|
49
|
+
2. Update proxy database — rescan repositories already saved locally.
|
|
50
|
+
3. Check application updates from this repository.
|
|
51
|
+
4. View results and copy confirmed working proxies.
|
|
52
|
+
|
|
53
|
+
Local database: data/database.json. Confirmed HTTP/SOCKS endpoints: data/working.txt.
|
|
54
|
+
|
|
55
|
+
## Verification
|
|
56
|
+
- HTTP and SOCKS5 are WORKING only after a request to Telegram HTTPS succeeds through that proxy.
|
|
57
|
+
- MTProto entries are marked REVIEW when the TCP port accepts a connection. TCP reachability alone does not prove an MTProto handshake, so they are excluded from automatic copy.
|
|
58
|
+
- Checks run from the computer launching the tool and reflect its current ISP/network route.
|
|
59
|
+
- Repository content is treated as untrusted text. No downloaded repository code is executed.
|
|
60
|
+
- Unauthenticated GitHub search is rate-limited; set GITHUB_TOKEN for higher limits.
|
|
61
|
+
|
|
62
|
+
Supported formats: tg://proxy links, t.me/proxy links, socks5/http URLs, and IPv4:port candidates.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# TELEGRAM PROXY SEARCHER
|
|
2
|
+
|
|
3
|
+
## Установка через PyPI
|
|
4
|
+
|
|
5
|
+
```powershell
|
|
6
|
+
py -m pip install proxy-search
|
|
7
|
+
telegram-proxy-searcher
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
Для изолированной установки CLI можно использовать `pipx install proxy-search`.
|
|
11
|
+
После установки локальная база и список рабочих прокси сохраняются в пользовательской папке данных Windows, macOS или Linux, а не внутри каталога Python.
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
Console utility by **zmlsag**. Searches GitHub repositories for Telegram proxy lists, extracts supported formats, checks HTTP/SOCKS proxies against Telegram from the user's current network, and stores results locally.
|
|
15
|
+
|
|
16
|
+
## Windows
|
|
17
|
+
1. Install Python 3.11+.
|
|
18
|
+
2. Run install.bat once.
|
|
19
|
+
3. Run start.bat.
|
|
20
|
+
|
|
21
|
+
Optional GitHub token (PowerShell):
|
|
22
|
+
$env:GITHUB_TOKEN="github_pat_..."
|
|
23
|
+
.\start.bat
|
|
24
|
+
|
|
25
|
+
## Menu
|
|
26
|
+
1. Find working proxies — search GitHub, index repositories, extract endpoints, check them.
|
|
27
|
+
2. Update proxy database — rescan repositories already saved locally.
|
|
28
|
+
3. Check application updates from this repository.
|
|
29
|
+
4. View results and copy confirmed working proxies.
|
|
30
|
+
|
|
31
|
+
Local database: data/database.json. Confirmed HTTP/SOCKS endpoints: data/working.txt.
|
|
32
|
+
|
|
33
|
+
## Verification
|
|
34
|
+
- HTTP and SOCKS5 are WORKING only after a request to Telegram HTTPS succeeds through that proxy.
|
|
35
|
+
- MTProto entries are marked REVIEW when the TCP port accepts a connection. TCP reachability alone does not prove an MTProto handshake, so they are excluded from automatic copy.
|
|
36
|
+
- Checks run from the computer launching the tool and reflect its current ISP/network route.
|
|
37
|
+
- Repository content is treated as untrusted text. No downloaded repository code is executed.
|
|
38
|
+
- Unauthenticated GitHub search is rate-limited; set GITHUB_TOKEN for higher limits.
|
|
39
|
+
|
|
40
|
+
Supported formats: tg://proxy links, t.me/proxy links, socks5/http URLs, and IPv4:port candidates.
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
import asyncio, base64, ipaddress, json, os, re, shutil, subprocess, sys, tempfile, zipfile
|
|
3
|
+
from datetime import datetime, timezone
|
|
4
|
+
from importlib.metadata import PackageNotFoundError, distribution as get_distribution
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
from urllib.parse import urlparse, parse_qs, urlencode
|
|
7
|
+
import httpx
|
|
8
|
+
from rich.console import Console
|
|
9
|
+
from rich.panel import Panel
|
|
10
|
+
from rich.progress import Progress, SpinnerColumn, BarColumn, TextColumn, TimeElapsedColumn
|
|
11
|
+
from rich.table import Table
|
|
12
|
+
from rich.prompt import Prompt, Confirm
|
|
13
|
+
from rich.text import Text
|
|
14
|
+
|
|
15
|
+
APP="TELEGRAM PROXY SEARCHER"; VERSION="1.0.0"; OWNER="zmlsaggg"; REPO="proxy-search"
|
|
16
|
+
ROOT=Path(sys.executable).resolve().parent if getattr(sys, "frozen", False) else Path(__file__).resolve().parent
|
|
17
|
+
PACKAGE_NAME="proxy-search"
|
|
18
|
+
try:
|
|
19
|
+
_installed_main = Path(get_distribution(PACKAGE_NAME).locate_file("main.py")).resolve()
|
|
20
|
+
_PYPI_INSTALL = _installed_main == Path(__file__).resolve()
|
|
21
|
+
except PackageNotFoundError:
|
|
22
|
+
_PYPI_INSTALL = False
|
|
23
|
+
|
|
24
|
+
if _PYPI_INSTALL:
|
|
25
|
+
if os.name == "nt":
|
|
26
|
+
_data_root = Path(os.getenv("LOCALAPPDATA", str(Path.home() / "AppData" / "Local")))
|
|
27
|
+
elif sys.platform == "darwin":
|
|
28
|
+
_data_root = Path.home() / "Library" / "Application Support"
|
|
29
|
+
else:
|
|
30
|
+
_data_root = Path(os.getenv("XDG_DATA_HOME", str(Path.home() / ".local" / "share")))
|
|
31
|
+
DATA = _data_root / "TelegramProxySearcher"
|
|
32
|
+
else:
|
|
33
|
+
# Preserve the existing repository-local database for source checkouts.
|
|
34
|
+
DATA = ROOT / "data"
|
|
35
|
+
DB_FILE=DATA/"database.json"; WORKING_FILE=DATA/"working.txt"
|
|
36
|
+
QUERIES=["mtproxy", '"mtproto proxy"', '"telegram proxy"', "tg://proxy", '"telegram bypass" proxy', "mtproto", "telegram socks5 proxy", "telegram-proxy-list", "телеграм прокси"]
|
|
37
|
+
MAX_REPO_FILES=35; MAX_FILE_BYTES=450_000; TIMEOUT=7.0
|
|
38
|
+
console=Console()
|
|
39
|
+
|
|
40
|
+
def now(): return datetime.now(timezone.utc).isoformat()
|
|
41
|
+
def load_db():
|
|
42
|
+
DATA.mkdir(exist_ok=True)
|
|
43
|
+
if not DB_FILE.exists(): return {"version":1,"repositories":{},"proxies":{}}
|
|
44
|
+
try:
|
|
45
|
+
d=json.loads(DB_FILE.read_text("utf-8")); d.setdefault("repositories",{}); d.setdefault("proxies",{}); return d
|
|
46
|
+
except (OSError,json.JSONDecodeError):
|
|
47
|
+
try: shutil.copy2(DB_FILE,DB_FILE.with_suffix(".corrupt.json"))
|
|
48
|
+
except OSError: pass
|
|
49
|
+
return {"version":1,"repositories":{},"proxies":{}}
|
|
50
|
+
def save_db(db):
|
|
51
|
+
DATA.mkdir(exist_ok=True); tmp=DB_FILE.with_suffix(".tmp")
|
|
52
|
+
tmp.write_text(json.dumps(db,ensure_ascii=False,indent=2),"utf-8"); tmp.replace(DB_FILE)
|
|
53
|
+
def gh_headers():
|
|
54
|
+
h={"Accept":"application/vnd.github+json","X-GitHub-Api-Version":"2022-11-28","User-Agent":APP}
|
|
55
|
+
token=os.getenv("GITHUB_TOKEN","").strip()
|
|
56
|
+
if token: h["Authorization"]="Bearer "+token
|
|
57
|
+
return h
|
|
58
|
+
|
|
59
|
+
def normalize(raw):
|
|
60
|
+
v=raw.strip().strip(chr(96)+"'\\\"()[]{}<>,;")
|
|
61
|
+
if not v or len(v)>700: return None
|
|
62
|
+
if v.startswith(("tg://proxy?","tg://socks?","https://t.me/proxy?","https://t.me/socks?")):
|
|
63
|
+
p=urlparse(v.replace("https://t.me/","tg://")); q=parse_qs(p.query)
|
|
64
|
+
host=(q.get("server") or q.get("host") or [""])[0]; port=(q.get("port") or [""])[0]; secret=(q.get("secret") or [""])[0]
|
|
65
|
+
try:
|
|
66
|
+
valid_host = bool(re.fullmatch(r"[A-Za-z0-9.-]{1,253}", host)) and ".." not in host
|
|
67
|
+
if valid_host:
|
|
68
|
+
try: ipaddress.ip_address(host)
|
|
69
|
+
except ValueError:
|
|
70
|
+
if not re.fullmatch(r"(?=.{1,253}$)[A-Za-z0-9](?:[A-Za-z0-9.-]*[A-Za-z0-9])?", host): valid_host = False
|
|
71
|
+
port=int(port)
|
|
72
|
+
if valid_host and 1<=port<=65535 and secret:
|
|
73
|
+
return {"id":f"mtproto://{host}:{port}/{secret}","type":"MTProto","host":host,"port":port,"secret":secret,"source":""}
|
|
74
|
+
except (ValueError,TypeError): pass
|
|
75
|
+
return None
|
|
76
|
+
if "://" in v:
|
|
77
|
+
p=urlparse(v); scheme=p.scheme.lower()
|
|
78
|
+
if scheme not in ("socks5","socks5h","http","https"): return None
|
|
79
|
+
try: host,port=p.hostname,p.port
|
|
80
|
+
except ValueError: return None
|
|
81
|
+
if host and port: return {"id":f"{'socks5' if scheme.startswith('socks') else 'http'}://{host}:{port}","type":"SOCKS5" if scheme.startswith("socks") else "HTTP","host":host,"port":port,"username":p.username,"password":p.password,"source":""}
|
|
82
|
+
return None
|
|
83
|
+
m=re.fullmatch(r"((?:\d{1,3}\.){3}\d{1,3}):(\d{1,5})",v)
|
|
84
|
+
if m:
|
|
85
|
+
try:
|
|
86
|
+
host=m.group(1); ipaddress.IPv4Address(host); port=int(m.group(2))
|
|
87
|
+
if 1<=port<=65535: return {"id":f"socks5://{host}:{port}","type":"SOCKS5","host":host,"port":port,"username":None,"password":None,"source":""}
|
|
88
|
+
except ValueError: pass
|
|
89
|
+
return None
|
|
90
|
+
|
|
91
|
+
def extract(text):
|
|
92
|
+
pats=[r"tg://(?:proxy|socks)\?[^\s\\\"'<>]+",r"https://t\.me/(?:proxy|socks)\?[^\s\\\"'<>]+",r"(?:socks5h?|https?)://[^\s\\\"'<>]+",r"(?<![\w.])(?:\d{1,3}\.){3}\d{1,3}:\d{2,5}(?!\d)"]
|
|
93
|
+
out={}
|
|
94
|
+
for pat in pats:
|
|
95
|
+
for raw in re.findall(pat,text,re.I):
|
|
96
|
+
item=normalize(raw)
|
|
97
|
+
if item: out[item["id"]]=item
|
|
98
|
+
return list(out.values())
|
|
99
|
+
|
|
100
|
+
async def gh_json(client,url,params=None):
|
|
101
|
+
r=await client.get(url,params=params,headers=gh_headers()); r.raise_for_status(); return r.json()
|
|
102
|
+
async def search_repos(client,progress,task):
|
|
103
|
+
found={}
|
|
104
|
+
for query in QUERIES:
|
|
105
|
+
progress.update(task,description=f"[cyan]GitHub: {query[:38]}")
|
|
106
|
+
try:
|
|
107
|
+
data=await gh_json(client,"https://api.github.com/search/repositories",{"q":query+" archived:false","sort":"updated","order":"desc","per_page":100,"page":1})
|
|
108
|
+
for r in data.get("items",[]):
|
|
109
|
+
if r.get("fork") or r.get("archived"): continue
|
|
110
|
+
found[r["full_name"]]={"full_name":r["full_name"],"html_url":r["html_url"],"default_branch":r.get("default_branch") or "main","description":r.get("description") or "","stars":r.get("stargazers_count",0),"updated_at":r.get("updated_at"),"added_at":now()}
|
|
111
|
+
except httpx.HTTPStatusError as e:
|
|
112
|
+
if e.response.status_code==403:
|
|
113
|
+
console.print("[yellow]GitHub ограничил поиск. Установи GITHUB_TOKEN для увеличения лимита.[/]"); break
|
|
114
|
+
console.print(f"[dim]Пропуск {query}: HTTP {e.response.status_code}[/]")
|
|
115
|
+
except (httpx.HTTPError,ValueError) as e: console.print(f"[dim]Ошибка поиска {query}: {e}[/]")
|
|
116
|
+
progress.advance(task)
|
|
117
|
+
return found
|
|
118
|
+
|
|
119
|
+
async def scan_repo(client,repo):
|
|
120
|
+
full=repo["full_name"]; branch=repo.get("default_branch") or "main"
|
|
121
|
+
try: tree=await gh_json(client,f"https://api.github.com/repos/{full}/git/trees/{branch}",{"recursive":"1"})
|
|
122
|
+
except (httpx.HTTPError,ValueError): return []
|
|
123
|
+
paths=[]
|
|
124
|
+
for n in tree.get("tree",[]):
|
|
125
|
+
path=n.get("path",""); low=path.lower()
|
|
126
|
+
if n.get("type")=="blob" and n.get("size",MAX_FILE_BYTES+1)<=MAX_FILE_BYTES and low.endswith((".md",".txt",".json",".yaml",".yml",".conf",".ini",".list",".csv")) and any(k in low for k in ("readme","proxy","config","list","server","mtproto","telegram","socks","sub")):
|
|
127
|
+
paths.append(path)
|
|
128
|
+
found={}
|
|
129
|
+
for path in paths[:MAX_REPO_FILES]:
|
|
130
|
+
try:
|
|
131
|
+
r=await client.get(f"https://raw.githubusercontent.com/{full}/{branch}/{path}",headers={"User-Agent":APP})
|
|
132
|
+
if r.status_code!=200: continue
|
|
133
|
+
for item in extract(r.text):
|
|
134
|
+
item["source"]=f"https://github.com/{full}/blob/{branch}/{path}"; found[item["id"]]=item
|
|
135
|
+
except httpx.HTTPError: pass
|
|
136
|
+
return list(found.values())
|
|
137
|
+
|
|
138
|
+
async def collect(db,refresh=False):
|
|
139
|
+
async with httpx.AsyncClient(timeout=httpx.Timeout(15,connect=8),limits=httpx.Limits(max_connections=12),follow_redirects=True) as client:
|
|
140
|
+
if not refresh:
|
|
141
|
+
with Progress(SpinnerColumn(),TextColumn("{task.description}"),BarColumn(),TimeElapsedColumn(),console=console) as p:
|
|
142
|
+
task=p.add_task("[cyan]Ищу GitHub-репозитории...",total=len(QUERIES)); repos=await search_repos(client,p,task)
|
|
143
|
+
for name,info in repos.items():
|
|
144
|
+
db["repositories"].setdefault(name,info); db["repositories"][name].update({k:v for k,v in info.items() if k in ("stars","updated_at","description","default_branch","html_url")})
|
|
145
|
+
console.print(f"[green]Найдено: {len(repos)} новых/обновлённых совпадений. В базе репозиториев: {len(db['repositories'])}[/]")
|
|
146
|
+
repos=list(db["repositories"].values()); sem=asyncio.Semaphore(8); added=0
|
|
147
|
+
async def run(repo):
|
|
148
|
+
async with sem: return repo,await scan_repo(client,repo)
|
|
149
|
+
with Progress(SpinnerColumn(),TextColumn("{task.description}"),BarColumn(),TextColumn("{task.completed}/{task.total}"),console=console) as p:
|
|
150
|
+
task=p.add_task("[cyan]Сканирую сохранённые репозитории...",total=len(repos))
|
|
151
|
+
for future in asyncio.as_completed([run(r) for r in repos]):
|
|
152
|
+
repo,items=await future; repo["scanned_at"]=now()
|
|
153
|
+
for item in items:
|
|
154
|
+
item["last_seen"]=now(); old=db["proxies"].get(item["id"])
|
|
155
|
+
if old is None: added+=1
|
|
156
|
+
db["proxies"][item["id"]]={**(old or {}),**item}
|
|
157
|
+
p.advance(task)
|
|
158
|
+
save_db(db); console.print(f"[green]Новых прокси: {added}. Всего уникальных: {len(db['proxies'])}[/]")
|
|
159
|
+
|
|
160
|
+
async def probe(item):
|
|
161
|
+
kind,host,port=item["type"],item["host"],int(item["port"])
|
|
162
|
+
if kind=="MTProto":
|
|
163
|
+
try:
|
|
164
|
+
reader,writer=await asyncio.wait_for(asyncio.open_connection(host,port),TIMEOUT); writer.close(); await writer.wait_closed()
|
|
165
|
+
return "REVIEW","TCP открыт; MTProto handshake ещё не подтверждён"
|
|
166
|
+
except Exception as e: return "DEAD",type(e).__name__
|
|
167
|
+
scheme="socks5" if kind=="SOCKS5" else "http"; auth=""
|
|
168
|
+
if item.get("username"): auth=f"{item['username']}:{item.get('password') or ''}@"
|
|
169
|
+
try:
|
|
170
|
+
async with httpx.AsyncClient(proxy=f"{scheme}://{auth}{host}:{port}",timeout=TIMEOUT,follow_redirects=True) as c:
|
|
171
|
+
r=await c.get("https://api.telegram.org/")
|
|
172
|
+
if r.status_code<500: return "WORKING",f"Telegram HTTPS HTTP {r.status_code}"
|
|
173
|
+
return "DEAD",f"Telegram HTTPS HTTP {r.status_code}"
|
|
174
|
+
except Exception as e: return "DEAD",type(e).__name__
|
|
175
|
+
|
|
176
|
+
def proxy_string(x):
|
|
177
|
+
if x["type"]=="MTProto": return "tg://proxy?"+urlencode({"server":x["host"],"port":x["port"],"secret":x["secret"]})
|
|
178
|
+
return f"{'socks5' if x['type']=='SOCKS5' else 'http'}://{x['host']}:{x['port']}"
|
|
179
|
+
|
|
180
|
+
async def check_all(db):
|
|
181
|
+
items=list(db["proxies"].values())
|
|
182
|
+
if not items: console.print("[yellow]База пуста. Сначала выполни поиск.[/]"); return
|
|
183
|
+
sem=asyncio.Semaphore(70)
|
|
184
|
+
async def run(x):
|
|
185
|
+
async with sem:
|
|
186
|
+
x["status"],x["check_detail"]=await probe(x); x["checked_at"]=now(); return x
|
|
187
|
+
with Progress(SpinnerColumn(),TextColumn("{task.description}"),BarColumn(),TextColumn("{task.completed}/{task.total}"),console=console) as p:
|
|
188
|
+
task=p.add_task("[cyan]Проверяю с текущего подключения...",total=len(items))
|
|
189
|
+
for f in asyncio.as_completed([run(x) for x in items]): await f; p.advance(task)
|
|
190
|
+
save_db(db)
|
|
191
|
+
good=[x for x in items if x.get("status")=="WORKING"]
|
|
192
|
+
WORKING_FILE.write_text("\n".join(proxy_string(x) for x in good)+("\n" if good else ""),"utf-8")
|
|
193
|
+
console.print(f"[green]Рабочие: {len(good)}[/] [yellow]На ручную проверку: {sum(x.get('status')=='REVIEW' for x in items)}[/] [red]Мёртвые: {sum(x.get('status')=='DEAD' for x in items)}[/]")
|
|
194
|
+
|
|
195
|
+
def show_results(db):
|
|
196
|
+
items=sorted((x for x in db["proxies"].values() if x.get("status") in ("WORKING","REVIEW")),key=lambda x:(x.get("status")!="WORKING",x["type"],x["host"]))
|
|
197
|
+
t=Table(title="ПРОКСИ ДЛЯ РУЧНОГО ОТБОРА",expand=True)
|
|
198
|
+
for name in ("#","STATUS","TYPE","ADDRESS","SOURCE"): t.add_column(name,overflow="ellipsis")
|
|
199
|
+
for i,x in enumerate(items,1):
|
|
200
|
+
color="green" if x["status"]=="WORKING" else "yellow"
|
|
201
|
+
t.add_row(str(i),f"[{color}]{x['status']}[/]",x["type"],f"{x['host']}:{x['port']}",x.get("source",""))
|
|
202
|
+
console.print(t); return items
|
|
203
|
+
|
|
204
|
+
def copy_results(items):
|
|
205
|
+
good=[x for x in items if x.get("status")=="WORKING"]
|
|
206
|
+
if not good: console.print("[yellow]Нет подтверждённых рабочих прокси.[/]"); return
|
|
207
|
+
payload="\n".join(proxy_string(x) for x in good)
|
|
208
|
+
try:
|
|
209
|
+
import pyperclip; pyperclip.copy(payload); console.print(f"[green]Скопировано в буфер: {len(good)}[/]")
|
|
210
|
+
except Exception:
|
|
211
|
+
WORKING_FILE.write_text(payload+"\n","utf-8"); console.print(f"[yellow]Буфер недоступен; сохранено в {WORKING_FILE}[/]")
|
|
212
|
+
|
|
213
|
+
async def remote_version():
|
|
214
|
+
url=f"https://raw.githubusercontent.com/{OWNER}/{REPO}/main/version.json"
|
|
215
|
+
try:
|
|
216
|
+
async with httpx.AsyncClient(timeout=8,follow_redirects=True) as c:
|
|
217
|
+
r=await c.get(url)
|
|
218
|
+
if r.status_code==200:
|
|
219
|
+
d=r.json(); return d.get("version"),d.get("download_url") or f"https://github.com/{OWNER}/{REPO}/archive/refs/heads/main.zip"
|
|
220
|
+
except Exception: pass
|
|
221
|
+
return None,None
|
|
222
|
+
|
|
223
|
+
def install_update(url):
|
|
224
|
+
if not url: return
|
|
225
|
+
if _PYPI_INSTALL:
|
|
226
|
+
try:
|
|
227
|
+
subprocess.run([sys.executable, "-m", "pip", "install", "--upgrade", PACKAGE_NAME], check=True)
|
|
228
|
+
console.print("[green]Обновление установлено через pip. Перезапусти программу.[/]")
|
|
229
|
+
except subprocess.CalledProcessError as e:
|
|
230
|
+
console.print(f"[red]Не удалось обновить пакет через pip (код {e.returncode}).[/]")
|
|
231
|
+
return
|
|
232
|
+
try:
|
|
233
|
+
with tempfile.TemporaryDirectory() as tmp:
|
|
234
|
+
archive=Path(tmp)/"update.zip"
|
|
235
|
+
with httpx.stream("GET",url,timeout=35,follow_redirects=True) as r:
|
|
236
|
+
r.raise_for_status()
|
|
237
|
+
with archive.open("wb") as f:
|
|
238
|
+
for chunk in r.iter_bytes(): f.write(chunk)
|
|
239
|
+
with zipfile.ZipFile(archive) as z:
|
|
240
|
+
prefix=z.namelist()[0].split("/")[0]+"/"
|
|
241
|
+
for name in z.namelist():
|
|
242
|
+
rel=name.removeprefix(prefix)
|
|
243
|
+
if rel in {"main.py","requirements.txt","README.md","version.json","install.bat","start.bat"}:
|
|
244
|
+
(ROOT/rel).write_bytes(z.read(name))
|
|
245
|
+
console.print("[green]Обновление установлено. Перезапусти программу.[/]")
|
|
246
|
+
except Exception as e: console.print(f"[red]Не удалось обновить: {e}[/]")
|
|
247
|
+
|
|
248
|
+
def check_version():
|
|
249
|
+
latest,url=asyncio.run(remote_version())
|
|
250
|
+
if not latest: console.print(f"[yellow]Не удалось проверить обновления. Текущая версия v{VERSION}.[/]")
|
|
251
|
+
elif latest==VERSION: console.print(f"[green]У вас последняя версия v{VERSION}.[/]")
|
|
252
|
+
else:
|
|
253
|
+
console.print(f"[bold yellow]Вышла новая версия v{latest}![/]")
|
|
254
|
+
if Confirm.ask("Скачать и установить?",default=False): install_update(url)
|
|
255
|
+
|
|
256
|
+
def banner():
|
|
257
|
+
console.clear()
|
|
258
|
+
console.print(Panel(Text(APP,justify="center",style="bold bright_cyan"),subtitle="GitHub repository scanner · Telegram proxy checker",border_style="bright_cyan"))
|
|
259
|
+
console.print("[dim]by zmlsag[/]\n")
|
|
260
|
+
|
|
261
|
+
def main():
|
|
262
|
+
DATA.mkdir(exist_ok=True)
|
|
263
|
+
latest, update_url = asyncio.run(remote_version())
|
|
264
|
+
if not latest:
|
|
265
|
+
version_label = f"[yellow]Версия v{VERSION} · статус обновлений неизвестен[/]"
|
|
266
|
+
elif latest == VERSION:
|
|
267
|
+
version_label = f"[green]У вас последняя версия v{VERSION}[/]"
|
|
268
|
+
else:
|
|
269
|
+
version_label = f"[bold yellow]Вышла новая версия v{latest} — нажми 3 для обновления[/]"
|
|
270
|
+
while True:
|
|
271
|
+
banner()
|
|
272
|
+
console.print("[bold cyan]1.[/] Найти рабочие прокси [dim](найти репозитории + проверить)[/]")
|
|
273
|
+
console.print("[bold cyan]2.[/] Обновить базу прокси [dim](повторно просканировать известные репозитории)[/]")
|
|
274
|
+
console.print(f"[bold cyan]3.[/] {version_label}")
|
|
275
|
+
console.print("[bold cyan]4.[/] Показать результаты / скопировать рабочие")
|
|
276
|
+
console.print("[bold cyan]0.[/] Выход\n")
|
|
277
|
+
choice=Prompt.ask("Выбери действие",choices=["1","2","3","4","0"],default="1")
|
|
278
|
+
if choice=="0": break
|
|
279
|
+
db=load_db()
|
|
280
|
+
try:
|
|
281
|
+
if choice=="1":
|
|
282
|
+
asyncio.run(collect(db,False)); asyncio.run(check_all(db))
|
|
283
|
+
items=show_results(db)
|
|
284
|
+
if items and Confirm.ask("Скопировать все подтверждённые рабочие прокси?",default=True): copy_results(items)
|
|
285
|
+
elif choice=="2": asyncio.run(collect(db,True)); asyncio.run(check_all(db))
|
|
286
|
+
elif choice=="3":
|
|
287
|
+
if latest and latest != VERSION:
|
|
288
|
+
if Confirm.ask(f"Установить v{latest}?",default=True): install_update(update_url)
|
|
289
|
+
else:
|
|
290
|
+
latest, update_url = asyncio.run(remote_version())
|
|
291
|
+
if latest == VERSION: console.print(f"[green]У вас последняя версия v{VERSION}.[/]")
|
|
292
|
+
elif latest: console.print(f"[yellow]Доступна новая версия v{latest}.[/]")
|
|
293
|
+
else: console.print("[yellow]Не удалось проверить обновления.[/]")
|
|
294
|
+
elif choice=="4":
|
|
295
|
+
items=show_results(db)
|
|
296
|
+
if items and Confirm.ask("Скопировать все подтверждённые рабочие прокси?",default=True): copy_results(items)
|
|
297
|
+
except KeyboardInterrupt: console.print("\n[yellow]Остановлено. Сохранённые данные не потеряны.[/]")
|
|
298
|
+
except Exception as e: console.print(f"[red]Ошибка: {e}[/]")
|
|
299
|
+
Prompt.ask("\nEnter — назад в меню",default="")
|
|
300
|
+
console.print("[dim]by zmlsag[/]")
|
|
301
|
+
if __name__=="__main__": main()
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: proxy-search
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Search GitHub for Telegram proxy lists and verify HTTP/SOCKS proxies against Telegram.
|
|
5
|
+
Project-URL: Homepage, https://github.com/zmlsaggg/proxy-search
|
|
6
|
+
Project-URL: Repository, https://github.com/zmlsaggg/proxy-search
|
|
7
|
+
Project-URL: Issues, https://github.com/zmlsaggg/proxy-search/issues
|
|
8
|
+
Classifier: Environment :: Console
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
14
|
+
Classifier: Topic :: Communications :: Chat
|
|
15
|
+
Classifier: Topic :: Internet
|
|
16
|
+
Classifier: Topic :: Utilities
|
|
17
|
+
Requires-Python: >=3.11
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
Requires-Dist: httpx[socks]<1,>=0.27
|
|
20
|
+
Requires-Dist: rich<15,>=13.7
|
|
21
|
+
Requires-Dist: pyperclip<2,>=1.9
|
|
22
|
+
|
|
23
|
+
# TELEGRAM PROXY SEARCHER
|
|
24
|
+
|
|
25
|
+
## Установка через PyPI
|
|
26
|
+
|
|
27
|
+
```powershell
|
|
28
|
+
py -m pip install proxy-search
|
|
29
|
+
telegram-proxy-searcher
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Для изолированной установки CLI можно использовать `pipx install proxy-search`.
|
|
33
|
+
После установки локальная база и список рабочих прокси сохраняются в пользовательской папке данных Windows, macOS или Linux, а не внутри каталога Python.
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
Console utility by **zmlsag**. Searches GitHub repositories for Telegram proxy lists, extracts supported formats, checks HTTP/SOCKS proxies against Telegram from the user's current network, and stores results locally.
|
|
37
|
+
|
|
38
|
+
## Windows
|
|
39
|
+
1. Install Python 3.11+.
|
|
40
|
+
2. Run install.bat once.
|
|
41
|
+
3. Run start.bat.
|
|
42
|
+
|
|
43
|
+
Optional GitHub token (PowerShell):
|
|
44
|
+
$env:GITHUB_TOKEN="github_pat_..."
|
|
45
|
+
.\start.bat
|
|
46
|
+
|
|
47
|
+
## Menu
|
|
48
|
+
1. Find working proxies — search GitHub, index repositories, extract endpoints, check them.
|
|
49
|
+
2. Update proxy database — rescan repositories already saved locally.
|
|
50
|
+
3. Check application updates from this repository.
|
|
51
|
+
4. View results and copy confirmed working proxies.
|
|
52
|
+
|
|
53
|
+
Local database: data/database.json. Confirmed HTTP/SOCKS endpoints: data/working.txt.
|
|
54
|
+
|
|
55
|
+
## Verification
|
|
56
|
+
- HTTP and SOCKS5 are WORKING only after a request to Telegram HTTPS succeeds through that proxy.
|
|
57
|
+
- MTProto entries are marked REVIEW when the TCP port accepts a connection. TCP reachability alone does not prove an MTProto handshake, so they are excluded from automatic copy.
|
|
58
|
+
- Checks run from the computer launching the tool and reflect its current ISP/network route.
|
|
59
|
+
- Repository content is treated as untrusted text. No downloaded repository code is executed.
|
|
60
|
+
- Unauthenticated GitHub search is rate-limited; set GITHUB_TOKEN for higher limits.
|
|
61
|
+
|
|
62
|
+
Supported formats: tg://proxy links, t.me/proxy links, socks5/http URLs, and IPv4:port candidates.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
main.py
|
|
3
|
+
pyproject.toml
|
|
4
|
+
proxy_search.egg-info/PKG-INFO
|
|
5
|
+
proxy_search.egg-info/SOURCES.txt
|
|
6
|
+
proxy_search.egg-info/dependency_links.txt
|
|
7
|
+
proxy_search.egg-info/entry_points.txt
|
|
8
|
+
proxy_search.egg-info/requires.txt
|
|
9
|
+
proxy_search.egg-info/top_level.txt
|
|
10
|
+
tests/test_parser.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
main
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=69", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "proxy-search"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "Search GitHub for Telegram proxy lists and verify HTTP/SOCKS proxies against Telegram."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
dependencies = [
|
|
12
|
+
"httpx[socks]>=0.27,<1",
|
|
13
|
+
"rich>=13.7,<15",
|
|
14
|
+
"pyperclip>=1.9,<2",
|
|
15
|
+
]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Environment :: Console",
|
|
18
|
+
"Operating System :: OS Independent",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Programming Language :: Python :: 3.11",
|
|
21
|
+
"Programming Language :: Python :: 3.12",
|
|
22
|
+
"Programming Language :: Python :: 3.13",
|
|
23
|
+
"Topic :: Communications :: Chat",
|
|
24
|
+
"Topic :: Internet",
|
|
25
|
+
"Topic :: Utilities",
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
[project.scripts]
|
|
29
|
+
telegram-proxy-searcher = "main:main"
|
|
30
|
+
|
|
31
|
+
[project.urls]
|
|
32
|
+
Homepage = "https://github.com/zmlsaggg/proxy-search"
|
|
33
|
+
Repository = "https://github.com/zmlsaggg/proxy-search"
|
|
34
|
+
Issues = "https://github.com/zmlsaggg/proxy-search/issues"
|
|
35
|
+
|
|
36
|
+
[tool.setuptools]
|
|
37
|
+
py-modules = ["main"]
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import unittest
|
|
2
|
+
|
|
3
|
+
from main import extract, normalize
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class ProxyParserTests(unittest.TestCase):
|
|
7
|
+
def test_mtproto_link(self):
|
|
8
|
+
item = normalize("tg://proxy?server=149.154.167.50&port=443&secret=abcdef0123456789")
|
|
9
|
+
self.assertIsNotNone(item)
|
|
10
|
+
self.assertEqual(item["type"], "MTProto")
|
|
11
|
+
self.assertEqual(item["port"], 443)
|
|
12
|
+
|
|
13
|
+
def test_socks_url(self):
|
|
14
|
+
item = normalize("socks5://127.0.0.1:1080")
|
|
15
|
+
self.assertEqual(item["type"], "SOCKS5")
|
|
16
|
+
self.assertEqual(item["host"], "127.0.0.1")
|
|
17
|
+
|
|
18
|
+
def test_http_url(self):
|
|
19
|
+
item = normalize("http://192.0.2.10:8080")
|
|
20
|
+
self.assertEqual(item["type"], "HTTP")
|
|
21
|
+
|
|
22
|
+
def test_invalid_port_is_rejected(self):
|
|
23
|
+
self.assertIsNone(normalize("socks5://127.0.0.1:99999"))
|
|
24
|
+
|
|
25
|
+
def test_extract_deduplicates(self):
|
|
26
|
+
text = "socks5://127.0.0.1:1080\nsocks5://127.0.0.1:1080"
|
|
27
|
+
self.assertEqual(len(extract(text)), 1)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
if __name__ == "__main__":
|
|
31
|
+
unittest.main()
|