testing proxies formatting
This commit is contained in:
1 parent
800bf1d449
commit
84e8dc328c
1 file changed
+6
-7
@@ -28,20 +28,19 @@ def get_bot_token(is_production: bool) -> str:
|
|||||||
|
|
||||||
@cache
|
@cache
|
||||||
def get_proxies() -> list[str]:
|
def get_proxies() -> list[str]:
|
||||||
parts = p.strip().split(":")
|
|
||||||
print(len(parts), parts)
|
|
||||||
with PROXIES_PATH.open() as f:
|
with PROXIES_PATH.open() as f:
|
||||||
proxies = []
|
proxies = []
|
||||||
for p in f:
|
for line in f:
|
||||||
if not p.strip():
|
line = line.strip()
|
||||||
|
if not line:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
parts = p.strip().split(":")
|
parts = line.split(":", 3)
|
||||||
if len(parts) == 4:
|
if len(parts) == 4 and not parts[1].startswith("//"):
|
||||||
host, port, user, password = parts
|
host, port, user, password = parts
|
||||||
proxies.append(f"http://{user}:{password}@{host}:{port}")
|
proxies.append(f"http://{user}:{password}@{host}:{port}")
|
||||||
else:
|
else:
|
||||||
proxies.append(f"http://{p.strip()}")
|
proxies.append(f"http://{line}")
|
||||||
|
|
||||||
if not proxies:
|
if not proxies:
|
||||||
raise ValueError("Proxy list cannot be empty")
|
raise ValueError("Proxy list cannot be empty")
|
||||||
|
|||||||
Reference in new issue
Block a user