adding cloudflare widget

pull/868/head
KillahBee 2 years ago
parent 01eea51555
commit fa1792cd5f

@ -429,5 +429,9 @@
"temp_tool": "Tool temp",
"temp_bed": "Bed temp",
"job_completion": "Completion"
},
"cloudflared" {
"origin_ip": "Origin IP",
"status": "Status"
}
}

@ -40,6 +40,9 @@ export default async function credentialedProxyHandler(req, res, map) {
headers.Authorization = `Token ${widget.key}`;
} else if (widget.type === "miniflux") {
headers["X-Auth-Token"] = `${widget.key}`;
} else if (widget.type === "cloudflared") {
headers["X-Auth-Email"] = `${widget.email}`;
headers["X-Auth-Key"] = `${widget.key}`;
} else {
headers["X-API-Key"] = `${widget.key}`;
}

@ -0,0 +1,30 @@
import Container from "components/services/widget/container";
import Block from "components/services/widget/block";
import useWidgetAPI from "utils/proxy/use-widget-api";
export default function Component({ service }) {
const { t } = useTranslation();
const { widget } = service;
const { data: statsData, error: statsError } = useWidgetAPI(widget, "cfd_tunnel");
if (statsError) {
return <Container error={statsError} />;
}
if (!statsData) {
return (
<Container service={service}>
<Block label="cloudflared.status" />
<Block label="cloudflared.origin_ip" />
</Container>
);
}
return (
<Container service={service}>
<Block label="cloudflared.status" value={statsData.status} />
<Block label="cloudflared.origin_ip" value={statsData.origin_ip} />
</Container>
);
}

@ -0,0 +1,18 @@
import credentialedProxyHandler from "utils/proxy/handlers/credentialed";
const widget = {
api: "https://api.cloudflare.com/client/v4/accounts/{accountid}/{endpoint}/{tunnelid}?",
proxyHandler: credentialedProxyHandler,
mappings: {
"cfd_tunnel": {
endpoint: "cfd_tunnel",
validate: [
"origin_ip",
"status",
],
},
},
};
export default widget;

@ -6,6 +6,7 @@ const components = {
autobrr: dynamic(() => import("./autobrr/component")),
bazarr: dynamic(() => import("./bazarr/component")),
changedetectionio: dynamic(() => import("./changedetectionio/component")),
cloudflared: dynamic(() => import("./cloudflared/component")),
coinmarketcap: dynamic(() => import("./coinmarketcap/component")),
deluge: dynamic(() => import("./deluge/component")),
downloadstation: dynamic(() => import("./downloadstation/component")),

@ -3,6 +3,7 @@ import authentik from "./authentik/widget";
import autobrr from "./autobrr/widget";
import bazarr from "./bazarr/widget";
import changedetectionio from "./changedetectionio/widget";
import cloudflared from "./cloudflared/widget";
import coinmarketcap from "./coinmarketcap/widget";
import deluge from "./deluge/widget";
import downloadstation from "./downloadstation/widget";
@ -61,6 +62,7 @@ const widgets = {
autobrr,
bazarr,
changedetectionio,
cloudflared,
coinmarketcap,
deluge,
diskstation: downloadstation,

Loading…
Cancel
Save