From 89c6528f245eda1974f47a2324ce4fddef1b6033 Mon Sep 17 00:00:00 2001 From: Michael Shamoon <4887959+shamoon@users.noreply.github.com> Date: Mon, 23 Jan 2023 10:31:08 -0800 Subject: [PATCH] cloudflare widget validation, handle multiple connections, fix translation file error, capitalize status --- public/locales/en/common.json | 2 +- src/widgets/cloudflared/component.jsx | 6 ++++-- src/widgets/cloudflared/widget.js | 6 +++++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 55edf803d..5477092aa 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -430,7 +430,7 @@ "temp_bed": "Bed temp", "job_completion": "Completion" }, - "cloudflared" { + "cloudflared": { "origin_ip": "Origin IP", "status": "Status" } diff --git a/src/widgets/cloudflared/component.jsx b/src/widgets/cloudflared/component.jsx index 061313580..2cbcd45b8 100644 --- a/src/widgets/cloudflared/component.jsx +++ b/src/widgets/cloudflared/component.jsx @@ -20,10 +20,12 @@ export default function Component({ service }) { ); } + const originIP = statsData.result.connections?.origin_ip ?? statsData.result.connections[0]?.origin_ip; + return ( - - + + ); } \ No newline at end of file diff --git a/src/widgets/cloudflared/widget.js b/src/widgets/cloudflared/widget.js index 787169341..1bb8819f7 100644 --- a/src/widgets/cloudflared/widget.js +++ b/src/widgets/cloudflared/widget.js @@ -1,12 +1,16 @@ import credentialedProxyHandler from "utils/proxy/handlers/credentialed"; const widget = { - api: "https://api.cloudflare.com/client/v4/accounts/{accountid}/{endpoint}/{tunnelid}?", + api: "https://api.cloudflare.com/client/v4/accounts/{accountid}/{endpoint}/{tunnelid}", proxyHandler: credentialedProxyHandler, mappings: { "cfd_tunnel": { endpoint: "cfd_tunnel", + validate: [ + "success", + "result" + ] }, }, };