v1.90fix3

This commit is contained in:
Deniz Şafak
2025-01-01 18:56:54 +03:00
committed by GitHub
parent bcbad5b8f8
commit 337c84e9a4
+24 -7
View File
@@ -355,7 +355,7 @@ def add_new_profile():
"Content-Type": "application/x-www-form-urlencoded", "Content-Type": "application/x-www-form-urlencoded",
"Connection": "keep-alive", "Connection": "keep-alive",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3" "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3"
}""") }""")
# check_every_second # check_every_second
check_frame = tk.Frame(container) check_frame = tk.Frame(container)
check_frame.pack(fill="x", pady=5) check_frame.pack(fill="x", pady=5)
@@ -625,12 +625,29 @@ def send_request():
# Function to check if internet is available # Function to check if internet is available
def is_internet_available(): def is_internet_available():
try: try:
#subprocess.run(['ping', internet_check_url, '-n', '3', '-l', '32', '-w', '20'], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, creationflags=subprocess.CREATE_NO_WINDOW) internet_check_url_clean = internet_check_url.replace("http://", "").replace("https://", "")
socket.create_connection((internet_check_url, 53), timeout=5) socket.setdefaulttimeout(3)
return True s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
#except subprocess.CalledProcessError: if internet_check_url_clean.replace('.', '').isdigit():
except OSError: address = internet_check_url_clean
else:
try:
address = socket.gethostbyname(internet_check_url_clean)
except socket.gaierror:
return False
if internet_check_url.startswith("https://"):
port = 443
elif internet_check_url.startswith("http://"):
port = 80
else:
port = 53
server_address = (address, port)
s.connect(server_address)
except OSError as error:
return False return False
finally:
s.close()
return True
# Function to get the currently connected SSID using system commands (for Windows) # Function to get the currently connected SSID using system commands (for Windows)
def get_connected_network(): def get_connected_network():
@@ -1009,4 +1026,4 @@ if __name__ == '__main__':
# Start the network status checking in the main thread # Start the network status checking in the main thread
check_network_status() check_network_status()
# Wait for all threads to finish # Wait for all threads to finish
tray_thread.join() tray_thread.join()