Skip to content

Commit fe2b7cb

Browse files
committed
fix: check if IP is available when using auth settings
1 parent 5a0c176 commit fe2b7cb

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

cloudproxy/check.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,22 @@ def fetch_ip(ip_address):
5151

5252
def check_alive(ip_address):
5353
try:
54-
result = requests.get("http://ipecho.net/plain", proxies={'http': "http://" + ip_address + ":8899"}, timeout=10)
54+
if settings.config["no_auth"]:
55+
proxies = {
56+
"http": "http://" + ip_address + ":8899",
57+
"https": "http://" + ip_address + ":8899",
58+
}
59+
else:
60+
auth = (
61+
settings.config["auth"]["username"] + ":" + settings.config["auth"]["password"]
62+
)
63+
64+
proxies = {
65+
"http": "http://" + auth + "@" + ip_address + ":8899",
66+
"https": "http://" + auth + "@" + ip_address + ":8899",
67+
}
68+
69+
result = requests.get("http://ipecho.net/plain", proxies=proxies, timeout=10)
5570
if result.status_code in (200, 407):
5671
return True
5772
else:

0 commit comments

Comments
 (0)