parent
74a52d9288
commit
c28e19baac
@ -0,0 +1,14 @@
|
||||
---
|
||||
title: Synology VPN client status
|
||||
description: Synology VPN client status Widget Configuration
|
||||
---
|
||||
|
||||
Note: the widget is not compatible with 2FA.
|
||||
|
||||
```yaml
|
||||
widget:
|
||||
type: synologyvpn
|
||||
url: http://downloadstation.host.or.ip:port
|
||||
username: username
|
||||
password: password
|
||||
```
|
@ -0,0 +1,24 @@
|
||||
import { useTranslation } from "next-i18next";
|
||||
|
||||
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: gatewayData, error: gatewayError } = useWidgetAPI(widget, "gatewayList");
|
||||
|
||||
if (gatewayError) {
|
||||
return <Container service={service} error={gatewayError} />;
|
||||
}
|
||||
|
||||
const configs = gatewayData?.data?.configs || [];
|
||||
const isVPNConnected = configs.some(config => config.class === "vpn-client");
|
||||
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="VPN connection status" value={isVPNConnected ? t("Connected") : t("Disconnected")} />
|
||||
</Container>
|
||||
);
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
import synologyProxyHandler from "../../utils/proxy/handlers/synology";
|
||||
|
||||
const widget = {
|
||||
// Variables to be filled at runtime
|
||||
api: "{url}/webapi/{cgiPath}?api={apiName}&version={maxVersion}&method={apiMethod}",
|
||||
proxyHandler: synologyProxyHandler,
|
||||
|
||||
mappings: {
|
||||
gatewayList: {
|
||||
apiName: "SYNO.Core.Network.Router.Gateway.List",
|
||||
apiMethod: "get&iptype=ipv4&type=wan",
|
||||
endpoint: "gatewayList",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default widget;
|
Loading…
Reference in new issue