From b0e9d560aecc7b1a5cf539c38ee5414d9a851876 Mon Sep 17 00:00:00 2001 From: iFargle Date: Fri, 17 Mar 2023 20:38:04 +0900 Subject: [PATCH 1/7] Add more debug info. --- renderer.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/renderer.py b/renderer.py index b825b94..0be23bc 100644 --- a/renderer.py +++ b/renderer.py @@ -235,12 +235,15 @@ def thread_machine_content(machine, machine_content, idx): # machine = passed in machine information # content = place to write the content + app.logger.debug("Machine Information") + app.logger.debug(str(machine)) + url = headscale.get_url() api_key = headscale.get_api_key() # Set the current timezone and local time - timezone = pytz.timezone(os.environ["TZ"] if os.environ["TZ"] else "UTC") - local_time = timezone.localize(datetime.now()) + timezone = pytz.timezone(os.environ["TZ"] if os.environ["TZ"] else "UTC") + local_time = timezone.localize(datetime.now()) # Get the machines routes pulled_routes = headscale.get_machine_routes(url, api_key, machine["id"]) From 3246db9e56ec168bf7057f04643f12144f23e1b5 Mon Sep 17 00:00:00 2001 From: iFargle Date: Fri, 17 Mar 2023 20:48:29 +0900 Subject: [PATCH 2/7] test --- server.py | 1 + 1 file changed, 1 insertion(+) diff --git a/server.py b/server.py index acddb64..fc426c0 100644 --- a/server.py +++ b/server.py @@ -29,6 +29,7 @@ executor = Executor(app) app.wsgi_app = ProxyFix(app.wsgi_app, x_for=1, x_proto=1, x_host=1, x_prefix=1) +app.logger.info("Headscale-WebUI Version: "+os.environ["APP_VERSION"]+" / "+os.environ["GIT_BRANCH"]) app.logger.info("LOG LEVEL SET TO %s", str(LOG_LEVEL)) app.logger.info("DEBUG STATE: %s", str(DEBUG_STATE)) From 7f71a0b74a8b0213bff5ca8b7762225557461961 Mon Sep 17 00:00:00 2001 From: iFargle Date: Fri, 17 Mar 2023 20:56:03 +0900 Subject: [PATCH 3/7] Possible fix for expiry time --- renderer.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/renderer.py b/renderer.py index 0be23bc..bf47e12 100644 --- a/renderer.py +++ b/renderer.py @@ -338,17 +338,21 @@ def thread_machine_content(machine, machine_content, idx): created_print = helper.pretty_print_duration(created_delta) created_time = str(created_local.strftime('%A %m/%d/%Y, %H:%M:%S'))+" "+str(timezone)+" ("+str(created_print)+")" - expiry_parse = parser.parse(machine["expiry"]) - expiry_local = expiry_parse.astimezone(timezone) - expiry_delta = expiry_local - local_time - expiry_print = helper.pretty_print_duration(expiry_delta, "expiry") - - if str(expiry_local.strftime('%Y')) in ("0001", "9999", "0000"): + # If there is no expiration date, we don't need to do any calculations: + if machine["expiry"] != "0001-01-01T00:00:00Z": + expiry_parse = parser.parse(machine["expiry"]) + expiry_local = expiry_parse.astimezone(timezone) + expiry_delta = expiry_local - local_time + expiry_print = helper.pretty_print_duration(expiry_delta, "expiry") + if str(expiry_local.strftime('%Y')) in ("0001", "9999", "0000"): + expiry_time = "No expiration date." + elif int(expiry_local.strftime('%Y')) > int(expiry_local.strftime('%Y'))+2: + expiry_time = str(expiry_local.strftime('%m/%Y'))+" "+str(timezone)+" ("+str(expiry_print)+")" + else: + expiry_time = str(expiry_local.strftime('%A %m/%d/%Y, %H:%M:%S'))+" "+str(timezone)+" ("+str(expiry_print)+")" + else: expiry_time = "No expiration date." - elif int(expiry_local.strftime('%Y')) > int(expiry_local.strftime('%Y'))+2: - expiry_time = str(expiry_local.strftime('%m/%Y'))+" "+str(timezone)+" ("+str(expiry_print)+")" - else: - expiry_time = str(expiry_local.strftime('%A %m/%d/%Y, %H:%M:%S'))+" "+str(timezone)+" ("+str(expiry_print)+")" + app.logger.debug("Machine: "+machine["name"]+" expires: "+str(expiry_local.strftime('%Y'))+" / "+str(expiry_delta.days)) expiring_soon = True if int(expiry_delta.days) < 14 and int(expiry_delta.days) > 0 else False From edfa130a3353e457a784f22bcd3c6f820e89807a Mon Sep 17 00:00:00 2001 From: iFargle Date: Fri, 17 Mar 2023 21:00:05 +0900 Subject: [PATCH 4/7] test --- renderer.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/renderer.py b/renderer.py index bf47e12..8ecc5e5 100644 --- a/renderer.py +++ b/renderer.py @@ -350,10 +350,11 @@ def thread_machine_content(machine, machine_content, idx): expiry_time = str(expiry_local.strftime('%m/%Y'))+" "+str(timezone)+" ("+str(expiry_print)+")" else: expiry_time = str(expiry_local.strftime('%A %m/%d/%Y, %H:%M:%S'))+" "+str(timezone)+" ("+str(expiry_print)+")" + app.logger.debug("Machine: "+machine["name"]+" expires: "+str(expiry_local.strftime('%Y'))+" / "+str(expiry_delta.days)) else: expiry_time = "No expiration date." + app.logger.debug("Machine: "+machine["name"]+" has no expiration date") - app.logger.debug("Machine: "+machine["name"]+" expires: "+str(expiry_local.strftime('%Y'))+" / "+str(expiry_delta.days)) expiring_soon = True if int(expiry_delta.days) < 14 and int(expiry_delta.days) > 0 else False # Get the first 10 characters of the PreAuth Key: From 2c56ea64a2730009e16f64577b90196922330c9e Mon Sep 17 00:00:00 2001 From: iFargle Date: Fri, 17 Mar 2023 21:05:47 +0900 Subject: [PATCH 5/7] test --- renderer.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/renderer.py b/renderer.py index 8ecc5e5..77bd60e 100644 --- a/renderer.py +++ b/renderer.py @@ -350,13 +350,14 @@ def thread_machine_content(machine, machine_content, idx): expiry_time = str(expiry_local.strftime('%m/%Y'))+" "+str(timezone)+" ("+str(expiry_print)+")" else: expiry_time = str(expiry_local.strftime('%A %m/%d/%Y, %H:%M:%S'))+" "+str(timezone)+" ("+str(expiry_print)+")" + + expiring_soon = True if int(expiry_delta.days) < 14 and int(expiry_delta.days) > 0 else False app.logger.debug("Machine: "+machine["name"]+" expires: "+str(expiry_local.strftime('%Y'))+" / "+str(expiry_delta.days)) else: expiry_time = "No expiration date." app.logger.debug("Machine: "+machine["name"]+" has no expiration date") - expiring_soon = True if int(expiry_delta.days) < 14 and int(expiry_delta.days) > 0 else False # Get the first 10 characters of the PreAuth Key: if machine["preAuthKey"]: preauth_key = str(machine["preAuthKey"]["key"])[0:10] From b6d5cd7c0bffa5701cce8d2fa43d85dc291c8329 Mon Sep 17 00:00:00 2001 From: iFargle Date: Fri, 17 Mar 2023 21:10:16 +0900 Subject: [PATCH 6/7] test --- renderer.py | 1 + 1 file changed, 1 insertion(+) diff --git a/renderer.py b/renderer.py index 77bd60e..291a20e 100644 --- a/renderer.py +++ b/renderer.py @@ -355,6 +355,7 @@ def thread_machine_content(machine, machine_content, idx): app.logger.debug("Machine: "+machine["name"]+" expires: "+str(expiry_local.strftime('%Y'))+" / "+str(expiry_delta.days)) else: expiry_time = "No expiration date." + expiring_soon = False app.logger.debug("Machine: "+machine["name"]+" has no expiration date") From 35c3c8b5ff11b03c3f92eb495f2a8c4e2694590d Mon Sep 17 00:00:00 2001 From: iFargle Date: Fri, 17 Mar 2023 21:33:59 +0900 Subject: [PATCH 7/7] Update app versions --- Jenkinsfile | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index da5560b..4ba119f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -3,7 +3,7 @@ pipeline { label 'linux-x64' } environment { - APP_VERSION = 'v0.5.5' + APP_VERSION = 'v0.5.6' HS_VERSION = "v0.20.0" // Version of Headscale this is compatible with BUILD_DATE = '' BUILDER_NAME = "multiarch" diff --git a/pyproject.toml b/pyproject.toml index a148932..b335c4b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "headscale-webui" -version = "v0.5.5" +version = "v0.5.6" description = "A simple web UI for small-scale Headscale deployments." authors = ["Albert Copeland "] license = "AGPL"