From 95b8a46ac8d6d6df132a5385a4dcf0b1b6671102 Mon Sep 17 00:00:00 2001 From: quietsy Date: Fri, 28 Jan 2022 01:45:04 +0200 Subject: [PATCH 1/2] Fix the availability check on apps with basic auth --- root/dashboard/swag-proxies.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/root/dashboard/swag-proxies.py b/root/dashboard/swag-proxies.py index d24d9c9..b520e71 100644 --- a/root/dashboard/swag-proxies.py +++ b/root/dashboard/swag-proxies.py @@ -1,10 +1,11 @@ import collections +import contextlib import concurrent.futures import glob import json import os import re -import requests +import socket import urllib3 @@ -32,10 +33,16 @@ def find_apps(): def is_available(url): try: - requests.head(url, timeout=5, verify=False) - return True + host, port = url.split("/")[2].split(":") + print(host + port) + with contextlib.closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as sock: + if sock.connect_ex((host, int(port))) == 0: + return True + else: + return False except: - return False + return False + urllib3.disable_warnings() apps = find_apps() From 71f2c81f5dfed23e3215f9bbd4d44311bd4e1f19 Mon Sep 17 00:00:00 2001 From: quietsy Date: Fri, 28 Jan 2022 01:49:52 +0200 Subject: [PATCH 2/2] Remove print --- root/dashboard/swag-proxies.py | 1 - 1 file changed, 1 deletion(-) diff --git a/root/dashboard/swag-proxies.py b/root/dashboard/swag-proxies.py index b520e71..1a5bb04 100644 --- a/root/dashboard/swag-proxies.py +++ b/root/dashboard/swag-proxies.py @@ -34,7 +34,6 @@ def find_apps(): def is_available(url): try: host, port = url.split("/")[2].split(":") - print(host + port) with contextlib.closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as sock: if sock.connect_ex((host, int(port))) == 0: return True