Skip to content

Commit

Permalink
Update main.py
Browse files Browse the repository at this point in the history
  • Loading branch information
txperl committed Oct 31, 2024
1 parent fc7fd32 commit 9a71a02
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions app/lib/common/login_helper/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,28 +41,31 @@ def check_network(self, is_no_proxy: bool = False, is_silent: bool = False):
# Determine the final proxy address, or empty
self.proxy = "" if is_no_proxy else self._determine_proxy(is_silent=is_silent)

self.auth_token_url = self.SOME_URLS[0]
return self._test_pixiv_connection(self.proxy)

# Determine the final auth host
# Check if the hosts are accessible
is_conn_array = [
self._test_access(url=url, proxy=self.proxy, is_silent=False)
for url in self.SOME_URLS
]
# is_conn_array = [
# self._test_access(url=url, proxy=self.proxy, is_silent=False)
# for url in self.SOME_URLS
# ]

# If Pixiv is accessible, just use the official
if is_conn_array[0]:
self.auth_token_url = self.SOME_URLS[0]
return True
# if is_conn_array[0]:
# self.auth_token_url = self.SOME_URLS[0]
# return True

# Or, get the real ip of auth service from DoH service to bypass SNI
for i in range(len(self.SOME_URLS)):
if is_conn_array[i] is False:
continue
final_ip = self._get_host_ip(
hostname=self.SOME_URLS[0], url=self.SOME_URLS[i]
)
if final_ip is not False:
self.auth_token_url = final_ip
return True
# for i in range(len(self.SOME_URLS)):
# if is_conn_array[i] is False:
# continue
# final_ip = self._get_host_ip(
# hostname=self.SOME_URLS[0], url=self.SOME_URLS[i]
# )
# if final_ip is not False:
# self.auth_token_url = final_ip
# return True

return False

Expand Down

0 comments on commit 9a71a02

Please sign in to comment.