mirror of
https://github.com/TrezOne/docker-mods-uptime-kuma-timeout-fix.git
synced 2026-07-19 09:53:02 -04:00
A bit of refactoring
This commit is contained in:
@@ -25,11 +25,10 @@ def find_apps():
|
|||||||
continue
|
continue
|
||||||
file = open(file_path, "r")
|
file = open(file_path, "r")
|
||||||
content = file.read()
|
content = file.read()
|
||||||
match_proxy(content, file_path, apps)
|
match_proxy(apps, auths, content, file_path)
|
||||||
match_auth(apps, auths)
|
|
||||||
return apps, auths
|
return apps, auths
|
||||||
|
|
||||||
def match_proxy(content, file_path, apps):
|
def match_proxy(apps, auths, content, file_path):
|
||||||
results = re.finditer(PROXY_REGEX, content)
|
results = re.finditer(PROXY_REGEX, content)
|
||||||
for result in results:
|
for result in results:
|
||||||
params = result.groupdict()
|
params = result.groupdict()
|
||||||
@@ -39,22 +38,19 @@ def match_proxy(content, file_path, apps):
|
|||||||
if file_path.startswith("/config/nginx/site-confs/") or file_path.endswith(".conf"):
|
if file_path.startswith("/config/nginx/site-confs/") or file_path.endswith(".conf"):
|
||||||
file_path = "auto-proxy" if file_path.startswith("/etc/nginx/http.d/") else file_path
|
file_path = "auto-proxy" if file_path.startswith("/etc/nginx/http.d/") else file_path
|
||||||
apps[app].add(file_path)
|
apps[app].add(file_path)
|
||||||
|
match_auth(auths, app, file_path, content)
|
||||||
|
|
||||||
def match_auth(apps, auths):
|
def match_auth(auths, app, file_path, content):
|
||||||
for app, file_paths in apps.items():
|
if re.findall(AUTHELIA_REGEX, content):
|
||||||
for file_path in file_paths:
|
auths[app][file_path] = "Authelia"
|
||||||
file = open(file_path, "r")
|
elif re.findall(AUTHENTIK_REGEX, content):
|
||||||
content = file.read()
|
auths[app][file_path] = "Authentik"
|
||||||
if re.findall(AUTHELIA_REGEX, content):
|
elif re.findall(BASIC_AUTH_REGEX, content):
|
||||||
auths[app][file_path] = "Authelia"
|
auths[app][file_path] = "Basic Auth"
|
||||||
elif re.findall(AUTHENTIK_REGEX, content):
|
elif re.findall(LDAP_REGEX, content):
|
||||||
auths[app][file_path] = "Authentik"
|
auths[app][file_path] = "LDAP"
|
||||||
elif re.findall(BASIC_AUTH_REGEX, content):
|
else:
|
||||||
auths[app][file_path] = "Basic Auth"
|
auths[app][file_path] = "No Auth"
|
||||||
elif re.findall(LDAP_REGEX, content):
|
|
||||||
auths[app][file_path] = "LDAP"
|
|
||||||
else:
|
|
||||||
auths[app][file_path] = "No Auth"
|
|
||||||
|
|
||||||
def is_available(url):
|
def is_available(url):
|
||||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
|
|||||||
Reference in New Issue
Block a user