mirror of
https://github.com/karl0ss/homepage.git
synced 2025-05-05 23:13:40 +01:00
Merge remote-tracking branch 'origin/main' into JDRssDownloader
This commit is contained in:
commit
7a3ebac8f0
@ -658,5 +658,8 @@
|
|||||||
"totalShows": "Tracked Shows",
|
"totalShows": "Tracked Shows",
|
||||||
"retryCache": "Retry Cache",
|
"retryCache": "Retry Cache",
|
||||||
"feedCache": "Feed Cache"
|
"feedCache": "Feed Cache"
|
||||||
|
},
|
||||||
|
"wgeasy": {
|
||||||
|
"clients": "Total Clients"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -397,7 +397,7 @@
|
|||||||
"queue": "À traiter",
|
"queue": "À traiter",
|
||||||
"processed": "Traité",
|
"processed": "Traité",
|
||||||
"errored": "En erreur",
|
"errored": "En erreur",
|
||||||
"saved": "Economisé"
|
"saved": "Gagné"
|
||||||
},
|
},
|
||||||
"miniflux": {
|
"miniflux": {
|
||||||
"read": "Lu",
|
"read": "Lu",
|
||||||
|
@ -239,11 +239,11 @@
|
|||||||
"uptime": "UP",
|
"uptime": "UP",
|
||||||
"days": "d",
|
"days": "d",
|
||||||
"hours": "h",
|
"hours": "h",
|
||||||
"used": "Used",
|
"used": "Korišteno",
|
||||||
"load": "Load",
|
"load": "Opterećenje",
|
||||||
"warn": "Warn",
|
"warn": "Upozori",
|
||||||
"total": "Total",
|
"total": "Ukupno",
|
||||||
"free": "Free"
|
"free": "Slobodno"
|
||||||
},
|
},
|
||||||
"changedetectionio": {
|
"changedetectionio": {
|
||||||
"totalObserved": "Ukupno promatrano",
|
"totalObserved": "Ukupno promatrano",
|
||||||
@ -478,7 +478,7 @@
|
|||||||
"up": "Aktivne stranice",
|
"up": "Aktivne stranice",
|
||||||
"down": "Neaktivne stranice",
|
"down": "Neaktivne stranice",
|
||||||
"uptime": "Radno vrijeme",
|
"uptime": "Radno vrijeme",
|
||||||
"incident": "Incident",
|
"incident": "Slučaj",
|
||||||
"m": "min"
|
"m": "min"
|
||||||
},
|
},
|
||||||
"komga": {
|
"komga": {
|
||||||
@ -609,36 +609,36 @@
|
|||||||
"poolUsage": "Korištenje memorijskog skupa",
|
"poolUsage": "Korištenje memorijskog skupa",
|
||||||
"cpuUsage": "Korištenje procesora",
|
"cpuUsage": "Korištenje procesora",
|
||||||
"memUsage": "Korištenje memorije",
|
"memUsage": "Korištenje memorije",
|
||||||
"volumeUsage": "Volume Usage",
|
"volumeUsage": "Korištenje jedinice memorije",
|
||||||
"invalid": "Invalid"
|
"invalid": "Neispravno"
|
||||||
},
|
},
|
||||||
"pfsense": {
|
"pfsense": {
|
||||||
"load": "Load Avg",
|
"load": "Prosječno opterećenje",
|
||||||
"memory": "Mem Usage",
|
"memory": "Korištenje memorije",
|
||||||
"wanStatus": "WAN Status",
|
"wanStatus": "Stanje WAN-a",
|
||||||
"up": "Up",
|
"up": "Up",
|
||||||
"down": "Down",
|
"down": "Down",
|
||||||
"temp": "Temp",
|
"temp": "Temperatura",
|
||||||
"disk": "Disk Usage",
|
"disk": "Korištenje diska",
|
||||||
"wanIP": "WAN IP"
|
"wanIP": "WAN IP"
|
||||||
},
|
},
|
||||||
"caddy": {
|
"caddy": {
|
||||||
"upstreams": "Upstreams",
|
"upstreams": "Glavne grane",
|
||||||
"requests": "Current requests",
|
"requests": "Aktualni zahtjevi",
|
||||||
"requests_failed": "Failed requests"
|
"requests_failed": "Neuspjeli zahtjevi"
|
||||||
},
|
},
|
||||||
"evcc": {
|
"evcc": {
|
||||||
"pv_power": "Production",
|
"pv_power": "Proizvodnja",
|
||||||
"battery_soc": "Battery",
|
"battery_soc": "Baterija",
|
||||||
"grid_power": "Grid",
|
"grid_power": "Raspored",
|
||||||
"home_power": "Consumption",
|
"home_power": "Potrošnja",
|
||||||
"charge_power": "Charger",
|
"charge_power": "Punjač",
|
||||||
"watt_hour": "Wh"
|
"watt_hour": "Wh"
|
||||||
},
|
},
|
||||||
"pialert": {
|
"pialert": {
|
||||||
"total": "Total",
|
"total": "Ukupno",
|
||||||
"connected": "Connected",
|
"connected": "Povezano",
|
||||||
"new_devices": "New Devices",
|
"new_devices": "Novi uređaji",
|
||||||
"down_alerts": "Down Alerts"
|
"down_alerts": "Obavijest o rušenju"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,13 +24,13 @@
|
|||||||
"used": "Kullanımda",
|
"used": "Kullanımda",
|
||||||
"load": "Yük",
|
"load": "Yük",
|
||||||
"mem": "MEM",
|
"mem": "MEM",
|
||||||
"temp": "TEMP",
|
"temp": "Geçici",
|
||||||
"max": "Max",
|
"max": "En Yüksek",
|
||||||
"uptime": "UP",
|
"uptime": "Çalışma Süresi",
|
||||||
"months": "mo",
|
"months": "Ay",
|
||||||
"days": "d",
|
"days": "Gün",
|
||||||
"hours": "h",
|
"hours": "Saat",
|
||||||
"minutes": "m"
|
"minutes": "Dakika"
|
||||||
},
|
},
|
||||||
"unifi": {
|
"unifi": {
|
||||||
"users": "Kullanıcılar",
|
"users": "Kullanıcılar",
|
||||||
@ -57,23 +57,23 @@
|
|||||||
"offline": "Çevrimdışı",
|
"offline": "Çevrimdışı",
|
||||||
"error": "Hata",
|
"error": "Hata",
|
||||||
"unknown": "Bilinmiyor",
|
"unknown": "Bilinmiyor",
|
||||||
"running": "Running",
|
"running": "Çalışan",
|
||||||
"starting": "Starting",
|
"starting": "Başlatılıyor",
|
||||||
"unhealthy": "Unhealthy",
|
"unhealthy": "Sağlıksız",
|
||||||
"not_found": "Not Found",
|
"not_found": "Bulunamadı",
|
||||||
"exited": "Exited",
|
"exited": "Durduruldu",
|
||||||
"partial": "Partial",
|
"partial": "Parçalı",
|
||||||
"healthy": "Healthy"
|
"healthy": "Sağlık"
|
||||||
},
|
},
|
||||||
"emby": {
|
"emby": {
|
||||||
"playing": "Oynatılıyor",
|
"playing": "Oynatılıyor",
|
||||||
"transcoding": "Dönüştürülüyor",
|
"transcoding": "Dönüştürülüyor",
|
||||||
"bitrate": "Bit Oranı",
|
"bitrate": "Bit Oranı",
|
||||||
"no_active": "Aktif akış yok",
|
"no_active": "Aktif akış yok",
|
||||||
"movies": "Movies",
|
"movies": "Filmler",
|
||||||
"series": "Series",
|
"series": "Diziler",
|
||||||
"episodes": "Episodes",
|
"episodes": "Bölümler",
|
||||||
"songs": "Songs"
|
"songs": "Şarkılar"
|
||||||
},
|
},
|
||||||
"tautulli": {
|
"tautulli": {
|
||||||
"playing": "Oynatılıyor",
|
"playing": "Oynatılıyor",
|
||||||
@ -90,7 +90,7 @@
|
|||||||
"streams": "Aktif Akış",
|
"streams": "Aktif Akış",
|
||||||
"movies": "Filmler",
|
"movies": "Filmler",
|
||||||
"tv": "TV Showları",
|
"tv": "TV Showları",
|
||||||
"albums": "Albums"
|
"albums": "Albümler"
|
||||||
},
|
},
|
||||||
"sabnzbd": {
|
"sabnzbd": {
|
||||||
"rate": "Oran",
|
"rate": "Oran",
|
||||||
@ -159,7 +159,7 @@
|
|||||||
"queries": "Sorgular",
|
"queries": "Sorgular",
|
||||||
"blocked": "Engellenen",
|
"blocked": "Engellenen",
|
||||||
"gravity": "Yer Çekimi",
|
"gravity": "Yer Çekimi",
|
||||||
"blocked_percent": "Blocked %"
|
"blocked_percent": "Engellenen %"
|
||||||
},
|
},
|
||||||
"adguard": {
|
"adguard": {
|
||||||
"queries": "Sorgular",
|
"queries": "Sorgular",
|
||||||
@ -235,15 +235,15 @@
|
|||||||
"glances": {
|
"glances": {
|
||||||
"cpu": "İşlemci",
|
"cpu": "İşlemci",
|
||||||
"wait": "Lütfen bekleyiniz",
|
"wait": "Lütfen bekleyiniz",
|
||||||
"temp": "TEMP",
|
"temp": "Sıcaklık",
|
||||||
"uptime": "UP",
|
"uptime": "Çalışma Süresi",
|
||||||
"days": "d",
|
"days": "Gün",
|
||||||
"hours": "h",
|
"hours": "Saat",
|
||||||
"load": "Load",
|
"load": "Yük",
|
||||||
"warn": "Warn",
|
"warn": "Uyarı",
|
||||||
"total": "Total",
|
"total": "Toplam",
|
||||||
"free": "Free",
|
"free": "Boş",
|
||||||
"used": "Used"
|
"used": "Kullanım"
|
||||||
},
|
},
|
||||||
"changedetectionio": {
|
"changedetectionio": {
|
||||||
"totalObserved": "Toplam Gözlenen",
|
"totalObserved": "Toplam Gözlenen",
|
||||||
@ -311,9 +311,9 @@
|
|||||||
"bookmark": "Yer İmi",
|
"bookmark": "Yer İmi",
|
||||||
"service": "Hizmet",
|
"service": "Hizmet",
|
||||||
"search": "Ara",
|
"search": "Ara",
|
||||||
"custom": "Custom",
|
"custom": "Özel",
|
||||||
"visit": "Visit",
|
"visit": "Ziyaret",
|
||||||
"url": "URL"
|
"url": "Link"
|
||||||
},
|
},
|
||||||
"homebridge": {
|
"homebridge": {
|
||||||
"available_update": "Sistem",
|
"available_update": "Sistem",
|
||||||
@ -384,14 +384,14 @@
|
|||||||
"deluge": {
|
"deluge": {
|
||||||
"download": "İndir",
|
"download": "İndir",
|
||||||
"upload": "Yükle",
|
"upload": "Yükle",
|
||||||
"leech": "Leech",
|
"leech": "Tüketici",
|
||||||
"seed": "Tohum"
|
"seed": "Tohum"
|
||||||
},
|
},
|
||||||
"flood": {
|
"flood": {
|
||||||
"download": "İndir",
|
"download": "İndir",
|
||||||
"upload": "Yükle",
|
"upload": "Yükle",
|
||||||
"leech": "Leech",
|
"leech": "Tüketici",
|
||||||
"seed": "Tohum"
|
"seed": "Sağlayıcı"
|
||||||
},
|
},
|
||||||
"tdarr": {
|
"tdarr": {
|
||||||
"queue": "Sıra",
|
"queue": "Sıra",
|
||||||
@ -421,7 +421,7 @@
|
|||||||
"downloadstation": {
|
"downloadstation": {
|
||||||
"download": "İndir",
|
"download": "İndir",
|
||||||
"upload": "Yükle",
|
"upload": "Yükle",
|
||||||
"leech": "Leech",
|
"leech": "Tüketici",
|
||||||
"seed": "Tohum"
|
"seed": "Tohum"
|
||||||
},
|
},
|
||||||
"mikrotik": {
|
"mikrotik": {
|
||||||
@ -448,7 +448,7 @@
|
|||||||
"layers": "Katmanlar"
|
"layers": "Katmanlar"
|
||||||
},
|
},
|
||||||
"medusa": {
|
"medusa": {
|
||||||
"wanted": "Wanted",
|
"wanted": "Aranan",
|
||||||
"queued": "Kuyrukta",
|
"queued": "Kuyrukta",
|
||||||
"series": "Seri"
|
"series": "Seri"
|
||||||
},
|
},
|
||||||
@ -554,11 +554,11 @@
|
|||||||
"targets_total": "Total Targets"
|
"targets_total": "Total Targets"
|
||||||
},
|
},
|
||||||
"minecraft": {
|
"minecraft": {
|
||||||
"players": "Players",
|
"players": "Oyuncular",
|
||||||
"version": "Version",
|
"version": "Versiyon",
|
||||||
"status": "Status",
|
"status": "Durum",
|
||||||
"up": "Online",
|
"up": "Çevrimiçi",
|
||||||
"down": "Offline"
|
"down": "Çevrimdışı"
|
||||||
},
|
},
|
||||||
"ghostfolio": {
|
"ghostfolio": {
|
||||||
"gross_percent_today": "Today",
|
"gross_percent_today": "Today",
|
||||||
@ -577,40 +577,40 @@
|
|||||||
"switches_on": "Switches On"
|
"switches_on": "Switches On"
|
||||||
},
|
},
|
||||||
"freshrss": {
|
"freshrss": {
|
||||||
"subscriptions": "Subscriptions",
|
"subscriptions": "Abonelikler",
|
||||||
"unread": "Unread"
|
"unread": "Okunmamış"
|
||||||
},
|
},
|
||||||
"channelsdvrserver": {
|
"channelsdvrserver": {
|
||||||
"shows": "Shows",
|
"shows": "Diziler",
|
||||||
"recordings": "Recordings",
|
"recordings": "Kayıtlar",
|
||||||
"scheduled": "Scheduled",
|
"scheduled": "Planlanmış",
|
||||||
"passes": "Passes"
|
"passes": "Geçilenler"
|
||||||
},
|
},
|
||||||
"whatsupdocker": {
|
"whatsupdocker": {
|
||||||
"monitoring": "Monitoring",
|
"monitoring": "Monitoring",
|
||||||
"updates": "Updates"
|
"updates": "Updates"
|
||||||
},
|
},
|
||||||
"tailscale": {
|
"tailscale": {
|
||||||
"never": "Never",
|
"never": "Asla",
|
||||||
"last_seen": "Last Seen",
|
"last_seen": "Son Görülme",
|
||||||
"now": "Now",
|
"now": "Şimdi",
|
||||||
"years": "{{number}}y",
|
"years": "{{number}} Yıl",
|
||||||
"weeks": "{{number}}w",
|
"weeks": "{{number}} Hafta",
|
||||||
"days": "{{number}}d",
|
"days": "{{number}} Gün",
|
||||||
"hours": "{{number}}h",
|
"hours": "{{number}} Saat",
|
||||||
"minutes": "{{number}}m",
|
"minutes": "{{number}} Dakika",
|
||||||
"seconds": "{{number}}s",
|
"seconds": "{{number}} Saniye",
|
||||||
"ago": "{{value}} Ago",
|
"ago": "{{value}} Önce",
|
||||||
"address": "Address",
|
"address": "Adres",
|
||||||
"expires": "Expires"
|
"expires": "Geciken"
|
||||||
},
|
},
|
||||||
"qnap": {
|
"qnap": {
|
||||||
"cpuUsage": "CPU Usage",
|
"cpuUsage": "İşlemci Kullanımı",
|
||||||
"memUsage": "MEM Usage",
|
"memUsage": "Bellek Kullanımı",
|
||||||
"systemTempC": "System Temp",
|
"systemTempC": "Sistem Sıcaklığı",
|
||||||
"poolUsage": "Pool Usage",
|
"poolUsage": "Havuz Kullanımı",
|
||||||
"volumeUsage": "Volume Usage",
|
"volumeUsage": "Alan Kullanımı",
|
||||||
"invalid": "Invalid"
|
"invalid": "Geçersiz"
|
||||||
},
|
},
|
||||||
"pfsense": {
|
"pfsense": {
|
||||||
"load": "Load Avg",
|
"load": "Load Avg",
|
||||||
@ -623,22 +623,22 @@
|
|||||||
"wanIP": "WAN IP"
|
"wanIP": "WAN IP"
|
||||||
},
|
},
|
||||||
"caddy": {
|
"caddy": {
|
||||||
"upstreams": "Upstreams",
|
"upstreams": "Akış",
|
||||||
"requests": "Current requests",
|
"requests": "Anlık İstekler",
|
||||||
"requests_failed": "Failed requests"
|
"requests_failed": "Başarısız İstekler"
|
||||||
},
|
},
|
||||||
"evcc": {
|
"evcc": {
|
||||||
"pv_power": "Production",
|
"pv_power": "Üretim",
|
||||||
"battery_soc": "Battery",
|
"battery_soc": "Batarya",
|
||||||
"grid_power": "Grid",
|
"grid_power": "Güç",
|
||||||
"home_power": "Consumption",
|
"home_power": "Tüketim",
|
||||||
"charge_power": "Charger",
|
"charge_power": "Şarj",
|
||||||
"watt_hour": "Wh"
|
"watt_hour": "Watt/Saat"
|
||||||
},
|
},
|
||||||
"pialert": {
|
"pialert": {
|
||||||
"total": "Total",
|
"total": "Toplam",
|
||||||
"connected": "Connected",
|
"connected": "Bağlandı",
|
||||||
"new_devices": "New Devices",
|
"new_devices": "Yeni Cihazlar",
|
||||||
"down_alerts": "Down Alerts"
|
"down_alerts": "Düşme Uyarıları"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,12 @@ export default async function credentialedProxyHandler(req, res, map) {
|
|||||||
} else {
|
} else {
|
||||||
headers.Authorization = `Basic ${Buffer.from(`${widget.username}:${widget.password}`).toString("base64")}`;
|
headers.Authorization = `Basic ${Buffer.from(`${widget.username}:${widget.password}`).toString("base64")}`;
|
||||||
}
|
}
|
||||||
|
} else if (widget.type === "paperlessngx") {
|
||||||
|
if (widget.key) {
|
||||||
|
headers.Authorization = `Token ${widget.key}`;
|
||||||
|
} else {
|
||||||
|
headers.Authorization = `Basic ${Buffer.from(`${widget.username}:${widget.password}`).toString("base64")}`;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
headers["X-API-Key"] = `${widget.key}`;
|
headers["X-API-Key"] = `${widget.key}`;
|
||||||
}
|
}
|
||||||
|
@ -90,6 +90,7 @@ const components = {
|
|||||||
uptimekuma: dynamic(() => import("./uptimekuma/component")),
|
uptimekuma: dynamic(() => import("./uptimekuma/component")),
|
||||||
watchtower: dynamic(() => import("./watchtower/component")),
|
watchtower: dynamic(() => import("./watchtower/component")),
|
||||||
whatsupdocker: dynamic(() => import("./whatsupdocker/component")),
|
whatsupdocker: dynamic(() => import("./whatsupdocker/component")),
|
||||||
|
wgeasy: dynamic(() => import("./wgeasy/component")),
|
||||||
xteve: dynamic(() => import("./xteve/component")),
|
xteve: dynamic(() => import("./xteve/component")),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import genericProxyHandler from "utils/proxy/handlers/generic";
|
import credentialedProxyHandler from "utils/proxy/handlers/credentialed";
|
||||||
|
|
||||||
const widget = {
|
const widget = {
|
||||||
api: "{url}/api/{endpoint}",
|
api: "{url}/api/{endpoint}",
|
||||||
proxyHandler: genericProxyHandler,
|
proxyHandler: credentialedProxyHandler,
|
||||||
|
|
||||||
mappings: {
|
mappings: {
|
||||||
"statistics": {
|
"statistics": {
|
||||||
|
33
src/widgets/wgeasy/component.jsx
Normal file
33
src/widgets/wgeasy/component.jsx
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
import { useTranslation } from "next-i18next";
|
||||||
|
|
||||||
|
import Block from "components/services/widget/block";
|
||||||
|
import Container from "components/services/widget/container";
|
||||||
|
import useWidgetAPI from "utils/proxy/use-widget-api";
|
||||||
|
|
||||||
|
export default function Component({ service }) {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
const { widget } = service;
|
||||||
|
|
||||||
|
const { data: wgeasyData, error: wgeasyAPIError } = useWidgetAPI(widget, "unified", {
|
||||||
|
refreshInterval: 5000,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (wgeasyAPIError) {
|
||||||
|
return <Container service={service} error={wgeasyAPIError} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!wgeasyData) {
|
||||||
|
return (
|
||||||
|
<Container service={service}>
|
||||||
|
<Block label="wgeasy.clients" />
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Container service={service}>
|
||||||
|
<Block label="wgeasy.clients" value={t("common.number", { value: wgeasyData.clientCount })} />
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
118
src/widgets/wgeasy/proxy.js
Normal file
118
src/widgets/wgeasy/proxy.js
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
/* eslint-disable no-underscore-dangle */
|
||||||
|
import { formatApiCall } from "utils/proxy/api-helpers";
|
||||||
|
import { httpProxy } from "utils/proxy/http";
|
||||||
|
import getServiceWidget from "utils/config/service-helpers";
|
||||||
|
import createLogger from "utils/logger";
|
||||||
|
import widgets from "widgets/widgets";
|
||||||
|
|
||||||
|
|
||||||
|
const proxyName = "wgeasyProxyHandler";
|
||||||
|
|
||||||
|
const logger = createLogger(proxyName);
|
||||||
|
let globalSid = null;
|
||||||
|
|
||||||
|
async function getWidget(req) {
|
||||||
|
const { group, service } = req.query;
|
||||||
|
if (!group || !service) {
|
||||||
|
logger.debug("Invalid or missing service '%s' or group '%s'", service, group);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
const widget = await getServiceWidget(group, service);
|
||||||
|
if (!widget) {
|
||||||
|
logger.debug("Invalid or missing widget for service '%s' in group '%s'", service, group);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return widget;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async function loginToWGEasy(endpoint, widget) {
|
||||||
|
const api = widgets?.[widget.type]?.api;
|
||||||
|
if (!api) {
|
||||||
|
return [403, null];
|
||||||
|
}
|
||||||
|
// Create new session on WgEasy
|
||||||
|
let url = new URL(formatApiCall(api, { endpoint, ...widget }));
|
||||||
|
|
||||||
|
let [status, contentType, data, responseHeaders] = await httpProxy(url, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
password: widget.password,
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
if (status !== 204) {
|
||||||
|
logger.error("HTTP %d communicating with NextPVR. Data: %s", status, data.toString());
|
||||||
|
return [status, data, responseHeaders];
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
globalSid = responseHeaders["set-cookie"][0]
|
||||||
|
} catch (e) {
|
||||||
|
logger.error("Error decoding NextPVR API data. Data: %s", data.toString());
|
||||||
|
return [status, null];
|
||||||
|
}
|
||||||
|
logger.info('gettingSID')
|
||||||
|
return [status, true];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async function fetchDataFromWGeasy(endpoint, widget, sid) {
|
||||||
|
const api = widgets?.[widget.type]?.api;
|
||||||
|
if (!api) {
|
||||||
|
return [403, null];
|
||||||
|
}
|
||||||
|
const url = `${new URL(formatApiCall(api, { endpoint, ...widget }))}`
|
||||||
|
const [status, contentType, data] = await httpProxy(url, {
|
||||||
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'Cookie': sid
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (status !== 200) {
|
||||||
|
logger.error("HTTP %d communicating with WGeasy. Data: %s", status, data.toString());
|
||||||
|
return [status, data];
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
return [status, JSON.parse(data), contentType];
|
||||||
|
} catch (e) {
|
||||||
|
logger.error("Error decoding WGeasy API data. Data: %s", data.toString());
|
||||||
|
return [status, null];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default async function WGeasyProxyHandler(req, res) {
|
||||||
|
const widget = await getWidget(req);
|
||||||
|
|
||||||
|
if (!globalSid) {
|
||||||
|
await loginToWGEasy('session', widget);
|
||||||
|
}
|
||||||
|
if (!widget) {
|
||||||
|
return res.status(400).json({ error: "Invalid proxy service type" });
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.debug("Getting data from WGeasy API");
|
||||||
|
// Calculate the number of clients
|
||||||
|
let [status, apiData] = await fetchDataFromWGeasy('wireguard/client', widget, globalSid);
|
||||||
|
|
||||||
|
if (status !== 200) {
|
||||||
|
return res.status(status).json({ error: { message: "HTTP error communicating with WGeasy API", data: Buffer.from(apiData).toString() } });
|
||||||
|
}
|
||||||
|
let clientCount;
|
||||||
|
clientCount = apiData.length;
|
||||||
|
|
||||||
|
const data = {
|
||||||
|
clientCount
|
||||||
|
};
|
||||||
|
|
||||||
|
return res.status(status).send(data);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
14
src/widgets/wgeasy/widget.js
Normal file
14
src/widgets/wgeasy/widget.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import nextpvrProxyHandler from "./proxy";
|
||||||
|
|
||||||
|
const widget = {
|
||||||
|
api: "{url}/api/{endpoint}",
|
||||||
|
proxyHandler: nextpvrProxyHandler,
|
||||||
|
|
||||||
|
mappings: {
|
||||||
|
unified: {
|
||||||
|
endpoint: "/",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default widget;
|
@ -83,6 +83,7 @@ import unmanic from "./unmanic/widget";
|
|||||||
import uptimekuma from "./uptimekuma/widget";
|
import uptimekuma from "./uptimekuma/widget";
|
||||||
import watchtower from "./watchtower/widget";
|
import watchtower from "./watchtower/widget";
|
||||||
import whatsupdocker from "./whatsupdocker/widget";
|
import whatsupdocker from "./whatsupdocker/widget";
|
||||||
|
import wgeasy from "./wgeasy/widget";
|
||||||
import xteve from "./xteve/widget";
|
import xteve from "./xteve/widget";
|
||||||
import jdrssdownloader from "./jdrssdownloader/widget";
|
import jdrssdownloader from "./jdrssdownloader/widget";
|
||||||
|
|
||||||
@ -175,6 +176,7 @@ const widgets = {
|
|||||||
uptimekuma,
|
uptimekuma,
|
||||||
watchtower,
|
watchtower,
|
||||||
whatsupdocker,
|
whatsupdocker,
|
||||||
|
wgeasy,
|
||||||
xteve,
|
xteve,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user