Skip to content
This repository has been archived by the owner on Apr 5, 2022. It is now read-only.

change to proxy.py to fix failing to connect to websocket errors #439

Merged
merged 2 commits into from Apr 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,9 @@ def get_board(self, access_token_in):
requests.get(
msg["data"]["name"],
stream=True,
proxies=proxy.get_random_proxy(self, name=None),
proxies=proxy.get_random_proxy(
self, name=None
),
).content
)
),
Expand Down
11 changes: 7 additions & 4 deletions src/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ def Init(self):
)
self.tor_ip = (
self.json_data["tor_ip"]
if "tor_ip" in self.json_data
and self.json_data["tor_ip"] is not None
if "tor_ip" in self.json_data and self.json_data["tor_ip"] is not None
else "127.0.0.1"
)

Expand Down Expand Up @@ -110,12 +109,16 @@ def get_proxies(self, proxies):
return proxies_list
return proxies_list

#name is the username of the worker and is used for personal proxies

# name is the username of the worker and is used for personal proxies
def get_random_proxy(self, name=None):
if not self.using_tor:
random_proxy = None
if name is not None:
if self.json_data["workers"][name]["personal_proxy"] is not None:
if (
"personal_proxy" in self.json_data["workers"][name]
and self.json_data["workers"][name]["personal_proxy"] is not None
):
proxy = self.json_data["workers"][name]["personal_proxy"]
return {"https": proxy, "http": proxy}
if self.proxies is not None:
Expand Down